-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbittrexApi.py
More file actions
executable file
·42 lines (35 loc) · 2.05 KB
/
Copy pathbittrexApi.py
File metadata and controls
executable file
·42 lines (35 loc) · 2.05 KB
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
import requests
import json
import operator
# bittrex api
# r = requests.get("https://bittrex.com/api/v1.1/public/getcurrencies")
r = requests.get("https://bittrex.com/api/v1.1/public/getmarketsummaries")
data = r.json()
# coinmarketplace api
rCMP = requests.get('https://api.coinmarketcap.com/v1/ticker/?limit=3')
data_from_CMP = rCMP.json()
# jsonCleaned = json.dumps(data, indent=4, sort_keys=True)
# print(json.dumps(data, indent=4, sort_keys=True))
print("***********************************")
bank = 1000
value_Of_BTC_in_USD = float(data_from_CMP[0]['price_usd'])
bank_In_BTC = (1/value_Of_BTC_in_USD) * bank
for i in data['result']:
if i['MarketName'].startswith('BTC'):
try:
maximunCoinsPerBank = bank_In_BTC / float(i['Last'])
maxProfitsMade_based_on_24hr_change = (maximunCoinsPerBank * float(i['High'])) - bank_In_BTC
minProfitsMade_based_on_24hr_change = (maximunCoinsPerBank * float(i['Low'])) - bank_In_BTC
except ZeroDivisionError:
pass
print('**** ' + i['MarketName'] + ' ****')
print('volume in USD: ' + str(i['Volume']))
print('current value in BTC : ' + str(float(i['Last'])) + ' btc')
print('current value in USD : ' + str((float(i['Last']) * value_Of_BTC_in_USD)) + ' USD')
print('maximun coins per ' + str(bank) + ' USD : ' + str(maximunCoinsPerBank) + ' ' + i['MarketName'])
print('investment in btc : ' + str(bank_In_BTC))
print('max profits based 24hr high in BTC : ' + str( maxProfitsMade_based_on_24hr_change) + ' satoshi')
print('min profits based 24hr low in BTC : ' + str(minProfitsMade_based_on_24hr_change) + ' satoshi')
print('max profits base on 24hr high in USD : ' + str((maxProfitsMade_based_on_24hr_change * value_Of_BTC_in_USD)) + ' USD')
print('min profits based on 24hr low in USD : ' + str((minProfitsMade_based_on_24hr_change * value_Of_BTC_in_USD)) + ' USD')
print('***********************************************************************')