Commit Graph

112 Commits

Author SHA1 Message Date
Andrew Kaszubski 13f2bba0b3 feat(portfolio): add Australian CGT Calculator with 50% discount - Issue #32 (66 tests)
Implements comprehensive Australian Capital Gains Tax calculator:
- CGT calculation with 50% discount for assets held >12 months
- FIFO (First In, First Out) cost basis matching
- Australian financial year support (July 1 - June 30)
- Capital loss tracking and carry-forward
- Tax year summary generation
- ATO-compliant tax report generation
- Foreign currency conversions
- Unrealised gains calculation

Classes:
- CGTMethod enum (discount, indexation, other)
- AssetType enum (shares, ETF, crypto, property, etc.)
- CGTAssetAcquisition dataclass (cost base parcel)
- CGTDisposal dataclass (sale record)
- CGTEvent dataclass (gain/loss event)
- TaxYearSummary dataclass (annual summary)
- AustralianCGTCalculator class (main calculator)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 21:53:27 +11:00
Andrew Kaszubski bedb59bce0 feat(portfolio): add Performance Metrics with Sharpe, drawdown, returns - Issue #31 (63 tests)
Implements comprehensive portfolio performance analytics:
- Returns calculation (daily, monthly, yearly, cumulative)
- Risk-adjusted metrics (Sharpe, Sortino, Calmar ratios)
- Volatility and downside deviation
- Drawdown analysis with period tracking
- Trade statistics (win rate, profit factor, expectancy)
- Benchmark comparison (alpha, beta, information ratio, tracking error)
- Utility functions (CAGR, rolling returns, period aggregation)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 21:44:15 +11:00
Andrew Kaszubski 6642047eaa feat(portfolio): add Portfolio State for holdings and mark-to-market - Issue #29 (68 tests)
Implements comprehensive portfolio state management:
- Holding dataclass with long/short support and P&L calculations
- CashBalance for multi-currency cash management
- PortfolioState class with:
  - Real-time mark-to-market valuation
  - Multi-currency support with exchange rate conversion
  - Thread-safe state updates
  - Position tracking with average cost calculation
  - Portfolio snapshots for historical tracking
- PriceProvider and ExchangeRateProvider protocols
- Serialization/deserialization support

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 21:37:17 +11:00
Andrew Kaszubski 9aee43312d feat(execution): add Risk Controls for pre-trade validation - Issue #28 (45 tests) 2025-12-26 21:29:14 +11:00
Andrew Kaszubski 6863e3ed87 feat(execution): add Order Manager for lifecycle management - Issue #27 (47 tests) 2025-12-26 21:24:54 +11:00
Andrew Kaszubski 834d18fb51 feat(execution): add Paper broker for simulation mode - Issue #26 (63 tests) 2025-12-26 21:19:25 +11:00
Andrew Kaszubski 1e32c0e965 feat(execution): add IBKR broker for futures and ASX equities - Issue #25 (38 tests) 2025-12-26 21:11:56 +11:00
Andrew Kaszubski 593d59937c feat(execution): add Alpaca broker for US stocks, ETFs, crypto - Issue #24 (37 tests) 2025-12-26 21:06:32 +11:00
Andrew Kaszubski 850346a47a feat(execution): add broker router for multi-broker asset class routing - Issue #23 (57 tests) 2025-12-26 20:58:40 +11:00
Andrew Kaszubski e4ef947c3b feat(execution): add abstract broker base interface - Fixes #22 2025-12-26 20:49:17 +11:00
Andrew Kaszubski 4f6f7c1c14 feat(memory): add memory integration for agent prompts - Fixes #21 2025-12-26 20:40:21 +11:00
Andrew Kaszubski 25c31d5f5d feat(memory): add risk profiles memory for user preferences - Fixes #20 2025-12-26 20:30:21 +11:00
Andrew Kaszubski dbfcea3740 feat(memory): add trade history memory with outcome tracking - Fixes #19 2025-12-26 20:22:03 +11:00
Andrew Kaszubski d72c214d4d feat(memory): add layered memory system with FinMem pattern - Fixes #18 2025-12-26 20:17:26 +11:00
Andrew Kaszubski 5a0606b59f feat(graph): integrate new analysts into workflow - Fixes #17 2025-12-26 20:11:28 +11:00
Andrew Kaszubski a17fc1f029 feat(agents): add Position Sizing Manager with Kelly and risk parity - Fixes #16
Implements Position Sizing Manager for optimal position sizing calculations.
The manager supports multiple sizing methodologies to accommodate different
trading styles and risk tolerances.

