From 0ad62c5b589360d3982f6baf534fe31daad881ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B8=D0=B4=D0=B5=D0=BD=D0=BA=D0=BE=20=D0=9A=D0=B8?= =?UTF-8?q?=D1=80=D0=B8=D0=BB=D0=BB=20=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B5?= =?UTF-8?q?=D0=B2=D0=B8=D1=87?= Date: Sun, 5 Jun 2022 12:46:43 +0700 Subject: [PATCH] Improve backtest report ui --- .gitignore | 1 + .../components/ReportDetails.tsx | 65 ++++++++++--------- .../components/ReportNavigator.tsx | 3 +- .../components/TradingViewChart.tsx | 10 +-- apps/backtest-report/pages/index.tsx | 4 +- 5 files changed, 43 insertions(+), 40 deletions(-) diff --git a/.gitignore b/.gitignore index 25feb7f16..34051dcda 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,7 @@ bbgo.sqlite3 node_modules +output otp*png diff --git a/apps/backtest-report/components/ReportDetails.tsx b/apps/backtest-report/components/ReportDetails.tsx index effd153dc..8e3365ac0 100644 --- a/apps/backtest-report/components/ReportDetails.tsx +++ b/apps/backtest-report/components/ReportDetails.tsx @@ -50,35 +50,34 @@ function StatsGridIcons({data}: StatsGridIconsProps) { const DiffIcon = stat.diff && stat.diff > 0 ? ArrowUpRight : ArrowDownRight; const DirIcon = stat.dir && stat.dir == "up" ? ArrowUpRight : ArrowDownRight; - return ( + return ( - +
{stat.title} + {stat.dir ? + ({color: stat.dir == "up" ? theme.colors.teal[6] : theme.colors.red[6]})} + size={16} + radius="sx" + > + + + : null} - + {stat.value}
- {stat.dir ? - ({color: stat.dir == "up" ? theme.colors.teal[6] : theme.colors.red[6]})} - size={38} - radius="md" - > - - - : null} {stat.diff ? - +
+ {stats}
@@ -151,7 +150,7 @@ const BalanceDetails = (props: BalanceDetailsProps) => { ; }); - return + return
@@ -177,6 +176,8 @@ const ReportDetails = (props: ReportDetailsProps) => { ; } + const strategyName = props.runID.split("_")[1] + const runID = props.runID.split("_").pop() const totalProfit = Math.round(reportSummary.symbolReports.map((report) => report.pnl.profit).reduce((prev, cur) => prev + cur) * 100) / 100 const totalUnrealizedProfit = Math.round(reportSummary.symbolReports.map((report) => report.pnl.unrealizedProfit).reduce((prev, cur) => prev + cur) * 100) / 100 const totalTrades = reportSummary.symbolReports.map((report) => report.pnl.numTrades).reduce((prev, cur) => prev + cur) || 0 @@ -187,36 +188,36 @@ const ReportDetails = (props: ReportDetailsProps) => { const volumeUnit = reportSummary.symbolReports.length == 1 ? reportSummary.symbolReports[0].market.baseCurrency : ''; return
- - RUN {props.runID} +
- {reportSummary.sessions.map((session) => Exchange {session})} - {reportSummary.symbols.map((symbol) => {symbol})} + Strategy: {strategyName} + {reportSummary.sessions.map((session) => Exchange: {session})} + {reportSummary.symbols.map((symbol) => Symbol: {symbol})} - {reportSummary.startTime.toString()} ~ {reportSummary.endTime.toString()} - { + {reportSummary.startTime.toString()} — {reportSummary.endTime.toString()} ~ { moment.duration((new Date(reportSummary.endTime)).getTime() - (new Date(reportSummary.startTime)).getTime()).humanize() } + Run ID: {runID}
0 ? "up" : "down"}, + {title: "Profit", value: "$" + totalProfit.toString(), dir: totalProfit >= 0 ? "up" : "down"}, { - title: "Unrealized Profit", - value: "$" + totalUnrealizedProfit.toString(), + title: "Unr. Profit", + value: totalUnrealizedProfit.toString() + "$", dir: totalUnrealizedProfit > 0 ? "up" : "down" }, {title: "Trades", value: totalTrades.toString()}, - {title: "Buy Volume", value: totalBuyVolume.toString() + ` ${volumeUnit}`}, - {title: "Sell Volume", value: totalSellVolume.toString() + ` ${volumeUnit}`}, + {title: "Buy Vol", value: totalBuyVolume.toString() + ` ${volumeUnit}`}, + {title: "Sell Vol", value: totalSellVolume.toString() + ` ${volumeUnit}`}, ]}/> - + - Initial Total Balances + Initial Total Balances - Final Total Balances + Final Total Balances diff --git a/apps/backtest-report/components/ReportNavigator.tsx b/apps/backtest-report/components/ReportNavigator.tsx index 6c96d774e..55e16d3bc 100644 --- a/apps/backtest-report/components/ReportNavigator.tsx +++ b/apps/backtest-report/components/ReportNavigator.tsx @@ -11,6 +11,7 @@ function fetchIndex(basePath: string, setter: (data: any) => void) { .then((res) => res.json()) .then((data) => { console.log("reportIndex", data); + data.runs.reverse() // last reports render first setter(data); }) .catch((e) => { @@ -47,7 +48,7 @@ const ReportNavigator = (props: ReportNavigatorProps) => { size="xs" center icon={ - + } diff --git a/apps/backtest-report/components/TradingViewChart.tsx b/apps/backtest-report/components/TradingViewChart.tsx index b91d5bda3..c3153d722 100644 --- a/apps/backtest-report/components/TradingViewChart.tsx +++ b/apps/backtest-report/components/TradingViewChart.tsx @@ -173,9 +173,9 @@ const ordersToMarkets = (interval: string, orders: Array | void): Array | void): Array {
{ @@ -31,7 +31,7 @@ const Home: NextPage = () => { } header={ -
+
BBGO Back-Test Report
}
Currency