fix score

This commit is contained in:
2023-10-02 19:49:25 +02:00
parent 7d33b77410
commit 7f83ee2ee2
4 changed files with 11 additions and 7 deletions

View File

@@ -6,7 +6,8 @@ import { MarketType } from "./type";
export type MarketTypePrice = { export type MarketTypePrice = {
type: MarketType; type: MarketType;
buy: number, buy: number,
sell: number sell: number,
orderCount: number
} }
type MarketTypePriceCache = { type MarketTypePriceCache = {
@@ -31,7 +32,8 @@ export const useApraisalStore = defineStore('appraisal', () => {
.map((item: any) => ({ .map((item: any) => ({
type: types.find(t => t.name === item.typeName) as MarketType, type: types.find(t => t.name === item.typeName) as MarketType,
buy: item.prices.buy.max, buy: item.prices.buy.max,
sell: item.prices.sell.min sell: item.prices.sell.min,
orderCount: item.prices.all.order_count
})); }));
} }

View File

@@ -46,7 +46,7 @@ const { sortedArray, headerProps } = useSort<Result>(computed(() => props.items
.map(r => { .map(r => {
const quartils = getHistoryQuartils(r.history, days.value); const quartils = getHistoryQuartils(r.history, days.value);
const profit = marketTaxStore.calculateProfit(quartils.q1, quartils.q3); const profit = marketTaxStore.calculateProfit(quartils.q1, quartils.q3);
const score = profit <= 0 ? 0 : Math.sqrt(quartils.totalVolume * r.sell * profit / days.value); const score = profit <= 0 ? 0 : Math.sqrt(quartils.totalVolume * r.sell * profit / Math.log(r.orderCount + 1));
return { return {
type: r.type, type: r.type,
@@ -61,8 +61,8 @@ const { sortedArray, headerProps } = useSort<Result>(computed(() => props.items
score score
}; };
}).filter(r => !onlyCheap.value || (r.buy <= r.q1 && r.profit >= (threshold.value / 100)))), { }).filter(r => !onlyCheap.value || (r.buy <= r.q1 && r.profit >= (threshold.value / 100)))), {
defaultSortKey: 'name', defaultSortKey: 'score',
defaultSortDirection: 'asc' defaultSortDirection: 'desc'
}) })
const getLineColor = (result: Result) => { const getLineColor = (result: Result) => {
if (result.profit < (threshold.value / 100)) { if (result.profit < (threshold.value / 100)) {

View File

@@ -8,7 +8,8 @@ export type ScanResult = {
type: MarketType; type: MarketType;
history: MarketOrderHistory[]; history: MarketOrderHistory[];
buy: number, buy: number,
sell: number sell: number,
orderCount: number,
} }
interface MarketScan extends RecordModel { interface MarketScan extends RecordModel {

View File

@@ -22,7 +22,8 @@ const addOrRelaod = async (type: MarketType) => {
type, type,
history, history,
buy: price.buy, buy: price.buy,
sell: price.sell sell: price.sell,
orderCount: price.orderCount
}; };
if (items.value.some(i => i.type.id === typeID)) { if (items.value.some(i => i.type.id === typeID)) {