score + filter

This commit is contained in:
2023-10-02 19:38:46 +02:00
parent 66f88ef1b1
commit 7d33b77410
5 changed files with 56 additions and 7 deletions
+4
View File
@@ -2,6 +2,7 @@ import { MarketOrderHistory } from "@/market";
export type HistoryQuartils = {
totalVolume: number,
totalOrders: number,
q1: number,
median: number,
q3: number,
@@ -10,6 +11,7 @@ export type HistoryQuartils = {
export const getHistoryQuartils = (history: MarketOrderHistory[], days?: number): HistoryQuartils => {
const now = Date.now();
let totalOrders = 0;
const volumes = history
.flatMap(h => {
const volume = h.volume;
@@ -20,6 +22,7 @@ export const getHistoryQuartils = (history: MarketOrderHistory[], days?: number)
const e = estimateVolume(h);
totalOrders += h.order_count;
return [[h.highest, e], [h.lowest, volume - e]];
})
.filter(h => h[1] > 0)
@@ -45,6 +48,7 @@ export const getHistoryQuartils = (history: MarketOrderHistory[], days?: number)
}
return {
totalVolume,
totalOrders,
q1: quartils[0],
median: quartils[1],
q3: quartils[2],