feat: implement Smart Volatility Scanner (issue #76) #77

Merged
jihoson merged 2 commits from feature/issue-76-smart-volatility-scanner into main 2026-02-06 07:43:55 +09:00
Collaborator

Summary

  • Add KIS API ranking endpoint integration (fetch_market_rankings, get_daily_prices)
  • Implement RSI calculation with Wilder's smoothing method
  • Create SmartVolatilityScanner with Python-first filtering pipeline
  • Refactor main.py to use dynamic candidate selection instead of static watchlists
  • Add selection_context logging to trades table for Evolution system

Implementation Details

New KIS API Methods:

  • fetch_market_rankings(type='volume') - Fetch top 30 volume surge stocks
  • get_daily_prices(stock_code, days=20) - Fetch OHLCV history for RSI

RSI Calculation:

  • Pure Python implementation (no numpy/pandas)
  • Wilder's smoothing method with 14-period default
  • Returns neutral (50.0) for insufficient data

SmartVolatilityScanner:

  • Filter 1: Volume ratio >= VOL_MULTIPLIER (default 2.0x)
  • Filter 2: RSI < RSI_OVERSOLD (30) OR RSI > RSI_MOMENTUM (70)
  • Returns top SCANNER_TOP_N candidates (default 3) by score
  • Graceful fallback to static watchlist on API failure

Selection Context Logging:

  • Stores RSI, volume_ratio, signal, score in trades.selection_context
  • Enables Evolution system to correlate selection criteria with outcomes

Configuration

RSI_OVERSOLD_THRESHOLD=30    # 0-50
RSI_MOMENTUM_THRESHOLD=70    # 50-100
VOL_MULTIPLIER=2.0           # >1.0
SCANNER_TOP_N=3              # 1-10

Test Plan

  • All tests pass (343 tests total)
  • 13 new tests for SmartVolatilityScanner and RSI
  • Coverage maintained at 73%
  • Existing main.py tests updated for new signature
  • Paper mode integration verified

Benefits

  • Reduces API costs: Process 1-3 qualified stocks instead of 20-30 ranked
  • Python-first filtering: Technical indicators before expensive AI calls
  • Evolution-ready: Selection context tracked for strategy optimization
  • Fault-tolerant: Falls back to static watchlist on API failure

🤖 Generated with Claude Code

## Summary - Add KIS API ranking endpoint integration (fetch_market_rankings, get_daily_prices) - Implement RSI calculation with Wilder's smoothing method - Create SmartVolatilityScanner with Python-first filtering pipeline - Refactor main.py to use dynamic candidate selection instead of static watchlists - Add selection_context logging to trades table for Evolution system ## Implementation Details **New KIS API Methods:** - `fetch_market_rankings(type='volume')` - Fetch top 30 volume surge stocks - `get_daily_prices(stock_code, days=20)` - Fetch OHLCV history for RSI **RSI Calculation:** - Pure Python implementation (no numpy/pandas) - Wilder's smoothing method with 14-period default - Returns neutral (50.0) for insufficient data **SmartVolatilityScanner:** - Filter 1: Volume ratio >= VOL_MULTIPLIER (default 2.0x) - Filter 2: RSI < RSI_OVERSOLD (30) OR RSI > RSI_MOMENTUM (70) - Returns top SCANNER_TOP_N candidates (default 3) by score - Graceful fallback to static watchlist on API failure **Selection Context Logging:** - Stores RSI, volume_ratio, signal, score in trades.selection_context - Enables Evolution system to correlate selection criteria with outcomes ## Configuration ```bash RSI_OVERSOLD_THRESHOLD=30 # 0-50 RSI_MOMENTUM_THRESHOLD=70 # 50-100 VOL_MULTIPLIER=2.0 # >1.0 SCANNER_TOP_N=3 # 1-10 ``` ## Test Plan - [x] All tests pass (343 tests total) - [x] 13 new tests for SmartVolatilityScanner and RSI - [x] Coverage maintained at 73% - [x] Existing main.py tests updated for new signature - [x] Paper mode integration verified ## Benefits - **Reduces API costs**: Process 1-3 qualified stocks instead of 20-30 ranked - **Python-first filtering**: Technical indicators before expensive AI calls - **Evolution-ready**: Selection context tracked for strategy optimization - **Fault-tolerant**: Falls back to static watchlist on API failure 🤖 Generated with [Claude Code](https://claude.com/claude-code)
agentson added 1 commit 2026-02-06 00:48:56 +09:00
feat: implement Smart Volatility Scanner with RSI/volume filters (issue #76)
Some checks failed
CI / test (pull_request) Has been cancelled
f0ae25c533
Add Python-first scanning pipeline that reduces Gemini API calls by filtering
stocks before AI analysis: KIS rankings API -> RSI/volume filter -> AI judgment.

## Implementation
- Add RSI calculation (Wilder's smoothing method) to VolatilityAnalyzer
- Add KIS API methods: fetch_market_rankings() and get_daily_prices()
- Create SmartVolatilityScanner with configurable thresholds
- Integrate scanner into main.py realtime mode
- Add selection_context logging to trades table for Evolution system

## Configuration
- RSI_OVERSOLD_THRESHOLD: 30 (configurable 0-50)
- RSI_MOMENTUM_THRESHOLD: 70 (configurable 50-100)
- VOL_MULTIPLIER: 2.0 (minimum volume ratio, configurable 1-10)
- SCANNER_TOP_N: 3 (max candidates per scan, configurable 1-10)

## Benefits
- Reduces Gemini API calls (process 1-3 qualified stocks vs 20-30 ranked)
- Python-based technical filtering before expensive AI judgment
- Tracks selection criteria (RSI, volume_ratio, signal, score) for strategy optimization
- Graceful fallback to static watchlist if ranking API fails

## Tests
- 13 new tests for SmartVolatilityScanner and RSI calculation
- All existing tests updated and passing
- Coverage maintained at 73%

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
agentson added 1 commit 2026-02-06 07:35:31 +09:00
docs: update documentation for Smart Volatility Scanner
Some checks failed
CI / test (pull_request) Has been cancelled
7725e7a8de
Update project documentation to reflect new Smart Volatility Scanner feature:

## CLAUDE.md
- Add Smart Volatility Scanner section with configuration guide
- Update project structure to include analysis/ module
- Update test count (273→343 tests)

## docs/architecture.md
- Add Analysis component (VolatilityAnalyzer + SmartVolatilityScanner)
- Add new KIS API methods (fetch_market_rankings, get_daily_prices)
- Update data flow diagram to show Python-first filtering pipeline
- Add selection_context to database schema documentation
- Add Smart Scanner configuration section
- Renumber components (Brain 2→3, Risk Manager 3→4, etc.)

## docs/requirements-log.md
- Document 2026-02-06 requirement for Smart Volatility Scanner
- Explain Python-First, AI-Last pipeline rationale
- Record implementation details and benefits
- Reference issue #76 and PR #77

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
jihoson merged commit a82a167915 into main 2026-02-06 07:43:55 +09:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: jihoson/The-Ouroboros#77