Skip to content

Add intraday volatility risk research#81

Merged
Pigbibi merged 3 commits into
mainfrom
intraday-dynamic-volatility-research-20260610
Jun 10, 2026
Merged

Add intraday volatility risk research#81
Pigbibi merged 3 commits into
mainfrom
intraday-dynamic-volatility-research-20260610

Conversation

@Pigbibi

@Pigbibi Pigbibi commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add reproducible intraday crash-circuit and daily/hourly/15-minute scheme research CLIs
  • document IBKR hourly/15-minute validation, threshold/cost sensitivity, combined execution findings, and extended-hours limitations
  • explicitly keep hourly SOXL/TQQQ rules out of live defaults; SOXL -8% is only a disabled/shadow validation candidate unless forward evidence confirms it
  • add focused unit coverage for hourly threshold behavior, re-entry, alignment, and execution timing overlays

Validation

  • PYTHONPATH=/home/ubuntu/Projects/UsEquityStrategies/src:/home/ubuntu/Projects/UsEquitySnapshotPipelines/src .venv/bin/python -m py_compile src/us_equity_snapshot_pipelines/intraday_crash_circuit_breaker_research.py src/us_equity_snapshot_pipelines/intraday_scheme_research.py src/us_equity_snapshot_pipelines/intraday_scheme_validation.py scripts/research_intraday_crash_circuit_breaker.py scripts/research_intraday_scheme.py scripts/research_intraday_scheme_validation.py
  • direct-call tests in tests/test_intraday_crash_circuit_breaker_research.py
  • git diff --check

Note: pytest is not installed in the local venv, so I used direct invocation for the new focused tests.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 24daf5f3df

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if intraday_close is None or intraday_close.empty:
return returns.copy(), pd.DataFrame()

pre_execution = _slot_pre_execution_returns(intraday_close, prices, slot).reindex(returns.index)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Skip dates with no intraday execution bar

When the return window extends beyond the 15-minute data coverage or has a missing session, this reindex creates an all-NaN row for every such date; the later fillna(0.0) then treats missing intraday prices as a flat pre-execution move and records turnover days as execution events with zero adjustment. This inflates the reported event counts and can silently dilute execution-timing results unless the caller happens to trim returns exactly to complete intraday coverage.

Useful? React with 👍 / 👎.

if pre_execution.empty:
return returns.copy(), pd.DataFrame()

previous_weights = weights.shift(1).reindex(returns.index).fillna(0.0)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve the prior weight at the start of a sliced window

For research windows that start after the backtest has already been running, weights has already been reindexed to returns.index, so the first row's shifted previous weight is filled as zero even if the strategy held a position on the prior trading day. The first intraday date is therefore treated as a new trade from cash, causing a spurious execution adjustment/event; compute the shift from the full normalized weight history before trimming to the return window, or keep the prior row when slicing.

Useful? React with 👍 / 👎.

@Pigbibi Pigbibi merged commit 28c2b21 into main Jun 10, 2026
1 check passed
@Pigbibi Pigbibi deleted the intraday-dynamic-volatility-research-20260610 branch June 10, 2026 04:35

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 755522df22

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

normalized = pd.DataFrame(
{
"symbol": frame[symbol_column].astype(str).str.upper().str.strip(),
"time": pd.to_datetime(frame[time_column], errors="coerce").dt.tz_localize(None),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Handle timezone-aware IBKR timestamps before stripping tz

When the intraday CSV uses timezone-aware timestamps (the new research doc says the IBKR pulls used formatDate=2, which produces UTC-aware datetimes), this expression raises TypeError: Already tz-aware, use tz_convert to convert. before any research can run. The reproducible --hourly-prices / --intraday-15m-prices commands therefore fail on the documented IBKR files; parse with utc=True and then convert/drop the timezone, or branch between tz_convert(None) and tz_localize(None).

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant