feat: фильтр праздников NYSE — бот не торгует когда биржа закрыта
- holidays.py: календарь NYSE holidays 2024–2027 (10 дат/год) - executor: _is_nyse_hours() пропускает праздники - все ORB-бэктесты: исключают holidays из train/test split и run_day() - OOS сравнение: +$18 PnL, +0.8pp WR, Sharpe 0.42→0.47 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -10,6 +10,7 @@ import numpy as np
|
||||
import pandas as pd
|
||||
|
||||
from data import fetch_candles
|
||||
from holidays import is_nyse_holiday
|
||||
from strategy import Params, Trade, run_day
|
||||
|
||||
NY = ZoneInfo("America/New_York")
|
||||
@@ -133,7 +134,9 @@ def compute_metrics(dollar_trades: list[dict], initial_capital: float,
|
||||
|
||||
def _run_on_dates(df: pd.DataFrame, params: Params) -> list[Trade]:
|
||||
all_trades = []
|
||||
for _, day_df in df.groupby("ny_date"):
|
||||
for dt, day_df in df.groupby("ny_date"):
|
||||
if is_nyse_holiday(dt):
|
||||
continue
|
||||
all_trades.extend(run_day(day_df.reset_index(drop=True), params, OR_MINUTES))
|
||||
return all_trades
|
||||
|
||||
@@ -158,7 +161,7 @@ def run_leverage_sweep(symbol: str, days: int = 60):
|
||||
df = fetch_candles(symbol, days, TIMEFRAME)
|
||||
df["ny_date"] = df["timestamp"].dt.tz_convert(NY).dt.date
|
||||
|
||||
dates = sorted(df["ny_date"].unique())
|
||||
dates = sorted(d for d in df["ny_date"].unique() if not is_nyse_holiday(d))
|
||||
split = int(len(dates) * TRAIN_RATIO)
|
||||
train_dates = set(dates[:split])
|
||||
test_dates = set(dates[split:])
|
||||
|
||||
Reference in New Issue
Block a user