2021-01-29 10:53:07 +00:00
|
|
|
import React, {useEffect, useState} from 'react';
|
|
|
|
|
|
|
|
import {makeStyles} from '@material-ui/core/styles';
|
|
|
|
import Typography from '@material-ui/core/Typography';
|
|
|
|
import Paper from '@material-ui/core/Paper';
|
|
|
|
import {queryTrades} from '../api/bbgo';
|
|
|
|
import {DataGrid} from '@material-ui/data-grid';
|
2021-02-01 09:13:27 +00:00
|
|
|
import DashboardLayout from '../layouts/DashboardLayout';
|
2021-01-29 10:53:07 +00:00
|
|
|
|
|
|
|
const columns = [
|
|
|
|
{field: 'gid', headerName: 'GID', width: 80, type: 'number'},
|
|
|
|
{field: 'exchange', headerName: 'Exchange'},
|
|
|
|
{field: 'symbol', headerName: 'Symbol'},
|
|
|
|
{field: 'side', headerName: 'Side', width: 90},
|
2021-02-01 09:13:27 +00:00
|
|
|
{field: 'price', headerName: 'Price', type: 'number', width: 120},
|
2021-01-29 10:53:07 +00:00
|
|
|
{field: 'quantity', headerName: 'Quantity', type: 'number'},
|
|
|
|
{field: 'isMargin', headerName: 'Margin'},
|
|
|
|
{field: 'isIsolated', headerName: 'Isolated'},
|
|
|
|
{field: 'tradedAt', headerName: 'Trade Time', width: 200},
|
|
|
|
];
|
|
|
|
|
|
|
|
const useStyles = makeStyles((theme) => ({
|
|
|
|
paper: {
|
2021-02-05 01:48:40 +00:00
|
|
|
margin: theme.spacing(2),
|
2021-01-29 10:53:07 +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 10:53:07 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
export default function Trades() {
|
|
|
|
const classes = useStyles();
|
|
|
|
|
|
|
|
const [trades, setTrades] = useState([])
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
queryTrades({}, (trades) => {
|
2021-02-01 09:13:27 +00:00
|
|
|
setTrades(trades.map((o) => {
|
|
|
|
o.id = o.gid;
|
|
|
|
return o
|
|
|
|
}))
|
2021-01-29 10:53:07 +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>
|
|
|
|
Trades
|
|
|
|
</Typography>
|
|
|
|
<div className={classes.dataGridContainer}>
|
|
|
|
<div style={{ flexGrow: 1 }}>
|
|
|
|
<DataGrid
|
|
|
|
rows={trades}
|
|
|
|
columns={columns}
|
|
|
|
showToolbar={true}
|
|
|
|
autoPageSize={true}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</Paper>
|
2021-02-01 09:13:27 +00:00
|
|
|
</DashboardLayout>
|
2021-01-29 10:53:07 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|