ETH Price Analyzer is a project which allows the collection of ETH prices from 9 Cryptocurrency exchanges, the logging of various price statistics, and a price vs. time data visualizer.
This project requires Python 3.6, but it could easily be modified to support older versions of python. Once you have the correct version of Python, install the requirements running pip install -r requirements.txt
.
In the logging folder, there are two python scripts related to log collection.
By running python stat_logger.py
, prices statistics from the following 9 Cryptocurrency exchanges can be collected and stored in a csv file:
- Binance
- Bitfinex
- Bitforex
- Bittrex
- Huobi
- KuCoin
- OKEx
- Poloniex
- TradeIO
The stat logger currently features the following modes which can be set by modifying the logging_mode
enum.
-
Basic
- Collects data every 30 seconds
- Generates a new date stamped csv every 24 hours
- Handles API exceptions for you <3
- Saves:
- The data & time when collected
- The last price of each exchange
- The lowest price and exchange name
- The highest price and exchange name
- The average price
- Price % spread between the highest and lowest exchange
-
Full
- Everything that basic logging does
- Collects data every 2 minutes
- Also saves:
- The highest bid of each exchange
- The lowest ask of each exchange
Due to stat_logger generating a new csv file every 24 hours, this script was created to "stich" them back together. This is especially important if you'd like to graph long term data, or if you experience gaps in your logging.
Usage: Run python log_combiner.py <directory>
where directory is the directory containing all of your log files. The output will be a csv file named "combined.csv".
Using the data generated by the logger, a graphing script has been written to allow you to visualize your data. A sample csv file containing 24 hours of data and its accompanying graph screenshot are contained in the graphing folder.
Here's what the graph of the data from 2019-07-22 looks like:
Features:
- Shows all 9 exchanges' data overlayed ontop of one another on a Price Vs. Time graph
- Hide/show exchange series by clicking the line beside its name in the legend
- Graph can zoom in and out
- Timezone is in MST but can be changed by modifying the value
timezone_offset
in csv_grapher.py
Usage: Run python csv_grapher.py <path-to-csv-file>
where path-to-csv-file is the path to a csv file generated by the stat logger.
In the exchange API folder are several classes encapsulated in the exchange_manager file. The exchange manager initializes an instance of each class implemented for each exchange API, and puts them in a dictionary where the keys are the exchange names as strings, and the values are the exchange objects.
This "exchange dictionary" can then be used as an argument in the following functions:
-
get_ETH_price_dict(exchanges)
- Returns a dictionary where the keys are the exchange names as strings and the values are the last ETH prices on the exchanges
-
get_ETH_bid_dict(exchanges)
- Returns a dictionary where the keys are the exchange names as strings and the values are the highest ETH bids on the exchanges
-
get_ETH_ask_dict(exchanges)
- Returns a dictionary where the keys are the exchange names as strings and the values are the lowest ETH asks on the exchanges