diff --git a/apps/vendor-okx/src/index.ts b/apps/vendor-okx/src/index.ts index d32035697..cf3f651b3 100644 --- a/apps/vendor-okx/src/index.ts +++ b/apps/vendor-okx/src/index.ts @@ -348,7 +348,10 @@ const tradingAccountInfo$ = combineLatest([ const usdtBalance = balanceApi.data[0]?.details.find((x) => x.ccy === 'USDT'); const equity = +(usdtBalance?.eq ?? 0); const balance = +(usdtBalance?.cashBal ?? 0); - const free = +(usdtBalance?.availEq ?? 0); + const free = Math.min( + balance, // free should no more than balance if there is much profits + +(usdtBalance?.availEq ?? 0), + ); const used = equity - free; // const used = +usdtBalance.frozenBal; const profit = equity - balance; diff --git a/common/changes/@yuants/vendor-okx/2024-11-09-23-28.json b/common/changes/@yuants/vendor-okx/2024-11-09-23-28.json new file mode 100644 index 000000000..1151a9507 --- /dev/null +++ b/common/changes/@yuants/vendor-okx/2024-11-09-23-28.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@yuants/vendor-okx", + "comment": "fix free margin calculations of trading account", + "type": "patch" + } + ], + "packageName": "@yuants/vendor-okx" +} \ No newline at end of file