Last Updated: December 2025 Version: v1.0 - Production VoterAgent Ready Framework: Microsoft AutoGen 0.7.x
Human-in-loop algorithmic trading platform using Microsoft AutoGen framework with validated pure-math MACD+RSI strategies.
Core Philosophy: Pure mathematical indicators + human oversight > complex LLM sentiment analysis
Current Status: Production-ready VoterAgent with multi-agent framework in development
| Component | Status | Performance | Notes |
|---|---|---|---|
| VoterAgent | ✅ Production | 0.468 OOS Sharpe (QQQ) | Pure MACD+RSI voting. Note: 0.856 Sharpe was from older, less rigorous tests. |
| main.py CLI | ✅ Functional | All 4 commands working | Fixed Oct 2025 |
| Alpaca Integration | ✅ Validated | Paper trading operational | 35/35 tests passing |
| Position Management | ✅ Complete | Broker-as-truth reconciliation | Real-time tracking |
| Order Management | ✅ Complete | Bracket, stop, trailing orders | Full lifecycle support |
| Trading Cycle | ✅ Optimized | 90% fewer API calls | Cost-efficient batching |
| Market Data | ✅ Complete | Alpaca + Polygon + Alpha Vantage | Multi-source with fallback |
| Documentation | ✅ Complete | Restructured with numbering | Presentation-ready |
| Component | Status | Notes |
|---|---|---|
| ScannerAgent | 🚧 Implementation | Multi-ticker MACD+RSI scanning (#386) |
| RiskAgent | 🚧 Implementation | Position sizing, circuit breaker (#387) |
| ExecutorAgent | ✅ Complete | Trade execution, simulation mode (#388) |
| TradingOrchestrator | ✅ Complete | Workflow management, state persistence (#389) |
| TradingPipeline | ✅ Complete | Full 5-phase daily workflow orchestrator (#323) |
| Agent Factory & Bus | ✅ Complete | Agent Bus infrastructure (#390) for pub-sub messaging |
| TrailingStopManager | ✅ Complete | Progressive stop logic (#321) |
| GTT Triggers | ✅ Complete | Persistent price triggers, multi-day trailing stops (#340) |
| Trading Modes | ✅ Complete | Natural language risk modes (#400) |
| Human-in-Loop CLI | ✅ Complete | Interactive trade approval interface with multiple execution modes |
Branch Status: Core pipeline infrastructure complete. Phase 2 agent implementations in active refactoring. Architecture decision: using Agent Bus (#390) for inter-agent communication.
Completed Components:
- VoterAgent with validated MACD+RSI voting (OOS Sharpe 0.468)
- Pure math calculations (no LLM dependencies)
- Alpaca paper trading integration
- Position and order management
- Cost-efficient trading cycle (90% fewer API calls)
- main.py CLI interface
- Market data pipeline (Alpaca, Polygon, Alpha Vantage)
- Comprehensive documentation restructure
- Test coverage (35/35 passing)
Key Achievement: Production-ready VoterAgent with validated performance
Critical Bug Fixes:
- Price validation for sub-penny rounding (Alpaca compliance)
- SDK integration with OrderData object handling
- Import issues and execute_lifecycle() method calls
- Status checking for Alpaca enum formats
- Robust error handling and fallback mechanisms
High Priority:
-
Human-in-Loop CLI (#308) - ✅ COMPLETE (Nov 2025)
- Interactive trade review interface
- Decision explanation and override capability
- Risk assessment display
- Multiple execution modes: CONFIRM, AUTO, PAPER, DISABLED
-
Complete Remaining Agents (#310) - ✅ IMPLEMENTATIONS COMPLETE, REFACTORING (Nov 2025)
- ScannerAgent: Multi-ticker MACD+RSI scanning (#386)
- RiskAgent: Position sizing and circuit breaker (#387)
- ExecutorAgent: Trade execution coordination (#388)
- TradingOrchestrator: Multi-agent workflow management (#389)
- Note: Refactoring to resolve Agent Bus integration collision
Medium Priority:
-
Agent Factory & Event Bus (#390) - 🚧 IN REFACTORING
- Centralized agent creation via AgentFactory singleton
- Pub-sub messaging via AgentBus for inter-agent communication
- 16 trading-specific EventType values
- Symbol filtering, TTL, correlation tracking
- Note: Event Bus (#397) duplicate rejected; using Agent Bus
-
Dynamic Trailing Stops (#321) - ✅ COMPLETE (Nov 2025)
- TrailingStopManager with progressive stop logic
- 2% breakeven, 4% lock 25%, 6% trail 50% profit
- Integrated into trade_lifecycle.py and trading_cycle.py
- Rate-limited to prevent API abuse
-
GTT Persistent Triggers (#340) - ✅ COMPLETE (Dec 2025)
- Persistent price triggers checked twice daily (scheduler)
- Conditions: price above/below, pct gain/loss, trailing stop, time window, volume
- Actions: alerts, order placement/cancellation via AlpacaOrderManager
- OCO groups for dual breakout/breakdown scenarios
- Multi-day trailing stop persistence via TrailingStopManager bridge
- 📁 Files:
src/trading/gtt/(manager, evaluator, executor, bridge)
Low Priority:
- Forward Testing Protocol (#324) - ✅ COMPLETE (Nov 2025)
- 30-day validation framework with state persistence
- Performance metrics: Sharpe, win rate, drawdown, profit factor
- Daily/weekly/final reports with go/no-go recommendations
- Automated acceptance criteria validation
- Branch:
feature/forward-testing-achat
| Component | Status | Notes |
|---|---|---|
| Multi-Account Manager | ✅ Complete | Account selection, API-first discovery (#401) |
| Security Architecture | 📋 Planned | Credential management, OS keyring (#402) |
#401 - Multi-Account Portfolio Management - ✅ COMPLETE:
- ✅ Account selection via CLI
--accountflag - ✅ Natural language commands: "list accounts", "switch to account X"
- ✅ Agent tools: AutoGen-compatible function calls
- ✅ API-first discovery (Alpaca tells us account details)
- ✅ Automatic paper vs live detection
- ✅ Legacy single-account config backward compatibility
- ✅ 19 unit tests (all passing)
- 📁 Files:
account_manager.py,account_commands.py,account_tools.py,accounts_config.py
#402 - Security Architecture (separate from #401):
- OS Keyring integration for credential storage
- Secure credential provider interface
- Paper/live account isolation
- Audit logging without credential exposure
- TODO markers added in #401 code for future integration
Completed:
-
Pullback/Breakout Limit Orders (#344) - ✅ FIXED (Nov 28, 2025)
- Pullback orders now place LIMIT orders at 2.5% below current price
- Breakout orders place LIMIT orders at 1.5% above current price
- GTC (Good-Til-Canceled) ensures orders wait indefinitely
- Fixed execution manager to pass entry_limit_price for timing contexts
- Merged to feature/development Nov 28, 2025
-
Interactive Help System (#369) - ✅ COMPLETE
/helpcommand with category-based organization/help search KEYWORDfor searchable documentation- Command examples, aliases, related commands
- 23+ commands documented across 5 categories
- Merged to feature/development Nov 2025
-
Order Cancellation (#360) - ✅ COMPLETE (B-chat)
cancel all orderswith confirmationcancel order <id>with partial ID matchingcancel <SYMBOL> ordersfor symbol-specific cancellation- Merged to feature/development Nov 2025
-
Order Details Display (#348) - ✅ COMPLETE (B-chat)
- Natural language queries: "what is my stop level on META"
- Shows entry orders, stop/target orders, current price
- Calculates distance and percentage from entry
- Merged to feature/development Nov 2025
In Progress:
-
CLI FunctionTool Infrastructure (#433, #455, #456, #457, #458) - ✅ PHASE 2 COMPLETE (Dec 2025)
- ✅ Tool registry with 17 modular tool files (7287 lines total)
- ✅ cli_session.py reduced from 2800+ to 1657 lines
- ✅ Extracted: mode, timeframe, account, portfolio, order, scheduler, alert, execution_mode
- ✅ Additional: voter, backup, gtt, watchlist, trailing_stop, entry_planning, user_alert
- 🔜 Phase 3: CLI command integration for new tool groups
- 📁 Files:
src/cli/tools/*.py(17 tool modules)
-
CLI Command Group Integration (#488, #489, #490) - ✅ COMPLETE (Dec 2025)
- #488:
/votercommands for ranked voting management ✅ - #489:
/timeframemulti-tf presets (trend_following, intraday, position) ✅ - #490:
/backupcommands for database management ✅ - All integrated in
src/cli/commands/slash_commands.py - Merged to feature/testing
- #488:
-
Execution Mode Switching (#332)
/togglecommand for quick mode switchingset execution-mode {confirm|auto|paper|disabled}- Mode persistence and validation
- Target: Dec 2025
-
Config Externalization (#358)
- Move hardcoded values to config files
- Cleaner parameter management
- Easier testing and deployment
- Target: Q1 2026
The project's GEX research contains contradictory findings that must be resolved before proceeding:
| Analysis Script | Finding | Optimal GEX Regime |
|---|---|---|
tsmom_vs_gex_analysis.py (#421) |
MACD+RSI performs best in positive gamma | POSITIVE_GAMMA |
tsmom_gex_hybrid.py (#516) |
Built on premise that TSMOM works best in negative gamma | NEGATIVE_GAMMA |
#516 TSMOM+GEX Hybrid ✅ CLOSED (Hypothesis Invalidated)
- Median improvement: -2.9% (hybrid performs WORSE than pure TSMOM)
- The "inverse regime weighting" hypothesis is NOT validated
- Script:
scripts/research/tsmom_gex_hybrid.py
#518 MACD Parameter Stability ✅ CLOSED (No Robust Edge)
- "Least Unprofitable" Parameters:
fast+nonewith OOS Sharpe -0.223 - Most MACD configs show IS→OOS decay (overfitting)
- Script:
scripts/research/macd_parameter_stability.py
#519 Transaction Cost Analysis ✅ CLOSED (MACD+RSI More Robust)
- TSMOM: Avg Net Sharpe -0.259, 19% pass rate, 4 trades/yr
- MACD+RSI: Avg Net Sharpe 0.173, 44% pass rate, 39 trades/yr
- Script:
scripts/research/transaction_cost_analysis.py
Recommended Actions Before Proceeding:
-
Resolve Research Contradiction - The two GEX analyses use different momentum definitions:
tsmom_vs_gex_analysis.pyuses MACD+RSI (short-term technical momentum)tsmom_gex_hybrid.pyuses academic TSMOM (12-month return)- These are fundamentally different strategies; results are not comparable
-
Standardize Strategy Definitions - Create canonical implementations:
academic_tsmom- Sign of 12-month return (Moskowitz 2012)vol_scaled_tsmom- Volatility-scaled versiontechnical_momentum- MACD+RSI voting
-
Validate GEX Hypothesis with Consistent Methodology - Re-run both analyses using the same strategy definition
Previously Planned (DEFERRED until resolution):
-
Integrate GEX as Regime Filter -
Adopt S² Scaling for GEX -
Implement Weekly KAMA as Trend Filter (Independent of GEX - can proceed)
- Finding: Weekly KAMA outperforms weekly MACD (avg Sharpe ~0.75).
- Action: Create a new
TrendFilterAgentor add KAMA as a voter.
-
Timeframe Specification (#365)
- Multi-timeframe analysis for VoterAgent
- Better signal quality through timeframe confluence
-
Ranked Voter System (#364)
- Multi-indicator consensus voting
- Confidence scoring across multiple signals
The following simulation fidelity issues must be addressed before production deployment:
| Gap | Issue | Impact | Resolution |
|---|---|---|---|
| Wick Risk | Vectorized backtests assume close-to-close holds | Overestimated Sharpe/Win rates (ignores intraday stop-outs) | Path-dependent simulation (#525) |
| Data Granularity | Some scripts estimate High/Low (close*1.01) | Cannot accurately simulate bracket orders in volatility regimes | Use actual OHLC data |
| Portfolio Correlation | Symbols analyzed in isolation | Diversification fails in negative gamma (correlations -> 1.0) | Portfolio-level simulation |
| Strategy Definitions | Multiple TSMOM/MACD definitions across scripts | Incoherent research narrative | Canonical implementations |
#525 Path-Dependent Simulation: Created scripts/research/path_dependent_simulation.py to address wick risk.
This engine checks SL/TP triggers intraday rather than assuming positions are held until close.
Future Enhancements:
-
JSON→YAML Conversion (#328)
- 40-50% token reduction for LLM feeds
- Optimize agent communication
- Cost savings on LLM calls
- Target: When implementing LLM-based agents
-
Live Trading Deployment
- Production credentials setup
- Enhanced monitoring dashboard
- Real-time alerting system
- Performance analytics
- Target: After human-in-loop CLI complete
-
Advanced Portfolio Analytics
- Multi-position performance tracking
- Risk-adjusted metrics
- Correlation analysis
- Drawdown reporting
| Metric | Value | Benchmark |
|---|---|---|
| Sharpe Ratio | 0.468 (OOS, QQQ) | >0.7 = Excellent |
| Total Return | 36.6% | Outperformed SPY |
| Win Rate | 51.4% | >50% target |
| Max Drawdown | -10.10% | <15% acceptable |
| Strategy | Pure MACD+RSI | No LLM sentiment |
Note: The 0.856 Sharpe ratio from older tests has been superseded by more rigorous walk-forward validation results.
| Metric | Value | Improvement |
|---|---|---|
| API Calls/Day | 10-15 | 90% fewer vs reactive |
| Cache Hit Rate | 85%+ | 90%+ faster access |
| Response Time | <500ms | Real-time decisions |
| Test Coverage | 313 passing | Priority 1-5 components (Issue #408 ✅) |
Paper Trading:
- Successfully placed 7 shares SPY @ $660 with bracket orders
- Risk Management: 5% stop loss / 8% take profit confirmed operational
- Fill Monitoring: Real-time order status tracking working
- State Persistence: Position tracking across system restarts validated
#308 - CLI Human-in-Loop Interface (P0 - ✅ COMPLETE)
- Scope: User-initiated conversational trade assistant
- Features: Natural language input, real VoterAgent analysis, entry/stop/target suggestions, GTC orders
- Why Critical: Core design principle is human oversight
- Status: ✅ 100% COMPLETE - MVP delivered and tested
- Completed:
- Core interfaces, models, orchestrator
- LLMParser with OpenAI gpt-4o-mini + o4-mini
- RealVoterStrategy with production VoterAgent (0.856 Sharpe)
- SimpleRiskManager with portfolio % calculations
- AlpacaExecutionManager with bracket order support
- CLI presentation layer with interactive REPL
- Factory pattern with config.json integration
- Main integration (trade-assist command)
- All tests passing (8/8)
- Real API integration validated
- Test Results:
- Natural language parsing: Working (3/3 tests)
- Real MACD+RSI analysis: Working (3/3 tests)
- SPY: SELL (65% conf), AAPL: BUY (65% conf)
- Usage:
python main.py trade-assist - Completed: November 8, 2025
#333 - Portfolio Manager Agent (P1 - ✅ PHASE 1 COMPLETE)
- Scope: Risk management, position sizing, portfolio allocation checks
- Features: Buying power checks, portfolio % limits, risk-based sizing, existing position handling
- Why Important: Safe trading requires intelligent portfolio management
- Depends On: #308 (needs basic trade interface first)
- Phase 1 Status: ✅ COMPLETE (Nov 2025)
- PortfolioManager class with YAML configuration
- Pre-trade risk assessment (TradeAssessment)
- Portfolio allocation display
- Integration with PositionSizer (#416)
- 17 unit tests
- Remaining Phases: Phase 2 (sector limits, correlation), Phase 3 (rebalancing)
- Why Critical: Multi-agent coordination needed for scale
- Blocker For: Full system deployment
- Components: Scanner, Risk, Executor, Orchestrator
- Target: Q1 2026
- Status: Placeholders exist
- Scope: Agent collaboration patterns (sequential, group chat, voting)
- Features: Multi-agent analysis, consensus building, dissenting opinions
- Why Important: Enables sophisticated multi-perspective analysis
- Depends On: #308, #310 (needs core agents implemented)
- Target: Q1-Q2 2026
- Status: Exploration phase, needs design discussion
- Scope: Centralized agent creation and pub-sub messaging infrastructure
- Delivered: AgentFactory singleton, AgentBus pub-sub, 16 EventTypes
- Features: Symbol filtering, TTL, correlation IDs, async wait_for_result()
- Supersedes: #316 (closed)
- Scope: Options contracts analysis (Greeks, IV, OI)
- Features: Call/put analysis, unusual activity detection, liquidity checks
- Why Useful: Expands trading beyond commons
- Depends On: #308 (commons version must work first)
- Target: Q1 2026
- Status: Data access validation needed (Alpaca options API)
- Why Important: Enhanced profit protection
- Integrates With: #308 (order lifecycle), #333 (risk management)
- Target: Q1 2026
- Scope: Expand beyond basic confirm/auto to conditional execution
- Features: Per-ticker whitelists, conditional auto-execute, risk-based autonomy
- Why Useful: Power users can delegate routine decisions
- Depends On: #308 (Levels 0 & 1 must work first)
- Target: Q2 2026
- Status: Design phase
- Why Useful: Statistical validation before live trading
- Depends On: #308 (needs human-in-loop CLI complete)
- Target: Q2 2026
- Why Useful: Cost reduction for LLM agents
- Depends On: LLM-based agents active (#331)
- Target: Q2 2026
- Scope: Break down complex functions in main.py
- Target Functions:
run_paper_trading_check()(26),main()(22) - Why Important: Improves testability and maintainability
- Status: Currently blocking commits without
--no-verify - Target: Q1 2026
- Scope: Ensure recent import changes didn't break functionality
- Coverage: Run full test suite with coverage metrics
- Why Important: Import pattern changes may have subtle effects
- Status: Test plan defined
- Target: December 2025
See Code Quality Guide for detailed tracking and standards.
- Fixed all import errors
- Validated Alpaca integration
- All 4 commands working
- Audited all scripts in scripts/ directory
- Fixed 2 research scripts with incorrect sys.path
- Updated pyproject.toml with minimal targeted exclusions
- Active utility scripts normalized, deprecated research preserved
- Commit: b486c03
- Files: config_usage_demo.py, generate_results_summary.py, pyproject.toml
- Assessed Phase 1 core trading logic (5 files)
- Found 85-90% type coverage already present
- Determined current coverage is production-ready
- Deferred further work until mypy is available
- Files: voter_agent.py, position_manager.py, account_manager.py, trailing_stop_manager.py, unified_price_fetcher.py
- Fixed 33 E501 line length violations across 5 files
- Ran Black/isort formatters for auto-fixes
- Manually split long f-strings and docstrings
- All changes purely stylistic - no functional modifications
- Commit: c0e9703
- Files: alpaca_execution_manager, timeframe_tools, alpaca_trading_client, alpaca_market_data, daily_scheduler
- Moved all inline imports to toplevel (C0415 resolved)
- Added try/except wrappers for optional dependencies
- Fixed import order across 10+ files
- Commits: c77f407, 77f3a8b, 21c8df5
- Files: main.py, alpaca_*, daily_scheduler, trading_pipeline, etc.
- MACD+RSI voting: 0.856 Sharpe (validated)
- LLM sentiment: ~60% accuracy (deprecated)
- Decision: VoterAgent uses pure calculations, no LLM
- System assists, humans decide
- Not autonomous AI trading
- Decision: Mandatory human approval for trades
- GTC orders reduce API calls 90%
- Broker-as-truth prevents state drift
- Decision: Batch operations, minimize API usage
- gpt-4o-mini for tool calling (cheap, fast)
- o3-mini for reasoning (better analysis)
- Decision: Available for future agents (not used by VoterAgent)
- Extensively tested in V0-V4 framework
- Performance inferior to pure math
- Decision: Deprecated, archived for reference
- 100+ API calls/day
- Expensive, rate-limited
- Decision: Proactive batching with GTC orders
- Diminishing returns beyond MACD+RSI
- Over-optimization risk
- Decision: Keep it simple, validated
# Clone and setup
git clone https://github.com/iAmGiG/AutoGen-TradingSystem.git
cd AutoGen-TradingSystem
conda create -n trading python=3.10
conda activate trading
pip install -e .
# Configure credentials in config/config.json
# Run test
python main.py test-voterImmediate Impact (Start Here):
- Human-in-loop CLI (#308) - Core feature missing
- RiskAgent implementation (#310) - Critical for safety
- Dynamic stops (#321) - Profit protection
Nice to Have (Later): 4. Event bus (#316) - Scalability 5. Forward testing (#324) - Validation 6. YAML optimization (#328) - Cost reduction
- Check this document for current priorities
- Review relevant GitHub issue
- Follow code conventions in
docs/03_reference/05_naming_conventions.md - Test in paper trading mode
- Submit PR with validation results
- Sharpe ratio > 0.7 (achieved 0.856)
- Win rate > 50% (achieved 51.4%)
- Max drawdown < 15% (achieved 10.10%)
- API efficiency > 80% reduction (achieved 90%)
- Core test coverage 80%+ (313 tests passing - #408 ✅ CLOSED)
- CLI functional (main.py working)
- Human-in-loop interface (in development)
- Real-time position tracking (complete)
- Interactive trade approval (planned)
- Paper trading validated (SPY bracket orders working)
- Broker reconciliation (operational)
- Live trading deployed (pending human-in-loop)
- Production monitoring (planned)
What We Tested:
- V0: Baseline MACD → 9.00% return
- V1: News sentiment → 9.61% return (marginal improvement)
- V2: VXX volatility → -3.53% return (contrarian failure)
- V3: Blended approach → 1.04% return (too conservative)
- V4: LLM reasoning → Variable (unreliable)
What We Learned:
- LLM sentiment adds complexity without consistent value
- Pure technical indicators (MACD+RSI) are more reliable
- Simple validated strategies > complex unproven ones
- Human oversight > autonomous AI trading
Current Approach:
- VoterAgent: Pure MACD+RSI → 0.856 Sharpe (proven)
- Human-in-loop: Humans make final decisions
- Cost-efficient: 90% fewer API calls
Issue #415 - Approved Ticker List with Entry Modes (✅ COMPLETE)
Branch: feature/development (merged)
Status: Implementation complete
Features Implemented:
- TickerDatabase with SQLite backend
- ApprovedTickersManager for ticker CRUD
- Entry modes: buy, buy_add, watch_only, disabled
- Per-ticker position limits
- Leveraged ETF metadata and lookups
- 18 unit tests
Files Added:
src/trading/ticker_database.py(SQLite backend)src/trading/approved_tickers.py(Manager class)tests/unit/trading/test_approved_tickers.py
Issue #416 - Position Sizing Automation Phase 1 (✅ COMPLETE)
Branch: feature/development (merged)
Status: Phase 1 complete
Features Implemented:
- PositionSizer class for profile-based sizing
- Conservative 5%, Moderate 10%, Aggressive 20% max positions
- Per-ticker limit integration (#415)
- Buying power validation
- Existing position awareness
- Risk calculation with stop prices
- 20 unit tests
Files Added:
src/trading/position_sizer.pytests/unit/trading/test_position_sizer.py
Remaining Phases: Phase 2 (risk-based sizing), Phase 3 (smart sizing)
Issue #333 - Portfolio Manager Agent Phase 1 (✅ COMPLETE)
Branch: feature/portfolio-manager-333
Status: Phase 1 complete, ready for merge
Features Implemented:
- PortfolioManager class with YAML configuration
- Pre-trade risk assessment (TradeAssessment)
- Portfolio allocation tracking and display
- Buying power and exposure validation
- Existing position warnings
- Position count limits
- Integration with PositionSizer (#416)
- 17 unit tests
Files Added:
src/trading/portfolio_manager.pyconfig_defaults/portfolio_config.yamltests/unit/trading/test_portfolio_manager.py
Remaining Phases: Phase 2 (sector limits, correlation), Phase 3 (rebalancing)
Issue #414 - Advanced Trailing Stop Automation (✅ IMPLEMENTATION COMPLETE)
Branch: feature/trailing-stops-414
Status: Ready for integration testing
Features Implemented:
- ClimbRate class with slow/medium/fast gain lock presets (20%-80% of gains)
- TrailingStopConfig extended with volatility-aware parameters
- ATR-based volatility adjustment (configurable multiplier)
- Profit-zone tracking (enters profit protection at threshold)
- Factory method:
TrailingStopManager.from_mode_manager() - Mode-specific config in trading_modes.yaml
Climb Rate Gain Locking:
- slow: 20%/40%/60% of gains
- medium: 25%/50%/75% of gains (default)
- fast: 33%/60%/80% of gains
Tests: 19 unit tests (all passing)
Next Steps:
- Integrate into trading cycle scheduler (#323)
- CLI command for trailing stop status (
show trailing stops) - Documentation of CLI usage
Infrastructure Discovery (Unblocks #248):
replace_stop_order()already exists insrc/trading/order_manager.py(lines 306-378)- Uses cancel-replace pattern (Alpaca's recommended approach)
- TrailingStopManager already integrates at line 288
- Partial exits (#248) can proceed using existing infrastructure
Issue #248 - Implement Partial Position Exits (✅ COMPLETE - MERGED)
Branch: feature/partial-exits-248 → Merged to feature/development
Status: Implementation complete, merged, and tested
Features Implemented:
- PartialExitManager class for multi-target position exits
- Default 50/50 split: Target 1 (limit order) + Target 2 (trailing stop)
- Per-mode configuration in trading_modes.yaml
- Integration with TrailingStopManager for Target 2 dynamic stops
- Comprehensive test coverage (21 tests, 90% coverage)
- Research: Partial Exit Strategies
Configuration by Trading Mode:
- Conservative: Target 1 at 4% profit
- Moderate: Target 1 at 5% profit
- Aggressive: Target 1 at 6% profit
Architecture:
ExitTargetdataclass for individual targetsPartialExitStatefor position tracking- Integration with
OrderManagerfor limit orders - Integration with
TrailingStopManager(#414) for trailing targets
Tests: 21 unit tests (all passing, 90% coverage)
Files Added:
src/trading/partial_exit_manager.py(143 lines)tests/unit/trading/test_partial_exit_manager.py(21 tests)
Files Modified:
config_defaults/trading_modes.yaml(partial_exits config)src/core/trading_modes.py(ModeParameters extended,get_partial_exit_config_dict())
Dependencies:
- Leverages #414 (Advanced Trailing Stops) for Target 2
- Uses #400 (Trading Modes) for per-mode configuration
- Built on
replace_stop_order()infrastructure from order_manager.py
Next Steps (Phase 2-4):
- Integration with trading_cycle.py
- CLI commands for manual position splitting (#424 - see below)
- Per-ticker overrides via profile hierarchy
Commit: 05d7355 → Merged 9f710cd
Issue #424 - Trailing Stop CLI Commands (✅ COMPLETE - MERGED)
Branch: feature/trailing-stop-cli-424 → Merged to feature/development
Status: Implementation complete, merged, and tested
Features Implemented:
- TrailingStopCommands class for CLI interface
show_trailing_stops()- Display all tracked positions with profit zonesshow_config()- Show trailing stop configuration settingsset_manual_stop()- Manual stop price override with validation
CLI Commands Available:
-
show trailing stops / trailing stops status
- Lists positions with entry, current price, stop, profit %, zone status
- Shows climb rate, volatility settings, adjustment counts
-
trailing-stop config / show stop settings
- Displays mode, climb rate, progressive thresholds
- Shows volatility-aware settings (ATR multiplier)
-
set trailing-stop SYMBOL PRICE
- Manual stop override with broker integration
- Validates stop price range, updates broker order
Tests: 21 unit tests + integration test examples
Files Added:
src/cli/trailing_stop_commands.py(290 lines)tests/unit/cli/test_trailing_stop_commands.py(21 tests)tests/integration/cli/test_trailing_stops_integration.py(integration examples)
Dependencies:
- #414 (Advanced Trailing Stop Automation) - backend complete
- #400 (Trading Modes) - configuration foundation
Next Steps:
- Register commands with CLI session natural language parser
- Add trailing stop status to morning/evening reports
Commit: 68b7de2 → Merged to feature/development
Design Decisions Established:
- Profile Hierarchy: Portfolio-level defaults → symbol-level overrides
- Autonomy Gradient: Entry (approved list) → Exit (human-approved system) → Stops (auto) → Sizing (auto)
- Killer Feature: Advanced trailing stops that protect profit once in profit zone
- LLM Boundary: GEX tools for price levels, not pure guessing
New Issues Created & Completed:
-
#415 - Approved Ticker List with Entry Modes (✅ COMPLETE)
- Three modes: buy, buy_add, watchOnly, disabled
- SQLite backend for persistence
- Per-ticker position limits
- Leveraged ETF metadata
-
#416 - Position Sizing Automation (✅ PHASE 1 COMPLETE)
- Profile-based sizing (conservative/moderate/aggressive)
- Max portfolio % limits, per-symbol overrides
- Integration with #415 for per-ticker limits
- Phase 2-3 pending (risk-based, smart sizing)
Unit Test Suite (branch: feature/development - merged):
- ✅ 313 unit tests across Priority 1-5 components
- ✅ TradingPipeline: 25 tests (5-phase workflow, error handling, metrics)
- ✅ AlpacaTradingClient: 42 tests (order lifecycle, bracket orders, position queries)
- ✅ ExecutorAgent: 58 tests (trade execution, signal processing, risk limits)
- ✅ PositionManager: 42 tests (broker reconciliation, state management, edge cases)
- ✅ AccountCommands CLI: 17 tests (multi-account listing, switching, agent data)
- ✅ TimeframeCommands CLI: 23 tests (timeframe validation, recommendations)
- ✅ TradingCacheManager: 45 tests (SQLite cache operations, TTL, expiration)
- ✅ Existing Tests: 61 tests (indicators, VoterAgent, simple signals)
- ✅ Test fixtures in conftest.py (MockPosition, MockOrder, MockAccount)
- ✅ Module-level mocking for config_defaults dependencies
Files Created:
tests/unit/trading/test_trading_pipeline.py(25 tests)tests/unit/trading/test_alpaca_trading_client.py(42 tests)tests/unit/trading/test_position_manager.py(42 tests)tests/unit/trading/test_executor_agent.py(58 tests)tests/unit/cli/test_account_commands.py(17 tests)tests/unit/cli/test_timeframe_commands.py(23 tests)tests/unit/data_sources/test_sqlite_cache.py(45 tests)tests/conftest.py(shared fixtures)
Run Tests:
python -m pytest tests/unit/ -v --no-covTradingPipeline Implementation (branch: feature/trading-pipeline-323):
- ✅ Complete 5-phase daily workflow orchestrator (#323)
- ✅ Phase 1: Data Collection - Market hours validation, data freshness
- ✅ Phase 2: Analysis - VoterAgent MACD+RSI signal generation
- ✅ Phase 3: Execution - ExecutorAgent order placement with position sizing
- ✅ Phase 4: Management - PositionManager tracking (broker-as-truth)
- ✅ Phase 5: End-of-Day - Broker reconciliation, report generation
- ✅ Scheduled runner with configurable times (morning/afternoon/custom)
- ✅ Comprehensive integration tests (352 lines)
- ✅ Full documentation (README_PIPELINE.md - 466 lines)
Trading Modes Configuration (branch: feature/trading-modes-400):
- ✅ Natural language risk modes (#400) - "buy SPY aggressively"
- ✅ Conservative/Moderate/Aggressive presets in YAML
- ✅ Integration with LLMParser for natural language extraction
- ✅ No CLI flags - everything through conversational interface
TrailingStopManager (branch: feature/trailing-stops-321):
- ✅ Progressive stop logic (#321) - 2%/4%/6% profit thresholds
- ✅ Integration with trade_lifecycle.py and trading_cycle.py
- ✅ Rate-limited updates to prevent API abuse
Agent Bus Infrastructure (branch: feature/agent-bus-390):
- ✅ AgentBus pub-sub messaging system (#390)
- ✅ 16 trading-specific EventType values
- ✅ Symbol filtering, TTL, correlation tracking
- ✅ Supersedes #316 and #397 (duplicates closed)
Files Created:
src/trading/trading_pipeline.py(608 lines) - Main orchestratorexamples/run_trading_pipeline.py(174 lines) - CLI demoexamples/scheduled_pipeline_runner.py(299 lines) - Scheduled automationsrc/trading/README_PIPELINE.md(466 lines) - Documentationconfig_defaults/trading_modes.yaml- Risk mode configurationsrc/core/trading_modes.py- TradingModeManager
Weekend Trading Enhancements (branch: feature/weekend-order-fix):
- ✅ Fixed off-hours bracket order validation failures
- ✅ Platform-aware emoji handling (Windows compatibility)
- ✅ Enhanced error detection using Alpaca API error codes (#377, #382)
- ✅ Extracted market hours configuration to YAML (#374, #379)
- ✅ Centralized user-facing messages to templates (#375, #380)
- ✅ Improved fallback handling for off-hours trading
Configuration Improvements:
- Created
market_hours.yamlwith NYSE 2025 holiday calendar - Created
cli_messages.yamlwith 50+ message templates - Integrated
MessageLoaderfor centralized message management - Platform-aware
safe_print()utility for cross-platform symbols
Code Quality:
- Error code-based validation (3-level detection: HTTP 422, Alpaca 4221xxxx, message patterns)
- Backward-compatible YAML configuration loading
- Message template system with fallback strings
- 4 commits, 6 issues resolved (#374, #375, #377, #379, #380, #382)
Documentation & Issue Organization:
- Consolidated 7 folders into 4 organized sections
- Added numerical sequencing (01-06 files)
- Created 5 new consolidated documents
- Removed "new" terminology throughout
- Enhanced research_papers.md with abstract and introduction
- Updated cross-references and navigation
GitHub Issue Cleanup:
- Closed 20 obsolete/completed issues (42 → 23 open)
- Created 4 new Phase 2 issues (#330, #331, #332, #333)
- Updated all key issues with dependency relationships
- Organized project board with priority/size/component fields
- Simplified #308 to focused MVP scope
- Fixed main.py CLI (all 4 commands working)
- Validated Alpaca integration (35/35 tests passing)
- Confirmed paper trading operational
- Validated VoterAgent performance
- VoterAgent production implementation
- Complete order management system
- Position tracking with broker reconciliation
- Cost-efficient trading cycle
- Comprehensive testing suite
#401 - Multi-Account Portfolio Management - ✅ COMPLETE:
- ✅ Account selection via
--accountCLI flag - ✅ Natural language commands: "list accounts", "switch to account X"
- ✅ Agent tools for AutoGen function calls
- ✅ API-first discovery (Alpaca API tells us account details)
- ✅ Automatic paper vs live detection from API response
- ✅ Legacy single-account config backward compatibility
- ✅ Simple config-based credentials (security hardening in #402)
- ✅ 19 unit tests (all passing)
- 📁 Files:
account_manager.py,account_commands.py,account_tools.py,accounts_config.py
Branch: feature/multi-account-401 - Ready for merge to feature/development
#323 - Trading Pipeline - ✅ COMPLETE:
- ✅ TradingPipeline 5-phase orchestrator
- ✅ VoterAgent integration for signal generation
- ✅ ExecutorAgent integration for order placement
- ✅ PositionManager broker-as-truth reconciliation
- ✅ Scheduled runner for automation
- ✅ Documentation and integration tests
Branch: feature/trading-pipeline-323 - Ready for merge
Next Priority - Complete Remaining Agent Implementations:
- ScannerAgent (#386) - Multi-ticker screening
- RiskAgent (#387) - Pre-execution validation, position limits
- Integrate TrailingStopManager into pipeline management phase
- Add RiskAgent validation to pipeline execution phase
Target: Q4 2025 completion → Unblocks full automated trading
#333 - Portfolio Manager Agent ✅ PHASE 1 COMPLETE:
- ✅ PortfolioManager class with YAML configuration
- ✅ Pre-trade risk assessment with warnings
- ✅ Portfolio allocation display
- ✅ Integration with PositionSizer (#416)
- Phase 2: Sector limits, correlation analysis
- Phase 3: Rebalancing, volatility-adjusted sizing
#390 - Agent Factory & Event Bus ✅ COMPLETE:
- ✅ AgentFactory singleton with creator registration
- ✅ AgentBus pub-sub with symbol filtering
- ✅ 42 unit tests passing
- ✅ Orchestrator refactored to use factory/bus
#321 - Dynamic Trailing Stops:
- Design stop adjustment algorithms
- Integrate with order lifecycle management
#310 - Complete Remaining Agents: ✅ ALL COMPLETE
- ✅ Implement ExecutorAgent (order coordination) - COMPLETE (#388)
- ✅ Implement RiskAgent (position sizing, stop-loss) - COMPLETE (#387)
- ✅ Implement ScannerAgent (opportunity identification) - COMPLETE (#386)
- ✅ Build TradingOrchestrator (workflow management) - COMPLETE (#389)
#330 - Options Analysis (after #308 commons stable):
- Validate Alpaca options data access
- Build options-specific analysis (Greeks, IV, OI)
- Extend CLI to accept options requests
#331 - Multi-Agent Coordination (after #310 complete):
- Design coordination pattern (sequential vs group chat vs voting)
- Implement agent debate/consensus system
- Test multi-agent workflow with paper trading
Live Trading Deployment (after #308 + #324 complete):
- Complete forward testing protocol (#324)
- Configure production credentials
- Set up monitoring dashboard
- Deploy with initial capital allocation
#332 - Autonomy Expansion (after #308 L0/L1 stable):
- Implement conditional auto-execute
- Add per-ticker whitelists
- Build rule-based autonomy system
This document tracks project status, roadmap, and development priorities. Updated monthly or after major milestones.
EPIC #436 - Code Quality Refactoring (✅ PHASE 1 COMPLETE)
Massive refactoring initiative to improve code organization, testability, and maintainability.
Issues Completed:
| Issue | Description | Reduction | PR |
|---|---|---|---|
| #437 | Extract validators from alpaca_trading_client.py | New modules | #448 |
| #438 | Split sqlite_cache.py by domain | 65% (1386→474 lines) | #448 |
| #440 | Extract scheduler_cli.py components | 69% (984→307 lines) | #449 |
| #441 | Extract validators from execution_manager | 20% (985→785 lines) | #450 |
| #442 | Extract state/reporter from orchestrator | 24% (958→728 lines) | #451 |
| #425 | In-house backtesting framework | New framework (~650 lines) | #452 |
New Modules Created:
-
Trading Validators (
src/trading/validators/):order_validator.py- Order validation with provider injectionenum_mappers.py- Centralized Alpaca enum mappingerror_handling.py- API error extraction and formattingresponse_parsers.py- Account/Order/Position response parsingbracket_validator.py- Bracket order error detection
-
Cache Domain Separation (
src/data_sources/cache/):base_cache.py- Base SQLite cache with shared logicohlcv_cache.py- Focused OHLCV market data cache
-
Scheduler CLI (
src/cli/scheduler/):message_loader.py- YAML message loadingdaemon_manager.py- Cross-platform daemon managementconfig_editor.py- Interactive config editingmonitor.py- Status/history/logs displaysetup_wizard.py- First-time setup flow
-
Trading Orchestrator (
src/autogen_agents/):workflow_state_manager.py- State persistence/recoveryworkflow_reporter.py- Report generation
-
Backtesting Framework (
src/backtesting/):backtest_engine.py- Main engine compatible with any signal generatorportfolio.py- Position/cash tracking with commission modeling Phase 1 Refactoring Complete - All 4 files refactored:
- ✅ #437 - alpaca_trading_client.py (validators extracted)
- ✅ #438 - sqlite_cache.py (65% reduction)
- ✅ #439 - trading_cycle.py (59% reduction, 4 components extracted)
- 🚧 #433 - cli_session.py (FunctionTool architecture, in progress)
Issue #439 Results (PR #454, merged Dec 2):
- trading_cycle.py: 1248 → 512 lines (59% reduction)
- Created 4 new components:
local_state_manager.py(140 lines) - JSON state persistencebroker_state_cache.py(278 lines) - TTL-based cachingstate_reconciler.py(475 lines) - State reconciliation logicreport_generator.py(251 lines) - Report formatting
- Maintained full backward compatibility via property accessors
Issue #433 Progress (cli_session.py - 3024 lines):
- Broken into 5 sequential sub-issues (#455-459)
- ✅ #455 - Tool infrastructure (Phase 1A complete, PR #463)
- ✅ #456 - Mode & timeframe tools (Phase 1B complete, PR #463)
- ✅ #457 - Display tools (Phase 1C complete, PR #464)
- Created
portfolio_tools.py(470 lines) - Portfolio/position display - Created
account_display_tools.py(177 lines) - Account management - 6 FunctionTools registered in PORTFOLIO_TOOLS and ACCOUNT_TOOLS categories
- Created
- ✅ #458 - Execution tools (Phase 1D complete, PR #465)
- Created
order_tools.py- Order management (5 tools) - Created
scheduler_tools.py- Scheduler status (4 tools) - Created
alert_tools.py- Position alerts (4 tools) - 13 FunctionTools registered in ORDER_TOOLS, SCHEDULER_TOOLS, and ALERT_TOOLS categories
- Refactored date_utils.py complexity issues
- Created
- ✅ #459 - Final integration (Phase 1E complete, PR #466)
- Integrated portfolio_tools.show_portfolio() into _handle_portfolio_request
- Integrated mode_tools functions into_handle_trading_mode_request
- Reduced cli_session.py from 3024 to 2879 lines (-145 lines)
- Pre-existing C901 complexity issues tracked in #436
CLI Folder Reorganization (Dec 2, 2025):
Reorganized src/cli/ folder into logical subdirectories for better maintainability:
src/cli/
├── commands/ # Natural language command handlers
│ ├── account_commands.py
│ ├── timeframe_commands.py
│ └── trailing_stop_commands.py
├── utils/ # CLI utility modules
│ ├── ticker_completer.py
│ ├── trading_tips.py
│ ├── help_system.py
│ └── decision_formatter.py
├── scheduler/ # Scheduler subsystem (existing)
├── tools/ # FunctionTool wrappers (existing)
├── scheduler_cli.py # Main scheduler interface
└── cli_session.py # Main CLI session (1916 lines, target <1500)
Changes Made:
- Created
commands/subdirectory for command handler modules - Created
utils/subdirectory for utility modules - Moved 7 files to appropriate subdirectories
- Updated all import paths across codebase
- Removed unused
example_tool.py - Updated test files with new import paths
api_error_translator.py- User-friendly error messages
Critical Bugs Fixed:
- Fixed
self.client.trading→self.client.trading_client(4 instances) - Removed duplicate
cancel_order()method bypassing safety checks
Remaining from EPIC #436:
- ✅ #433 - cli_session.py FunctionTool architecture (COMPLETE - PRs #463-466)
- #439 - trading_cycle.py extraction (deferred)
Issue #425 - Backtesting Framework (✅ COMPLETE)
- In-house framework refactored from validated experiment_293
- Validated: 0.856 Sharpe on AAPL 2024
- CLI integration ready
- Research paper structure (LaTeX) prepared
Issue #420 - TSMOM Research (🔜 NEXT - Assigned to B)
- TSMOMSignalGenerator implemented (12-month momentum)
- Ready for 2016-2024 validation experiments
- Research paper in progress
Issue #501 - Big Data GEX Calculation Pipeline (✅ COMPLETE - Dec 18, 2025)
- Vectorized pandas operations: 100-1000x speedup vs row-by-row
- SQLite WAL optimization: 5-10x faster bulk inserts
- Processed 50.88M options records -> 17,835 daily GEX metrics
- Execution time: ~10 minutes total, ~1,700 records/second
- Database: 34 symbols x 5+ years of daily GEX regimes
- Production-ready with multiprocessing parallelization
Issue #421 - TSMOM vs GEX Analysis (✅ COMPLETE - Dec 18, 2025)
- Analyzed 34 symbols across 5 asset classes
- TSMOM Sharpe in positive gamma: 1.282 average
- Key insight: 70% signal overlap, complementary indicators
- Best performers: TNA (3.78), FAS (3.48), LABU (3.08)
- Recommendation: Use GEX for position sizing, not signal filtering
Issue #496 - Cross-Asset Regime Correlation (✅ COMPLETE - Dec 18, 2025)
- Equity: 81.9% positive gamma (stable)
- Volatility: 32.8% positive gamma (inverted)
- Bonds: 85.2% positive gamma (hedging utility)
- UVXY leads SPY by 1 day (0.456 correlation)
- Strategic implications: Cross-asset rotation signals
Documentation Delivered:
- gex_pipeline_architecture.md (technical design, big data techniques)
- tsmom_vs_gex_analysis.md (comparative signal analysis)
- cross_asset_correlation.md (asset class regime relationships)
- COMPLETION_SUMMARY.md (project milestones and findings)
A Chat Stream - Execution Pipeline (branch: feature/core-execution)
Issue #366 - OHLCV-Based Intraday Entry Plan (COMPLETE)
- Created
src/trading/instruments/entry_planning.py - ATR-based stop-loss and take-profit calculation
- Support/resistance detection using recent price extremes
- Volume confirmation for entry quality scoring
- Integrated into
real_voter_strategy.pywith fallback to percentage-based stops - Commit:
3bf530c
Files Added:
src/trading/instruments/entry_planning.py(~200 lines)
Files Modified:
src/trading/instruments/__init__.py(exports)src/strategies/real_voter_strategy.py(integration)
Issue #372 - Multi-Level Price Targets (COMPLETE)
- Created
src/trading/orders/multi_level_targets.py MultiLevelTargetManagerclass for 1-5 price target managementDistributionStrategyenum: equal, progressive, inverse, custom- ATR-based target calculation using OHLCV data
- Order splitting capability for existing positions
- Integration with
PartialExitManagerandTrailingStopManager - Commit:
a3dbeac
Files Added:
src/trading/orders/multi_level_targets.py(~450 lines)
Files Modified:
src/trading/orders/__init__.py(exports)
Next: #414 KILLER Advanced Trailing Stop Automation
Large File Refactoring - COMPLETED:
| Issue | File | Before | After | Reduction | Status |
|---|---|---|---|---|---|
| #509 | cli_session.py | 1657 | 1018 | 38% | ✅ CLOSED |
| #510 | sqlite_cache.py | 1587 | 947 | 40% | ✅ CLOSED |
| #511 | alpaca_trading_client.py | 1568 | 1075 | 31% | ✅ CLOSED |
| #512 | scanner_agent.py | 969 | 813 | 16% | ✅ CLOSED |
| #513 | date_utils.py | 844 | - | - | OPEN |
| #514 | google_search_api.py | 914 | - | - | OPEN |
New Modules Created:
-
#509 - IntentClassifier (
src/cli/utils/intent_classifier.py)- Extracted
classify_intent()andresolve_ticker_with_llm()methods - LLM-based intent classification with pattern matching fallback
- Extracted
-
#510 - Cache Mixins (
src/cache/)options_cache.py-OptionsCacheMixin(329 lines)trade_cache.py-TradeCacheMixin(263 lines)
-
#511 - Advanced Orders (
src/trading/broker/advanced_orders.py)AdvancedOrdersMixinwith trailing stop, bracket, modify methods
-
#512 - Scanner Config (
src/autogen_agents/agents/scanner_config.py)- Config loaders, dataclasses (TierLimits, ScanConfig, ScanResult)
Commits:
4b40777- refactor(#509): extract IntentClassifier from cli_session.py094c920- refactor(#510): extract options and trade cache mixins76182fa- refactor(#511): extract advanced orders mixin7d54640- refactor(#512): extract scanner configuration
#521 - DRY Improvements & Code Quality Cleanup (✅ CLOSED):
| Task | Module Created | Description |
|---|---|---|
| Error sanitization | src/cli/utils/error_utils.py |
Shared sanitize_error_message() function |
| Platform UI utils | src/cli/utils/ui_utils.py |
get_error_prefix(), get_mode_indicator(), clear_screen() |
| Magic constant | RealVoterStrategy |
MIN_REQUIRED_CANDLES = 42 with MACD derivation comment |
- Removed 4 instances of
platform.system() == "Windows"checks - Fixed bug: Windows
clsrequiresshell=True(shell built-in) - Commits:
361d849,3134cdb
Other Large Files (700+ lines) for future consideration:
- trailing_stop_manager.py (812) - Single class, focused
- alpaca_execution_manager.py (784) - Has validators
- db_backup.py (780) - Single class, utility
- alerts_watchlists.py (738) - Could split
- trading_orchestrator.py (723) - Could split
- gtt_manager.py (712) - 4 classes
- voter_tools.py (709) - FunctionTool pattern, ok
Branch: feature/testing