bbgo_origin/frontend/pages/trades.js

69 lines
1.8 KiB
JavaScript
Raw Normal View History

2022-06-11 00:57:54 +00:00
import React, { useEffect, useState } from 'react';
2021-01-29 10:53:07 +00:00
2022-06-12 15:19:39 +00:00
import { makeStyles } from '@mui/styles';
2022-06-12 15:11:42 +00:00
import Typography from '@mui/material/Typography';
import Paper from '@mui/material/Paper';
2022-06-11 00:57:54 +00:00
import { queryTrades } from '../api/bbgo';
2022-06-12 15:09:12 +00:00
import { DataGrid } from '@mui/x-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 = [
2022-06-11 00:57:54 +00:00
{ field: 'gid', headerName: 'GID', width: 80, type: 'number' },
{ field: 'exchange', headerName: 'Exchange' },
{ field: 'symbol', headerName: 'Symbol' },
{ field: 'side', headerName: 'Side', width: 90 },
{ field: 'price', headerName: 'Price', type: 'number', width: 120 },
{ field: 'quantity', headerName: 'Quantity', type: 'number' },
{ field: 'isMargin', headerName: 'Margin' },
{ field: 'isIsolated', headerName: 'Isolated' },
{ field: 'tradedAt', headerName: 'Trade Time', width: 200 },
2021-01-29 10:53:07 +00:00
];
const useStyles = makeStyles((theme) => ({
2022-06-11 00:57:54 +00:00
paper: {
margin: theme.spacing(2),
padding: theme.spacing(2),
},
dataGridContainer: {
display: 'flex',
height: 'calc(100vh - 64px - 120px)',
},
2021-01-29 10:53:07 +00:00
}));
export default function Trades() {
2022-06-11 00:57:54 +00:00
const classes = useStyles();
2021-01-29 10:53:07 +00:00
2022-06-11 00:57:54 +00:00
const [trades, setTrades] = useState([]);
2021-01-29 10:53:07 +00:00
2022-06-11 00:57:54 +00:00
useEffect(() => {
queryTrades({}, (trades) => {
setTrades(
trades.map((o) => {
o.id = o.gid;
return o;
2021-01-29 10:53:07 +00:00
})
2022-06-11 00:57:54 +00:00
);
});
}, []);
2021-01-29 10:53:07 +00:00
2022-06-11 00:57:54 +00:00
return (
<DashboardLayout>
<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>
</DashboardLayout>
);
2021-01-29 10:53:07 +00:00
}