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