Merge branch 'main' into dependabot/docker/dot-devcontainer/vscode/devcontainers/typescript-node-0.204.0-buster

This commit is contained in:
Matthias 2022-04-29 06:45:50 +02:00
commit f8c44d9adb
10 changed files with 80 additions and 58 deletions

View File

@ -48,6 +48,7 @@
"@typescript-eslint/parser": "^5.21.0",
"@vue/eslint-config-prettier": "^6.0.0",
"@vue/eslint-config-typescript": "^5.1.0",
"@vue/runtime-dom": "^3.2.33",
"@vue/test-utils": "^1.3.0",
"cypress": "^9.6.0",
"eslint": "^6.7.2",

View File

@ -56,7 +56,7 @@ forceexit
</button>
<button
v-if="botStore.activeBot.isWebserverMode && false"
:disabled="isTrading"
:disabled="botStore.activeBot.isTrading"
class="btn btn-secondary btn-sm ml-1"
title="Start Trading mode"
@click="botStore.activeBot.startTrade()"

View File

@ -86,7 +86,12 @@
<summary>Orders</summary>
<div v-for="(order, key) in trade.orders" :key="key">
<span>
(#{{ key + 1 }}) <DateTimeTZ :date="order.order_timestamp" show-timezone />
(#{{ key + 1 }})
<DateTimeTZ
v-if="order.order_timestamp"
:date="order.order_timestamp"
show-timezone
/>
<b class="ml-1">{{ order.ft_order_side }}</b> for
<b>{{ formatPrice(order.safe_price) }}</b> | {{ order.remaining }} /
{{ order.filled }}</span

13
src/shims-tsx.d.ts vendored
View File

@ -1,13 +0,0 @@
import Vue, { VNode } from 'vue';
declare global {
namespace JSX {
// tslint:disable no-empty-interface
type Element = VNode;
// tslint:disable no-empty-interface
type ElementClass = Vue;
interface IntrinsicElements {
[elem: string]: any;
}
}
}

5
src/shims.vue.d.ts vendored
View File

@ -1,5 +0,0 @@
declare module '*.vue' {
import Vue from 'vue';
export default Vue;
}

View File

@ -42,6 +42,7 @@ import {
BlacklistPayload,
ForceEnterPayload,
TradeResponse,
ClosedTrade,
} from '@/types';
import axios, { AxiosInstance, AxiosResponse } from 'axios';
import { defineStore } from 'pinia';
@ -62,7 +63,7 @@ export function createBotSubStore(botId: string, botName: string) {
versionState: '',
lastLogs: [] as LogLine[],
refreshRequired: true,
trades: [] as Trade[],
trades: [] as ClosedTrade[],
openTrades: [] as Trade[],
tradeCount: 0,
performanceStats: [] as Performance[],
@ -129,7 +130,7 @@ export function createBotSubStore(botId: string, botName: string) {
if (!dTrade) {
dTrade = state.trades.find((item) => item.trade_id === state.detailTradeId);
}
return dTrade;
return dTrade as Trade;
},
plotConfig: (state) =>
state.customPlotConfig[state.plotConfigName] || { ...EMPTY_PLOTCONFIG },
@ -255,30 +256,31 @@ export function createBotSubStore(botId: string, botName: string) {
const res = await fetchTrades(pageLength, 0);
const result: TradeResponse = res.data;
let { trades } = result;
if (Array.isArray(trades) && trades.length !== result.total_trades) {
// Pagination necessary
// Don't use Promise.all - this would fire all requests at once, which can
// cause problems for big sqlite databases
do {
// eslint-disable-next-line no-await-in-loop
const res = await fetchTrades(pageLength, trades.length);
if (Array.isArray(trades)) {
if (trades.length !== result.total_trades) {
// Pagination necessary
// Don't use Promise.all - this would fire all requests at once, which can
// cause problems for big sqlite databases
do {
// eslint-disable-next-line no-await-in-loop
const res = await fetchTrades(pageLength, trades.length);
const result: TradeResponse = res.data;
trades = trades.concat(result.trades);
totalTrades = res.data.total_trades;
} while (trades.length !== totalTrades);
const result: TradeResponse = res.data;
trades = trades.concat(result.trades);
totalTrades = res.data.total_trades;
} while (trades.length !== totalTrades);
}
const tradesCount = trades.length;
// Add botId to all trades
trades = trades.map((t) => ({
...t,
botId,
botName,
botTradeId: `${botId}__${t.trade_id}`,
}));
this.trades = trades;
this.tradeCount = tradesCount;
}
const tradesCount = trades.length;
// Add botId to all trades
trades = trades.map((t) => ({
...t,
botId,
botName,
botTradeId: `${botId}__${t.trade_id}`,
}));
this.trades = trades;
this.tradeCount = tradesCount;
return Promise.resolve();
} catch (error) {
if (axios.isAxiosError(error)) {
@ -304,14 +306,15 @@ export function createBotSubStore(botId: string, botName: string) {
this.refreshRequired = true;
this.refreshSlow(false);
}
const openTrades = result.data.map((t) => ({
...t,
botId,
botName,
botTradeId: `${botId}__${t.trade_id}`,
}));
this.openTrades = openTrades;
if (Array.isArray(result.data)) {
const openTrades = result.data.map((t) => ({
...t,
botId,
botName,
botTradeId: `${botId}__${t.trade_id}`,
}));
this.openTrades = openTrades;
}
})
.catch(console.error);
},

View File

@ -4,6 +4,7 @@ import {
BotDescriptor,
BotDescriptors,
BotState,
ClosedTrade,
DailyPayload,
DailyRecord,
DailyReturnValue,
@ -95,8 +96,8 @@ export const useBotStore = defineStore('wrapper', {
});
return result;
},
allTradesAllBots: (state): Trade[] => {
const result: Trade[] = [];
allTradesAllBots: (state): ClosedTrade[] => {
const result: ClosedTrade[] = [];
Object.entries(state.botStores).forEach(([, botStore]) => {
result.push(...botStore.trades);
});

View File

@ -1,5 +1,5 @@
import { Lock } from './locks';
import { Trade } from './trades';
import { ClosedTrade, Trade } from './trades';
export interface BacktestPayload {
strategy: string;
@ -46,7 +46,7 @@ export interface ExitReasonResults {
}
export interface StrategyBacktestResult {
trades: Trade[];
trades: ClosedTrade[];
locks: Lock[];
best_pair: PairResult;
worst_pair: PairResult;

View File

@ -33,5 +33,13 @@
"exclude": [
"node_modules",
// "tests"
]
],
"vueCompilerOptions": {
"experimentalCompatMode": 2,
"experimentalTemplateCompilerOptions": {
"compatConfig": {
"MODE": 2
} // optional
}
}
}

View File

@ -1523,13 +1523,30 @@
estree-walker "^2.0.2"
magic-string "^0.25.7"
"@vue/reactivity@^3.2.31":
"@vue/reactivity@3.2.33", "@vue/reactivity@^3.2.31":
version "3.2.33"
resolved "https://registry.yarnpkg.com/@vue/reactivity/-/reactivity-3.2.33.tgz#c84eedb5225138dbfc2472864c151d3efbb4b673"
integrity sha512-62Sq0mp9/0bLmDuxuLD5CIaMG2susFAGARLuZ/5jkU1FCf9EDbwUuF+BO8Ub3Rbodx0ziIecM/NsmyjardBxfQ==
dependencies:
"@vue/shared" "3.2.33"
"@vue/runtime-core@3.2.33":
version "3.2.33"
resolved "https://registry.yarnpkg.com/@vue/runtime-core/-/runtime-core-3.2.33.tgz#2df8907c85c37c3419fbd1bdf1a2df097fa40df2"
integrity sha512-N2D2vfaXsBPhzCV3JsXQa2NECjxP3eXgZlFqKh4tgakp3iX6LCGv76DLlc+IfFZq+TW10Y8QUfeihXOupJ1dGw==
dependencies:
"@vue/reactivity" "3.2.33"
"@vue/shared" "3.2.33"
"@vue/runtime-dom@^3.2.33":
version "3.2.33"
resolved "https://registry.yarnpkg.com/@vue/runtime-dom/-/runtime-dom-3.2.33.tgz#123b8969247029ea0d9c1983676d4706a962d848"
integrity sha512-LSrJ6W7CZTSUygX5s8aFkraDWlO6K4geOwA3quFF2O+hC3QuAMZt/0Xb7JKE3C4JD4pFwCSO7oCrZmZ0BIJUnw==
dependencies:
"@vue/runtime-core" "3.2.33"
"@vue/shared" "3.2.33"
csstype "^2.6.8"
"@vue/shared@3.2.33", "@vue/shared@^3.2.31":
version "3.2.33"
resolved "https://registry.yarnpkg.com/@vue/shared/-/shared-3.2.33.tgz#69a8c99ceb37c1b031d5cc4aec2ff1dc77e1161e"
@ -2211,6 +2228,11 @@ cssstyle@^2.3.0:
dependencies:
cssom "~0.3.6"
csstype@^2.6.8:
version "2.6.20"
resolved "https://registry.yarnpkg.com/csstype/-/csstype-2.6.20.tgz#9229c65ea0b260cf4d3d997cb06288e36a8d6dda"
integrity sha512-/WwNkdXfckNgw6S5R125rrW8ez139lBHWouiBvX8dfMFtcn6V81REDqnH7+CRpRipfYlyU1CmOnOxrmGcFOjeA==
cypress@^9.6.0:
version "9.6.0"
resolved "https://registry.yarnpkg.com/cypress/-/cypress-9.6.0.tgz#84473b3362255fa8f5e627a596e58575c9e5320f"