Sizing Methods:
- Kelly Criterion (full, half, quarter) for edge-based optimal sizing
- ATR-based sizing for volatility-adjusted position sizing
- Risk Parity allocation for balanced portfolio risk
- Volatility targeting for consistent risk contribution
- Fixed fractional for controlled percentage risk

Key Features:
- Multiple sizing method comparison for best fit selection
- Risk level presets (conservative, moderate, aggressive)
- Position constraints and drawdown limits
- Stop loss level recommendations based on ATR
- Win/loss ratio analysis for Kelly calculations

Tools:
- calculate_kelly_position_size: Edge-based optimal sizing
- calculate_atr_position_size: Volatility-adjusted position sizing
- calculate_risk_parity_allocation: Multi-asset balanced risk allocation
- calculate_volatility_target_size: Target volatility-based sizing
- get_position_sizing_recommendation: Comprehensive multi-method comparison

Enums:
- SizingMethod: 8 different sizing approaches
- RiskLevel: Conservative, moderate, aggressive presets

Tests: 52 unit tests covering Kelly calculations, ATR sizing, risk parity
weights, volatility targeting, constraints, and integration workflows.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 17:39:20 +11:00
Andrew Kaszubski b0140a82b3 feat(agents): add Correlation Analyst for cross-asset analysis - Fixes #15
Implements Correlation Analyst agent for cross-asset correlation analysis
and sector rotation detection. The agent analyzes inter-market relationships
to identify diversification opportunities and sector leadership changes.

Features:
- Cross-asset correlation analysis (stocks vs bonds, gold, oil, dollar)
- Sector rotation analysis across all 11 S&P 500 sectors
- Rolling correlation trend tracking with breakdown detection
- Relative strength calculation for sector leadership
- Economic cycle phase identification (early/mid/late cycle, recession)
- Cycle-based sector recommendations

Tools:
- get_cross_asset_correlation_analysis: Multi-asset correlation with regime interpretation
- get_sector_rotation_analysis: Sector rankings, leadership, rotation signals
- get_correlation_matrix: Pairwise correlation matrix for portfolio construction
- get_rolling_correlation_trend: Time-series correlation dynamics

Enums:
- CorrelationStrength: 9-level classification from very strong negative to very strong positive
- SectorPhase: Economic cycle phases for rotation timing
- SectorLeadership: Leading, lagging, improving, weakening classifications

Tests: 59 unit tests covering correlation calculations, classification logic,
sector rotation, breakdown detection, and integration scenarios.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 17:30:53 +11:00
Andrew Kaszubski bdff87a571 feat(agents): add Macro Analyst with FRED interpretation - Fixes #14
Implements Macro Analyst agent for economic regime detection and FRED data
interpretation. The agent analyzes macroeconomic indicators to identify
market regimes and provide investment implications.

Features:
- Economic regime detection (expansion, contraction, goldilocks, stagflation)
- Yield curve analysis (normal, inverted, flat, steep)
- Monetary policy stance classification (hawkish, dovish, neutral, emergency)
- Inflation regime tracking (deflation, low, target, elevated, high)
- Recession probability calculation based on yield curve inversions
- Real rate analysis for policy restrictiveness

Tools:
- get_economic_regime_analysis: GDP, unemployment, inflation regime detection
- get_yield_curve_analysis: 2Y-10Y spread analysis with recession probability
- get_monetary_policy_analysis: Fed policy stance interpretation
- get_inflation_regime_analysis: CPI/PCE trajectory and asset implications

