mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-11 02:33:51 +00:00
Add strategy endpoint
This commit is contained in:
parent
9416c4d39e
commit
5a6a71e08a
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<string>) {
|
||||
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', {
|
||||
|
|
|
@ -140,10 +140,17 @@ export interface ClosedTrade extends Trade {
|
|||
open_order_id?: string;
|
||||
}
|
||||
|
||||
export interface StrategyResult {
|
||||
export interface StrategyListResult {
|
||||
strategies: Array<string>;
|
||||
}
|
||||
|
||||
export interface StrategyResult {
|
||||
/** Strategy name */
|
||||
strategy: string;
|
||||
/** Code of the strategy class */
|
||||
code: string;
|
||||
}
|
||||
|
||||
export interface AvailablePairPayload {
|
||||
timeframe?: string;
|
||||
stake_currency?: string;
|
||||
|
|
Loading…
Reference in New Issue
Block a user