This commit is contained in:
Sirttas
2026-06-13 00:06:55 +02:00
parent d0c198118d
commit 3348b9f668
4 changed files with 18 additions and 8 deletions
+11
View File
@@ -471,6 +471,11 @@ paths:
type: array type: array
items: items:
$ref: "#/components/schemas/MarketPriceResponse" $ref: "#/components/schemas/MarketPriceResponse"
"400":
description: |-
Returned when:
- the types parameter is missing
- a types value is not a numeric id
/ledgers: /ledgers:
get: get:
tags: tags:
@@ -832,6 +837,10 @@ components:
marketTypeId: marketTypeId:
type: integer type: integer
format: int64 format: int64
buy:
type: number
sell:
type: number
q1: q1:
type: number type: number
median: median:
@@ -846,12 +855,14 @@ components:
score: score:
type: number type: number
required: required:
- buy
- marketTypeId - marketTypeId
- median - median
- profit - profit
- q1 - q1
- q3 - q3
- score - score
- sell
- totalVolume - totalVolume
MarketPriceResponse: MarketPriceResponse:
type: object type: object
+2
View File
@@ -115,6 +115,8 @@ export interface MarketPriceResponse {
} }
export interface MarketScanResponse { export interface MarketScanResponse {
'marketTypeId': number; 'marketTypeId': number;
'buy': number;
'sell': number;
'q1': number; 'q1': number;
'median': number; 'median': number;
'q3': number; 'q3': number;
+3 -3
View File
@@ -21,10 +21,10 @@ export const calculateScore = (quartils: HistoryQuartils, profit: number, orderC
return Math.sqrt((Math.pow(quartils.totalVolume, 1.1) * Math.pow(quartils.q1, 1.2) * Math.pow(profit, 0.5) * Math.pow(Math.max(1, orderCount), -0.7)) / days); return Math.sqrt((Math.pow(quartils.totalVolume, 1.1) * Math.pow(quartils.q1, 1.2) * Math.pow(profit, 0.5) * Math.pow(Math.max(1, orderCount), -0.7)) / days);
} }
export const toScanResult = (res: MarketScanResponse, type: MarketType, price: MarketTypePrice): ScanResult => ({ export const toScanResult = (res: MarketScanResponse, type: MarketType): ScanResult => ({
type, type,
buy: price.buy, buy: res.buy,
sell: price.sell, sell: res.sell,
q1: res.q1, q1: res.q1,
median: res.median, median: res.median,
q3: res.q3, q3: res.q3,
+2 -5
View File
@@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import {getMarketTypes, TaxInput, useApraisalStore, useMarketTaxStore} from "@/market"; import {getMarketTypes, TaxInput, useMarketTaxStore} from "@/market";
import {BuyModal} from '@/market/acquisition'; import {BuyModal} from '@/market/acquisition';
import {ScanResult, ScanResultTable, toScanResult} from '@/market/scan'; import {ScanResult, ScanResultTable, toScanResult} from '@/market/scan';
import {marketApi} from "@/mammon"; import {marketApi} from "@/mammon";
@@ -8,7 +8,6 @@ import {ref, watch} from 'vue';
const buyModal = ref<typeof BuyModal>(); const buyModal = ref<typeof BuyModal>();
const apraisalStore = useApraisalStore();
const marketTaxStore = useMarketTaxStore(); const marketTaxStore = useMarketTaxStore();
const days = useStorage('market-scan-days', 365); const days = useStorage('market-scan-days', 365);
const items = ref<ScanResult[]>([]); const items = ref<ScanResult[]>([]);
@@ -23,13 +22,11 @@ const scan = async () => {
marketTaxStore.scc / 100 marketTaxStore.scc / 100
); );
const types = await getMarketTypes(data.map(r => r.marketTypeId)); const types = await getMarketTypes(data.map(r => r.marketTypeId));
const prices = await apraisalStore.getPrices(types);
items.value = data.flatMap(r => { items.value = data.flatMap(r => {
const type = types.find(t => t.id === r.marketTypeId); const type = types.find(t => t.id === r.marketTypeId);
const price = prices.find(p => p.type.id === r.marketTypeId);
return type && price ? [toScanResult(r, type, price)] : []; return type ? [toScanResult(r, type)] : [];
}); });
} finally { } finally {
loading.value = false; loading.value = false;