mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-27 05:25:17 +00:00
Show trading loading status
This commit is contained in:
parent
8d9ff616bb
commit
f39d3189b3
|
@ -64,7 +64,19 @@
|
||||||
:theme="getChartTheme"
|
:theme="getChartTheme"
|
||||||
>
|
>
|
||||||
</CandleChart>
|
</CandleChart>
|
||||||
<label v-else style="margin: auto auto; font-size: 1.5rem">No data available</label>
|
<div v-else class="m-auto">
|
||||||
|
<b-spinner
|
||||||
|
v-if="isLoadingDataset"
|
||||||
|
label="Spinning"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-else
|
||||||
|
style="font-size: 1.5rem"
|
||||||
|
>
|
||||||
|
{{ noDatasetText }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<transition name="fade" mode="in-out">
|
<transition name="fade" mode="in-out">
|
||||||
|
@ -131,8 +143,12 @@ export default class CandleChartContainer extends Vue {
|
||||||
|
|
||||||
@ftbot.Action setPlotConfigName;
|
@ftbot.Action setPlotConfigName;
|
||||||
|
|
||||||
|
@ftbot.Getter [BotStoreGetters.candleDataStatus]!: 'loading' | 'success' | 'error';
|
||||||
|
|
||||||
@ftbot.Getter [BotStoreGetters.candleData]!: PairHistory;
|
@ftbot.Getter [BotStoreGetters.candleData]!: PairHistory;
|
||||||
|
|
||||||
|
@ftbot.Getter [BotStoreGetters.historyStatus]!: 'loading' | 'success' | 'error';
|
||||||
|
|
||||||
@ftbot.Getter [BotStoreGetters.history]!: PairHistory;
|
@ftbot.Getter [BotStoreGetters.history]!: PairHistory;
|
||||||
|
|
||||||
@ftbot.Getter [BotStoreGetters.selectedPair]!: string;
|
@ftbot.Getter [BotStoreGetters.selectedPair]!: string;
|
||||||
|
@ -160,6 +176,32 @@ export default class CandleChartContainer extends Vue {
|
||||||
return this.dataset ? this.dataset.columns : [];
|
return this.dataset ? this.dataset.columns : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get isLoadingDataset(): boolean {
|
||||||
|
if (this.historicView) {
|
||||||
|
return this.historyStatus === 'loading';
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.candleDataStatus === 'loading';
|
||||||
|
}
|
||||||
|
|
||||||
|
get noDatasetText(): string {
|
||||||
|
const status = this.historicView ? this.historyStatus : this.candleDataStatus;
|
||||||
|
|
||||||
|
switch (status) {
|
||||||
|
case 'loading':
|
||||||
|
return 'Loading...';
|
||||||
|
|
||||||
|
case 'success':
|
||||||
|
return 'No data available';
|
||||||
|
|
||||||
|
case 'error':
|
||||||
|
return 'Failed to load data';
|
||||||
|
|
||||||
|
default:
|
||||||
|
return 'Unknown';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
get hasDataset(): boolean {
|
get hasDataset(): boolean {
|
||||||
return !!this.dataset;
|
return !!this.dataset;
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,12 +90,14 @@ export enum BotStoreGetters {
|
||||||
pairlist = 'pairlist',
|
pairlist = 'pairlist',
|
||||||
balance = 'balance',
|
balance = 'balance',
|
||||||
detailTradeId = 'detailTradeId',
|
detailTradeId = 'detailTradeId',
|
||||||
|
historyStatus = 'historyStatus',
|
||||||
history = 'history',
|
history = 'history',
|
||||||
lastLogs = 'lastLogs',
|
lastLogs = 'lastLogs',
|
||||||
performanceStats = 'performanceStats',
|
performanceStats = 'performanceStats',
|
||||||
dailyStats = 'dailyStats',
|
dailyStats = 'dailyStats',
|
||||||
strategy = 'strategy',
|
strategy = 'strategy',
|
||||||
strategyList = 'strategyList',
|
strategyList = 'strategyList',
|
||||||
|
candleDataStatus = 'candleDataStatus',
|
||||||
candleData = 'candleData',
|
candleData = 'candleData',
|
||||||
backtestRunning = 'backtestRunning',
|
backtestRunning = 'backtestRunning',
|
||||||
backtestStep = 'backtestStep',
|
backtestStep = 'backtestStep',
|
||||||
|
@ -310,9 +312,15 @@ export function createBotSubStore(botId: string, botName: string) {
|
||||||
[BotStoreGetters.strategyList](state: FtbotStateType): string[] {
|
[BotStoreGetters.strategyList](state: FtbotStateType): string[] {
|
||||||
return state.strategyList;
|
return state.strategyList;
|
||||||
},
|
},
|
||||||
|
[BotStoreGetters.candleDataStatus](state: FtbotStateType): 'loading' | 'success' | 'error' {
|
||||||
|
return state.candleDataStatus;
|
||||||
|
},
|
||||||
[BotStoreGetters.candleData](state: FtbotStateType): PairHistory | {} {
|
[BotStoreGetters.candleData](state: FtbotStateType): PairHistory | {} {
|
||||||
return state.candleData;
|
return state.candleData;
|
||||||
},
|
},
|
||||||
|
[BotStoreGetters.historyStatus](state: FtbotStateType): 'loading' | 'success' | 'error' {
|
||||||
|
return state.historyStatus;
|
||||||
|
},
|
||||||
// TODO: Type me
|
// TODO: Type me
|
||||||
[BotStoreGetters.history](state: FtbotStateType) {
|
[BotStoreGetters.history](state: FtbotStateType) {
|
||||||
return state.history;
|
return state.history;
|
||||||
|
@ -406,9 +414,15 @@ export function createBotSubStore(botId: string, botName: string) {
|
||||||
updatePairs(state: FtbotStateType, pairlist: string[]) {
|
updatePairs(state: FtbotStateType, pairlist: string[]) {
|
||||||
state.pairlist = pairlist;
|
state.pairlist = pairlist;
|
||||||
},
|
},
|
||||||
|
setCandleDataStatus(state: FtbotStateType, loading: 'loading' | 'success' | 'error') {
|
||||||
|
state.candleDataStatus = loading;
|
||||||
|
},
|
||||||
updatePairCandles(state: FtbotStateType, { pair, timeframe, data }) {
|
updatePairCandles(state: FtbotStateType, { pair, timeframe, data }) {
|
||||||
state.candleData = { ...state.candleData, [`${pair}__${timeframe}`]: data };
|
state.candleData = { ...state.candleData, [`${pair}__${timeframe}`]: data };
|
||||||
},
|
},
|
||||||
|
setHistoryStatus(state: FtbotStateType, loading: 'loading' | 'success' | 'error') {
|
||||||
|
state.historyStatus = loading;
|
||||||
|
},
|
||||||
updatePairHistory(state: FtbotStateType, { pair, timeframe, data }) {
|
updatePairHistory(state: FtbotStateType, { pair, timeframe, data }) {
|
||||||
// Intentionally drop the previous state here.
|
// Intentionally drop the previous state here.
|
||||||
state.history = { [`${pair}__${timeframe}`]: data };
|
state.history = { [`${pair}__${timeframe}`]: data };
|
||||||
|
@ -621,6 +635,7 @@ export function createBotSubStore(botId: string, botName: string) {
|
||||||
},
|
},
|
||||||
[BotStoreActions.getPairCandles]({ commit }, payload: PairCandlePayload) {
|
[BotStoreActions.getPairCandles]({ commit }, payload: PairCandlePayload) {
|
||||||
if (payload.pair && payload.timeframe) {
|
if (payload.pair && payload.timeframe) {
|
||||||
|
commit('setCandleDataStatus', 'loading');
|
||||||
return api
|
return api
|
||||||
.get('/pair_candles', {
|
.get('/pair_candles', {
|
||||||
params: { ...payload },
|
params: { ...payload },
|
||||||
|
@ -631,8 +646,12 @@ export function createBotSubStore(botId: string, botName: string) {
|
||||||
timeframe: payload.timeframe,
|
timeframe: payload.timeframe,
|
||||||
data: result.data,
|
data: result.data,
|
||||||
});
|
});
|
||||||
|
commit('setCandleDataStatus', 'success');
|
||||||
})
|
})
|
||||||
.catch(console.error);
|
.catch((err) => {
|
||||||
|
console.error(err);
|
||||||
|
commit('setCandleDataStatus', 'error');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
// Error branchs
|
// Error branchs
|
||||||
const error = 'pair or timeframe not specified';
|
const error = 'pair or timeframe not specified';
|
||||||
|
@ -643,6 +662,7 @@ export function createBotSubStore(botId: string, botName: string) {
|
||||||
},
|
},
|
||||||
[BotStoreActions.getPairHistory]({ commit }, payload: PairHistoryPayload) {
|
[BotStoreActions.getPairHistory]({ commit }, payload: PairHistoryPayload) {
|
||||||
if (payload.pair && payload.timeframe && payload.timerange) {
|
if (payload.pair && payload.timeframe && payload.timerange) {
|
||||||
|
commit('setHistoryStatus', 'loading');
|
||||||
return api
|
return api
|
||||||
.get('/pair_history', {
|
.get('/pair_history', {
|
||||||
params: { ...payload },
|
params: { ...payload },
|
||||||
|
@ -655,8 +675,12 @@ export function createBotSubStore(botId: string, botName: string) {
|
||||||
timerange: payload.timerange,
|
timerange: payload.timerange,
|
||||||
data: result.data,
|
data: result.data,
|
||||||
});
|
});
|
||||||
|
commit('setHistoryStatus', 'success');
|
||||||
})
|
})
|
||||||
.catch(console.error);
|
.catch((err) => {
|
||||||
|
console.error(err);
|
||||||
|
commit('setHistoryStatus', 'error');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
// Error branchs
|
// Error branchs
|
||||||
const error = 'pair or timeframe or timerange not specified';
|
const error = 'pair or timeframe or timerange not specified';
|
||||||
|
|
|
@ -40,8 +40,10 @@ export interface FtbotStateType {
|
||||||
selectedPair: string;
|
selectedPair: string;
|
||||||
// TODO: type me
|
// TODO: type me
|
||||||
candleData: {};
|
candleData: {};
|
||||||
|
candleDataStatus: 'loading' | 'success' | 'error';
|
||||||
// TODO: type me
|
// TODO: type me
|
||||||
history: {};
|
history: {};
|
||||||
|
historyStatus: 'loading' | 'success' | 'error';
|
||||||
strategyPlotConfig?: PlotConfig;
|
strategyPlotConfig?: PlotConfig;
|
||||||
customPlotConfig: PlotConfigStorage;
|
customPlotConfig: PlotConfigStorage;
|
||||||
plotConfigName: string;
|
plotConfigName: string;
|
||||||
|
@ -83,7 +85,9 @@ const state = (): FtbotStateType => {
|
||||||
detailTradeId: undefined,
|
detailTradeId: undefined,
|
||||||
selectedPair: '',
|
selectedPair: '',
|
||||||
candleData: {},
|
candleData: {},
|
||||||
|
candleDataStatus: 'loading',
|
||||||
history: {},
|
history: {},
|
||||||
|
historyStatus: 'loading',
|
||||||
strategyPlotConfig: undefined,
|
strategyPlotConfig: undefined,
|
||||||
customPlotConfig: {},
|
customPlotConfig: {},
|
||||||
plotConfigName: getPlotConfigName(),
|
plotConfigName: getPlotConfigName(),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user