The Cryptonomics™
  • Home
  • Blockchain
  • Bitcoin
  • Ethereum
  • NFTS
  • Altcoin
  • Mining
  • Consulting
Reading: python – How is crossWalletBalance calculated with Binance perpetual futures in cross-margin mode?
Share

[ccpw id=”2210″]

The Cryptonomics™The Cryptonomics™
Font ResizerAa
Search
  • Home
  • Blockchain
  • Bitcoin
  • Ethereum
  • NFTS
  • Altcoin
  • Mining
  • Consulting
Follow US
  • About Us
  • Advertising Solutions
  • Privacy
  • Terms
  • Advertise
Copyright © MetaMedia™ Capital Inc, All right reserved
The Cryptonomics™ > Bitcoin > python – How is crossWalletBalance calculated with Binance perpetual futures in cross-margin mode?
Bitcoin

python – How is crossWalletBalance calculated with Binance perpetual futures in cross-margin mode?

admin
Last updated: January 21, 2025 12:02 am
admin Published January 21, 2025
Share
python – How is crossWalletBalance calculated with Binance perpetual futures in cross-margin mode?


I am attempting to breed and determine how crossWalletBalance worth, retrieved from Binance API, is calculated by Binance in USDⓈ-M perpetual futures. Significantly, I would want it for simulating the calculation of liquidation costs in cross-margin mode in response to the system famous right here. Nevertheless, I am persistently failing to breed the worth from Binance API.

So far as I perceive, in cross-margin mode crossWalletBalance corresponds to the whole steadiness, comprised of pockets steadiness and margin steadiness, which incorporates unrealized PnLs, as described right here.

So as to confirm my calculations, I take advantage of Binance Testnet, the place I place market orders utilizing Python’s CCXT bindings. Let’s suppose I open a number of brief positions. By fetching all positions with non-zero variety of contracts, I retrieve deserialized JSON with related information on all open positions grouped by symbols:

positions = alternate.fetch_account_positions()
[pos for pos in positions if float(pos['contracts']) != 0]

Present free USDT steadiness is fetched utilizing one other HTTP-request wrapped into CCXT’s alternate.fetch_free_balance().

Fields of weird curiosity among the many JSON are:

  • initMargin – place preliminary margin; I take advantage of it for calculating margin steadiness;
  • unrealizedProfit – UPnL; I additionally use it for calculating margin steadiness;
  • crossWalletBalance – floor fact worth for reference and checking whether or not my calculations are right;
  • crossMargin – for reference, to double-check that crossWalletBalance minus all unrealizedProfits equals to it.

I assume that the price taken is 0.0004, and have double-checked this reality utilizing the historical past of my trades on Binance Testnet web page.

I’ve tried a number of formulae modifications based mostly on beforehand talked about manuals. Significantly, I take advantage of pockets steadiness system from right here:

Pockets Stability = Whole Internet Switch + Whole Realized Revenue + Whole Internet Funding Charge - Whole Fee

…assuming that:

  • Whole Internet Switch equals to free USDT steadiness;
  • Whole Realized Revenue is zero, as quickly as positions are nonetheless open;
  • Whole Internet Funding Charge is zero, since positions are assumed to be closed nearly instantly, subsequently, funding charges don’t relate;
  • Whole Fee is 0.0004. It’s taken as soon as, since positions are nonetheless open;

Significantly, amongst others, I’ve tried the next formulae:

  • crossWalletBalance == free USDT steadiness * Whole Fee + initMargins for all positions + unrealizedProfit for all positions, signal included;
  • crossWalletBalance == free USDT steadiness + (initMargins for all positions + unrealizedProfit) * Whole Fee for all positions, signal included.
  • Totally different variations that disregard charges or embody margin charges.

Nevertheless, contemplating that collaterals are about 13000 digital “USDT”s, and the trades are throughout the leveraged vary of a number of 1000’s of USDTs, I persistently obtain values that differ from the bottom fact crossWalletBalance worth from a number of to tens-hundreds of “USDT”s, relying on the system.

I’d be glad about any assist or hints on this respect.



Supply hyperlink

You Might Also Like

Poorly understood, extensively unaccepted: The Bitcoin-at-$100,000 alternative

NFT Dealer Dumps His Punk Into Bids For 4.2 WETH

Bhutan Goes Absolutely Crypto for Tourism in Historic Partnership With Binance Pay

Falling DXY a part of US monetary system’s ‘long-term transition’ — Will Bitcoin proceed to shine?

Kraken completes latest Proof of Reserves, elevating the bar for crypto platform transparency

Share This Article
Facebook Twitter Email Copy Link Print
Previous Article Vitalik Buterin addresses controversy as Ethereum Basis sells one other 100 ETH Vitalik Buterin addresses controversy as Ethereum Basis sells one other 100 ETH
Next Article Coinbase Solana transactions delayed amid memecoin frenzy Coinbase Solana transactions delayed amid memecoin frenzy
Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Subscribe to our newslettern

Get Newest Articles Instantly!

- Advertisement -
Ad imageAd image
Popular News
Bitcoin hits 1k to reclaim six-figures as Trump confirms US, UK commerce deal
Bitcoin hits $101k to reclaim six-figures as Trump confirms US, UK commerce deal
The journey to a mature asset administration system
The journey to a mature asset administration system
High 3 Meme Coin Gems Price Shopping for Earlier than Could 2024 – PEPE, WIF, and DOGEVERSE
High 3 Meme Coin Gems Price Shopping for Earlier than Could 2024 – PEPE, WIF, and DOGEVERSE

Follow Us on Socials

We use social media to react to breaking news, update supporters and share information

Facebook Instagram Linkedin Pinterest Tiktok Twitter Youtube
The Cryptonomics™

Cryptonomics Magazine is your premier digital source for blockchain insights, offering cutting-edge research, news, interviews, and ICO updates for everyone from entrepreneurs to institutions. We drive blockchain knowledge and growth.

Subscribe to our newsletter

Always Stay Up to Date

Subscribe to our newsletter to get our newest articles instantly!

Bitcoin hits $101k to reclaim six-figures as Trump confirms US, UK commerce deal
May 9, 2025
Meta exploring stablecoin integration for payouts: Report
May 8, 2025
XRP Is Types Bullish Reverse Dragon Head Sample, How Excessive Can Worth Go?
May 8, 2025
Bitcoin Eyes $100K As Trump Teases “Main Commerce Deal”
May 8, 2025
Poorly understood, extensively unaccepted: The Bitcoin-at-$100,000 alternative
May 8, 2025
Copyright © The Cryptonomics™ , All right reserved
  • About Us
  • Advertising Solutions
  • Privacy
  • Terms
  • Advertise
Join Us!

Subscribe & Stay Ahead of the Curve with Cryptonomics !

Zero spam, Unsubscribe at any time.
Welcome Back!

Sign in to your account

Lost your password?