-
Notifications
You must be signed in to change notification settings - Fork 0
/
bitbns_live_prices_v2.py
executable file
·46 lines (35 loc) · 1.19 KB
/
bitbns_live_prices_v2.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
#!/usr/bin/env python36
import requests, graphitesend, redis
import time, json
def SendData():
response = requests.get(URL)
if response.status_code == 200:
AllData = response.json()
sitename = "bitbns"
new_dict = {}
for data in AllData:
for each_crypto in data:
crypto_name = each_crypto
for key,val in data[crypto_name].items():
if 'buyPrice' in key:
new_key = sitename + '-' + crypto_name.lower() + "-buy"
elif 'sellPrice' in key:
new_key = sitename + '-' + crypto_name.lower() + "-sell"
elif 'lastTradePrice' in key:
new_key = sitename + '-' + crypto_name.lower() + "-last"
if '_' not in key:
new_dict.update({new_key:val})
g.send_dict(new_dict)
r.hmset("Bitbns", new_dict)
else:
pass
if __name__ == "__main__":
URL="https://bitbns.com/order/getTickerAll"
SERVER = '127.0.0.1'
CARBON_PORT = 2003
REDIS_PORT = 6379
r = redis.Redis(host=SERVER, port=REDIS_PORT, db=0)
g = graphitesend.init(graphite_server=SERVER, graphite_port=CARBON_PORT, prefix='ohio-analyzer-1.metrics-bitbns', system_name='')
while True:
SendData()
time.sleep(5)