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

View File

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

View File

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

View File

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