diff --git a/src/store/modules/ftbot.ts b/src/store/modules/ftbot.ts index 4ce4a06e..73dc58e6 100644 --- a/src/store/modules/ftbot.ts +++ b/src/store/modules/ftbot.ts @@ -11,6 +11,7 @@ import { PlotConfig, StrategyResult, EMPTY_PLOTCONFIG, + AvailablePairPayload, } from '@/types'; import { saveCustomPlotConfig } from '@/shared/storage'; @@ -44,6 +45,7 @@ export default { strategyPlotConfig: {}, customPlotConfig: { ...EMPTY_PLOTCONFIG }, strategyList: [], + pairlist: [], }, getters: { [BotStoreGetters.openTrades](state) { @@ -102,6 +104,9 @@ export default { updateStrategyList(state, result: StrategyResult) { state.strategyList = result.strategies; }, + updatePairs(state, pairlist: Array) { + state.pairlist = pairlist; + }, updatePairCandles(state, { pair, timeframe, data }) { state.candleData = { ...state.candleData, [`${pair}__${timeframe}`]: data }; }, @@ -202,6 +207,18 @@ export default { .then((result) => commit('updateStrategyList', result.data)) .catch(console.error); }, + getAvailablePairs({ commit }, payload: AvailablePairPayload) { + return api + .get('/available_pairs', { + params: { ...payload }, + }) + .then((result) => { + // result is of type AvailablePairResult + const { pairs } = result.data; + commit('updatePairs', pairs); + }) + .catch(console.error); + }, getPerformance({ commit }) { return api .get('/performance') diff --git a/src/types/types.ts b/src/types/types.ts index 02be5995..3b3f8d72 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -144,6 +144,20 @@ export interface StrategyResult { strategies: Array; } +export interface AvailablePairPayload { + timeframe?: string; + stake_currency?: string; +} + +export interface AvailablePairResult { + pairs: Array; + /** + * List of lists, as [pair, timeframe] + */ + pair_interval: Array>; + length: number; +} + export interface PairCandlePayload { pair: string; timeframe: string; diff --git a/src/views/Graphs.vue b/src/views/Graphs.vue index 430d5609..8918f722 100644 --- a/src/views/Graphs.vue +++ b/src/views/Graphs.vue @@ -8,7 +8,12 @@
- + +
@@ -55,6 +60,8 @@ export default class Graphs extends Vue { timerange = ''; + @ftbot.State pairlist; + @ftbot.State candleData; @ftbot.State history; @@ -72,10 +79,13 @@ export default class Graphs extends Vue { @ftbot.Action public getWhitelist; + @ftbot.Action + public getAvailablePairs!: (payload: AvailablePairPayload) => void; + mounted() { this.getWhitelist(); this.refresh(); - // eslint-disable-next-line @typescript-eslint/camelcase + this.getAvailablePairs({ timeframe: this.timeframe }); } get dataset() {