128324427f
Merge pull request 'feat: implement Token Efficiency - Context optimization (issue #24 )' ( #28 ) from feature/issue-24-token-efficiency into main
...
CI / test (push) Has been cancelled
Reviewed-on: #28
2026-02-04 18:39:20 +09:00
agentson
61f5aaf4a3
fix: resolve linting issues in token efficiency implementation
...
CI / test (pull_request) Has been cancelled
- Fix ambiguous variable names (l → layer)
- Remove unused imports and variables
- Organize import statements
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2026-02-04 18:35:55 +09:00
agentson
4f61d5af8e
feat: implement token efficiency optimization for issue #24
...
Implement comprehensive token efficiency system to reduce LLM costs:
- Add prompt_optimizer.py: Token counting, compression, abbreviations
- Add context_selector.py: Smart L1-L7 context layer selection
- Add summarizer.py: Historical data aggregation and summarization
- Add cache.py: TTL-based response caching with hit rate tracking
- Enhance gemini_client.py: Integrate optimization, caching, metrics
Key features:
- Compressed prompts with abbreviations (40-50% reduction)
- Smart context selection (L7 for normal, L6-L5 for strategic)
- Response caching for HOLD decisions and high-confidence calls
- Token usage tracking and metrics (avg tokens, cache hit rate)
- Comprehensive test coverage (34 tests, 84-93% coverage)
Metrics tracked:
- Total tokens used
- Avg tokens per decision
- Cache hit rate
- Cost per decision
All tests passing (191 total, 76% overall coverage).
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2026-02-04 18:09:51 +09:00
f40f19e735
Merge pull request 'feat: implement Latency Control with criticality-based prioritization (Pillar 1)' ( #27 ) from feature/issue-21-latency-control into main
...
CI / test (push) Has been cancelled
Reviewed-on: #27
2026-02-04 17:02:40 +09:00
agentson
ce952d97b2
feat: implement latency control system with criticality-based prioritization
...
CI / test (pull_request) Has been cancelled
Add urgency-based response system to react faster in critical market situations.
Components:
- CriticalityAssessor: Evaluates market conditions (P&L, volatility, volume surge)
and assigns urgency levels (CRITICAL <5s, HIGH <30s, NORMAL <60s, LOW batch)
- PriorityTaskQueue: Thread-safe priority queue with timeout enforcement,
metrics tracking, and graceful degradation when full
- Integration with main.py: Assess criticality at trading cycle start,
monitor latency per criticality level, log queue metrics
Auto-elevate to CRITICAL when:
- P&L < -2.5% (near circuit breaker at -3.0%)
- Stock moves >5% in 1 minute
- Volume surge >10x average
Integration with Volatility Hunter:
- Uses VolatilityAnalyzer.calculate_momentum() for assessment
- Pulls volatility scores from Context Tree L7_REALTIME
- Auto-detects market conditions for criticality
Tests:
- 30 comprehensive tests covering criticality assessment, priority queue,
timeout enforcement, metrics tracking, and integration scenarios
- Coverage: criticality.py 100%, priority_queue.py 96%
- All 157 tests pass
Resolves issue #21 - Pillar 1: 속도와 시의성의 최적화
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2026-02-04 16:45:16 +09:00
53d3637b3e
Merge pull request 'feat: implement Evolution Engine for self-improving strategies (Pillar 4)' ( #26 ) from feature/issue-19-evolution-engine into main
...
CI / test (push) Has been cancelled
Reviewed-on: #26
2026-02-04 16:37:22 +09:00
agentson
ae7195c829
feat: implement evolution engine for self-improving strategies
...
CI / test (pull_request) Has been cancelled
Complete Pillar 4 implementation with comprehensive testing and analysis.
Components:
- EvolutionOptimizer: Analyzes losing decisions from DecisionLogger,
identifies failure patterns (time, market, action), and uses Gemini
to generate improved strategies with auto-deployment capability
- ABTester: A/B testing framework with statistical significance testing
(two-sample t-test), performance comparison, and deployment criteria
(>60% win rate, >20 trades minimum)
- PerformanceTracker: Tracks strategy win rates, monitors improvement
trends over time, generates comprehensive dashboards with daily/weekly
metrics and trend analysis
Key Features:
- Uses DecisionLogger.get_losing_decisions() for failure identification
- Pattern analysis: market distribution, action types, time-of-day patterns
- Gemini integration for AI-powered strategy generation
- Statistical validation using scipy.stats.ttest_ind
- Sharpe ratio calculation for risk-adjusted returns
- Auto-deploy strategies meeting 60% win rate threshold
- Performance dashboard with JSON export capability
Testing:
- 24 comprehensive tests covering all evolution components
- 90% coverage of evolution module (304 lines, 31 missed)
- Integration tests for full evolution pipeline
- All 105 project tests passing with 72% overall coverage
Dependencies:
- Added scipy>=1.11,<2 for statistical analysis
Closes #19
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2026-02-04 16:34:10 +09:00
ad1f17bb56
Merge pull request 'feat: implement Volatility Hunter for real-time market scanning' ( #25 ) from feature/issue-20-volatility-hunter into main
...
CI / test (push) Has been cancelled
Reviewed-on: #25
2026-02-04 16:32:31 +09:00
agentson
62b1a1f37a
feat: implement Volatility Hunter for real-time market scanning
...
CI / test (pull_request) Has been cancelled
Implements issue #20 - Behavioral Rule: Volatility Hunter
Components:
1. src/analysis/volatility.py
- VolatilityAnalyzer with ATR calculation
- Price change tracking (1m, 5m, 15m intervals)
- Volume surge detection (ratio vs average)
- Price-volume divergence analysis
- Momentum scoring (0-100 scale)
- Breakout/breakdown detection
2. src/analysis/scanner.py
- MarketScanner for real-time stock scanning
- Scans all available stocks every 60 seconds
- Ranks by momentum score
- Identifies top 5 movers per market
- Dynamic watchlist updates
3. Integration with src/main.py
- Auto-adjust WATCHLISTS dynamically
- Replace laggards with leaders (max 2 per scan)
- Volume confirmation required
- Integrated with Context Tree L7 (real-time layer)
4. Comprehensive tests
- 22 tests in tests/test_volatility.py
- 99% coverage for analysis module
- Tests for all volatility calculations
- Tests for scanner ranking and watchlist updates
- All tests passing
Key Features:
- Scan ALL stocks, not just current watchlist
- Dynamic watchlist that adapts to market leaders
- Context Tree integration for real-time data storage
- Breakout detection with volume confirmation
- Multi-timeframe momentum analysis
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2026-02-04 16:29:06 +09:00
2a80030ceb
Merge pull request 'feat: implement decision logging system with context snapshots' ( #18 ) from feature/issue-17-decision-logging into main
...
CI / test (push) Has been cancelled
Reviewed-on: #18
2026-02-04 15:54:11 +09:00
agentson
2f9efdad64
feat: integrate decision logger with main trading loop
...
CI / test (pull_request) Has been cancelled
- Add DecisionLogger to main.py trading cycle
- Log all decisions with context snapshot (L1-L2 layers)
- Capture market data and balance info in context
- Add comprehensive tests (9 tests, 100% coverage)
- All tests passing (63 total)
Implements issue #17 acceptance criteria:
- ✅ decision_logs table with proper schema
- ✅ DecisionLogger class with all required methods
- ✅ Automatic logging in trading loop
- ✅ Tests achieve 100% coverage of decision_logger.py
- ⚠️ Context snapshot uses L1-L2 data (L3-L7 pending issue #15 )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2026-02-04 15:47:53 +09:00
agentson
6551d7af79
WIP: Add decision logging infrastructure
...
- Add decision_logs table to database schema
- Create decision logger module with comprehensive logging
- Prepare for decision tracking and audit trail
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2026-02-04 15:47:53 +09:00
7515a5a314
Merge pull request 'feat: implement L1-L7 context tree for multi-layered memory management' ( #16 ) from feature/issue-15-context-tree into main
...
CI / test (push) Has been cancelled
Reviewed-on: #16
2026-02-04 15:40:00 +09:00
agentson
254b543c89
Merge main into feature/issue-15-context-tree
...
CI / test (pull_request) Has been cancelled
Resolved conflicts in CLAUDE.md by:
- Keeping main's refactored structure (docs split into separate files)
- Added Context Tree documentation link to docs section
- Preserved all constraints and guidelines from main
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2026-02-04 15:25:13 +09:00
agentson
917b68eb81
feat: implement L1-L7 context tree for multi-layered memory management
...
CI / test (pull_request) Has been cancelled
Implements Pillar 2 (Multi-layered Context Management) with a 7-tier
hierarchical memory system from real-time market data to generational
trading wisdom.
## New Modules
- `src/context/layer.py`: ContextLayer enum and metadata config
- `src/context/store.py`: ContextStore for CRUD operations
- `src/context/aggregator.py`: Bottom-up aggregation (L7→L6→...→L1)
## Database Changes
- Added `contexts` table for hierarchical data storage
- Added `context_metadata` table for layer configuration
- Indexed by layer, timeframe, and updated_at for fast queries
## Context Layers
- L1 (Legacy): Cumulative wisdom (kept forever)
- L2 (Annual): Yearly metrics (10 years retention)
- L3 (Quarterly): Strategy pivots (3 years)
- L4 (Monthly): Portfolio rebalancing (2 years)
- L5 (Weekly): Stock selection (1 year)
- L6 (Daily): Trade logs (90 days)
- L7 (Real-time): Live market data (7 days)
## Tests
- 18 new tests in `tests/test_context.py`
- 100% coverage on context modules
- All 72 tests passing (54 existing + 18 new)
## Documentation
- Added `docs/context-tree.md` with comprehensive guide
- Updated `CLAUDE.md` architecture section
- Includes usage examples and best practices
Closes #15
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2026-02-04 14:12:29 +09:00
2becbddb4a
Merge pull request 'refactor: split CLAUDE.md into focused documentation structure' ( #14 ) from feature/issue-13-docs-refactor into main
...
CI / test (push) Has been cancelled
Reviewed-on: #14
2026-02-04 10:15:09 +09:00
agentson
05e8986ff5
refactor: split CLAUDE.md into focused documentation structure
...
CI / test (pull_request) Has been cancelled
- Restructure docs into topic-specific files to minimize context
- Create docs/workflow.md (Git + Agent workflow)
- Create docs/commands.md (Common failures + build commands)
- Create docs/architecture.md (System design + data flow)
- Create docs/testing.md (Test structure + guidelines)
- Rewrite CLAUDE.md as concise hub with links to detailed docs
- Update .gitignore to exclude data/ directory
Benefits:
- Reduced context size for AI assistants
- Faster reference lookups
- Better maintainability
- Topic-focused documentation
Closes #13
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2026-02-04 10:13:48 +09:00
3c676c2b8d
Merge pull request 'docs: add common command failures and solutions' ( #12 ) from feature/issue-11-command-failures into main
...
CI / test (push) Has been cancelled
Reviewed-on: #12
2026-02-04 10:03:29 +09:00
agentson
3dd222bd3b
docs: add common command failures and solutions
...
CI / test (pull_request) Has been cancelled
- Document tea CLI TTY errors and YES="" workaround
- Record wrong parameter names (--body vs --description)
- Add Gitea API hostname corrections
- Include Git configuration errors
- Document Python/pytest common issues
Each failure includes:
- ❌ Failing command
- 💡 Failure reason
- ✅ Working solution
- 📝 Additional notes
Closes #11
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2026-02-04 10:02:41 +09:00
f4e6b609a4
Merge pull request 'docs: add agent workflow and parallel execution strategy' ( #10 ) from feature/issue-9-agent-workflow into main
...
CI / test (push) Has been cancelled
Reviewed-on: #10
2026-02-04 09:51:01 +09:00
agentson
9c5bd254b5
docs: add agent workflow and parallel execution strategy
...
CI / test (pull_request) Has been cancelled
- Document modern AI development workflow using specialized agents
- Add guidelines for when to use git worktree/subagents vs main conversation
- Define agent roles: ticket mgmt, design, code, test, docs, review
- Include implementation examples with Task tool
- Update test count (35 → 54) with new market_schedule tests
Closes #9
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2026-02-04 09:47:14 +09:00
5c9261ce5b
Merge pull request 'feat: implement timezone-based global market auto-selection' ( #7 ) from feature/issue-5-global-market-auto-selection into main
...
CI / test (push) Has been cancelled
Reviewed-on: #7
2026-02-04 09:33:39 +09:00
ef4305cfc3
Merge pull request 'docs: add Git workflow policy to CLAUDE.md' ( #6 ) from feature/issue-4-add-git-workflow-policy into main
...
CI / test (push) Has been cancelled
Reviewed-on: #6
2026-02-04 09:33:16 +09:00
agentson
b26ff0c1b8
feat: implement timezone-based global market auto-selection
...
CI / test (pull_request) Has been cancelled
Implement comprehensive multi-market trading system with automatic
market selection based on timezone and trading hours.
## New Features
- Market schedule module with 10 global markets (KR, US, JP, HK, CN, VN)
- Overseas broker for KIS API international stock trading
- Automatic market detection based on current time and timezone
- Next market open waiting logic when all markets closed
- ConnectionError retry with exponential backoff (max 3 attempts)
## Architecture Changes
- Market-aware trading cycle with domestic/overseas broker routing
- Market context in AI prompts for better decision making
- Database schema extended with market and exchange_code columns
- Config setting ENABLED_MARKETS for market selection
## Testing
- 19 new tests for market schedule (timezone, DST, lunch breaks)
- All 54 tests passing
- Lint fixes with ruff
## Files Added
- src/markets/schedule.py - Market schedule and timezone logic
- src/broker/overseas.py - KIS overseas stock API client
- tests/test_market_schedule.py - Market schedule test suite
## Files Modified
- src/main.py - Multi-market main loop with retry logic
- src/config.py - ENABLED_MARKETS setting
- src/db.py - market/exchange_code columns with migration
- src/brain/gemini_client.py - Dynamic market context in prompts
Resolves #5
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2026-02-04 09:29:25 +09:00
agentson
1d46cb31fb
docs: add Git workflow policy to CLAUDE.md
...
CI / test (pull_request) Has been cancelled
Add comprehensive Git workflow policy section to ensure all code
changes follow proper process: issue creation, feature branch,
PR, and merge. Explicitly prohibit direct pushes to main branch.
Resolves #4
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2026-02-04 08:50:46 +09:00
2e63ac4a29
Merge pull request 'docs: add CLAUDE.md for AI assistant context' ( #3 ) from feature/issue-2-add-claude-md into main
...
CI / test (push) Has been cancelled
Reviewed-on: #3
2026-02-04 03:29:34 +09:00
9bb7e3ec85
docs: add CLAUDE.md for AI assistant context
...
CI / test (pull_request) Has been cancelled
- Add build & test commands reference
- Document architecture and component interactions
- Include key constraints from docs/agents.md
- Provide configuration and test structure overview
Closes #2
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2026-02-04 03:23:43 +09:00
006aaed46a
Fix SSL hostname mismatch for KIS VTS paper trading endpoint
...
CI / test (push) Has been cancelled
The KIS virtual trading server (openapivts.koreainvestment.com) serves a
certificate with a hostname mismatch. Disable SSL hostname verification
only for the VTS endpoint via a custom TCPConnector; production endpoints
remain fully verified.
Closes #1
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2026-02-04 03:10:32 +09:00
e025136047
Fix Docker runtime errors: migrate to google-genai SDK and fix SQLite permissions
...
CI / test (push) Has been cancelled
Migrate from deprecated google-generativeai to google-genai (>=1.0) using the
new Client-based API, and fix SQLite "unable to open database file" in Docker
by chowning the data directory to appuser before switching users.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2026-02-04 02:56:31 +09:00
03c6b2b942
Update README.md with Korean documentation
...
CI / test (push) Has been cancelled
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2026-02-04 02:11:06 +09:00
d1750af80f
Add complete Ouroboros trading system with TDD test suite
...
CI / test (push) Has been cancelled
Implement the full autonomous trading agent architecture:
- KIS broker with async API, token refresh, leaky bucket rate limiter, and hash key signing
- Gemini-powered decision engine with JSON parsing and confidence threshold enforcement
- Risk manager with circuit breaker (-3% P&L) and fat finger protection (30% cap)
- Evolution engine for self-improving strategy generation via failure analysis
- 35 passing tests written TDD-first covering risk, broker, and brain modules
- CI/CD pipeline, Docker multi-stage build, and AI agent context docs
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2026-02-04 02:08:48 +09:00
9d9945822a
Initial commit
2026-02-04 00:22:48 +09:00