-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplotting_arbitrage_data.py
164 lines (136 loc) · 3.9 KB
/
plotting_arbitrage_data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
from poloniex import Poloniex
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import matplotlib.ticker as mticker
from matplotlib.finance import candlestick_ohlc
import csv
class candlestick_plot ():
avg_gdax = []
avg_bitstamp = []
avg_kraken = []
avg_cex = []
class spread_plot ():
gdax_bitstamp = []
gdax_kraken = []
gdax_cex = []
bitstamp_cex =[]
bitstamp_kraken =[]
kraken_cex =[]
Candlestick = candlestick_plot ()
Spread = spread_plot ()
with open("coinbase_june.csv") as csvfile:
readCSV = csv.reader(csvfile, delimiter=',')
#row time/avg/max/min
print readCSV
for row in readCSV :
try:
Candlestick.avg_gdax.append(float(row[1]))
except:
continue
with open("bitstamp_june.csv") as csvfile:
readCSV = csv.reader(csvfile, delimiter=',')
error = 0
#row time/avg/max/min
print readCSV
for row in readCSV :
try:
Candlestick.avg_bitstamp.append(float(row[1]))
except:
continue
with open("cex_june.csv") as csvfile:
readCSV = csv.reader(csvfile, delimiter=',')
#row time/avg/max/min
for row in readCSV :
try:
Candlestick.avg_cex.append(float(row[1]))
except:
continue
with open("kraken_june.csv") as csvfile:
readCSV = csv.reader(csvfile, delimiter=',')
#row time/avg/max/min
for row in readCSV :
try:
Candlestick.avg_kraken.append(float(row[1]))
except:
continue
def spread_graphs():
i=0
for values in Candlestick.avg_gdax:
try:
Spread.gdax_kraken.append(abs(1-(Candlestick.avg_gdax[i]/Candlestick.avg_kraken[i])))
except:
continue
i=i+1
i=0
for values in Candlestick.avg_gdax:
try:
Spread.gdax_bitstamp.append(abs(1-(Candlestick.avg_gdax[i]/Candlestick.avg_bitstamp[i])))
except:
continue
i=i+1
i=0
for values in Candlestick.avg_gdax:
try:
Spread.gdax_cex.append(abs(1-(Candlestick.avg_gdax[i]/Candlestick.avg_cex[i])))
except:
continue
i=i+1
i=0
for values in Candlestick.avg_bitstamp:
try:
Spread.bitstamp_cex.append(abs(1-(Candlestick.avg_bitstamp[i]/Candlestick.avg_cex[i])))
except:
continue
i=i+1
i=0
for values in Candlestick.avg_bitstamp:
try:
Spread.bitstamp_kraken.append(abs(1-(Candlestick.avg_bitstamp[i]/Candlestick.avg_kraken[i])))
except:
continue
i=i+1
i=0
for values in Candlestick.avg_kraken:
try:
Spread.kraken_cex.append(abs(1-(Candlestick.avg_kraken[i]/Candlestick.avg_cex[i])))
except:
continue
i=i+1
spread_graphs()
plt.plot(Spread.gdax_kraken)
plt.show()
"""
300, 5min
900, 15min
1800,30min
7200,2hr
14400,4hr
86400,1d
data1 = polo.returnChartData('BTC_ETH',90,14400)
btc_plot = candlestick_plot()
def test_last_values ():
i=0
btc_plot.currency = 'USDT_BTC'
for item in data1:
btc_plot.date.append(float(item['date']))
btc_plot.high.append (float(item['high']))
btc_plot.low.append(float(item['low']))
btc_plot.day_open.append(float(item['open']))
btc_plot.day_close.append(float(item['close']))
btc_plot.volume.append(float(item['volume']))
btc_plot.quoteVolume.append(float(item['quoteVolume']))
btc_plot.weightedAverage.append(float(item['weightedAverage']))
i=i+1
fig = plt.figure()
ax1 = plt.subplot2grid((1,1), (0,0))
test_last_values ()
x=0
y= len(btc_plot.date)
ohlc = []
while x < y:
append_me = btc_plot.date[x],btc_plot.day_open[x],btc_plot.high[x],btc_plot.low[x], btc_plot.day_close[x], btc_plot.volume[x]
ohlc.append(append_me)
x+=1
candlestick_ohlc(ax1, ohlc)
plt.show()
"""