mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-23 11:35:14 +00:00
Add multitrade getter
This commit is contained in:
parent
c762009a6f
commit
52ab11b376
|
@ -1,4 +1,4 @@
|
|||
import { BotDescriptor, BotDescriptors } from '@/types';
|
||||
import { BotDescriptor, BotDescriptors, MultiClosedTrades } from '@/types';
|
||||
import { AxiosInstance } from 'axios';
|
||||
import { BotStoreActions, BotStoreGetters, createBotSubStore } from './ftbot';
|
||||
|
||||
|
@ -13,13 +13,14 @@ interface FTMultiBotState {
|
|||
export enum MultiBotStoreGetters {
|
||||
hasBots = 'hasBots',
|
||||
botCount = 'botCount',
|
||||
nextBotId = 'nextBotId',
|
||||
selectedBot = 'selectedBot',
|
||||
selectedBotObj = 'selectedBotObj',
|
||||
allAvailableBots = 'allAvailableBots',
|
||||
allAvailableBotsList = 'allAvailableBotsList',
|
||||
allIsBotOnline = 'allIsBotOnline',
|
||||
nextBotId = 'nextBotId',
|
||||
allAutoRefresh = 'allAutoRefresh',
|
||||
allClosedTrades = 'allClosedTrades',
|
||||
}
|
||||
|
||||
export default function createBotStore(store) {
|
||||
|
@ -39,6 +40,14 @@ export default function createBotStore(store) {
|
|||
[MultiBotStoreGetters.botCount](state: FTMultiBotState): number {
|
||||
return Object.keys(state.availableBots).length;
|
||||
},
|
||||
[MultiBotStoreGetters.nextBotId](state: FTMultiBotState): string {
|
||||
let botCount = Object.keys(state.availableBots).length;
|
||||
|
||||
while (`ftbot.${botCount}` in state.availableBots) {
|
||||
botCount += 1;
|
||||
}
|
||||
return `ftbot.${botCount}`;
|
||||
},
|
||||
[MultiBotStoreGetters.selectedBot](state: FTMultiBotState): string {
|
||||
return state.selectedBot;
|
||||
},
|
||||
|
@ -65,13 +74,13 @@ export default function createBotStore(store) {
|
|||
});
|
||||
return result;
|
||||
},
|
||||
[MultiBotStoreGetters.nextBotId](state: FTMultiBotState): string {
|
||||
let botCount = Object.keys(state.availableBots).length;
|
||||
[MultiBotStoreGetters.allClosedTrades](state: FTMultiBotState, getters): MultiClosedTrades {
|
||||
const result = {};
|
||||
|
||||
while (`ftbot.${botCount}` in state.availableBots) {
|
||||
botCount += 1;
|
||||
}
|
||||
return `ftbot.${botCount}`;
|
||||
getters.allAvailableBotsList.forEach((e) => {
|
||||
result[e] = getters[`${e}/closedTrades`];
|
||||
});
|
||||
return result;
|
||||
},
|
||||
};
|
||||
// Autocreate getters from botStores
|
||||
|
|
|
@ -79,3 +79,7 @@ export interface TradeResponse {
|
|||
/** Total trade count */
|
||||
total_trades: number;
|
||||
}
|
||||
|
||||
export interface MultiClosedTrades {
|
||||
[key: string]: ClosedTrade;
|
||||
}
|
||||
|
|
|
@ -147,8 +147,10 @@ import {
|
|||
ProfitInterface,
|
||||
DailyPayload,
|
||||
BotState,
|
||||
MultiClosedTrades,
|
||||
} from '@/types';
|
||||
import { BotStoreGetters } from '@/store/modules/ftbot';
|
||||
import { MultiBotStoreGetters } from '@/store/modules/botStoreWrapper';
|
||||
|
||||
const ftbot = namespace('ftbot');
|
||||
const layoutNs = namespace('layout');
|
||||
|
@ -167,6 +169,8 @@ const layoutNs = namespace('layout');
|
|||
export default class Dashboard extends Vue {
|
||||
@ftbot.Getter closedTrades!: Trade[];
|
||||
|
||||
@ftbot.Getter [MultiBotStoreGetters.allClosedTrades]!: MultiClosedTrades;
|
||||
|
||||
@ftbot.Getter [BotStoreGetters.dailyStats]!: DailyReturnValue;
|
||||
|
||||
@ftbot.Getter [BotStoreGetters.openTrades]!: Array<Trade>;
|
||||
|
|
Loading…
Reference in New Issue
Block a user