Created
June 13, 2018 15:06
-
-
Save Technoash/decf4a8b464e1acf4dceeb694692b291 to your computer and use it in GitHub Desktop.
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 requests | |
| import json | |
| c1 = "XLM" | |
| c2 = "BTC" | |
| url = "https://min-api.cryptocompare.com/data/histohour?fsym=" + c1 + "&tsym=" + c2 + "&limit=168&e=Poloniex" | |
| data = [] | |
| def req(): | |
| global data | |
| tmp = requests.get(url).json() | |
| for x in reversed(tmp['Data']): | |
| data.append(1/x["close"]) | |
| req() | |
| #### IGNORE EVERYTHING ABOVE, IT IS JUST TO GET THE PRICES INTO data | |
| # WE HAVE 2000 XLM | |
| # MANUAL BUY AT 5.4 TRON per XLM 2000x5.4 TRON | |
| # OBTAIN 10800 TRN | |
| # COMPUTER SELL AT 4.3 TRON PER XLM 10800/4.3 XLM | |
| # OBTAIN 2500 XLM | |
| margin = 0.01 | |
| s = 0 | |
| for x in data: | |
| s += x | |
| average = s/len(data) | |
| print("Average for {} hours is {} {}/{}".format(len(data), int(average), c1, c2)) | |
| print("Current price {} {}/{}".format(int(data[0]), c1, c2)) | |
| if data[0] > average*(1+margin): | |
| print("Sell at current price") | |
| if data[0] < average*(1-margin): | |
| print("Buy at current price") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment