Implement apiv 2.35 pair_candles post call

This commit is contained in:
Matthias 2024-04-28 11:50:42 +02:00
parent e87daa38bf
commit 658271ea91
2 changed files with 26 additions and 11 deletions

View File

@ -52,6 +52,7 @@ import {
ExitStats, ExitStats,
EntryStats, EntryStats,
PairIntervalTuple, PairIntervalTuple,
PairHistory,
} from '@/types'; } from '@/types';
import axios, { AxiosResponse } from 'axios'; import axios, { AxiosResponse } from 'axios';
import { defineStore } from 'pinia'; import { defineStore } from 'pinia';
@ -349,17 +350,30 @@ export function createBotSubStore(botId: string, botName: string) {
if (payload.pair && payload.timeframe) { if (payload.pair && payload.timeframe) {
this.candleDataStatus = LoadingStatus.loading; this.candleDataStatus = LoadingStatus.loading;
try { try {
const result = await api.get('/pair_candles', { let result: PairHistory | null = null;
if (this.botApiVersion >= 2.35) {
// Modern approach, allowing filtering of columns
const { data } = await api.post<PairCandlePayload, AxiosResponse<PairHistory>>(
'/pair_candles',
payload,
);
result = data;
} else {
const { data } = await api.get<PairHistory>('/pair_candles', {
params: { ...payload }, params: { ...payload },
}); });
result = data;
}
if (result) {
this.candleData = { this.candleData = {
...this.candleData, ...this.candleData,
[`${payload.pair}__${payload.timeframe}`]: { [`${payload.pair}__${payload.timeframe}`]: {
pair: payload.pair, pair: payload.pair,
timeframe: payload.timeframe, timeframe: payload.timeframe,
data: result.data, data: result,
}, },
}; };
}
this.candleDataStatus = LoadingStatus.success; this.candleDataStatus = LoadingStatus.success;
} catch (err) { } catch (err) {
console.error(err); console.error(err);

View File

@ -209,6 +209,7 @@ export interface PairCandlePayload {
pair: string; pair: string;
timeframe: string; timeframe: string;
limit?: number; limit?: number;
columns?: string[];
} }
export interface PairHistoryPayload { export interface PairHistoryPayload {