269745cd3e3b4323783c33fc2ca038bfa120d659
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
Vault Dashboard
A real-time options hedging dashboard for Lombard loan protection strategies.
Features
- Live Options Data: Integration with Interactive Brokers and free data sources
- Hedge Calculations: Black-Scholes pricing, Greeks, strategy comparisons
- Interactive Charts: TradingView-quality visualizations with Lightweight Charts
- Strategy Analysis: Protective puts, collars, laddered positions
- Real-time Updates: WebSocket-based live data streaming
Quick Start
Local Development
# Create virtual environment
python3 -m venv .venv
source .venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Run development server
python -m uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
Docker
# Build
docker build -t vault-dash .
# Run
docker run -p 8000:8000 vault-dash
Docker Compose
docker-compose up -d
Turnstile configuration
Workspace creation on the public welcome page is protected by Cloudflare Turnstile.
Local and test environments may use Cloudflare's published test keys:
TURNSTILE_SITE_KEY=1x00000000000000000000AA
TURNSTILE_SECRET_KEY=1x0000000000000000000000000000000AA
Negative-path testing can use the always-fail/blocked test keys:
TURNSTILE_SITE_KEY=2x00000000000000000000AB
TURNSTILE_SECRET_KEY=2x0000000000000000000000000000000AA
Production must provide real keys via environment variables:
TURNSTILE_SITE_KEY=...
TURNSTILE_SECRET_KEY=...
In Forgejo deployment:
vars.TURNSTILE_SITE_KEYprovides the public site keysecrets.TURNSTILE_SECRET_KEYprovides the server-side secret key
Browser tests run with APP_ENV=test and the Turnstile test keys.
Architecture
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ IBKR │────▶│ FastAPI │────▶│ Redis │
│ Gateway │ │ Backend │ │ (cache) │
└─────────────┘ └─────────────┘ └─────────────┘
│
▼
┌─────────────────────────────┐
│ NiceGUI Dashboard │
│ (WebSocket client) │
└─────────────────────────────┘
Configuration
Copy config/settings.example.yaml to config/settings.yaml and configure:
# Broker settings
broker:
type: ibkr # or alpaca, yfinance
# IBKR settings
ibkr:
host: 127.0.0.1
port: 7497 # TWS: 7497, Gateway: 4001
client_id: 1
# Portfolio defaults
portfolio:
gold_value: 1000000
loan_amount: 600000
ltv_ratio: 0.60
margin_call_threshold: 0.75
# Data sources
data:
primary: yfinance # or ibkr, alpaca
cache_ttl: 300
Deployment
See DEPLOYMENT.md for GitLab CI/CD and VPS deployment instructions.
License
MIT
Languages
Python
98.9%
Shell
0.9%
Dockerfile
0.1%