feat: 添加现货和合约账户余额获取功能至基础套利引擎,更新UI以显示账户余额信息

This commit is contained in:
discountry
2025-10-07 16:06:14 +08:00
parent 58f5de4a48
commit d778e20c23
2 changed files with 108 additions and 0 deletions
+29
View File
@@ -87,6 +87,8 @@ export function BasisApp({ onExit }: BasisAppProps) {
const nextFundingTime = snapshot.nextFundingTime ? new Date(snapshot.nextFundingTime).toLocaleTimeString() : "-";
const feedStatus = snapshot.feedStatus;
const lastLogs = snapshot.tradeLog.slice(-5);
const spotBalances = (snapshot.spotBalances ?? []).filter((b) => Math.abs(b.free) > 0 || Math.abs(b.locked) > 0);
const futuresBalances = (snapshot.futuresBalances ?? []).filter((b) => Math.abs(b.wallet) > 0);
return (
<Box flexDirection="column" paddingX={1}>
@@ -118,6 +120,33 @@ export function BasisApp({ onExit }: BasisAppProps) {
<Text color="gray">: {fundingUpdated} : {nextFundingTime}</Text>
</Box>
<Box flexDirection="row" marginBottom={1}>
<Box flexDirection="column" marginRight={4}>
<Text color="cyan">0</Text>
{spotBalances.length ? (
spotBalances.map((b) => (
<Text key={`spot-${b.asset}`}>
{b.asset}: {formatNumber(b.free, 8)} {formatNumber(b.locked, 8)}
</Text>
))
) : (
<Text color="gray"></Text>
)}
</Box>
<Box flexDirection="column">
<Text color="cyan">0</Text>
{futuresBalances.length ? (
futuresBalances.map((b) => (
<Text key={`fut-${b.asset}`}>
{b.asset}: {formatNumber(b.wallet, 8)} {formatNumber(b.available, 8)}
</Text>
))
) : (
<Text color="gray"></Text>
)}
</Box>
</Box>
<Box flexDirection="column" marginBottom={1}>
<Text color={snapshot.opportunity ? "greenBright" : "redBright"}> / </Text>
<Text color={snapshot.opportunity ? "green" : undefined}>: {spread} USDT {spreadBps} bp</Text>