mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-23 19:45:15 +00:00
Add botstorewrapper
This commit is contained in:
parent
b2f893b9ec
commit
a2d8b68abb
|
@ -4,7 +4,8 @@ import Vuex from 'vuex';
|
||||||
import userService from '@/shared/userService';
|
import userService from '@/shared/userService';
|
||||||
import { getCurrentTheme, getTheme, storeCurrentTheme } from '@/shared/themes';
|
import { getCurrentTheme, getTheme, storeCurrentTheme } from '@/shared/themes';
|
||||||
import axios, { AxiosInstance } from 'axios';
|
import axios, { AxiosInstance } from 'axios';
|
||||||
import { createBotSubStore, BotStoreGetters } from './modules/ftbot';
|
import createBotStore from './modules/botStoreWrapper';
|
||||||
|
import { BotStoreGetters } from './modules/ftbot';
|
||||||
import alertsModule from './modules/alerts';
|
import alertsModule from './modules/alerts';
|
||||||
import layoutModule from './modules/layout';
|
import layoutModule from './modules/layout';
|
||||||
import settingsModule from './modules/settings';
|
import settingsModule from './modules/settings';
|
||||||
|
@ -16,7 +17,7 @@ const initCurrentTheme = getCurrentTheme();
|
||||||
|
|
||||||
export default new Vuex.Store({
|
export default new Vuex.Store({
|
||||||
modules: {
|
modules: {
|
||||||
ftbot: createBotSubStore(),
|
ftbot: createBotStore(),
|
||||||
alerts: alertsModule,
|
alerts: alertsModule,
|
||||||
layout: layoutModule,
|
layout: layoutModule,
|
||||||
uiSettings: settingsModule,
|
uiSettings: settingsModule,
|
||||||
|
@ -122,7 +123,7 @@ export default new Vuex.Store({
|
||||||
commit('setRefreshing', false);
|
commit('setRefreshing', false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async refreshSlow({ dispatch, commit, getters, state }, forceUpdate = false) {
|
async refreshSlow({ dispatch, getters, state }, forceUpdate = false) {
|
||||||
if (state.refreshing && !forceUpdate) {
|
if (state.refreshing && !forceUpdate) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -137,7 +138,7 @@ export default new Vuex.Store({
|
||||||
updates.push(dispatch('ftbot/getBlacklist'));
|
updates.push(dispatch('ftbot/getBlacklist'));
|
||||||
|
|
||||||
await Promise.all(updates);
|
await Promise.all(updates);
|
||||||
commit('ftbot/updateRefreshRequired', false);
|
dispatch('ftbot/setRefreshRequired', false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
refreshFrequent({ dispatch }, slow = true) {
|
refreshFrequent({ dispatch }, slow = true) {
|
||||||
|
|
36
src/store/modules/botStoreWrapper.ts
Normal file
36
src/store/modules/botStoreWrapper.ts
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
import { BotStoreActions, BotStoreGetters, createBotSubStore } from './ftbot';
|
||||||
|
|
||||||
|
export default function createBotStore() {
|
||||||
|
const state = {
|
||||||
|
selectedBot: 'ftbot.0',
|
||||||
|
};
|
||||||
|
const actions = {
|
||||||
|
// Actions automatically filled below
|
||||||
|
addBot(context, botName: string) {
|
||||||
|
//
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const getters = {};
|
||||||
|
// Autocreate getters
|
||||||
|
Object.keys(BotStoreGetters).forEach((e) => {
|
||||||
|
getters[e] = (state, getters) => {
|
||||||
|
return getters[`${state.selectedBot}/${e}`];
|
||||||
|
};
|
||||||
|
});
|
||||||
|
// Autocreate Actions
|
||||||
|
Object.keys(BotStoreActions).forEach((e) => {
|
||||||
|
actions[e] = ({ state, dispatch }, ...args) => {
|
||||||
|
return dispatch(`${state.selectedBot}/${e}`, ...args);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
namespaced: true,
|
||||||
|
modules: {
|
||||||
|
'ftbot.0': createBotSubStore(),
|
||||||
|
},
|
||||||
|
state,
|
||||||
|
getters,
|
||||||
|
actions,
|
||||||
|
};
|
||||||
|
}
|
|
@ -87,6 +87,7 @@ export enum BotStoreGetters {
|
||||||
|
|
||||||
export enum BotStoreActions {
|
export enum BotStoreActions {
|
||||||
ping = 'ping',
|
ping = 'ping',
|
||||||
|
setRefreshRequired = 'setRefreshRequired',
|
||||||
setDetailTrade = 'setDetailTrade',
|
setDetailTrade = 'setDetailTrade',
|
||||||
setSelectedPair = 'setSelectedPair',
|
setSelectedPair = 'setSelectedPair',
|
||||||
getTrades = 'getTrades',
|
getTrades = 'getTrades',
|
||||||
|
@ -388,6 +389,9 @@ export function createBotSubStore() {
|
||||||
.catch(console.error);
|
.catch(console.error);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
[BotStoreActions.setRefreshRequired]({ commit }, refreshRequired: boolean) {
|
||||||
|
commit('setRefreshRequired', refreshRequired);
|
||||||
|
},
|
||||||
[BotStoreActions.setDetailTrade]({ commit }, trade: Trade) {
|
[BotStoreActions.setDetailTrade]({ commit }, trade: Trade) {
|
||||||
commit('setDetailTrade', trade);
|
commit('setDetailTrade', trade);
|
||||||
},
|
},
|
||||||
|
|
|
@ -54,41 +54,42 @@ export interface FtbotStateType {
|
||||||
backtestHistory: Record<string, StrategyBacktestResult>;
|
backtestHistory: Record<string, StrategyBacktestResult>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const state: FtbotStateType = {
|
const state = (): FtbotStateType => {
|
||||||
version: '',
|
return {
|
||||||
lastLogs: [],
|
version: '',
|
||||||
refreshRequired: true,
|
lastLogs: [],
|
||||||
trades: [],
|
refreshRequired: true,
|
||||||
openTrades: [],
|
trades: [],
|
||||||
tradeCount: 0,
|
openTrades: [],
|
||||||
performanceStats: [],
|
tradeCount: 0,
|
||||||
whitelist: [],
|
performanceStats: [],
|
||||||
blacklist: [],
|
whitelist: [],
|
||||||
profit: {},
|
blacklist: [],
|
||||||
botState: undefined,
|
profit: {},
|
||||||
balance: {},
|
botState: undefined,
|
||||||
dailyStats: {},
|
balance: {},
|
||||||
pairlistMethods: [],
|
dailyStats: {},
|
||||||
detailTradeId: undefined,
|
pairlistMethods: [],
|
||||||
selectedPair: '',
|
detailTradeId: undefined,
|
||||||
candleData: {},
|
selectedPair: '',
|
||||||
history: {},
|
candleData: {},
|
||||||
strategyPlotConfig: undefined,
|
history: {},
|
||||||
customPlotConfig: {},
|
strategyPlotConfig: undefined,
|
||||||
plotConfigName: getPlotConfigName(),
|
customPlotConfig: {},
|
||||||
availablePlotConfigNames: getAllPlotConfigNames(),
|
plotConfigName: getPlotConfigName(),
|
||||||
strategyList: [],
|
availablePlotConfigNames: getAllPlotConfigNames(),
|
||||||
strategy: {},
|
strategyList: [],
|
||||||
pairlist: [],
|
strategy: {},
|
||||||
currentLocks: undefined,
|
pairlist: [],
|
||||||
// backtesting
|
currentLocks: undefined,
|
||||||
backtestRunning: false,
|
// backtesting
|
||||||
backtestProgress: 0.0,
|
backtestRunning: false,
|
||||||
backtestStep: BacktestSteps.none,
|
backtestProgress: 0.0,
|
||||||
backtestTradeCount: 0,
|
backtestStep: BacktestSteps.none,
|
||||||
backtestResult: undefined,
|
backtestTradeCount: 0,
|
||||||
selectedBacktestResultKey: '',
|
backtestResult: undefined,
|
||||||
backtestHistory: {},
|
selectedBacktestResultKey: '',
|
||||||
|
backtestHistory: {},
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export default state;
|
export default state;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user