Repository navigation
Expand file tree
/
Copy pathdaily-data-retrieval.py
More file actions
executable file
Β·495 lines (479 loc) Β· 26.1 KB
/
Copy pathdaily-data-retrieval.py
File metadata and controls
executable file
Β·495 lines (479 loc) Β· 26.1 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
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
#! /usr/bin/env python3
from datetime import datetime
from LuxorLabs.luxor import API
from os.path import exists
from satsperfiatunit import SatsPerFiatUnitPanel
import json
import os
import sys
import time
import vicariousnetwork
def getdatefile():
return datetime.utcnow().strftime("%Y-%m-%d-%H") + ".json"
def isFirstOfTheMonth():
return (int(datetime.utcnow().strftime("%e")) == 1)
def getAndSaveFile(url, savetofile, headers={}):
vicariousnetwork.getandsavefile(True, url, savetofile, headers)
def makeDirIfNotExists(path):
if not exists(path):
print(f"Creating folder {path}")
os.makedirs(path)
# --------------------------------------------------------------------------------------------------------------------
# getAndSaveBisqInfo
#
# Retrieves the current bisq market data and saves to the data directory for historical tracking
# Some relevant fields are within a currency pair: last, high, low. The buy and sell reflect offer spreads
# btc_usd <last, high, low, volume_left, volume_right, buy, sell>
# bsq_btc <last, high, low, volume_left, volume_right, buy, sell>
# --------------------------------------------------------------------------------------------------------------------
def getAndSaveBisqInfo():
print("---")
if not enableBisq:
print("WARNING: Call to getAndSaveBisqInfo made but enableBisq is False")
return
datefile = getdatefile()
print(f"Retrieving and saving Bisq Market Price info to {datefile}")
p = SatsPerFiatUnitPanel()
vicariousnetwork.getpriceinfo(useTor=p.useTor, url=p.priceUrl)
def getAndSaveCollectAPIInfo():
print("---")
if not enableCollectAPI:
print("WARNING: Call to getAndSaveCollectAPIInfo made but enableCollectAPI is False")
return
datefile = getdatefile()
with open(configFileCollectAPI) as f:
config = json.load(f)
if "dailyretrieve" in config:
for dailyretrieve in config["dailyretrieve"]:
# check if enabled
enabled = True
if "enabled" in dailyretrieve:
enabled = dailyretrieve["enabled"]
if not enabled:
continue
url = dailyretrieve["url"]
subfolder = dailyretrieve["saveToSubfolder"]
targetfolder = collectAPIDataDirectory + subfolder + "/"
makeDirIfNotExists(targetfolder)
filename = targetfolder + datefile
print(f"Retrieving and saving Collect API info for {url} to {datefile}")
if not os.path.exists(filename):
headers = {}
if "headers" in dailyretrieve:
headers = dailyretrieve["headers"]
getAndSaveFile(url, filename, headers)
time.sleep(5)
else:
print(f"Skipping download of {filename} as it already exists")
# --------------------------------------------------------------------------------------------------------------------
# getAndSaveCompassMiningHardwareInfo
#
# Provides details about the hardware for sale available from compass mining as a snapshot.
# Some relevant fields are
# payload.hardwareIsFeatured array of new asics to be hosted at facilities new contract
# payload.hardwareGrouped array of reseller asics to stay in facilities new contract
# payload.hardwareAtHome array of new asics available to ship to home
#
# Within the hardwareGrouped, structure of an item has these fields
# manufacturer, baseModelName, name, hashrate, description, algorithm, imageURL, images [ url, order], minCost,
# maxCost, isPSP, power, compass_finance, pricePerHashrate, pricePerHashrateForSorting,
# minOnlineDateFormattedSeconds, maxOnlineDateFormattedSeconds, hashrateSorting
# Within the hardwareAtHome, structure of an item has these fields
# manuracturer, batch, baseModelName, id, name, shipping_date, costPrice, prift, type, condition, available_stock,
# deposit_months, images [order, url], hostingFacility, salePrice, weight_lbs, location, shipping_min_order,
# photoURL, is_bundle, hashrate, cost, power, algorithm, power_watts, online_date, description, is_reseller,
# max_items_per_user, monthly_bundle_price, pricePerHashrate, pricePerHashrateForSorting, hashrateSorting
# --------------------------------------------------------------------------------------------------------------------
def getAndSaveCompassMiningHardwareInfo():
print("---")
if not enableCompassHardware:
print("WARNING: Call to getAndSaveCompassMiningHardwareInfo made but enableCompassHardware is False")
return
datefile = getdatefile()
print(f"Retrieving and saving Compass Mining Hardware info to {datefile}")
with open(configFileCompassHardware) as f:
config = json.load(f)
filename = compassHardwareDataDirectory + datefile
getAndSaveFile(config["hardwareurl"], filename)
# --------------------------------------------------------------------------------------------------------------------
# getAndSaveCompassMiningStatusInfo
#
# Provides details about the facility status at Compass Mining as a snapshot
#
# In addition, saving snapshots for details for individual facilities
# --------------------------------------------------------------------------------------------------------------------
def getAndSaveCompassMiningStatusInfo():
print("---")
if not enableCompassStatus:
print("WARNING: Call to getAndSaveCompassMiningStatusInfo made but enableCompassStatus is False")
return
datefile = getdatefile().replace(".json", ".html")
print(f"Retrieving and saving Compass Mining Status info to {datefile}")
with open(configFileCompassStatus) as f:
config = json.load(f)
filename = compassStatusDataDirectory + datefile
baseurl = config["statusurl"]
getAndSaveFile(baseurl, filename)
if isFirstOfTheMonth():
# getAndSaveCompassFacilityStatus(baseurl, "canada/alberta", "3kdqgw2547nv", 1)
getAndSaveCompassFacilityStatus(baseurl, "canada/british-columbia", "5zbr66zwp1ch", 1)
getAndSaveCompassFacilityStatus(baseurl, "canada/manitoba1", "t9ck2m81j50d", 1)
getAndSaveCompassFacilityStatus(baseurl, "canada/manitoba2", "3jz0mjsctwx8", 1)
# getAndSaveCompassFacilityStatus(baseurl, "canada/manitoba3", "rdv8ddlbyhyb", 1)
getAndSaveCompassFacilityStatus(baseurl, "canada/manitoba4", "y266jn235v5k", 1)
getAndSaveCompassFacilityStatus(baseurl, "canada/manitoba5", "9hcxtxzr6m3p", 1)
getAndSaveCompassFacilityStatus(baseurl, "canada/manitoba6", "n89q0k5qwf85", 1)
getAndSaveCompassFacilityStatus(baseurl, "canada/manitoba7", "zdj1pbf1p8dg", 1)
getAndSaveCompassFacilityStatus(baseurl, "canada/newfoundland1", "0p5x9pj0xg1z", 1) # new august 2022
getAndSaveCompassFacilityStatus(baseurl, "canada/newfoundland2", "mj5mff51w9dy", 1) # new august 2022
getAndSaveCompassFacilityStatus(baseurl, "canada/ontario", "1zjg8wgylr7x", 1) # 54x
# getAndSaveCompassFacilityStatus(baseurl, "canada/quebec", "n9yqj1td9v32", 1)
getAndSaveCompassFacilityStatus(baseurl, "iceland/southern-peninsula", "0wtyz0xpgswf", 1)
# getAndSaveCompassFacilityStatus(baseurl, "kazakhstan/pavlodar-region", "k4kgphjfmg1q", 1)
# getAndSaveCompassFacilityStatus(baseurl, "russia/krasnoyarsk-krai", "9yg10xhkyzym", 1)
# getAndSaveCompassFacilityStatus(baseurl, "russia/irkutsk", "jsmkt30pdk16", 1)
# getAndSaveCompassFacilityStatus(baseurl, "usa/alabama", "44f9l6qw3723", 1)
getAndSaveCompassFacilityStatus(baseurl, "usa/florida", "z056gck1hqh0", 1)
# getAndSaveCompassFacilityStatus(baseurl, "usa/florida2", "53db4g6rh5sc", 1)
getAndSaveCompassFacilityStatus(baseurl, "usa/georgia", "2zhw91nntctn", 1)
getAndSaveCompassFacilityStatus(baseurl, "usa/georgia2", "m6tgmv50632p", 1) # 49x closing september 2022. moving to Texas 1
getAndSaveCompassFacilityStatus(baseurl, "usa/indiana", "dd5w0sjpymlt", 1)
getAndSaveCompassFacilityStatus(baseurl, "usa/iowa", "nq11cxscsv6v", 1)
getAndSaveCompassFacilityStatus(baseurl, "usa/kentucky1", "8zjbpfwpj6ph", 1)
# getAndSaveCompassFacilityStatus(baseurl, "usa/kentucky2", "dcg727xjytwy", 1)
# getAndSaveCompassFacilityStatus(baseurl, "usa/maine1", "0q8l9035qf85", 1)
# getAndSaveCompassFacilityStatus(baseurl, "usa/maine2", "pjmk518l4v5t", 1)
getAndSaveCompassFacilityStatus(baseurl, "usa/minnesota", "hy8mm5gxdtqm", 1)
getAndSaveCompassFacilityStatus(baseurl, "usa/missouri", "rp79n8732323", 1)
getAndSaveCompassFacilityStatus(baseurl, "usa/nebraska", "mjlq41wzc465", 1)
getAndSaveCompassFacilityStatus(baseurl, "usa/nevada", "5fjs6hpxdsv0", 1)
getAndSaveCompassFacilityStatus(baseurl, "usa/new-mexico", "7gfpdjccgfzq", 1)
getAndSaveCompassFacilityStatus(baseurl, "usa/north-carolina", "2vqp9540jn0t", 1)
getAndSaveCompassFacilityStatus(baseurl, "usa/oklahoma1", "1l88pl4v2qtr", 1)
# getAndSaveCompassFacilityStatus(baseurl, "usa/oklahoma2", "ky917p6zlk1m", 1)
getAndSaveCompassFacilityStatus(baseurl, "usa/oklahoma3", "1hczfjx1kvhb", 1)
# getAndSaveCompassFacilityStatus(baseurl, "usa/pennsylvania", "11srlh63flpy", 1)
getAndSaveCompassFacilityStatus(baseurl, "usa/south-carolina", "14kjx3pjvvbl", 1)
getAndSaveCompassFacilityStatus(baseurl, "usa/texas", "hqy3cy37xcsp", 1)
getAndSaveCompassFacilityStatus(baseurl, "usa/texas2", "fzy7c2q8z6m8", 1) # 56x
getAndSaveCompassFacilityStatus(baseurl, "usa/washington", "6v408kf7qk7v", 1)
# --------------------------------------------------------------------------------------------------------------------
# getAndSaveCompassFacilityStatus
#
# Helper method to build directories as needed and download multiple pages of reported status for a facility over time
# --------------------------------------------------------------------------------------------------------------------
def getAndSaveCompassFacilityStatus(baseurl, facilityname, facilityid, pages):
if not enableCompassStatus:
print("WARNING: Call to getAndSaveCompassFacilityStatus made but enableCompassStatus is False")
return
folder = compassStatusDataDirectory + facilityname + "-" + facilityid + "/"
makeDirIfNotExists(folder)
for page in range(pages):
strpage = str(int(page+1))
filename = folder + "page" + strpage + ".html"
fileurl = baseurl + "uptime/" + facilityid + "?page=" + strpage
getAndSaveFile(fileurl, filename)
time.sleep(10) # wait between queries
# --------------------------------------------------------------------------------------------------------------------
# getAndSaveF2PoolAccountInfo
#
# Provides details about the hashrate of account, but only for a 24 hour period.
# Payout history goes back quite a ways and should be consistent, adding new records each day there was activity
# Some relevant fields are
# hashrate_history.<fieldname> <fieldname> date time in 10 minute increments
# payout_history[][<date value>, <description>, <amount>] <date value> ISO8601 timestamp in day increment
# <description> `txid moved to user_payout`
# <value> is a float amount, may have e notation
# payout_history_fee[][<date value>,<description>,<amount>] same as above, just the fees for the pool
# user_payout[][<date value>, <txid>, <amount>, <address>] <date value> ISO8601 timestamp of payout time
# <txid> bitcoin transaction id of the payout
# <amount> amount of bitcoin sent
# <address> bitcoin address sent to
# --------------------------------------------------------------------------------------------------------------------
def getAndSaveF2PoolAccountInfo():
print("---")
if not enableF2Pool:
print("WARNING: Call to getAndSaveF2PoolAccountInfo made but enableF2Pool is False")
return
datefile = getdatefile()
print(f"Retrieving and saving F2Pool info to {datefile}")
with open(configFileF2Pool) as f:
config = json.load(f)
if "account" not in config:
print("F2Pool account not set. Skipping")
return
account = config["account"]
if len(account) == 0 or "--your-account-name-on-f2pool--" in account:
print("F2Pool account not set. Skipping")
return
filename = f2PoolDataDirectory + datefile
fileurl = "https://api.f2pool.com/bitcoin/" + account
getAndSaveFile(fileurl, filename)
# --------------------------------------------------------------------------------------------------------------------
# getAndSaveFearAndGreedInfo
#
# Retrieves the fear and greed info from Alternative.me
# Full API documentation at https://alternative.me/crypto/fear-and-greed-index/#api
# --------------------------------------------------------------------------------------------------------------------
def getAndSaveFearAndGreedInfo():
print("---")
if not enableFearAndGreed:
print("WARNING: Call to getAndSaveFearAndGreedInfo made but enableFearAndGreed is False")
return
datefile = getdatefile()
print(f"Retrieving and saving Fear and Greed info to {datefile}")
filename = fearAndGreedDataDirectory + datefile
fileurl = "https://api.alternative.me/fng/?limit=0&format=json&date_format=cn"
getAndSaveFile(fileurl, filename)
# --------------------------------------------------------------------------------------------------------------------
# getAndSaveLuxorHashrateInfo
#
# Retrieves information from Luxor Mining for an account via graphql
# Full API documentation at https://docs.luxor.tech/docs/
# Using Python library from https://github.com/LuxorLabs/graphql-python-client
# --------------------------------------------------------------------------------------------------------------------
def getAndSaveLuxorHashrateInfo():
print("---")
if not enableLuxor:
print("WARNING: Call to getAndSaveLuxorHashrateInfo made but enableLuxor is False")
return
datefile = getdatefile()
print(f"Retrieving and saving Luxor Hashrate info to {datefile}")
try:
with open(configFileLuxor) as f:
config = json.load(f)
filename = luxorDataDirectory + datefile
apikey = config["apikey"]
username = config["username"]
if len(apikey) == 0 or "--your-luxor" in apikey:
print(f"Luxor apikey not set. Skipping")
return
if len(username) == 0 or "--your-luxor" in username:
print(f"Luxor username not set. Skipping")
return
LUXORAPI = API(host = 'https://api.beta.luxor.tech/graphql', method='POST', org='luxor', key=apikey)
resp = LUXORAPI.get_hashrate_score_history(username,'BTC',100)
with open(filename, 'a', encoding="utf-8") as outfile:
json.dump(resp, outfile)
print("ok.\n")
except Exception as e:
print("error\n")
print(e)
# --------------------------------------------------------------------------------------------------------------------
# getAndSaveBraiinspoolInfo
#
# Retrieves information from Braiins pool for an account via REST (p.k.a Slushpool)
# API documentation at https://help.slushpool.com/en/support/solutions/articles/77000433512-api-configuration-guide
# now at https://help.braiins.com/en/support/solutions/articles/77000433512-api-configuration-guide
# --------------------------------------------------------------------------------------------------------------------
def getAndSaveBraiinspoolInfo():
print("---")
if not enableBraiinspool:
print("WARNING: Call to getAndSaveBraiinspoolInfo made but enableBraiinspool is False")
return
with open(configFileBraiinspool) as f:
config = json.load(f)
if "authtoken" not in config:
print("Braiinspool authtoken not set. Skipping")
return
authtoken = config["authtoken"]
if len(authtoken) == 0 or "--put-your-auth-token-here--" in authtoken:
print("Braiinspool authtoken not set. Skipping")
return
headers = {"Slushpool-Auth-Token": authtoken}
getAndSaveBraiinspoolFile("pool stats", "poolstats/", "https://pool.braiins.com/stats/json/btc", headers)
getAndSaveBraiinspoolFile("user performance", "userprofile/", "https://pool.braiins.com/accounts/profile/json/btc", headers)
getAndSaveBraiinspoolFile("90 day daily rewards", "dailyreward/", "https://pool.braiins.com/accounts/rewards/json/btc", headers)
getAndSaveBraiinspoolFile("worker performance", "workers/", "https://pool.braiins.com/accounts/workers/json/btc", headers)
# --------------------------------------------------------------------------------------------------------------------
# getAndSaveBraiinspoolFile
#
# Helper method to build directories as needed, log what being done, and download respective file
# --------------------------------------------------------------------------------------------------------------------
def getAndSaveBraiinspoolFile(comment, subdirectory, fileurl, headers):
datefile = getdatefile()
folder=braiinspoolDataDirectory + subdirectory
makeDirIfNotExists(folder)
filename=folder + datefile
print("-")
print(f"Retrieving and saving Braiins pool {comment} to {filename}")
time.sleep(6) # braiins pool throttles/blocks if more than 1 per 5 seconds
getAndSaveFile(fileurl, filename, headers)
# --------------------------------------------------------------------------------------------------------------------
# Main program entry point
# --------------------------------------------------------------------------------------------------------------------
if __name__ == '__main__':
# Defaults
enableBisq = True
enableCollectAPI = False # No free data available
enableCompassHardware = False # API changed. Data no longer available
enableCompassStatus = False # Deprecated
enableF2Pool = False
enableFearAndGreed = True
enableLuxor = False
enableBraiinspool = False
dataDirectory="../data/"
configFolder="../config/"
configFileBisq=configFolder + "satsperfiatunit.json"
configFileCollectAPI=configFolder + "collectapi.json"
configFileCompassHardware=configFolder + "compassmininghardware.json"
configFileCompassStatus=configFolder + "compassminingstatus.json"
configFileF2Pool=configFolder + "miningpool-f2pool.json"
configFileFearAndGreed=configFolder + "fearandgreed.json"
configFileLuxor=configFolder + "miningpool-luxorpool.json"
configFileBraiinspool=configFolder + "miningpool-braiinspool.json"
sleepInterval=300 # This is for the main loop controller
# Time Intervals for remote data pulls
sleepIntervalBisq=3600
sleepIntervalCollectAPI=86400
sleepIntervalCompassHardware=3600
sleepIntervalCompassStatus=82800
sleepIntervalF2Pool=82800
sleepIntervalFearAndGreed=41400
sleepIntervalLuxor=82800
sleepIntervalBraiinspool=82800
lastTimeBisq=0
lastTimeCollectAPI=0
lastTimeCompassHardware=0
lastTimeCompassStatus=0
lastTimeF2Pool=0
lastTimeFearAndGreed=0
lastTimeLuxor=0
lastTimeBraiinspool=0
# Check that config exists
if enableBisq and not exists(configFileBisq):
enableBisq = False
print(f"The Bisq Sats per USD configuration file was not defined at {configFileBisq}")
print(f"Bisq data will not be downloaded")
if enableCollectAPI and not exists(configFileCollectAPI):
enableCollectAPI = False
print(f"The Collect API configuration file was not defined at {configFileCollectAPI}")
print(f"Collect API data will not be downloaded")
if enableCompassHardware and not exists(configFileCompassHardware):
enableCompassHardware = False
print(f"The Compass Mining Hardware configuration file was not defined at {configFileCompassHardware}")
print(f"Compass Mining Hardware data will not be downloaded")
if enableCompassStatus and not exists(configFileCompassStatus):
enableCompassStatus = False
print(f"The Compass Mining Status configuration file was not defined at {configFileCompassStatus}")
print(f"Compass Mining Status will not be downloaded")
if enableF2Pool and not exists(configFileF2Pool):
enableF2Pool = False
print(f"The F2Pool configuration file was not defined at {configFileF2Pool}")
print(f"F2Pool data will not be downloaded")
if enableFearAndGreed and not exists(configFileFearAndGreed):
pass
#enableFearAndGreed = False
#print(f"The Fear And Greed configuration file was not defined at {configFileFearAndGreed}")
#print(f"Fear and Greed data will not be downloaded")
if enableLuxor and not exists(configFileLuxor):
enableLuxor = False
print(f"The Luxor configuration file was not defined at {configFileLuxor}")
print(f"Luxor data will not be downloaded")
if enableBraiinspool and not exists(configFileBraiinspool):
enableBraiinspool = False
print(f"The Braiins pool configuration file was not defined at {configFileBraiinspool}")
print(f"Braiins pool data will not be downloaded")
# Data directories
if not exists(dataDirectory):
os.makedirs(dataDirectory)
bisqDataDirectory = dataDirectory + "bisq/"
if enableBisq:
makeDirIfNotExists(bisqDataDirectory)
collectAPIDataDirectory = dataDirectory + "collectapi/"
if enableCollectAPI:
makeDirIfNotExists(collectAPIDataDirectory)
compassHardwareDataDirectory = dataDirectory + "compassmininghardware/"
if enableCompassHardware:
makeDirIfNotExists(compassHardwareDataDirectory)
compassStatusDataDirectory = dataDirectory + "compassminingstatus/"
if enableCompassStatus:
makeDirIfNotExists(compassStatusDataDirectory)
f2PoolDataDirectory = dataDirectory + "f2pool/"
if enableF2Pool:
makeDirIfNotExists(f2PoolDataDirectory)
fearAndGreedDataDirectory = dataDirectory + "fearandgreed/"
if enableFearAndGreed:
makeDirIfNotExists(fearAndGreedDataDirectory)
luxorDataDirectory = dataDirectory + "luxor/"
if enableLuxor:
makeDirIfNotExists(luxorDataDirectory)
braiinspoolDataDirectory = dataDirectory + "braiinspool/"
if enableBraiinspool:
makeDirIfNotExists(braiinspoolDataDirectory)
# Check for single run
if len(sys.argv) > 1:
if sys.argv[1] in ['-h','--help']:
print(f"Retrieves API information and stores in the data directory for later user")
print(f"Usage:")
print(f"1) Call without arguments to run continuously using the configuration or defaults")
print(f"2) Pass the desired API identifier to retrieve and exit")
arg0 = sys.argv[0]
print(f" {arg0} bisq")
print(f" {arg0} braiinspool")
print(f" {arg0} collectapi")
print(f" {arg0} compassmininghardware")
print(f" {arg0} compsasminingstatus")
print(f" {arg0} f2pool")
print(f" {arg0} fearandgreed")
print(f" {arg0} luxor")
else:
apistub = sys.argv[1]
if apistub == 'bisq':
if enableBisq:
getAndSaveBisqInfo()
elif apistub == 'braiinspool':
if enableBraiinspool:
getAndSaveBraiinspoolInfo()
elif apistub == 'collectapi':
if enableCollectAPI:
getAndSaveCollectAPIInfo()
elif apistub == 'compassmininghardware':
if enableCompassHardware:
getAndSaveCompassMiningHardwareInfo()
elif apistub == 'compassminingstatus':
if enableCompassStatus:
getAndSaveCompassMiningStatusInfo()
elif apistub == 'f2pool':
if enableF2Pool:
getAndSaveF2PoolAccountInfo()
elif apistub == 'fearandgreed':
if enableFearAndGreed:
getAndSaveFearAndGreedInfo()
elif apistub == 'luxor':
if enableLuxor:
getAndSaveLuxorHashrateInfo()
else:
print("Value not recognized. Call the program with --help for more guidance")
exit(1)
exit(0)
# Loop
while True:
currentTime = int(time.time())
if enableBisq and currentTime > lastTimeBisq + sleepIntervalBisq:
getAndSaveBisqInfo()
lastTimeBisq = currentTime if lastTimeBisq == 0 else lastTimeBisq + sleepIntervalBisq
if enableBraiinspool and currentTime > lastTimeBraiinspool + sleepIntervalBraiinspool:
getAndSaveBraiinspoolInfo()
lastTimeBraiinspool = currentTime if lastTimeBraiinspool == 0 else lastTimeBraiinspool + sleepIntervalBraiinspool
if enableCollectAPI and currentTime > lastTimeCollectAPI + sleepIntervalCollectAPI:
getAndSaveCollectAPIInfo()
lastTimeCollectAPI = currentTime if lastTimeCollectAPI == 0 else lastTimeCollectAPI + sleepIntervalCollectAPI
if enableCompassHardware and currentTime > lastTimeCompassHardware + sleepIntervalCompassHardware:
getAndSaveCompassMiningHardwareInfo()
lastTimeCompassHardware = currentTime if lastTimeCompassHardware == 0 else lastTimeCompassHardware + sleepIntervalCompassHardware
if enableCompassStatus and currentTime > lastTimeCompassStatus + sleepIntervalCompassStatus:
getAndSaveCompassMiningStatusInfo()
lastTimeCompassStatus = currentTime if lastTimeCompassStatus == 0 else lastTimeCompassStatus + sleepIntervalCompassStatus
if enableF2Pool and currentTime > lastTimeF2Pool + sleepIntervalF2Pool:
getAndSaveF2PoolAccountInfo()
lastTimeF2Pool = currentTime if lastTimeF2Pool == 0 else lastTimeF2Pool + sleepIntervalF2Pool
if enableFearAndGreed and currentTime > lastTimeFearAndGreed + sleepIntervalFearAndGreed:
getAndSaveFearAndGreedInfo()
lastTimeFearAndGreed = currentTime if lastTimeFearAndGreed == 0 else lastTimeFearAndGreed + sleepIntervalFearAndGreed
if enableLuxor and currentTime > lastTimeLuxor + sleepIntervalLuxor:
getAndSaveLuxorHashrateInfo()
lastTimeLuxor = currentTime if lastTimeLuxor == 0 else lastTimeLuxor + sleepIntervalLuxor
print("---")
print(f"Done retrieving data for this round. sleeping for {sleepInterval}")
time.sleep(sleepInterval)