From ec86d491350e903279931995330b4e8a7c0f9e72 Mon Sep 17 00:00:00 2001 From: c9s Date: Mon, 27 Jun 2022 16:50:01 +0800 Subject: [PATCH] add price change and improve time format --- apps/backtest-report/components/TradingViewChart.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/backtest-report/components/TradingViewChart.tsx b/apps/backtest-report/components/TradingViewChart.tsx index 1d5c2a35a..4752197da 100644 --- a/apps/backtest-report/components/TradingViewChart.tsx +++ b/apps/backtest-report/components/TradingViewChart.tsx @@ -648,7 +648,10 @@ const createLegendUpdater = (legend: HTMLDivElement, prefix: string) => { const createOHLCLegendUpdater = (legend: HTMLDivElement, prefix: string) => { return (param: any, time : any) => { if (param) { - legend.innerHTML = prefix + ` O: ${param.open} H: ${param.high} L: ${param.low} C: ${param.close} T: ${new Date(time * 1000)}`; + const change = param.close - param.open + const t = new Date(time * 1000) + const dateStr = moment(t).format("MMM Do YY hh:mm:ss A Z"); + legend.innerHTML = prefix + ` O: ${param.open} H: ${param.high} L: ${param.low} C: ${param.close} CHG: ${change} T: ${dateStr}`; } else { legend.innerHTML = prefix + ' O: - H: - L: - C: - T: -'; }