This commit is contained in:
darkeye 2025-01-11 15:15:28 +01:00
parent 69a548a200
commit e002eeec44

View File

@ -111,7 +111,7 @@ export default class AggregatedDataPoint {
}
this.hasValues = true;
this.minPrice = Math.min(this.minPrice, bid.price);
this.maxPrice = Math.max(this.maxPrice = bid.price);
this.maxPrice = Math.max(this.maxPrice, bid.price);
this.endPrice = bid.price;
this.#priceValues.push(parseFloat(bid.price));
if(this.bestBid == null || this.bestBid.price < bid.price){
@ -143,9 +143,12 @@ export default class AggregatedDataPoint {
*/
end(endTime){
this.endTime = endTime;
let priceSum = 0;
this.#priceValues.forEach(p => priceSum += p);
this.avgPrice = priceSum / this.#priceValues.length;
if(this.#priceValues.length > 0){
let priceSum = 0;
this.#priceValues.forEach(p => priceSum += p);
this.avgPrice = priceSum / this.#priceValues.length;
}
console.log(this.minPrice, this.maxPrice, this.avgPrice, this.minPrice <= this.avgPrice, this.avgPrice <= this.maxPrice);
this.#priceValues = [];
}