Commit Graph

88 Commits

Author SHA1 Message Date
Bu5hm4nn
99c7911b78 test: add e2e test for actual backtest scenario execution
- Add test_backtest_scenario_runs_and_displays_results that:
  - Creates workspace and navigates to backtests page
  - Selects Synthetic data source (uses deterministic fixture data)
  - Fills fixture-supported dates (2024-01-02 to 2024-01-08)
  - Fills scenario parameters (units, loan, LTV)
  - Runs backtest and verifies results display
  - Checks for Start value, End value, Daily Results table
  - Verifies no runtime errors

- Fix existing backtests page tests to create workspace first:
  - test_backtest_page_loads_with_valid_databento_dates
  - test_backtest_page_handles_invalid_dates_gracefully
  - Backtests page requires workspace_id in URL

- Add TODO comment about date_range_hint not updating for Databento
  on initial render (separate bug to fix)
2026-04-03 14:10:37 +02:00
Bu5hm4nn
dbd6e103c0 fix: pin black to 26.3.1 across all environments
- Pin black version in requirements-dev.txt (was >=24.0.0)
- Update pre-commit to use black 26.3.1 with Python 3.12
- Add language_version: python3.12 to pre-commit black hook
- Reformat files with new black version for consistency
2026-04-01 13:58:49 +02:00
Bu5hm4nn
6bcf78e5df style: format UI files and remove lint excludes
- Remove app/components/ and app/pages/ from ruff/black excludes
- Pre-commit reformatted multi-line strings for consistency
- All files now follow the same code style
2026-04-01 13:55:55 +02:00
Bu5hm4nn
66d6eb3df2 style: format test file with black 2026-03-31 23:55:16 +02:00
Bu5hm4nn
c203dd9a83 fix(test): remove unused variable in e2e test 2026-03-31 23:40:12 +02:00
Bu5hm4nn
aa22766ae3 test(e2e): add backtest page regression tests for CORE-003
- test_backtest_page_loads_with_valid_databento_dates: Verifies page loads with valid default dates
- test_backtest_page_handles_invalid_dates_gracefully: Ensures validation errors instead of 500

These tests catch regressions where:
- Default dates are before dataset availability
- Databento API errors cause 500 instead of validation
- Date validation is missing or broken
2026-03-30 17:52:09 +02:00
Bu5hm4nn
2d1ecc2fcf fix(backtest): ensure data_source is passed through all validation calls
- Pass data_source to derive_entry_spot in backtests.py
- Remove default 'synthetic' value for data_source in derive_entry_spot and validate_preview_inputs
- Update all tests to explicitly pass data_source parameter
- Improve error message with helpful suggestion for Databento/Yahoo Finance
2026-03-30 09:21:49 +02:00
Bu5hm4nn
eaaf78cd12 fix(backtest): improve error message for dates outside fixture window
- Add helpful message suggesting Databento/Yahoo Finance for dates outside fixture range
- Update test to expect BOUNDED policy for backtest UI
2026-03-30 09:11:56 +02:00
Bu5hm4nn
70b09cbf0b fix(backtest): remove BT-001A exact window restriction now that full data access is available
- Change WindowPolicy from EXACT to BOUNDED for backtest fixture
- Pass data_source to run_read_only_scenario so real data can be used
- Fix injected provider identity preservation in BacktestPageService
- Add type: ignore for BacktestHistoricalProvider protocol assignment
- Revert TypedDict change to avoid cascading type issues in pages/
- Update tests to reflect new BOUNDED policy behavior
2026-03-30 08:57:15 +02:00
Bu5hm4nn
8e1aa4ad26 fix(lint): remove unused imports and reformat with black 2026-03-30 08:42:07 +02:00
Bu5hm4nn
1ad369727d chore: change local development port from 8000 to 8100
- Update docker-compose.yml to map host port 8100 -> container 8000
- Update all Playwright test BASE_URL to port 8100
- Update .env.example with documentation about port mapping
- This avoids conflicts with other services on port 8000
2026-03-29 20:36:17 +02:00
Bu5hm4nn
70e14e2a98 fix(e2e): update Playwright test for dynamic dates and UI changes
- Update 'Scenario Form' to 'Scenario Configuration' (correct label)
- Update Event Comparison test to use 'Initial portfolio value' instead of 'Underlying units'
- Make backtests test more flexible for dynamic default dates
- Increase timeout and retry count for second workspace settings check
- Update workspace-related assertions to be more lenient
2026-03-29 19:47:58 +02:00
Bu5hm4nn
269745cd3e fix: address PR review feedback for validation functions
1. Fix Friday logic edge case comment
   - Clarified get_default_backtest_dates() docstring
   - Removed confusing 'at least a week old' comment
   - Explicitly documented Friday behavior

2. Reorder validation checks in validate_date_range_for_symbol()
   - Now checks start > end first (most fundamental)
   - Then checks end > today (future dates)
   - Finally checks symbol-specific bounds
   - Users get most actionable error first

