Package: cmctestingthree
CoinMarketCap history scraperContentsInstallationUsageCommand LineUsageExamplesModule[Sequential]ObtainCoinMarketCapUSD price historydata for CoinMarketCap-listed cryptocurrencies in CSV format.Use this library as a command-line script to obtain historical cryptocurrency data on the fly, or import the library to obtain cryptocurrency data for your programs.InstallationDownload the zip file or navigate to the desired install directory and run:$gitclonehttps://github.com/Alescontrela/coinmarketcap-history.gitTo install the required dependencies, navigate into the repo and run:$pipinstall-rrequirements.txtUsageCommand LineAmong other things, this is useful for US tax reporting.  If you want to know the cost basis for a trade (or for coins acquired through mining), the IRS requires you to denominate that cost basis in USD.  In the case of token-for-token trades (e.g. purchasing ETH with BTC), that requires you know the USD:BTC exchange rate at the time of the trade.Surprisingly, as of October 2017, it's not easy to get this data in a machine-readable format anywhere online.Rather than getting the exchange rate at the exact moment of your trade, which is generally not feasible, the IRS standard (at least for similar situations w/stock) is to use the average of a stock's high and low price for the day. CoinMarketCap doesn't provide this figure, but this tool calculates this number and includes it in the output.Command Line UsageIn the terminal, navigate into the repo directory and run:$pythoncoinmarketcap.py<currency1><start_date><end_date>where:currencyis the (case-insensitive) name of the currency / token as displayed on CoinMarketCap, with dashes in place of spacesstart_dateis the beginning of the range to fetch data for inyyyy-mm-ddformat. For example, 2017-10-01 (for 2017 October 10th)end_yearis the end of the range to fetch data for inyyyy-mm-ddformat. You may use a date in the future to obtain the latest data. Format is the same as in the start date.Data for multiple cryptocurrencies can be obtained with:$pythoncoinmarketcap.py<currency_1,currency_2,...,currency_n><start_date><end_date>Note:currencies must be comma-separated, with no spaces in between.The above information can also be found by running:$pythoncoinmarketcap.py-hWrite outputs to a file by running:$coinmarketcap.py<currency><start_date><end_date>><output_filename>Command Line ExamplesCollecting data for one cryptocurrency:$pythoncoinmarketcap.pybitcoin2017-01-012017-12-31Collecting data for multiple cryptocurrencies:$pythoncoinmarketcap.pybitcoin,ripple,ethereum2017-01-012017-12-31Writing output to a file:$pythoncoinmarketcap.pybitcoin2017-01-012017-12-31>bitcoin_prices.csvWriting output for multiple cryptocurrencies to a file:$pythoncoinmarketcap.pybitcoin,ripple,ethereum2017-01-012017-12-31>bitcoin_ripple_ethereum_prices.csvModuleYou can also usecoinmarketcap.pyas a module in other python modules to get back a pandas dataframe with a cryptocurrency's history.First, you may need to add the path tocoinmarketcap_usd_history.pyin yoursys.paththrough a command like the following:sys.path.append(<path_to_coinmarketcap_usd_history.py_parent_folder>)(Alternatively, just move thecoinmarketcap_usd_history.pyfile to the directory of the including module.)Second, import the module:import coinmarketcap_usd_historyFinally perform this to obtain the dataframe:df=coinmarketcap_usd_history.main(['bitcoin','2017-01-01','2017-12-31','--dataframe'])If you just wish to have the CSV output returned as a string to another python module, simply omit the'--dataframe'parameter.