mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
apply moment js
This commit is contained in:
parent
fb5bcf635f
commit
4961214c1b
|
@ -1,5 +1,7 @@
|
|||
import React, {useEffect, useState} from 'react';
|
||||
|
||||
import moment from 'moment';
|
||||
|
||||
import TradingViewChart from './TradingViewChart';
|
||||
|
||||
import {ReportSummary} from "../types";
|
||||
|
@ -149,7 +151,8 @@ const ReportDetails = (props: ReportDetailsProps) => {
|
|||
</div>;
|
||||
}
|
||||
|
||||
const totalProfit = reportSummary.symbolReports.map((report) => report.pnl.profit).reduce((prev, cur) => prev + cur)
|
||||
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)
|
||||
|
||||
const totalBuyVolume = reportSummary.symbolReports.map((report) => report.pnl.buyVolume).reduce((prev, cur) => prev + cur)
|
||||
|
@ -165,9 +168,19 @@ const ReportDetails = (props: ReportDetailsProps) => {
|
|||
<div>
|
||||
{reportSummary.sessions.map((session) => <Badge>Exchange {session}</Badge>)}
|
||||
{reportSummary.symbols.map((symbol) => <Badge>{symbol}</Badge>)}
|
||||
|
||||
<Badge>{reportSummary.startTime.toString()} ~ {reportSummary.endTime.toString()}</Badge>
|
||||
<Badge>{
|
||||
moment.duration((new Date(reportSummary.endTime)).getTime() - (new Date(reportSummary.startTime)).getTime()).humanize()
|
||||
}</Badge>
|
||||
</div>
|
||||
<StatsGridIcons data={[
|
||||
{title: "Profit", value: "$" + totalProfit.toString(), dir: totalProfit > 0 ? "up" : "down"},
|
||||
{
|
||||
title: "Unrealized 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}`},
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
"d3-format": "^3.1.0",
|
||||
"d3-time-format": "^4.1.0",
|
||||
"lightweight-charts": "^3.8.0",
|
||||
"moment": "^2.29.3",
|
||||
"next": "12.1.6",
|
||||
"react": "18.1.0",
|
||||
"react-dom": "18.1.0",
|
||||
|
|
|
@ -1651,6 +1651,11 @@ minimist@^1.2.0, minimist@^1.2.6, minimist@~1.2.5:
|
|||
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44"
|
||||
integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==
|
||||
|
||||
moment@^2.29.3:
|
||||
version "2.29.3"
|
||||
resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.3.tgz#edd47411c322413999f7a5940d526de183c031f3"
|
||||
integrity sha512-c6YRvhEo//6T2Jz/vVtYzqBzwvPT95JBQ+smCytzf7c50oMZRsR/a4w88aD34I+/QVSfnoAnSBFPJHItlOMJVw==
|
||||
|
||||
ms@2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"
|
||||
|
|
Loading…
Reference in New Issue
Block a user