all changes done over the last 2 weeks
This commit is contained in:
@@ -0,0 +1,185 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
📊 System Status Check - Trading Bot V2.2
|
||||
"""
|
||||
|
||||
import sqlite3
|
||||
from datetime import datetime, timedelta
|
||||
import os
|
||||
|
||||
DB_PATH = "trading_bot.db"
|
||||
|
||||
def check_status():
|
||||
"""Comprehensive system status check"""
|
||||
|
||||
print("=" * 70)
|
||||
print("📊 TRADING BOT V2.2 - SYSTEM STATUS")
|
||||
print("=" * 70)
|
||||
|
||||
if not os.path.exists(DB_PATH):
|
||||
print(f"❌ Database not found: {DB_PATH}")
|
||||
return
|
||||
|
||||
conn = sqlite3.connect(DB_PATH)
|
||||
cursor = conn.cursor()
|
||||
|
||||
try:
|
||||
# 1. CONSECUTIVE LOSSES
|
||||
print("\n🎯 CONSECUTIVE LOSSES:")
|
||||
cursor.execute("""
|
||||
SELECT net_profit
|
||||
FROM trades
|
||||
WHERE status = 'closed'
|
||||
ORDER BY exit_time DESC
|
||||
LIMIT 20
|
||||
""")
|
||||
|
||||
trades = cursor.fetchall()
|
||||
consecutive = 0
|
||||
for trade in trades:
|
||||
if trade[0] < 0:
|
||||
consecutive += 1
|
||||
else:
|
||||
break
|
||||
|
||||
print(f" Current: {consecutive}")
|
||||
print(f" Status: {'✅ OK' if consecutive < 5 else '🚨 BLOCKED (≥5)'}")
|
||||
|
||||
# 2. RECENT TRADES
|
||||
print("\n📋 LAST 10 TRADES:")
|
||||
cursor.execute("""
|
||||
SELECT ticket, entry_time, exit_time, profit, net_profit, exit_reason, regime
|
||||
FROM trades
|
||||
WHERE status = 'closed'
|
||||
ORDER BY exit_time DESC
|
||||
LIMIT 10
|
||||
""")
|
||||
|
||||
for row in cursor.fetchall():
|
||||
ticket, entry, exit, profit, net_profit, reason, regime = row
|
||||
symbol = "✅" if net_profit > 0 else "❌"
|
||||
print(f" {symbol} #{ticket}: ${net_profit:.2f} | {regime or 'unknown'} | {reason or 'unknown'}")
|
||||
|
||||
# 3. PERFORMANCE STATS
|
||||
print("\n📈 PERFORMANCE (Last 20 trades):")
|
||||
cursor.execute("""
|
||||
SELECT
|
||||
COUNT(*) as total,
|
||||
SUM(CASE WHEN net_profit > 0 THEN 1 ELSE 0 END) as wins,
|
||||
SUM(CASE WHEN net_profit < 0 THEN 1 ELSE 0 END) as losses,
|
||||
SUM(net_profit) as total_pnl,
|
||||
AVG(net_profit) as avg_pnl
|
||||
FROM trades
|
||||
WHERE status = 'closed'
|
||||
ORDER BY exit_time DESC
|
||||
LIMIT 20
|
||||
""")
|
||||
|
||||
row = cursor.fetchone()
|
||||
if row:
|
||||
total, wins, losses, total_pnl, avg_pnl = row
|
||||
if total > 0:
|
||||
win_rate = (wins / total) * 100
|
||||
print(f" Total Trades: {total}")
|
||||
print(f" Wins: {wins} | Losses: {losses}")
|
||||
print(f" Win Rate: {win_rate:.1f}%")
|
||||
print(f" Total P&L: ${total_pnl:.2f}")
|
||||
print(f" Avg P&L: ${avg_pnl:.2f}")
|
||||
|
||||
# 4. RANGING VS TRENDING
|
||||
print("\n🔍 REGIME BREAKDOWN (Last 20 trades):")
|
||||
cursor.execute("""
|
||||
SELECT
|
||||
regime,
|
||||
COUNT(*) as count,
|
||||
SUM(CASE WHEN net_profit > 0 THEN 1 ELSE 0 END) as wins,
|
||||
SUM(net_profit) as pnl
|
||||
FROM trades
|
||||
WHERE status = 'closed'
|
||||
ORDER BY exit_time DESC
|
||||
LIMIT 20
|
||||
""")
|
||||
|
||||
cursor.execute("""
|
||||
SELECT
|
||||
regime,
|
||||
COUNT(*) as count,
|
||||
SUM(CASE WHEN net_profit > 0 THEN 1 ELSE 0 END) as wins,
|
||||
SUM(net_profit) as pnl
|
||||
FROM (
|
||||
SELECT * FROM trades
|
||||
WHERE status = 'closed'
|
||||
ORDER BY exit_time DESC
|
||||
LIMIT 20
|
||||
)
|
||||
GROUP BY regime
|
||||
""")
|
||||
|
||||
for row in cursor.fetchall():
|
||||
regime, count, wins, pnl = row
|
||||
win_rate = (wins / count * 100) if count > 0 else 0
|
||||
print(f" {regime or 'unknown'}: {count} trades, {win_rate:.1f}% WR, ${pnl:.2f}")
|
||||
|
||||
# 5. TODAY'S ACTIVITY
|
||||
print("\n📅 TODAY'S TRADES:")
|
||||
today = datetime.now().date()
|
||||
cursor.execute("""
|
||||
SELECT COUNT(*), SUM(net_profit)
|
||||
FROM trades
|
||||
WHERE status = 'closed'
|
||||
AND DATE(exit_time) = ?
|
||||
""", (today.isoformat(),))
|
||||
|
||||
row = cursor.fetchone()
|
||||
if row and row[0] > 0:
|
||||
print(f" Trades: {row[0]}")
|
||||
print(f" P&L: ${row[1]:.2f}")
|
||||
else:
|
||||
print(" No trades today")
|
||||
|
||||
# 6. OPEN POSITIONS
|
||||
print("\n🔓 OPEN POSITIONS:")
|
||||
cursor.execute("""
|
||||
SELECT ticket, entry_time, entry_price, profit
|
||||
FROM trades
|
||||
WHERE status = 'open'
|
||||
""")
|
||||
|
||||
open_pos = cursor.fetchall()
|
||||
if open_pos:
|
||||
for row in open_pos:
|
||||
print(f" #{row[0]}: Entry ${row[2]:.2f}, Unrealized P&L: ${row[3]:.2f}")
|
||||
else:
|
||||
print(" No open positions")
|
||||
|
||||
# 7. FINAL VERDICT
|
||||
print("\n" + "=" * 70)
|
||||
if consecutive < 5:
|
||||
print("✅ SYSTEM STATUS: READY TO TRADE")
|
||||
print("=" * 70)
|
||||
print("\n🛡️ ACTIVE PROTECTIONS:")
|
||||
print(" 🛑 Ranging Filter - blocks ADX < 25")
|
||||
print(" 💾 Exit Logging - all exits tracked")
|
||||
print(" 📊 Drawdown Protection - monitoring")
|
||||
print("\n💡 NEXT EXPECTED ACTION:")
|
||||
print(" Waiting for trending market signal (ADX > 25)")
|
||||
print(" Session Filter active (NY + Asian sessions only)")
|
||||
else:
|
||||
print("🚨 SYSTEM STATUS: TRADING PAUSED")
|
||||
print("=" * 70)
|
||||
print(f"\n⚠️ Reason: {consecutive} consecutive losses (limit: 5)")
|
||||
print("\n💡 TO RESUME:")
|
||||
print(" 1. Wait for cooldown (24h)")
|
||||
print(" 2. OR: Run reset_consecutive_losses.py")
|
||||
print(" 3. Restart Jupyter Kernel")
|
||||
|
||||
except Exception as e:
|
||||
print(f"\n❌ ERROR: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
check_status()
|
||||
Reference in New Issue
Block a user