-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisplay_data.py
82 lines (70 loc) · 2.43 KB
/
display_data.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
76
77
78
79
80
81
82
import json
from datetime import datetime
class MockNiceHashData:
def get_mining_data(self):
return {
"miningRigs": [
{
"minerStatus": "MINING",
"stats": {
"speedAccepted": 95450000 # 95.45 MH/s
}
},
{
"minerStatus": "MINING",
"stats": {
"speedAccepted": 85320000 # 85.32 MH/s
}
}
]
}
def get_wallet_balance(self):
return {
"currencies": [
{
"currency": "BTC",
"available": "0.00123456"
},
{
"currency": "ETH",
"available": "0.05432100"
}
]
}
def format_hashrate(hashrate):
if hashrate > 1e9:
return f"{hashrate/1e9:.2f} GH/s"
elif hashrate > 1e6:
return f"{hashrate/1e6:.2f} MH/s"
elif hashrate > 1e3:
return f"{hashrate/1e3:.2f} KH/s"
return f"{hashrate:.2f} H/s"
def display_stats():
api = MockNiceHashData()
try:
# Get mock data
mining_data = api.get_mining_data()
wallet_data = api.get_wallet_balance()
# Print timestamp
print(f"\n=== NiceHash Stats ({datetime.now().strftime('%Y-%m-%d %H:%M:%S')}) ===\n")
# Process mining rigs data
if 'miningRigs' in mining_data:
total_hashrate = 0
active_rigs = 0
for rig in mining_data['miningRigs']:
if rig['minerStatus'] == 'MINING':
active_rigs += 1
if 'stats' in rig and rig['stats']:
total_hashrate += float(rig['stats'].get('speedAccepted', 0))
print(f"Active Rigs: {active_rigs}")
print(f"Total Hashrate: {format_hashrate(total_hashrate)}")
# Process wallet data
if 'currencies' in wallet_data:
print("\nWallet Balances:")
for currency in wallet_data['currencies']:
if float(currency['available']) > 0:
print(f"{currency['currency']}: {float(currency['available']):.8f}")
except Exception as e:
print(f"Error: {str(e)}")
if __name__ == "__main__":
display_stats()