diff --git a/src/components/ftbot/StrategyList.vue b/src/components/ftbot/StrategyList.vue index 14be1016..7ea5a2d1 100644 --- a/src/components/ftbot/StrategyList.vue +++ b/src/components/ftbot/StrategyList.vue @@ -17,10 +17,14 @@ export default class StrategyList extends Vue { @ftbot.Action getStrategyList; + // eslint-disable-next-line @typescript-eslint/no-unused-vars + @ftbot.Action getStrategy!: (strategy: string) => void; + @ftbot.State strategyList; @Emit('input') emitStrategy(strategy: string) { + this.getStrategy(strategy); return strategy; } diff --git a/src/store/modules/ftbot.ts b/src/store/modules/ftbot.ts index 057b26a8..681e2e73 100644 --- a/src/store/modules/ftbot.ts +++ b/src/store/modules/ftbot.ts @@ -9,11 +9,12 @@ import { PairCandlePayload, PairHistoryPayload, PlotConfig, - StrategyResult, + StrategyListResult, EMPTY_PLOTCONFIG, AvailablePairPayload, PlotConfigStorage, WhitelistResponse, + StrategyResult, } from '@/types'; import { @@ -58,6 +59,7 @@ export default { plotConfigName: getPlotConfigName(), availablePlotConfigNames: getAllPlotConfigNames(), strategyList: [], + strategy: {}, pairlist: [], }, getters: { @@ -126,9 +128,12 @@ export default { setDetailTrade(state, trade: Trade) { state.detailTradeId = trade ? trade.trade_id : null; }, - updateStrategyList(state, result: StrategyResult) { + updateStrategyList(state, result: StrategyListResult) { state.strategyList = result.strategies; }, + updateStrategy(state, strategy: StrategyResult) { + state.strategy = strategy; + }, updatePairs(state, pairlist: Array) { state.pairlist = pairlist; }, @@ -241,6 +246,16 @@ export default { .then((result) => commit('updateStrategyList', result.data)) .catch(console.error); }, + async getStrategy({ commit }, strategy: string) { + try { + const result = await api.get(`/strategy/${strategy}`, {}); + commit('updateStrategy', result.data); + return Promise.resolve(result.data); + } catch (error) { + console.error(error); + return Promise.reject(error); + } + }, async getAvailablePairs({ commit }, payload: AvailablePairPayload) { try { const result = await api.get('/available_pairs', { diff --git a/src/types/types.ts b/src/types/types.ts index 3f3825ad..ca769e82 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -140,10 +140,17 @@ export interface ClosedTrade extends Trade { open_order_id?: string; } -export interface StrategyResult { +export interface StrategyListResult { strategies: Array; } +export interface StrategyResult { + /** Strategy name */ + strategy: string; + /** Code of the strategy class */ + code: string; +} + export interface AvailablePairPayload { timeframe?: string; stake_currency?: string;