Initial commit: Vault Dashboard for options hedging
- FastAPI + NiceGUI web application - QuantLib-based Black-Scholes pricing with Greeks - Protective put, laddered, and LEAPS strategies - Real-time WebSocket updates - TradingView-style charts via Lightweight-Charts - Docker containerization - GitLab CI/CD pipeline for VPS deployment - VPN-only access configuration
This commit is contained in:
22
tests/test_portfolio.py
Normal file
22
tests/test_portfolio.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
def test_ltv_calculation(sample_portfolio) -> None:
|
||||
assert sample_portfolio.current_ltv == pytest.approx(0.60, rel=1e-12)
|
||||
assert sample_portfolio.ltv_at_price(460.0) == pytest.approx(0.60, rel=1e-12)
|
||||
assert sample_portfolio.ltv_at_price(368.0) == pytest.approx(0.75, rel=1e-12)
|
||||
|
||||
|
||||
def test_net_equity_calculation(sample_portfolio) -> None:
|
||||
assert sample_portfolio.net_equity == pytest.approx(400_000.0, rel=1e-12)
|
||||
assert sample_portfolio.net_equity_at_price(420.0) == pytest.approx(
|
||||
sample_portfolio.gold_ounces * 420.0 - 600_000.0,
|
||||
rel=1e-12,
|
||||
)
|
||||
|
||||
|
||||
def test_margin_call_threshold(sample_portfolio) -> None:
|
||||
assert sample_portfolio.margin_call_price() == pytest.approx(368.0, rel=1e-12)
|
||||
assert sample_portfolio.ltv_at_price(sample_portfolio.margin_call_price()) == pytest.approx(0.75, rel=1e-12)
|
||||
Reference in New Issue
Block a user