Tests: 57 unit tests covering all classification logic, edge cases, and
integration scenarios.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 17:23:30 +11:00
Andrew Kaszubski 8522b4bd53 feat(agents): add Momentum Analyst with multi-TF analysis - Fixes #13
Implements specialized Momentum Analyst agent with:
- Multi-timeframe ROC (Rate of Change) analysis across periods
- ADX (Average Directional Index) trend strength measurement
- RSI momentum divergence detection for reversal signals
- create_momentum_analyst factory for LangChain integration

Tests: 47 unit tests covering ROC, ADX, RSI, divergence detection

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 17:12:01 +11:00
Andrew Kaszubski ae7899a6fc feat(dataflows): add data caching layer with rate limit awareness - Fixes #12
Implements [DATA-11] Data caching layer - FRED rate limits with:
- CacheEntry: Generic cache entries with TTL and metadata
- CacheStats: Hit/miss/stale statistics tracking
- RateLimitState: Per-source rate limit tracking with exponential backoff
- MemoryCache: In-memory LRU cache backend
- FileCache: File-based JSON cache backend
- DataCache: Main cache with source-specific TTLs and stale-while-rate-limited
- @cached decorator: Function result caching

Features:
- Multi-backend support (memory, file)
- TTL-based expiration with configurable per-source defaults
- Stale-while-revalidate when rate limited
- Thread-safe operations throughout
- 41 tests covering all components

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 16:51:48 +11:00
Andrew Kaszubski 2c802647e4 feat(dataflows): add vendor registry pattern for extensible data vendor routing - Fixes #11
Implements [DATA-10] Interface routing - add new data vendors with:
- VendorRegistry: Thread-safe singleton for centralized vendor registration
- VendorCapability enum: STOCK_DATA, FUNDAMENTALS, NEWS, MACROECONOMIC, etc.
- BaseVendor ABC: 3-stage lifecycle (transform_query, extract_data, transform_data)
- SimpleVendor: Wrapper for migrating existing vendor functions
- Decorators: @register_vendor, @vendor_method, @rate_limited, @with_retry, @cache_result
- RateLimiter: Thread-safe sliding window rate limiting
- 84 tests covering registry, base vendor, and decorators

