Fix datetime comparison in log_daily_performance by converting to date objects

This commit is contained in:
justin committed 2026-02-09 14:02:40 -07:00
1 parent 41ecc4cb4c
commit b4d44d144e
2 files changed
+3 -3

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"DEBUG_MODE": true, "DEBUG_MODE": true,
"SYMBOL": "SPY", "SYMBOL": "QQQ",
"BAR_TIMEFRAME": "5Min", "BAR_TIMEFRAME": "5Min",
"RISK_PER_TRADE": 0.01, "RISK_PER_TRADE": 0.01,
"SHORT_WINDOW": 10, "SHORT_WINDOW": 10,
+2 -2
View File
@@ -526,8 +526,8 @@ def log_daily_performance(date, opening_equity, closing_equity, total_trades, wi
if PERFORMANCE_PATH.exists(): if PERFORMANCE_PATH.exists():
existing = pd.read_csv(PERFORMANCE_PATH) existing = pd.read_csv(PERFORMANCE_PATH)
df = pd.concat([existing, df], ignore_index=True) df = pd.concat([existing, df], ignore_index=True)
cutoff_date = datetime.now(EASTERN) - timedelta(days=180) cutoff_date = (datetime.now(EASTERN) - timedelta(days=180)).date()
df['date'] = pd.to_datetime(df['date']) df['date'] = pd.to_datetime(df['date']).dt.date
df = df[df['date'] > cutoff_date] df = df[df['date'] > cutoff_date]
df.to_csv(PERFORMANCE_PATH, index=False) df.to_csv(PERFORMANCE_PATH, index=False)