diff --git a/src/web_dashboard.py b/src/web_dashboard.py index 7c6bafc..6236f8f 100644 --- a/src/web_dashboard.py +++ b/src/web_dashboard.py @@ -1,13 +1,31 @@ #!/usr/bin/env python3 -from fastapi import FastAPI, Response +from fastapi import FastAPI +from fastapi.responses import HTMLResponse from binance.client import Client -import json, os, time from datetime import datetime +import json, os, time, sqlite3 app = FastAPI() - env = {} with open('/home/marc/bot-deploy/.env') as f: + for line in f: + k, _, v = line.partition('=') + env[k.strip()] = v.strip() + +binance = Client(env.get('BINANCE_API_KEY_LIVE'), env.get('BINANCE_API_SECRET_LIVE')) +DB_PATH = '/home/marc/bot-deploy/pnl_history.db' + +def init_db(): + conn = sqlite3.connect(DB_PATH) + c = conn.cursor() + c.execute("""CREATE TABLE IF NOT EXISTS pnl_snapshots (timestamp INTEGER PRIMARY KEY, portfolio_value REAL, pnl_usdt REAL, pnl_pct REAL, usdt_free REAL, active_positions INTEGER)""") + conn.commit() + conn.close() + +init_db() + +# Rest des Codes... +deploy/.env') as f: for line in f: k,_,v = line.partition('=') env[k.strip()] = v.strip()