myhashrate=140
import locale
from datetime import datetime
import requests
login_url = "https://api.qubic.li/Auth/Login"
login_payload = {
    "userName": "guest@qubic.li",
    "password": "guest13@Qubic.li"
}
login_headers = {
    "Content-Type": "application/json",
    "Origin": "https://app.qubic.li",
    "Referer": "https://app.qubic.li/"
}
login_response = requests.post(login_url, json=login_payload, headers=login_headers)
token = login_response.json().get("token")   

url = "https://api.qubic.li/Score/Get"
headers = {
    'Accept': 'application/json',
    "Authorization": f"Bearer {token}"
}
response = requests.get(url, headers=headers)    
scores_dict = response.json()
price_url="https://tradeogre.com/api/v1/ticker/QUBIC-USDT"
price_response=requests.get(price_url)
price_dict=price_response.json()
qubic_price=float(price_dict["price"])
epoch = scores_dict['scoreStatistics'][0]['epoch']
net_it=scores_dict['estimatedIts']
sol_h=scores_dict['solutionsPerHour']
avg=round(scores_dict['averageScore'],2)
sol_d=round(sol_h/(net_it/myhashrate)*24,2)
it_price=0.85*qubic_price*(1000000000000/net_it/7/1.06)
sol_coin=int(0.85*(1000000000000/1.06)/(sol_h*24*7))
my_rev=myhashrate*it_price
locale.setlocale(locale.LC_TIME, 'zh_CN.UTF-8')
now = datetime.now()
formatted_time = now.strftime("%Y-%m-%d %H:%M <%A>")
sol_url = "https://api.qubic.li/My/Pool/f4535705-eeac-4c4f-9ddc-4c3a91b40b13/Performance"
sol_response=requests.get(sol_url,headers=headers)
sol_dict=sol_response.json()
my_sol=sol_dict["foundSolutions"]
ratio=my_sol/(avg*1.06)
sum_it=0
for miner in sol_dict["miners"]:
    sum_it+=miner["currentIts"]
coin_rev=int(1257396449*(ratio))
print('-'*35)
print("当前时间：", formatted_time)
print('当前纪元：',epoch)
print('全网算力:',net_it, ' it/s','\n每小时Solution数量：',sol_h,'\n当前平均分：',avg)
print('当前Qubic价格：',"{:.8f}$".format(qubic_price))
print('1个Solution预估币量：',"{:,}".format(sol_coin))
print('-'*35)
print(myhashrate,'算力每日Solution产出：',sol_d)
print(myhashrate,"算力每日收益(USDT)：","{:.2f}".format(my_rev))
print(myhashrate,"算力每日收益(RMB)：","{:.2f}".format(my_rev*7.2))
print(myhashrate, "算力每周收益(RMB)：", "{:.2f}".format(my_rev * 7.2 * 7))
print(myhashrate, "算力每月收益(RMB)：", "{:.2f}".format(my_rev * 7.2 * 30))
print('-'*35)
print('在线矿机数量：',len(sol_dict["miners"]))
print('在线矿机总算力：',sum_it,'it/s')
print('我找到的Sol：',my_sol)
print('当前预计分配比例：',"{:.2f}%".format(ratio*100))
print('预计收益（币）：','{:,}'.format(coin_rev))
print('预计收益（USDT):','{:.2f}'.format(coin_rev*qubic_price))
print('预计收益（RMB):','{:.2f}'.format(coin_rev*qubic_price*7.2))
print('-'*35)