Tracking cryptocurrency prices using Binance API

After recently investing in various cryptocurrencies through Binance I found that their website didn’t show enough data regarding total profit/loss, they did however have an api which could be used to gather that data. The solution was to develop a simple (I am no developer!) site which would show current portfolio price and total profit/loss as an amount and as a percentage. You can see which endpoints Binance offer here . My approach was to find the total investment amount using the depositHistory enpoint, convert that to USD at the time of investment using the cryptocompare api (this api can give historical crypto prices so we can determine the cost at time of investment) and then find the price of my current investments by finding their ethereum price and converting that to usd. I am sure there is probably a more elegant way of doing this however I wanted something quick an easy. I called the cryptocompare api myself using HttpClient and passed in the symbol I wanted the price for and the time I wanted it (cryptocompare want the time as a timestamp).

HttpClient client = new HttpClient();
CryptoHistory usdPrice = null;
HttpResponseMessage usdResponse = await client.GetAsync("" +
 deposit.InsertTime.ToString().Remove(deposit.InsertTime.ToString().Length - 3));
if (usdResponse.IsSuccessStatusCode)

The Binance api was called using this C# client made by Jose Mejia and works perfectly so there was no point in calling the endpoints myself when someone else had wrapped it up. Anyway you can find the completed wesbite on my github here, I will warn you that is is very crude and I am no developer so it could all have probably been done a lot more elegantly using ajax and partialviews. Feel free to send a pull request with improvements. The finished site can be found here

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.