Files:
- tradingagents/dataflows/vendor_registry.py (253 lines)
- tradingagents/dataflows/base_vendor.py (222 lines)
- tradingagents/dataflows/vendor_decorators.py (188 lines)
- tests/unit/dataflows/test_vendor_registry.py (30 tests)
- tests/unit/dataflows/test_base_vendor.py (27 tests)
- tests/unit/dataflows/test_vendor_decorators.py (27 tests)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 16:47:41 +11:00
Andrew Kaszubski bbd85c91b6 feat(dataflows): add benchmark data module with SPY, sector ETFs, RS, correlation, beta - Fixes #10 2025-12-26 16:14:57 +11:00
Andrew Kaszubski 19171a4b31 feat(dataflows): add multi-timeframe OHLCV aggregation - Fixes #9 2025-12-26 15:48:40 +11:00
Andrew Kaszubski 4d693fb331 feat(dataflows): add FRED API integration for economic data - Fixes #8 2025-12-26 15:25:54 +11:00
Andrew Kaszubski 68be12c451 feat(db): fix Alembic migrations and add documentation (#7) - SQLite batch mode for constraints, migrations README 2025-12-26 14:50:09 +11:00
Andrew Kaszubski 1ea006e41f feat(db): add Trade model with CGT tracking and Australian FY support (#6) - TradeSide/TradeStatus/TradeOrderType enums, 50% discount for >12mo holdings, multi-currency FX, 87 tests 2025-12-26 14:46:06 +11:00
Andrew Kaszubski 1c6c2fadf1 feat(db): add Settings model with risk profiles and alert preferences (#5) - Implements RiskProfile enum, risk parameters, JSON alert_preferences, one-to-one User relationship, CheckConstraints, cascade delete, 43 tests 2025-12-26 14:16:42 +11:00
Andrew Kaszubski 0d09f15bd6 feat(db): add Portfolio model with LIVE/PAPER/BACKTEST types - Fixes #4 2025-12-26 13:46:39 +11:00
Andrew Kaszubski d3892b0da9 feat(db): add User model fields for tax, timezone, API key - Fixes #3 2025-12-26 13:15:37 +11:00
Andrew Kaszubski 9933a929df feat(api): add FastAPI backend with JWT auth and strategies endpoint (#48)
- Add FastAPI application with async/await support (tradingagents/api/)
- Implement JWT authentication with Argon2 password hashing (PyJWT, pwdlib)
- Create /api/v1/auth/login endpoint for user authentication
- Create /api/v1/strategies CRUD endpoints (list, create, get, update, delete)
- Add SQLAlchemy 2.0 async models (User, Strategy) with PostgreSQL/SQLite
- Add Alembic migrations for database schema management
- Add comprehensive test suite (208 tests in tests/api/)
- Add Pydantic schemas for request/response validation
- Add CORS and error handling middleware
- Update documentation (CHANGELOG.md, README.md)

Security: Argon2 password hashing, JWT expiration, user isolation,
SQL injection prevention via SQLAlchemy ORM, no hardcoded secrets

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 11:50:03 +11:00
Andrew Kaszubski e5575250df feat(tests): add UAT and evaluation tests for agent outputs - Fixes #53
- Created tradingagents/utils/output_validator.py with ValidationResult dataclass

- Added validate_report_completeness(), validate_decision_quality() for content validation

- Added validate_debate_state(), validate_agent_state() for state coherence

- Created tests/unit/test_output_validators.py with 54 unit tests

- Created tests/e2e/test_uat_agent_outputs.py with 23 UAT scenarios

- Added agent state fixtures to tests/conftest.py (sample_agent_state, debates)

- Total: 77 tests covering report quality, signal extraction, and state integrity

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 11:38:37 +11:00
Andrew Kaszubski b4653ca37b feat(tests): add test fixtures directory with mock data - Fixes #51
- Created tests/fixtures/ with FixtureLoader class (14 loader methods)

- Added stock_data fixtures: US, CN (with Chinese columns), standardized OHLCV

- Added metadata fixtures: 5 analysis examples with datetime parsing

- Added report_sections fixtures: 7 complete analyst report sections

- Added api_responses fixtures: OpenAI embeddings and error responses

- Added configurations fixtures: vendor and LLM provider configs

- Created comprehensive README.md (595 lines) documenting fixture usage

- Updated docs/testing/writing-tests.md with fixture examples

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 11:23:29 +11:00
Andrew Kaszubski edae1ab2cc feat(llm): add DeepSeek provider and HuggingFace embedding fallback (Issue #41) 2025-12-26 11:07:48 +11:00
Andrew Kaszubski 5ea9e905c5 feat(tests): restructure tests into unit/integration/e2e directories - Fixes #50
- Moved 5 unit tests to tests/unit/ (exceptions, logging, report, docs, conftest)

- Moved 4 integration tests to tests/integration/ (openrouter, akshare, cli, deepseek)

- Created tests/e2e/ directory with README.md and conftest.py placeholder

- Added pytestmark = pytest.mark.unit/integration to all test files

- Updated pytest.ini with testpaths for new structure

- Updated docs/testing/README.md with new directory structure

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 11:04:20 +11:00
Andrew Kaszubski d6b9df162e feat(dataflows): add AKShare data vendor for US and Chinese stock data (Issue #16) 2025-12-26 10:42:15 +11:00
Andrew Kaszubski 36de8f0470 feat(tests): add pytest conftest.py hierarchy with shared fixtures - Fixes #49
- Created tests/conftest.py with 12 shared fixtures (environment mocks, LangChain/ChromaDB mocking, configuration)

- Created tests/unit/conftest.py with 6 unit-specific fixtures (data vendors, sample data)

- Created tests/integration/conftest.py with 2 integration fixtures (live ChromaDB, temp dirs)

- Added pytest.ini with 7 custom markers (unit, integration, e2e, llm, chromadb, slow, requires_api_key)

- Added tests/test_conftest_hierarchy.py with 83 tests validating fixture infrastructure

- Updated docs/testing/README.md and writing-tests.md with fixture usage documentation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 10:40:30 +11:00
Andrew Kaszubski c0dfb21c00 feat(docs): add comprehensive documentation structure - Fixes #52
- Add docs/ directory with 17 documentation files

- Architecture: multi-agent-system, data-flow, llm-integration

- API Reference: trading-graph, agents, dataflows

- Guides: adding-new-analyst, adding-llm-provider, adding-data-vendor, configuration

- Testing: README, running-tests, writing-tests

- Development: setup, contributing

- Update PROJECT.md with TESTING STRATEGY requirements

- Add test_documentation_structure.py for validation

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 10:18:50 +11:00
Andrew Kaszubski 436f6cc092 feat(reports): add report exporter with YAML frontmatter and JSON metadata (Issue #21) 2025-12-26 10:11:42 +11:00
Andrew Kaszubski bb0ea33100 feat(logging): add dual-output logging and rate limit error handling - Fixes #39 2025-12-26 09:54:07 +11:00
Andrew Kaszubski d8093aa889 chore: improve .env gitignore pattern and remove .env.example
- Update .gitignore to use .env* wildcard pattern

- Covers all variants: .env.local, .env.backup, .env.production, etc.

- Remove .env.example to prevent accidental secret exposure

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 09:30:08 +11:00
Andrew Kaszubski 9ee81be48b fix(memory): use get_or_create_collection for idempotent ChromaDB init - Fixes #30 2025-12-26 09:20:04 +11:00
Andrew Kaszubski 164cb0d2fc fix(tests): add mock_env_openrouter fixture to all OpenRouter tests
- Add mock_env_openrouter to tests that use openrouter_config
- Update API key validation tests to expect ValueError when OPENROUTER_API_KEY missing
- All 30 tests now pass

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 16:02:04 +11:00
Andrew Kaszubski 5443aaa209 feat(llm): add OpenRouter API support with proper headers and API key handling
- Add explicit OPENROUTER_API_KEY environment variable handling
- Add HTTP-Referer and X-Title headers for OpenRouter attribution
- Fix case sensitivity for provider names (ollama now case-insensitive)
- Add embedding fallback to OpenAI when using OpenRouter (since OpenRouter lacks embedding API)
- Add comprehensive test suite (30 tests) for OpenRouter integration
- Update README.md and PROJECT.md with OpenRouter configuration docs
- Add CHANGELOG.md documenting the changes

Patterns borrowed from ~/.claude/lib/genai_validate.py for multi-provider support.

Closes #1

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 15:51:25 +11:00
Andrew Kaszubski 0bd3741e8a feat: Add Anthropic LLM support and fix data vendor compatibility
- Switch to Anthropic Claude as LLM provider in main.py

- Add get_google_global_news() wrapper for proper signature matching

- Add get_fundamentals() to yfinance vendor

- Register yfinance and google as vendors for fundamentals and global news

- Make memory system fail gracefully when OpenAI embeddings unavailable
2025-12-25 15:23:28 +11:00
Edward Sun 13b826a31d
Merge pull request #245 from TauricResearch/feat/tooloptim
Y Finance Tools Optimizations
2025-10-09 00:34:10 -07:00
Edward Sun b2ef960da7 updated readme 2025-10-09 00:32:04 -07:00
Edward Sun a5dcc7da45 update readme 2025-10-06 20:33:12 -07:00
Edward Sun 7bb2941b07 optimized yfin fetching to be much faster 2025-10-06 19:58:01 -07:00
Yijia Xiao 32be17c606
Merge pull request #235 from luohy15/data_vendor
Add Alpha Vantage API Integration and Refactor Data Provider Architecture
2025-10-05 16:01:30 -07:00
Edward Sun c07dcf026b added fallbacks for tools 2025-10-03 22:40:09 -07:00