JKorf / Binance.Net

A C# .netstandard client library for the Binance REST and Websocket Spot and Futures API focusing on clear usage and models
https://jkorf.github.io/Binance.Net/
MIT License
1.02k stars 420 forks source link

Is there a way to get the average price of a token bought from the API #1336

Open orionflame opened 6 months ago

orionflame commented 6 months ago

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.

XHighIntell commented 6 months ago

Get the last 100 orders and calculate it

deivid1 commented 6 months ago

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