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:
Bu5hm4nn
2026-03-21 19:21:40 +01:00
commit 00a68bc767
63 changed files with 6239 additions and 0 deletions

53
scripts/healthcheck.py Executable file
View File

@@ -0,0 +1,53 @@
#!/usr/bin/env python3
"""Simple deployment health check utility."""
from __future__ import annotations
import argparse
import sys
import time
from urllib.error import HTTPError, URLError
from urllib.request import urlopen
import json
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(description="Poll an HTTP health endpoint until it is ready.")
parser.add_argument("url", help="Health endpoint URL, e.g. https://vault.example.com/health")
parser.add_argument("--timeout", type=int, default=120, help="Maximum wait time in seconds")
parser.add_argument("--interval", type=int, default=5, help="Poll interval in seconds")
parser.add_argument("--expect-status", default="ok", help="Expected JSON status field")
parser.add_argument("--expect-environment", default=None, help="Optional expected JSON environment field")
return parser.parse_args()
def fetch_json(url: str) -> dict:
with urlopen(url, timeout=10) as response:
body = response.read().decode("utf-8")
return json.loads(body)
def main() -> int:
args = parse_args()
deadline = time.time() + args.timeout
last_error = "unknown error"
while time.time() < deadline:
try:
payload = fetch_json(args.url)
if payload.get("status") != args.expect_status:
raise RuntimeError(f"unexpected status: {payload!r}")
if args.expect_environment and payload.get("environment") != args.expect_environment:
raise RuntimeError(f"unexpected environment: {payload!r}")
print(f"healthcheck passed: {payload}")
return 0
except (HTTPError, URLError, TimeoutError, ValueError, RuntimeError) as exc:
last_error = str(exc)
time.sleep(args.interval)
print(f"healthcheck failed after {args.timeout}s: {last_error}", file=sys.stderr)
return 1
if __name__ == "__main__":
raise SystemExit(main())