Add available_pairs to select historic data pairs

This commit is contained in:
Matthias 2020-08-01 17:39:47 +02:00
parent 32fa21fbf8
commit c9c5d5a6cd
3 changed files with 43 additions and 2 deletions

View File

@ -11,6 +11,7 @@ import {
PlotConfig, PlotConfig,
StrategyResult, StrategyResult,
EMPTY_PLOTCONFIG, EMPTY_PLOTCONFIG,
AvailablePairPayload,
} from '@/types'; } from '@/types';
import { saveCustomPlotConfig } from '@/shared/storage'; import { saveCustomPlotConfig } from '@/shared/storage';
@ -44,6 +45,7 @@ export default {
strategyPlotConfig: {}, strategyPlotConfig: {},
customPlotConfig: { ...EMPTY_PLOTCONFIG }, customPlotConfig: { ...EMPTY_PLOTCONFIG },
strategyList: [], strategyList: [],
pairlist: [],
}, },
getters: { getters: {
[BotStoreGetters.openTrades](state) { [BotStoreGetters.openTrades](state) {
@ -102,6 +104,9 @@ export default {
updateStrategyList(state, result: StrategyResult) { updateStrategyList(state, result: StrategyResult) {
state.strategyList = result.strategies; state.strategyList = result.strategies;
}, },
updatePairs(state, pairlist: Array<string>) {
state.pairlist = pairlist;
},
updatePairCandles(state, { pair, timeframe, data }) { updatePairCandles(state, { pair, timeframe, data }) {
state.candleData = { ...state.candleData, [`${pair}__${timeframe}`]: data }; state.candleData = { ...state.candleData, [`${pair}__${timeframe}`]: data };
}, },
@ -202,6 +207,18 @@ export default {
.then((result) => commit('updateStrategyList', result.data)) .then((result) => commit('updateStrategyList', result.data))
.catch(console.error); .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 }) { getPerformance({ commit }) {
return api return api
.get('/performance') .get('/performance')

View File

@ -144,6 +144,20 @@ export interface StrategyResult {
strategies: Array<string>; strategies: Array<string>;
} }
export interface AvailablePairPayload {
timeframe?: string;
stake_currency?: string;
}
export interface AvailablePairResult {
pairs: Array<string>;
/**
* List of lists, as [pair, timeframe]
*/
pair_interval: Array<Array<string>>;
length: number;
}
export interface PairCandlePayload { export interface PairCandlePayload {
pair: string; pair: string;
timeframe: string; timeframe: string;

View File

@ -8,7 +8,12 @@
<b-button @click="refresh">&#x21bb;</b-button> <b-button @click="refresh">&#x21bb;</b-button>
</div> </div>
<div class="col-mb-2"> <div class="col-mb-2">
<b-form-select :options="whitelist" v-model="pair" @change="refresh"> </b-form-select> <b-form-select
:options="historicView ? pairlist : whitelist"
v-model="pair"
@change="refresh"
>
</b-form-select>
</div> </div>
</div> </div>
<div class="mt-2 row" v-if="historicView"> <div class="mt-2 row" v-if="historicView">
@ -55,6 +60,8 @@ export default class Graphs extends Vue {
timerange = ''; timerange = '';
@ftbot.State pairlist;
@ftbot.State candleData; @ftbot.State candleData;
@ftbot.State history; @ftbot.State history;
@ -72,10 +79,13 @@ export default class Graphs extends Vue {
@ftbot.Action @ftbot.Action
public getWhitelist; public getWhitelist;
@ftbot.Action
public getAvailablePairs!: (payload: AvailablePairPayload) => void;
mounted() { mounted() {
this.getWhitelist(); this.getWhitelist();
this.refresh(); this.refresh();
// eslint-disable-next-line @typescript-eslint/camelcase this.getAvailablePairs({ timeframe: this.timeframe });
} }
get dataset() { get dataset() {