3. Add server-side numeric bounds validation
   - New validate_numeric_inputs() function
   - Validates units > 0, loan >= 0, 0 < LTV < 1
   - Called in run_backtest() before service call

4. Add boundary tests
   - Test start_date exactly at SYMBOL_MIN_DATES boundary
   - Test same-day date range (start == end)
   - Test end_date exactly today
   - Test end_date tomorrow (future)
   - Test validation order returns most actionable error
   - Test near-zero and large values for units calculation
   - Test LTV at boundaries (0, 1, 0.01, 0.99)

5. Add tests for validate_numeric_inputs
   - Valid inputs, zero/negative values
   - LTV boundary conditions
2026-03-29 19:29:46 +02:00
Bu5hm4nn
f9ea7f0b67 fix: address PR review issues for event comparison and backtests
Critical fixes:
- Add validate_and_calculate_units() helper with proper error handling
- Handle division by zero for entry_spot in refresh_preview() and render_report()
- Add server-side validation for initial_value > 0
- Add try/except for derive_entry_spot() to handle fixture source limitations

Important improvements:
- Add dynamic default dates with get_default_backtest_dates()
- Add validate_date_range_for_symbol() for symbol-specific date bounds
- Add SYMBOL_MIN_DATES validation for backtests
- Update date_range_hint based on selected symbol

Tests:
- Add test_page_validation.py with 21 tests for:
  - validate_and_calculate_units edge cases
  - validate_date_range_for_symbol bounds checking
  - get_default_backtest_dates dynamic generation
  - SYMBOL_MIN_DATES constant verification
2026-03-29 18:45:29 +02:00
Bu5hm4nn
7f347fa2a6 fix(tests): fix BacktestSettingsRepository.load() and workspace seeding tests
- BacktestSettingsRepository.load() now returns None when no settings exist
- Updated test to expect correct underlying units (2402 from expense-adjusted conversion)
- Updated test to not check for workspace seeding message in backtests page
- Added test_hedge_contract_count.py and test_backtest_settings.py to CI test suite
- Build job now depends on lint and test passing
2026-03-29 15:34:49 +02:00
Bu5hm4nn
2e2a832b31 fix(tests): use GLD launch date in decay test
Use date(2004, 11, 18) instead of date(2004, 1, 1) since GLD didn't
exist before November 18, 2004. The validation now correctly raises
ValueError for pre-launch dates.
2026-03-29 14:47:36 +02:00
Bu5hm4nn
dc4ee1f261 feat(CONV-001): add GLD launch date validation, feat(DATA-DB-003): add cache CLI
CONV-001:
- Add GLD_LAUNCH_DATE constant (November 18, 2004)
- Validate reference_date in gld_ounces_per_share()
- Raise ValueError for dates before GLD launch
- Update docstring with valid date range
- Add comprehensive test coverage for edge cases

DATA-DB-003:
- Create scripts/cache_cli.py with three commands:
  - vault-dash cache stats: Show cache statistics
  - vault-dash cache list: List cached entries
  - vault-dash cache clear: Clear all cache files
- Add Makefile targets: cache-stats, cache-list, cache-clear
- Integrate with DatabentoHistoricalPriceSource methods
2026-03-29 12:00:30 +02:00
Bu5hm4nn
9a3b835c95 feat(DATA-DB-004): add Databento settings UI and independent scenario config
- Updated backtests page with Data Source card
  - Data source selector (databento/yfinance/synthetic)
  - Dataset dropdown (XNAS.BASIC, GLBX.MDP3)
  - Resolution dropdown (ohlcv-1d, ohlcv-1h)
  - Cost estimate display (placeholder for now)

- Added Scenario Configuration card
  - Underlying symbol selector (GLD/GC/XAU)
  - Start/end date inputs
  - Start price input (0 = auto-derive)
  - Underlying units, loan amount, margin call LTV

- BacktestPageService updates:
  - get_historical_prices() with data_source parameter
  - get_cost_estimate() for Databento cost estimation
  - get_cache_stats() for cache status display
  - Support for injected custom provider identity
  - DataSourceInfo for provider metadata

- BacktestSettingsRepository integration:
  - Load/save settings per workspace
  - Default values from BacktestSettings.create_default()

- Test update: TLT validation message changed to reflect
  new multi-symbol support (GLD, GC, XAU)
2026-03-29 11:12:11 +02:00
Bu5hm4nn
43067bb275 feat(DATA-DB-002): add BacktestSettings model and repository
- BacktestSettings dataclass with all configuration fields
- BacktestSettingsRepository for persistence per workspace
- Settings independent of portfolio configuration
- Full validation for dates, symbols, LTV, etc.
- 16 comprehensive tests

