Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
orionflame opened this issue Dec 30, 2023 · 2 comments
Open

Comments

@orionflame
Copy link

orionflame commented Dec 30, 2023

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.

@orionflame orionflame changed the title Fixing the old code after updating to the latest API Is there a way to get the average price of a token bought from the API Dec 30, 2023
@XHighIntell
Copy link

Get the last 100 orders and calculate it

@deivid1
Copy link

deivid1 commented Dec 31, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants