pinia: fix some stuff

This commit is contained in:
Matthias 2022-04-18 20:00:36 +02:00
parent 7bb2b0fe72
commit f7ec082720
4 changed files with 17 additions and 27 deletions

View File

@ -7,9 +7,9 @@
:key="comb.pair"
button
class="d-flex justify-content-between align-items-center py-1"
:active="comb.pair === selectedPair"
:active="comb.pair === botStore.activeBot.selectedPair"
:title="`${comb.pair} - ${comb.tradeCount} trades`"
@click="setSelectedPair(comb.pair)"
@click="botStore.activeBot.setSelectedPair(comb.pair)"
>
<div>
{{ comb.pair }}
@ -20,7 +20,7 @@
<ProfitPill
v-if="backtestMode && comb.tradeCount > 0"
:profit-ratio="comb.profit"
:stake-currency="stakeCurrency"
:stake-currency="botStore.activeBot.stakeCurrency"
/>
</b-list-group-item>
</b-list-group>
@ -28,13 +28,11 @@
<script lang="ts">
import { formatPercent, timestampms } from '@/shared/formatters';
import { BotStoreGetters } from '@/store/modules/ftbot';
import { Lock, Trade } from '@/types';
import TradeProfit from '@/components/ftbot/TradeProfit.vue';
import ProfitPill from '@/components/general/ProfitPill.vue';
import StoreModules from '@/store/storeSubModules';
import { defineComponent, computed } from '@vue/composition-api';
import { useNamespacedActions, useNamespacedGetters } from 'vuex-composition-helpers';
import { useBotStore } from '@/stores/ftbotwrapper';
interface CombinedPairList {
pair: string;
@ -59,12 +57,7 @@ export default defineComponent({
backtestMode: { required: false, default: false, type: Boolean },
},
setup(props) {
const { selectedPair, stakeCurrency } = useNamespacedGetters(StoreModules.ftbot, [
BotStoreGetters.selectedPair,
BotStoreGetters.stakeCurrency,
]);
const { setSelectedPair } = useNamespacedActions(StoreModules.ftbot, ['setSelectedPair']);
const botStore = useBotStore();
const combinedPairList = computed(() => {
const comb: CombinedPairList[] = [];
@ -144,9 +137,7 @@ export default defineComponent({
return {
combinedPairList,
tableFields,
selectedPair,
stakeCurrency,
setSelectedPair,
botStore,
};
},
});

View File

@ -3,40 +3,38 @@
<div class="mb-2">
<h3>Performance</h3>
</div>
<b-table class="table-sm" :items="performanceStats" :fields="tableFields"></b-table>
<b-table
class="table-sm"
:items="botStore.activeBot.performanceStats"
:fields="tableFields"
></b-table>
</div>
</template>
<script lang="ts">
import { formatPrice } from '@/shared/formatters';
import { BotStoreGetters } from '@/store/modules/ftbot';
import { defineComponent, computed } from '@vue/composition-api';
import { useNamespacedGetters } from 'vuex-composition-helpers';
import StoreModules from '@/store/storeSubModules';
import { useBotStore } from '@/stores/ftbotwrapper';
export default defineComponent({
name: 'Performance',
setup() {
const { performanceStats, botState } = useNamespacedGetters(StoreModules.ftbot, [
BotStoreGetters.performanceStats,
BotStoreGetters.botState,
]);
const botStore = useBotStore();
const tableFields = computed(() => {
return [
{ key: 'pair', label: 'Pair' },
{ key: 'profit', label: 'Profit %' },
{
key: 'profit_abs',
label: `Profit ${botState.value?.stake_currency}`,
label: `Profit ${botStore.activeBot.botState?.stake_currency}`,
formatter: (v: number) => formatPrice(v, 5),
},
{ key: 'count', label: 'Count' },
];
});
return {
performanceStats,
botState,
tableFields,
botStore,
};
},
});

View File

@ -158,6 +158,7 @@ export function createBotSubStore(botId: string, botName: string) {
},
botName: (state) => state.botState?.bot_name || 'freqtrade',
allTrades: (state) => [...state.openTrades, ...state.trades] as Trade[],
activeLocks: (state) => state.currentLocks?.locks || [],
},
actions: {
botAdded() {

View File

@ -27,7 +27,7 @@
<b-tab title="Pairs combined" active>
<PairSummary
:pairlist="botStore.activeBot.whitelist"
:current-locks="botStore.activeBot.currentLocks"
:current-locks="botStore.activeBot.activeLocks"
:trades="botStore.activeBot.openTrades"
/>
</b-tab>