Files
nexus-quant-terminal/backend/app/core/greeks.py
T
Kansaram 61e145a442 feat: launch NEXUS TERMINAL — Bloomberg-style FX options analytics platform
Full-stack forex options analytics terminal with Bloomberg-inspired UI.

Backend (FastAPI + Python):
- Garman-Kohlhagen options pricing engine with full Greeks
- Goldman Sachs gs-quant AI signals (RSI, MACD, Bollinger, Hurst, OU)
- Monte Carlo GBM simulation and volatility surface generation
- CFTC COT institutional positioning + Forex Factory economic calendar
- Live data proxy: OpenSky aircraft + USGS earthquakes (CORS-safe)
- Multi-leg strategy library (straddle, iron condor, butterfly, spreads)

Frontend (React 18 + Vite):
- NEXUS animated orbital logo (3-ring SVG) + canvas favicon animation
- Bloomberg terminal design: JetBrains Mono, color-mix() tokens
- 11 dashboard tabs: Greeks, Chart, AI Signals, 3D Surfaces, Breakeven,
  Scenarios, Monte Carlo, Institutional, Calendar, Live Map, Live Feeds
- Live World Map (react-leaflet): aircraft, earthquakes, weather radar
- Live Feeds: CoinGecko crypto top-12 + Windy.com global webcams
- Economic calendar with filters + institutional flow (CFTC COT)
- Animated landing page + session-based routing
- Fully responsive dark-only terminal design system

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-07 18:19:23 +05:30

42 lines
1.5 KiB
Python

"""greeks.py — Portfolio-level Greek aggregation using Garman-Kohlhagen model."""
from .garman_kohlhagen import (
gk_delta, gk_gamma, gk_vega, gk_theta, gk_rho_d, gk_phi
)
def portfolio_greeks(
options: list[dict], S: float, sigma: float,
T: float, r_d: float, r_f: float
) -> dict:
"""Aggregate GK Greeks across all legs of a forex options portfolio."""
total = {"delta": 0.0, "gamma": 0.0, "vega": 0.0,
"theta": 0.0, "rho_d": 0.0, "phi": 0.0}
legs = []
for opt in options:
otype = opt["type"]
K, qty = float(opt["K"]), float(opt["qty"])
leg_T = float(opt.get("T", T))
d = gk_delta(S, K, leg_T, r_d, r_f, sigma, otype) * qty
g = gk_gamma(S, K, leg_T, r_d, r_f, sigma) * qty
v = gk_vega(S, K, leg_T, r_d, r_f, sigma) * qty
th = gk_theta(S, K, leg_T, r_d, r_f, sigma, otype) * qty
rho = gk_rho_d(S, K, leg_T, r_d, r_f, sigma, otype) * qty
phi = gk_phi(S, K, leg_T, r_d, r_f, sigma, otype) * qty
total["delta"] += d; total["gamma"] += g; total["vega"] += v
total["theta"] += th; total["rho_d"] += rho; total["phi"] += phi
legs.append({
"label": f"{'+'if qty>0 else ''}{int(qty)} {otype.upper()} K={K}",
"delta": round(d, 5), "gamma": round(g, 7),
"vega": round(v, 4), "theta": round(th, 4),
})
return {
"total": {k: round(v, 6) for k, v in total.items()},
"legs": legs,
}