mirror of
https://github.com/Mihirkansara/nexus-quant-terminal.git
synced 2026-08-01 21:17:44 +00:00
61e145a442
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>
34 lines
1.3 KiB
Python
34 lines
1.3 KiB
Python
"""surface.py — 2-D risk surface computation over spot × vol grid."""
|
||
|
||
import numpy as np
|
||
from .greeks import portfolio_greeks
|
||
from .garman_kohlhagen import gk_price
|
||
|
||
|
||
def compute_surfaces(options, S_range, sigma_range, T, r_d, r_f):
|
||
"""Compute Delta, Gamma, Vega, Theta, and P&L surfaces."""
|
||
n_s, n_v = len(S_range), len(sigma_range)
|
||
D = np.zeros((n_s, n_v)); G = np.zeros((n_s, n_v))
|
||
V = np.zeros((n_s, n_v)); Th = np.zeros((n_s, n_v))
|
||
|
||
for i, S in enumerate(S_range):
|
||
for j, sigma in enumerate(sigma_range):
|
||
g = portfolio_greeks(options, S, sigma, T, r_d, r_f)["total"]
|
||
D[i,j]=g["delta"]; G[i,j]=g["gamma"]
|
||
V[i,j]=g["vega"]; Th[i,j]=g["theta"]
|
||
|
||
# P&L via Delta-Gamma approx around grid midpoint
|
||
S0 = S_range[len(S_range)//2]
|
||
sig0 = sigma_range[len(sigma_range)//2]
|
||
base = portfolio_greeks(options, S0, sig0, T, r_d, r_f)["total"]
|
||
PnL = np.zeros((n_s, n_v))
|
||
for i, S in enumerate(S_range):
|
||
dS = S - S0
|
||
PnL[i,:] = base["delta"]*dS + 0.5*base["gamma"]*dS**2
|
||
|
||
return {
|
||
"S_range": S_range.tolist(), "sigma_range": sigma_range.tolist(),
|
||
"delta": D.tolist(), "gamma": G.tolist(),
|
||
"vega": V.tolist(), "theta": Th.tolist(), "pnl": PnL.tolist(),
|
||
}
|