Skip to content

feat: multi-timeframe technical analysis (weekly/monthly)#13

Merged
ShuhaoQing merged 8 commits into
mainfrom
feat/multi-timeframe-analysis
Apr 7, 2026
Merged

feat: multi-timeframe technical analysis (weekly/monthly)#13
ShuhaoQing merged 8 commits into
mainfrom
feat/multi-timeframe-analysis

Conversation

@ShuhaoQing

@ShuhaoQing ShuhaoQing commented Apr 7, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add daily→weekly/monthly price bar aggregation engine (haoinvest/engine/aggregation.py)
  • analyze technical now outputs layered indicators: monthly → weekly → daily
  • Default data window expanded from 1 year to 2 years for monthly MACD support
  • New MultiTimeframeTechnical model wraps all three timeframes
  • CLI provides numerical data only — qualitative interpretation left to agent

Design Decisions

  • Computation-layer aggregation (not API-based): zero additional network calls, all markets handled uniformly, mathematically identical to API weekly/monthly data for complete periods
  • Backward compatible: existing analyze_technical() unchanged, batch mode stays daily-only, daily kv_output format preserved

Test plan

  • 9 unit tests for aggregation (weekly/monthly OHLCV, None handling, ISO week boundary, edge cases)
  • 3 new multi-timeframe analysis tests (sufficient data, insufficient monthly, timeframe labels)
  • All 332 existing tests pass
  • Manual: uv run haoinvest analyze technical 600519 shows monthly/weekly/daily sections
  • Manual: uv run haoinvest analyze technical 600519 --json has monthly/weekly/daily keys

🤖 Generated with Claude Code

Shuhao Qing and others added 8 commits April 7, 2026 14:03
Support multi-timeframe analysis by aggregating daily PriceBar data
into weekly (ISO week) and monthly (calendar month) bars. OHLCV
aggregation handles None values gracefully.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
TechnicalIndicators gains a timeframe tag (daily/weekly/monthly).
New MultiTimeframeTechnical wraps daily + optional weekly/monthly
results for multi-timeframe analysis output.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
New analyze_technical_multi() computes daily/weekly/monthly indicators
in a single call by aggregating daily bars and reusing compute_technical.
Existing analyze_technical() unchanged for backward compatibility.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The technical command now shows monthly→weekly→daily indicator layers.
Default data window expanded from 1 year to 2 years to support monthly
MACD calculation. JSON output includes all three timeframes. Batch mode
remains daily-only for readability.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Design document for adding weekly/monthly indicator output to the
analyze technical command via computation-layer aggregation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Address code review feedback: document sort invariant in _aggregate_bars.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…date

_ensure_prices_cached now checks if the earliest cached bar covers the
requested start date. If not, it fetches the missing earlier portion.
This fixes the issue where expanding the default window from 1→2 years
would skip fetching because >10 bars already existed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
3 years (36 monthly bars) ensures monthly MACD(26) has sufficient data.
The previous 2-year window only yielded 24 monthly bars, falling short.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ShuhaoQing ShuhaoQing merged commit b87a2b4 into main Apr 7, 2026
1 check passed
@ShuhaoQing ShuhaoQing deleted the feat/multi-timeframe-analysis branch April 7, 2026 09:33
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