mirror of
https://github.com/c9s/bbgo.git
synced 2024-09-20 08:11:08 +00:00
show order tag in the order list
This commit is contained in:
parent
2784408b8b
commit
11dacbc2cd
|
@ -1,6 +1,7 @@
|
||||||
import {Button, Checkbox, Group, Table} from "@mantine/core";
|
import {Button, Checkbox, Group, Table} from "@mantine/core";
|
||||||
import React, {useState} from "react";
|
import React, {useState} from "react";
|
||||||
import {Order} from "../types";
|
import {Order} from "../types";
|
||||||
|
import moment from "moment";
|
||||||
|
|
||||||
interface OrderListTableProps {
|
interface OrderListTableProps {
|
||||||
orders: Order[];
|
orders: Order[];
|
||||||
|
@ -12,7 +13,7 @@ const OrderListTable = (props: OrderListTableProps) => {
|
||||||
let orders = props.orders;
|
let orders = props.orders;
|
||||||
|
|
||||||
const [showCanceledOrders, setShowCanceledOrders] = useState(false);
|
const [showCanceledOrders, setShowCanceledOrders] = useState(false);
|
||||||
const [limit, setLimit] = useState(props.limit || 5);
|
const [limit, setLimit] = useState(props.limit || 100);
|
||||||
|
|
||||||
if (!showCanceledOrders) {
|
if (!showCanceledOrders) {
|
||||||
orders = orders.filter((order: Order) => {
|
orders = orders.filter((order: Order) => {
|
||||||
|
@ -40,7 +41,8 @@ const OrderListTable = (props: OrderListTableProps) => {
|
||||||
<td>{order.price}</td>
|
<td>{order.price}</td>
|
||||||
<td>{order.quantity}</td>
|
<td>{order.quantity}</td>
|
||||||
<td>{order.status}</td>
|
<td>{order.status}</td>
|
||||||
<td>{order.creation_time.toString()}</td>
|
<td>{formatDate(order.creation_time)}</td>
|
||||||
|
<td>{order.tag}</td>
|
||||||
</tr>
|
</tr>
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -63,6 +65,7 @@ const OrderListTable = (props: OrderListTableProps) => {
|
||||||
<th>Quantity</th>
|
<th>Quantity</th>
|
||||||
<th>Status</th>
|
<th>Status</th>
|
||||||
<th>Creation Time</th>
|
<th>Creation Time</th>
|
||||||
|
<th>Tag</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>{rows}</tbody>
|
<tbody>{rows}</tbody>
|
||||||
|
@ -70,4 +73,9 @@ const OrderListTable = (props: OrderListTableProps) => {
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const formatDate = (d : Date) : string => {
|
||||||
|
return moment(d).format("MMM Do YY hh:mm:ss A Z");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export default OrderListTable;
|
export default OrderListTable;
|
||||||
|
|
|
@ -657,6 +657,10 @@ const createLegendUpdater = (legend: HTMLDivElement, prefix: string) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const formatDate = (d : Date) : string => {
|
||||||
|
return moment(d).format("MMM Do YY hh:mm:ss A Z");
|
||||||
|
}
|
||||||
|
|
||||||
const createOHLCLegendUpdater = (legend: HTMLDivElement, prefix: string) => {
|
const createOHLCLegendUpdater = (legend: HTMLDivElement, prefix: string) => {
|
||||||
return (param: any, time : any) => {
|
return (param: any, time : any) => {
|
||||||
if (param) {
|
if (param) {
|
||||||
|
@ -664,7 +668,7 @@ const createOHLCLegendUpdater = (legend: HTMLDivElement, prefix: string) => {
|
||||||
const changePercentage = Math.round((param.close - param.open) / param.close * 10000.0) / 100.0;
|
const changePercentage = Math.round((param.close - param.open) / param.close * 10000.0) / 100.0;
|
||||||
const ampl = Math.round((param.high - param.low) / param.low * 10000.0) / 100.0;
|
const ampl = Math.round((param.high - param.low) / param.low * 10000.0) / 100.0;
|
||||||
const t = new Date(time * 1000);
|
const t = new Date(time * 1000);
|
||||||
const dateStr = moment(t).format("MMM Do YY hh:mm:ss A Z");
|
const dateStr = formatDate(t);
|
||||||
legend.innerHTML = prefix + ` O: ${param.open} H: ${param.high} L: ${param.low} C: ${param.close} CHG: ${change} (${changePercentage}%) AMP: ${ampl}% T: ${dateStr}`;
|
legend.innerHTML = prefix + ` O: ${param.open} H: ${param.high} L: ${param.low} C: ${param.close} CHG: ${change} (${changePercentage}%) AMP: ${ampl}% T: ${dateStr}`;
|
||||||
} else {
|
} else {
|
||||||
legend.innerHTML = prefix + ' O: - H: - L: - C: - T: -';
|
legend.innerHTML = prefix + ' O: - H: - L: - C: - T: -';
|
||||||
|
|
|
@ -11,4 +11,5 @@ export interface Order {
|
||||||
update_time: Date;
|
update_time: Date;
|
||||||
creation_time: Date;
|
creation_time: Date;
|
||||||
time?: Date;
|
time?: Date;
|
||||||
|
tag?: string;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user