Skip to content

Commit

Permalink
fix(okx): free margin calculations of trading account (#892)
Browse files Browse the repository at this point in the history
  • Loading branch information
zccz14 authored Nov 9, 2024
1 parent 69fd0dc commit e25484f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 4 additions & 1 deletion apps/vendor-okx/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions common/changes/@yuants/vendor-okx/2024-11-09-23-28.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@yuants/vendor-okx",
"comment": "fix free margin calculations of trading account",
"type": "patch"
}
],
"packageName": "@yuants/vendor-okx"
}

0 comments on commit e25484f

Please sign in to comment.