Skip to content

Instantly share code, notes, and snippets.

@Scheevel
Created December 16, 2025 19:13
Show Gist options
  • Select an option

  • Save Scheevel/64b9b8c5a10704cba33e384c1a1d305d to your computer and use it in GitHub Desktop.

Select an option

Save Scheevel/64b9b8c5a10704cba33e384c1a1d305d to your computer and use it in GitHub Desktop.
Planning Epic 9: Universe selection, screening, and batch backtesting for EOS.
↳ analyst
*research-prompt In the context of this project, I am not selecting good examples for back testing. Honestly validate my reasoning and propose to me a solution for finding stock that are most likely to have a high occurrence of the strategy we are seeking. Currently I am filtering using finviz.com screener (not required, just the tool I chose) and I am screening for: Beta > 4 , Avg Vol > 2M, hight Market Cap.
-
Option #3 First discuss alternative screening criteria before research. I'm interested in what you think.
-
Option #1 Build research prompt to validate these screening criteria. And, finviz, and doing this by hand is clunky. If there is an API or some other datasource that we could leverage, that would make life easier.
-
option #2 Save this to a file in the project docs/research/universe-selection-prompt.md
↳ analyst
In the context of what we've built so far, chat me up on this, we can call the concept "Simplified Alternative"
-
Clarifying answers: Use SPY + QQQ constituents as base universe. Apply only RVOL ≥ 2.0 and ATR% 1-5% filters at trade time. Skip explicit institutional ownership filter (ETF inclusion implies it). Use the DER formula as it is well-designed (Volume/AvgVolume) the component captures the most predictive factor in the research. Consider adding a hard RVOL ≥ 1.0 cutoff before applying DER ranking to eliminate "below average volume" setups that show negative expected returns. Ask me any clarifying questions.
-
Clarifying answers: #1 A simple union of ~503 unique tickers. #2 Dual threshold concept. #3 Both. #4 see workflow. #5 A predefined universe that exists and is likely to contain a target rich environment
-
Clarifying answers: #1 ATR calculation. #2 N is any qualifying result. #3 No preference. #4 Add new additions, and keep removed, they may still be good targets
-
Clarifying answers: #1 correct universe will continually expand. #2 Start with Option 1-day cooling off for backtesting. It's cleaner to analyze and eliminates a category of setup that has different risk/reward characteristics anyway. #3 Your choice, which ever refresh method is most automatic.
-
Comibine these options. Document this as a formal spec in `docs/` using a template. In the document compare to current EOS implementation, analyze the existing codebase to identify what changes this would require and prototype the universe builder, and sketch out the weekly refresh logic.
-
Yes, Create the Epic 9 document
-
Yes, generate the stories, shard as needed, combine when possible.
↳ architect
please evaluate the @ epic-9 and all the `story-9.x` documents, in the context of this project's architecture do you see any concerns or areas needing clarification?
-
Focusing on just 2 for a moment: yfinance Holdings API Unreliability, how would you suggest implementing instead IEX Cloud's ETF holdings endpoint as primary?
-
Summarize this The etfpy + JSON fallback approach into a hand-off document to share with other team members for implementation
-
Other clarifying answers: #1 Missing get_daily_data() Method on DataFetcher: see "Story 9.0: Daily Data Support". #2 yfinance Holdings API Unreliability: → RESOLVED: Created ETF Holdings Implementation spec (docs/specs/etf-holdings-implementation.md) using etfpy + JSON fallback. Updated Story 9.1 to reference spec and replace yfinance-based implementation with etfpy. #3 RVOL Formula Inconsistency. #4 Circular Import Risk in Gate Evaluation: refactor the document to instead have CoolingOffManager return a simple tuple (passed, reason) and then let the Scanner wrap it in a GateResult. #5 Scanner's DER Calculation Differs from Existing Implementation <- this has been updated in the documentation
#6 Database Schema Migration Strategy: Story 9.4 has been updated with a clear Schema Migration Strategy. #7 CLI Command Structure Ambiguity: Story 9.4 has been updated to explicitly document a decision. #8 Batch Backtest Thread Safety: The story has been updated for thread safety. #9 Missing OR_Body Calculation Detail: Not a problem, the Scanner code correctly accesses orb.session_open as a dataclass attribute, not as a DataFrame column. The concern was based on a misreading of the code structure - orb is the OpeningRange object returned by ORBCalculator.calculate_orb(), and session_open is one of its fields. #10 Test Coverage Targets Vary: Standardize to >85% across all stories.
↳ analyst
Critical concern: get_daily_data() method is missing. Story 9.1 assumes DataFetcher.get_daily_data() exists: From story-9.1-universe-foundation.md (line 267) df = self.data_fetcher.get_daily_data(ticker, start_date, as_of_date)
Problem: The existing DataFetcher only provides get_data() which fetches 5-minute intraday data, not daily data. ATR% calculation requires daily OHLCV bars. Clarification Needed: Is there a story to add a get_daily_data() method to DataFetcher? Or calculate ATR from 5-minute data aggregated to daily? Or use a separate yfinance call with interval='1d'?
-
create a separate small "Story 9.0: Daily Data Support" as a prerequisite
-
Can you explain why Two different RVOL formulas appear in the documents: Spec (line 160): RVOL = OR_Volume / (AvgVol₂₀ × 0.0625) Story 9.2 (line 315): OR_PERIOD_FRACTION = 15 / 390 # = 0.03846... Clarification Needed: Which is canonical? 15/240 = 0.0625 (4-hour approximation) or 15/390 = 0.0385 (precise 6.5-hour day)
-
Yes, and rename the variable from `AvgVol₂₀` to `AvgVol` (which removes the subscript)
-
Story 9.4 proposes new tables (universe_snapshots, universe_members, cooling_off, scan_results) but doesn't specify: How to migrate existing databases or whether to extend eos/database/schema.sql or create schema_universe.sql Should we instead create a separate eos/database/schema_universe.sql and have DatabaseManager._ensure_schema_exists() execute both schema files? → RESOLVED: Updated Story 9.4 with "Schema Migration Strategy" section. Approach: separate schema_universe.sql with multi-file loading in _ensure_schema_exists(). Existing DBs auto-migrate on next use.
-
Story 9.4 proposes: `eos universe refresh` and `eos universe list` and `eos scan run` and `eos scan results` But the existing CLI pattern in eos/cli/commands.py uses flat commands. Clarification Needed: Will this introduce command groups (universe, scan) to the CLI? If so, update existing commands for consistency?
-
Option #1 Update Story 9.4 to explicitly document this decision → RESOLVED: Updated Story 9.4 with "CLI Architecture Decision" section. Decision: Use flat commands (eos refresh-universe, eos scan, etc.) to maintain consistency with existing CLI pattern.
-
Story 9.5 uses ThreadPoolExecutor: In story-9.5-batch-backtester.md (line 256) with ThreadPoolExecutor(max_workers=self.max_workers) as executor. The concerns are 1) Is BacktestRunner thread-safe? (Uses shared DataFetcher, HDF5Cache) 2) Does HDF5Cache support concurrent writes? 3) Should this use ProcessPoolExecutor for CPU-bound work? → RESOLVED: Added "Thread Safety Considerations" section to Story 9.5. Solution: Worker-local BacktestRunner instances (each worker creates its own), plus ticker deduplication to prevent concurrent access to same cache files. ThreadPoolExecutor is fine since HDF5 files are per-ticker.
-
The Scanner's _calculate_der_for_orb() method uses: or_body = abs(last_or_bar['close'] - orb.session_open) But the existing ORBCalculator.calculate_orb() returns an OpeningRange object that doesn't expose session_open as a DataFrame column - it's a property. Clarification Needed to ensure the Scanner correctly accesses ORB data structures. → VERIFIED: Not a problem. OpeningRange dataclass (eos/models/orb.py:21) has `session_open: float` as a direct attribute. The code `orb.session_open` correctly accesses the property from the ORBCalculator result.
-
Should the hand-off document @ etf-holdings-implementation.md. be incorporated into one of the @ epic-9 stories?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment