Binance.Net
Binance.Net copied to clipboard
Is there a way to get the average price of a token bought from the API
Hi,
With all the new changes since the last time I used this API, did Binance add any new functions to get the average price of a token bought by the user?
So if you bought 1 BTC at $100 and another one at $200, then the average price of your token, i.e. the unit price would be $150. From this you can calculate the PNL.
Or do they have a way to get the PNL for each token?
Thanks a lot in advance.
Get the last 100 orders and calculate it
Formula is: total token2 / total token1 = avg price eg: for ethbtc, total BTC traded / total ETH traded , and you get average price. You can confirm it in Binance position history, it should be exactly the same average price than the result of the formula