bbgo_origin/frontend/pages/orders.js

73 lines
2.3 KiB
JavaScript
Raw Normal View History

2021-01-29 08:50:06 +00:00
import React, {useEffect, useState} from 'react';
2021-01-29 05:15:44 +00:00
import {makeStyles} from '@material-ui/core/styles';
import Typography from '@material-ui/core/Typography';
import Paper from '@material-ui/core/Paper';
2021-01-29 10:34:03 +00:00
import {queryClosedOrders} from '../api/bbgo';
2021-01-29 08:50:06 +00:00
import {DataGrid} from '@material-ui/data-grid';
2021-02-01 09:13:27 +00:00
import DashboardLayout from '../layouts/DashboardLayout';
2021-01-29 08:50:06 +00:00
const columns = [
{field: 'gid', headerName: 'GID', width: 80, type: 'number'},
2021-02-01 09:13:27 +00:00
{field: 'clientOrderID', headerName: 'Client Order ID', width: 130},
2021-01-29 08:50:06 +00:00
{field: 'exchange', headerName: 'Exchange'},
{field: 'symbol', headerName: 'Symbol'},
{field: 'orderType', headerName: 'Type'},
{field: 'side', headerName: 'Side', width: 90},
2021-02-01 09:13:27 +00:00
{field: 'averagePrice', headerName: 'Average Price', type: 'number', width: 120},
2021-01-29 08:50:56 +00:00
{field: 'quantity', headerName: 'Quantity', type: 'number'},
{field: 'executedQuantity', headerName: 'Executed Quantity', type: 'number'},
2021-01-29 08:50:06 +00:00
{field: 'status', headerName: 'Status'},
{field: 'isMargin', headerName: 'Margin'},
{field: 'isIsolated', headerName: 'Isolated'},
2021-01-29 10:53:07 +00:00
{field: 'creationTime', headerName: 'Create Time', width: 200},
2021-01-29 08:50:06 +00:00
];
2021-01-29 05:15:44 +00:00
const useStyles = makeStyles((theme) => ({
paper: {
2021-02-05 01:48:40 +00:00
margin: theme.spacing(2),
2021-01-29 05:15:44 +00:00
padding: theme.spacing(2),
},
2021-02-05 01:48:40 +00:00
dataGridContainer: {
display: 'flex',
height: 'calc(100vh - 64px - 120px)',
}
2021-01-29 05:15:44 +00:00
}));
export default function Orders() {
const classes = useStyles();
2021-01-29 08:50:06 +00:00
const [orders, setOrders] = useState([])
useEffect(() => {
2021-01-29 10:34:03 +00:00
queryClosedOrders({}, (orders) => {
2021-02-01 09:13:27 +00:00
setOrders(orders.map((o) => {
o.id = o.gid;
return o
}))
2021-01-29 08:50:06 +00:00
})
}, [])
2021-01-29 05:15:44 +00:00
return (
2021-02-01 09:13:27 +00:00
<DashboardLayout>
2021-02-05 01:48:40 +00:00
<Paper className={classes.paper}>
<Typography variant="h4" gutterBottom>
Orders
</Typography>
<div className={classes.dataGridContainer}>
<div style={{flexGrow: 1}}>
<DataGrid
rows={orders}
columns={columns}
pageSize={50}
autoPageSize={true}
/>
</div>
</div>
</Paper>
2021-02-01 09:13:27 +00:00
</DashboardLayout>
2021-01-29 05:15:44 +00:00
);
}