Fields:
- settings_id, name: identification
- data_source: databento|yfinance|synthetic
- dataset, schema: Databento configuration
- start_date, end_date: date range
- underlying_symbol, start_price, underlying_units: position config
- loan_amount, margin_call_ltv: LTV analysis
- template_slugs: strategies to test
- cache_key, data_cost_usd: caching metadata
- provider_ref: provider configuration
2026-03-29 10:46:25 +02:00
Bu5hm4nn
bf13ab5b46 feat(DATA-DB-001): add Databento historical price source for backtesting
- Add DatabentoHistoricalPriceSource implementing HistoricalPriceSource protocol
- Smart caching with Parquet storage and metadata tracking
- Auto symbol-to-dataset resolution (GLD→XNAS.BASIC, GC=F→GLBX.MDP3)
- Cache management with age threshold invalidation
- Cost estimation via metadata.get_cost()
- Add databento>=0.30.0 to requirements.txt
- Add DATABENTO_API_KEY to .env.example
- Full test coverage with 16 tests
2026-03-29 09:58:02 +02:00
Bu5hm4nn
bb06fa7e80 feat(PORTFOLIO-003): add premium and spread for physical gold positions 2026-03-28 23:53:46 +01:00
Bu5hm4nn
0e972e9dd6 feat(PORTFOLIO-002): add position storage costs 2026-03-28 23:48:41 +01:00
Bu5hm4nn
dac0463d55 feat(DISPLAY-002): GLD mode shows real share prices 2026-03-28 21:45:00 +01:00
Bu5hm4nn
1a39956757 feat(PORTFOLIO-001): add position-level portfolio entries 2026-03-28 21:29:30 +01:00
Bu5hm4nn
3b98ebae69 feat(DATA-004): add underlying instrument selector 2026-03-28 16:40:18 +01:00
Bu5hm4nn
3bf3774191 Merge branch 'feature/PRICING-002-basis-display' 2026-03-28 09:18:29 +01:00
Bu5hm4nn
9d06313480 feat(PRICING-002): add GLD/GC=F basis display on overview 2026-03-28 09:18:26 +01:00
Bu5hm4nn
966cee7963 feat(PRICING-003): use true GLD backing for hedge contract count 2026-03-28 09:18:26 +01:00
Bu5hm4nn
894d88f72f feat(PRICING-001): add GLD expense ratio decay correction 2026-03-28 09:04:35 +01:00
Bu5hm4nn
4620234967 feat(EXEC-001): add hedge strategy builder 2026-03-27 22:33:20 +01:00
Bu5hm4nn
554a41a060 refactor(BT-001C): share historical fixture provider 2026-03-27 21:41:50 +01:00
Bu5hm4nn
477514f838 feat(BT-002): add historical snapshot provider 2026-03-27 18:31:28 +01:00
Bu5hm4nn
1a6760bee3 feat(PORT-003): add historical ltv charts 2026-03-27 16:39:33 +01:00
Bu5hm4nn
3c9ff201e1 feat(BT-003B): add event comparison drilldown 2026-03-26 22:05:31 +01:00
Bu5hm4nn
bdf56ecebe fix(CORE-001D): close boundary review gaps 2026-03-26 17:34:09 +01:00
Bu5hm4nn
94f3c1ef83 feat(CORE-001D): close remaining boundary cleanup slices 2026-03-26 17:27:44 +01:00
Bu5hm4nn
99d22302ee fix(CORE-001D3B): validate alert history entry types 2026-03-26 15:19:42 +01:00
Bu5hm4nn
65da5b8f1d fix(CORE-001D3B): reject malformed alert history entries 2026-03-26 15:16:21 +01:00
Bu5hm4nn
ff76e326b1 feat(CORE-001D3B): surface alert history degraded state 2026-03-26 15:12:04 +01:00
Bu5hm4nn
38d244356c refactor(settings): separate preview validation from internal failures 2026-03-26 15:00:53 +01:00
Bu5hm4nn
e860c40567 fix(settings): reject fractional refresh intervals 2026-03-26 14:05:49 +01:00
Bu5hm4nn
2759d9a36f fix(settings): track dirty state across all inputs 2026-03-26 13:59:56 +01:00
Bu5hm4nn
cfa3cfcc08 fix(settings): clarify last-saved status state 2026-03-26 13:54:56 +01:00
Bu5hm4nn
f7c134a709 fix(settings): preserve whole-dollar loan formatting 2026-03-26 13:34:34 +01:00
Bu5hm4nn
ea3b384103 fix(settings): fail closed on blank loan input 2026-03-26 13:28:30 +01:00
Bu5hm4nn
753e9d3146 fix(CORE-001D3A): accept decimal boundary inputs 2026-03-26 13:19:18 +01:00
Bu5hm4nn
bb557009c7 feat(CORE-001D3A): normalize alerts and settings service boundaries 2026-03-26 13:10:30 +01:00
Bu5hm4nn
91f67cd414 fix(pre-alpha): preserve injected provider identity 2026-03-26 12:32:52 +01:00
Bu5hm4nn
52d943e614 fix(pre-alpha): preserve injected template services 2026-03-26 12:26:38 +01:00
Bu5hm4nn
d7117bb6a3 fix(pre-alpha): preserve injected backtest services 2026-03-26 12:18:39 +01:00