bbgo_origin/apps/frontend/components/Detail.tsx

57 lines
1.6 KiB
TypeScript
Raw Normal View History

2022-06-16 08:47:35 +00:00
import { styled } from '@mui/styles';
import type { GridStrategy } from '../api/bbgo';
import RunningTime from './RunningTime';
import Summary from './Summary';
import Stats from './Stats';
const StrategyContainer = styled('section')(() => ({
display: 'flex',
flexDirection: 'column',
justifyContent: 'space-around',
2022-06-16 10:17:59 +00:00
width: '350px',
2022-06-16 08:47:35 +00:00
border: '1px solid rgb(248, 149, 35)',
borderRadius: '10px',
padding: '10px',
}));
const Strategy = styled('div')(() => ({
fontSize: '20px',
}));
export const Description = styled('div')(() => ({
color: 'rgb(140, 140, 140)',
'& .duration': {
marginLeft: '3px',
},
}));
2022-06-16 14:30:05 +00:00
export default function Detail({ data }: { data: GridStrategy }) {
2022-06-16 08:47:35 +00:00
const { strategy, stats, startTime } = data;
const totalProfitsPercentage = (stats.totalProfits / stats.investment) * 100;
const gridProfitsPercentage = (stats.gridProfits / stats.investment) * 100;
const gridAprPercentage = (stats.gridProfits / 5) * 365;
const now = Date.now();
const durationMilliseconds = now - startTime;
const seconds = durationMilliseconds / 1000;
return (
<StrategyContainer>
<Strategy>{strategy}</Strategy>
<div>{data[strategy].symbol}</div>
2022-06-16 14:30:05 +00:00
<RunningTime seconds={seconds} />
2022-06-16 08:47:35 +00:00
<Description>
2022-06-16 14:30:05 +00:00
0 arbitrages in 24 hours / Total <span>{stats.totalArbs}</span>{' '}
arbitrages
2022-06-16 08:47:35 +00:00
</Description>
2022-06-16 14:30:05 +00:00
<Summary stats={stats} totalProfitsPercentage={totalProfitsPercentage} />
2022-06-16 08:47:35 +00:00
<Stats
2022-06-16 14:30:05 +00:00
stats={stats}
gridProfitsPercentage={gridProfitsPercentage}
2022-06-16 08:47:35 +00:00
gridAprPercentage={gridAprPercentage}
/>
</StrategyContainer>
);
2022-06-16 14:30:05 +00:00
}