import os import sys from sqlalchemy import create_engine, text import json from datetime import datetime # Database connection DB_USER = os.getenv('DB_USER', 'root') DB_PASSWORD = os.getenv('DB_PASSWORD', '12345678') DB_HOST = os.getenv('DB_HOST', 'localhost') DB_PORT = os.getenv('DB_PORT', '3306') DB_NAME = 'auto_trade_sys_new' DATABASE_URL = f"mysql+pymysql://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{DB_PORT}/{DB_NAME}" def check_today_trades(): try: engine = create_engine(DATABASE_URL) with engine.connect() as conn: # Query trades from today (2026-02-13) query = text(""" SELECT id, symbol, side, entry_price, exit_price, pnl, pnl_percent, exit_reason, exit_time, entry_time FROM trades WHERE DATE(entry_time) = '2026-02-13' OR DATE(exit_time) = '2026-02-13' ORDER BY exit_time DESC LIMIT 10 """) result = conn.execute(query) trades = [] for row in result: trades.append({ "id": row[0], "symbol": row[1], "side": row[2], "entry_price": float(row[3]) if row[3] else None, "exit_price": float(row[4]) if row[4] else None, "pnl": float(row[5]) if row[5] else None, "pnl_percent": float(row[6]) if row[6] else None, "exit_reason": row[7], "exit_time": str(row[8]) if row[8] else None, "entry_time": str(row[9]) if row[9] else None }) print(json.dumps(trades, indent=2)) except Exception as e: print(f"Error: {e}") if __name__ == "__main__": check_today_trades()