Bot Information
Round #:
Price:
Take Profit Price:
Trigger Price:
Order #:
Safety Orders Placed:
Distance from TP:
Next Update In:
import asyncio
from pyodide.http import pyfetch
from js import document, console
from datetime import datetime, timedelta
async def install_packages():
await micropip.install(['packaging'])
async def fetch_bot_info():
symbol = "ORDI"
url = f'https://solid-daylight-427909-s7.ey.r.appspot.com/api/{symbol}_bot_info'
response = await pyfetch(url)
return await response.json()
async def update_bot_info():
try:
bot_info = await fetch_bot_info()
console.log("Fetched bot info:", bot_info)
current_number = bot_info['current_number']
tp_number = bot_info['tp_number']
document.getElementById("current-number").innerText = f"{current_number:.10f}"
document.getElementById("tp-number").innerText = f"{tp_number:.3f}"
document.getElementById("so-number").innerText = f"{bot_info['so_number']:.10f}"
document.getElementById("current-order").innerText = str(bot_info['current_order'])
document.getElementById("most-sos").innerText = str(bot_info['most_sos'])
document.getElementById("round-num").innerText = str(bot_info['round_num'])
# Calculate the percentage away from TP_NUMBER
tp_percent = (tp_number - current_number) / tp_number * 100
document.getElementById("tp-distance").innerText = f"{tp_percent:.2f}% away from TP"
except Exception as e:
console.error(f"Error updating bot info: {str(e)}")
console.error(f"Error details: {e.__class__.__name__}: {str(e)}")
async def update_countdown():
while True:
now = datetime.now()
if now.second == 1:
await update_bot_info()
next_minute = (now + timedelta(minutes=1)).replace(second=0, microsecond=0)
time_left = (next_minute - now).total_seconds()
document.getElementById("countdown").innerText = f"{int(time_left)} seconds"
await asyncio.sleep(1)
async def main():
await install_packages()
await update_bot_info() # Initial update
await update_countdown()
pyscript.run_until_complete(main())