Last active
August 14, 2018 18:55
-
-
Save L-Kov/73b3740081f3349cf00478090ece5ec5 to your computer and use it in GitHub Desktop.
Simple visualization for top bids/asks of ZRX-WETH market on Radar Relay and DDEx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import requests as r | |
import matplotlib.pyplot as plt | |
# number of data points (+- 1 data point/sec) | |
period = 100 | |
# marketId(s) | |
idex_pair, radar_pair = 'ETH_ZRX', 'ZRX-WETH' | |
idex_api = 'https://api.idex.market/returnTicker' | |
radar_api = 'https://api.radarrelay.com/v0/markets/{}/ticker'.format(radar_pair) | |
idex_bids, idex_asks, radar_bids, radar_asks = [], [], [], [] | |
for i in range(0,period): | |
# query and store market data | |
idex_data = r.get(idex_api).json()[idex_pair] | |
radar_data = r.get(radar_api).json() | |
# append best bids to lists | |
idex_bids.append(idex_data['highestBid']) | |
radar_bids.append(radar_data['bid']) | |
# append best asks to lists | |
idex_asks.append(idex_data['lowestAsk']) | |
radar_asks.append(radar_data['ask']) | |
time.sleep(1) | |
# generate line plot | |
fig, ax = plt.subplots() | |
ax.plot(idex_bids, 'r-', label='idex bids') | |
ax.plot(radar_bids, 'b-', label='radar bids') | |
ax.plot(idex_asks, 'r--', label='idex asks') | |
ax.plot(radar_asks, 'b--', label='radar asks') | |
legend = ax.legend(loc='upper left', fontsize='large') | |
plt.ylabel('price') | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment