Use "reduced" pair_history endpoint

This commit is contained in:
Matthias 2024-04-28 15:58:16 +02:00
parent d51246d1d1
commit fa18c043c4
3 changed files with 20 additions and 6 deletions

View File

@ -192,6 +192,7 @@ function refresh() {
timerange: props.timerange,
strategy: props.strategy,
freqaimodel: props.freqaiModel,
columns: plotStore.usedColumns,
});
} else {
botStore.activeBot.getPairCandles({
@ -234,7 +235,7 @@ watch(
() => {
// all plotstore.usedColumns are in the dataset
const hasAllColumns = plotStore.usedColumns.every((c) => datasetColumns.value.includes(c));
if (!props.historicView && settingsStore.useReducedPairCalls && !hasAllColumns) {
if (settingsStore.useReducedPairCalls && !hasAllColumns) {
console.log('triggering refresh');
refresh();
}

View File

@ -394,16 +394,28 @@ export function createBotSubStore(botId: string, botName: string) {
if (payload.pair && payload.timeframe) {
this.historyStatus = LoadingStatus.loading;
try {
const { data } = await api.get('/pair_history', {
const settingsStore = useSettingsStore();
let result: PairHistory | null = null;
if (this.botApiVersion >= 2.35 && settingsStore.useReducedPairCalls) {
// Modern approach, allowing filtering of columns
const { data } = await api.post<PairHistoryPayload, AxiosResponse<PairHistory>>(
'/pair_history',
payload,
);
result = data;
} else {
const { data } = await api.get<PairHistory>('/pair_history', {
params: { ...payload },
timeout: 50000,
});
result = data;
}
this.history = {
[`${payload.pair}__${payload.timeframe}`]: {
pair: payload.pair,
timeframe: payload.timeframe,
timerange: payload.timerange,
data: data,
data: result,
},
};
this.historyStatus = LoadingStatus.success;

View File

@ -27,6 +27,7 @@ export interface PairHistoryPayload {
timerange: string;
strategy: string;
freqaimodel?: string;
columns?: string[];
}
export interface PairHistory {