Wouldn’t we expect that honour to go to Bitcoin, with symbol BTC? And what about all those other coins that you’ve probably never heard of? What’s going on here? Now we can go ahead and create a DataFrame from our coin_data dictionary and sort it by market capitalization:Ĭoin_data = pd.om_dict(coin_data, orient='index')Ĭoin_data = coin_data.sort_values('MKTCAP', ascending=False)Īll good so far, but interrogating this data by doing coin_data.head(20) reveals that the coin with the highest market cap is something called AMO: That key is going to be troublesome when we turn our dictionary into a more analysis-friendly data structure, like a pandas DataFrame , so let’s get rid of it: That ‘USD’ key is common to all the coins in coin_data and it specifies the counter-currency in which prices are displayed. Each outer key corresponds to a coin symbol, and looks like this: Message = cc.get_price(coins_to_get, curr='USD', full=True)Ĭoin_data now contains a whole bunch of dictionaries-within-dictionaries that hold our data. # limited to a list containing at most 300 characters # Here’s the code for accomplishing all that: In our case, we prefer to work with the raw data, so we’ll keep it and discard the rest. Note that the outer-most keys in the resulting dictionary are ‘RAW’ and ‘DISPLAY’ which hold the raw data and data formatted for better displaying respectively. The API returns a json string, which we can interpret as a dictionary in Python. To get around that limitation, we’ll pass lists of 50 coins at a time, until we’ve passed our entire list of all available coins. We can get price data for a list of coins using the function cryptocompare.get_price() and if we specify full=True , the API will return a whole bunch of data for each coin in the list, including last traded price, 24-hour volume, number of coins in circulation, and of course market capitalisation.Ĭryptocompare’s API will only allow us to pass it a list of coins that contains no more than 300 characters at any one time. Let’s focus on the biggest players in crypto-world: the coins with the largest market capitalisation. To get a list of all the coins available on Cryptocompare, we can use the following Python script:Īt the time of writing, this returned a list of 2,609 coins! By comparison, there are around 2,800 stocks listed on the New York Stock Exchange. ![]() Now that we’ve got our library of API functions, let’s take a look at what we can do with Cryptocompare! List all Available Coins If you’re feeling adventurous, you can install the version that I forked into my own Git Hub account and modified to increase those limits. This version will limit you to one month’s worth of daily price data and one week’s worth of hourly data. To install the dev version from Git Hub, do: ![]() You can install the current stable release by doing pip install cryptocompare , but I installed the latest development version direct from Git Hub, as only that version had support for minutely price history at the time of writing. For this post, I decided to use a library called cryptocompare . ![]() When it comes to interacting with Cryptocompare’s API, there are already some nice Python libraries that take care of most of the heavy lifting for us. It is possible to drill down and extract information from individual exchanges, and even to take aggregated price feeds from all the exchanges that Cryptocompare is plugged into – and there are quite a few! Interacting with the Cryptocompare API The user-experience is quite pleasant, as you can see from the screenshot of their real-time coin comparison table:Īs nice as the user-interface is, what I really like about Cryptocompare is its API, which provides programmatic access to a wealth of crypto-related data. ![]() Cryptocompare is a platform providing data and insights on pretty much everything in the crypto-sphere, from market data for cryptocurrencies to comparisons of the various crytpo-exchanges, to recommendations for where to spend your crypto assets.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |