wikicrafter / bpnlcalc

PNL calculation for Futures trading

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

B-PNL Calc Demo

Keep in mind that this is still a simplified version and may not fully replicate Binance's exact calculations but I try my best!

Calculate Initial Investment:

This is the amount of money you initially invest in the trade.

Calculate Leverage Multiplier:

Convert the leverage ratio to a multiplier: 1 + (leverage / 100).

Calculate Contract Quantity:

Divide the initial investment by the entry price and multiply by the leverage multiplier: (initialInvestment / entryPrice) * leverageMultiplier.

Calculate Entry and Exit Values:

Multiply the contract quantity by the entry and exit prices to get the total value at entry and exit: entryValue = contractQuantity * entryPrice, exitValue = contractQuantity * exitPrice.

Calculate Profit or Loss:

The profit or loss is the difference between the exit value and entry value: profitLoss = exitValue - entryValue.

Calculate Funding Cost:

Funding costs are commonly associated with perpetual contracts and are calculated based on the funding rate and the duration the position is held: fundingCost = (entryValue + exitValue) * (fundingRate / 100) * (daysHeld / 365).

Calculate Trading Fee:

Trading fees are calculated as a percentage of the total value of the trade: totalTradingFee = (entryValue + exitValue) * (tradingFee / 100).

Calculate Total Costs:

Sum up all the costs, including trading fees and funding costs: totalCosts = totalTradingFee + fundingCost.

NFA & DYOR

If you like my repo and want to support me then here is my USDT address on Tron (TRC20) Chain: TLL3LgZeCAn7QsJ8RZuADpn5mawbELwmgx

About

PNL calculation for Futures trading

License:MIT License


Languages

Language:JavaScript 44.6%Language:HTML 41.1%Language:CSS 14.3%