This commit is contained in:
Jun Su 2022-06-16 22:30:05 +08:00
parent 575d0d24a2
commit 12164b694d
6 changed files with 47 additions and 37 deletions

View File

@ -156,7 +156,6 @@ export interface GridStats {
}
export async function queryStrategiesMetrics(): Promise<GridStrategy[]> {
const temp = {
id: 'uuid',
instanceID: 'testInstanceID',
@ -168,7 +167,7 @@ export async function queryStrategiesMetrics(): Promise<GridStrategy[]> {
oneDayArbs: 0,
totalArbs: 3,
investment: 100,
totalProfits: 5.6,
totalProfits: 5.6,
gridProfits: 2.5,
floatingPNL: 3.1,
currentPrice: 29000,
@ -177,15 +176,15 @@ export async function queryStrategiesMetrics(): Promise<GridStrategy[]> {
},
status: 'RUNNING',
startTime: 1654938187102,
}
};
const testArr = [];
for(let i = 0; i < 11 ; i++){
const cloned = {...temp}
cloned.id = "uuid" + i;
for (let i = 0; i < 11; i++) {
const cloned = { ...temp };
cloned.id = 'uuid' + i;
testArr.push(cloned);
}
}
return testArr
return testArr;
}

View File

@ -26,7 +26,7 @@ export const Description = styled('div')(() => ({
},
}));
export default function Detail({ data }:{ data: GridStrategy}) {
export default function Detail({ data }: { data: GridStrategy }) {
const { strategy, stats, startTime } = data;
const totalProfitsPercentage = (stats.totalProfits / stats.investment) * 100;
const gridProfitsPercentage = (stats.gridProfits / stats.investment) * 100;
@ -40,19 +40,17 @@ export default function Detail({ data }:{ data: GridStrategy}) {
<StrategyContainer>
<Strategy>{strategy}</Strategy>
<div>{data[strategy].symbol}</div>
<RunningTime seconds={seconds}/>
<RunningTime seconds={seconds} />
<Description>
0 arbitrages in 24 hours / Total <span>{stats.totalArbs}</span> arbitrages
0 arbitrages in 24 hours / Total <span>{stats.totalArbs}</span>{' '}
arbitrages
</Description>
<Summary
stats={stats}
totalProfitsPercentage={totalProfitsPercentage}
/>
<Summary stats={stats} totalProfitsPercentage={totalProfitsPercentage} />
<Stats
stats={stats}
gridProfitsPercentage={gridProfitsPercentage}
stats={stats}
gridProfitsPercentage={gridProfitsPercentage}
gridAprPercentage={gridAprPercentage}
/>
</StrategyContainer>
);
}
}

View File

@ -1,5 +1,5 @@
import { styled } from '@mui/styles';
import { Description } from './Detail'
import { Description } from './Detail';
const RunningTimeSection = styled('div')(() => ({
display: 'flex',
@ -15,20 +15,20 @@ const StatusSign = styled('span')(() => ({
marginRight: '5px',
}));
export default function RunningTime({seconds}:{seconds: number}){
export default function RunningTime({ seconds }: { seconds: number }) {
const day = Math.floor(seconds / (60 * 60 * 24));
const hour = Math.floor((seconds % (60 * 60 * 24)) / 3600);
const min = Math.floor(((seconds % (60 * 60 * 24)) % 3600) / 60);
return (
<RunningTimeSection>
<StatusSign />
<Description>
Running for
<span className="duration">{day}</span>D
<span className="duration">{hour}</span>H
<span className="duration">{min}</span>M
</Description>
</RunningTimeSection>
<StatusSign />
<Description>
Running for
<span className="duration">{day}</span>D
<span className="duration">{hour}</span>H
<span className="duration">{min}</span>M
</Description>
</RunningTimeSection>
);
}
}

View File

@ -1,5 +1,5 @@
import { styled } from '@mui/styles';
import {StatsTitle, StatsValue, Percentage} from './Summary';
import { StatsTitle, StatsValue, Percentage } from './Summary';
const StatsSection = styled('div')(() => ({
display: 'grid',
@ -7,7 +7,15 @@ const StatsSection = styled('div')(() => ({
gap: '10px',
}));
export default function Stats({stats, gridProfitsPercentage, gridAprPercentage}:{stats: GridStats, gridProfitsPercentage: number, gridAprPercentage: number}){
export default function Stats({
stats,
gridProfitsPercentage,
gridAprPercentage,
}: {
stats: GridStats;
gridProfitsPercentage: number;
gridAprPercentage: number;
}) {
return (
<StatsSection>
<div>
@ -39,4 +47,4 @@ export default function Stats({stats, gridProfitsPercentage, gridAprPercentage}:
</div>
</StatsSection>
);
}
}

View File

@ -25,7 +25,13 @@ export const Percentage = styled('div')(() => ({
color: 'rgb(123, 169, 90)',
}));
export default function Summary({stats, totalProfitsPercentage}:{stats: GridStats,totalProfitsPercentage:number}) {
export default function Summary({
stats,
totalProfitsPercentage,
}: {
stats: GridStats;
totalProfitsPercentage: number;
}) {
return (
<SummarySection>
<SummaryBlock>
@ -39,5 +45,5 @@ export default function Summary({stats, totalProfitsPercentage}:{stats: GridStat
<Percentage>{totalProfitsPercentage}%</Percentage>
</SummaryBlock>
</SummarySection>
)
}
);
}

View File

@ -38,7 +38,6 @@ export default function Strategies() {
return <Detail key={element.id} data={element} />;
})}
</StrategiesContainer>
</DashboardLayout>
);
}