-
Notifications
You must be signed in to change notification settings - Fork 0
/
BTCUSDGBAACKUP.py
76 lines (55 loc) · 2.42 KB
/
BTCUSDGBAACKUP.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
## I used this to see if my chart is even accurate
import requests
import time
from inputimeout import inputimeout, TimeoutOccurred
from datetime import datetime
from matplotlib import pyplot
from matplotlib.animation import FuncAnimation
bitcoinList = []
ethereumList = []
count = 0
count2 = 0
# from the visualizer
x_data, y_data = [], []
figure = pyplot.figure()
line, = pyplot.plot_date(x_data, y_data, '-')
# from the visualizer
#TestList = ["21666.096434195875", "21666.096434195875", "21654.701921178068", "21654.701921178068", "21654.701921178068", "21654.153910142228", "21654.153910142228", "21654.153910142228", "21654.153910142228", "21654.153910142228", "21654.153910142228", "21652.72347584858", "21652.72347584858", "21652.72347584858", "21652.255619286407", "21652.255619286407", "21652.255619286407", "21652.14718688133"]
def update(frame):
x_data.append(datetime.now())
#y_data.append(randrange(0, 100)) THIS WAS WHAT IS ORIGINALLY IN THIS FUNCTION
try:
user_input = inputimeout(prompt='q?', timeout=1)
if user_input == 'q':
print("the length of the bitcoin list is " + str(len(bitcoinList)))
print("the first value in the list is " + str(bitcoinList[0]))
print("the last value in the list is " + str(bitcoinList[len(bitcoinList)-1]))
quit()
except TimeoutOccurred:
pass
url = "http://api.coincap.io/v2/assets/bitcoin/"
payload = {}
headers = {}
response = requests.request("GET", url, headers=headers, data=payload)
bitcoinPrice = response.json()['data']['priceUsd']
bitcoinList.append(float(bitcoinPrice))
#print(len(bitcoinList))
#time.sleep(0)
while len(bitcoinList) > 60:
bitcoinList.pop(0)
##barHeight = (bitcoinList[len(bitcoinList)-1] - bitcoinList[0])/bitcoinList[0]
currentPrice = bitcoinList[len(bitcoinList)-1]
#print(barHeight)
print(currentPrice)
y_data.append(currentPrice)
line.set_data(x_data, y_data)
figure.gca().relim()
figure.gca().autoscale_view()
return line,
while (True and count < 500):
animation = FuncAnimation(figure, update, interval=1000)
if count2 == 0:
pyplot.show()
count2 += 1
count +=1
######## from visualizer