Files
nexus-quant-terminal/backend/app/core/black_scholes.py
T
KansaramandClaude Sonnet 4.6 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

50 lines
1.6 KiB
Python

import numpy as np
from scipy.stats import norm
def _d1_d2(S, K, T, r, sigma):
S = np.asarray(S, dtype=float)
sqrt_T = np.sqrt(T)
d1 = (np.log(S / K) + (r + 0.5 * sigma ** 2) * T) / (sigma * sqrt_T)
d2 = d1 - sigma * sqrt_T
return d1, d2
def bs_price(S, K, T, r, sigma, option_type="call"):
d1, d2 = _d1_d2(S, K, T, r, sigma)
if option_type == "call":
return float(np.asarray(S) * norm.cdf(d1) - K * np.exp(-r * T) * norm.cdf(d2))
return float(K * np.exp(-r * T) * norm.cdf(-d2) - np.asarray(S) * norm.cdf(-d1))
def bs_delta(S, K, T, r, sigma, option_type="call"):
d1, _ = _d1_d2(S, K, T, r, sigma)
return float(norm.cdf(d1) if option_type == "call" else norm.cdf(d1) - 1.0)
def bs_gamma(S, K, T, r, sigma):
d1, _ = _d1_d2(S, K, T, r, sigma)
return float(norm.pdf(d1) / (np.asarray(S) * sigma * np.sqrt(T)))
def bs_vega(S, K, T, r, sigma):
d1, _ = _d1_d2(S, K, T, r, sigma)
return float(np.asarray(S) * norm.pdf(d1) * np.sqrt(T))
def bs_theta(S, K, T, r, sigma, option_type="call"):
d1, d2 = _d1_d2(S, K, T, r, sigma)
S = np.asarray(S)
decay = -(S * norm.pdf(d1) * sigma) / (2 * np.sqrt(T))
if option_type == "call":
return float(decay - r * K * np.exp(-r * T) * norm.cdf(d2))
return float(decay + r * K * np.exp(-r * T) * norm.cdf(-d2))
def bs_rho(S, K, T, r, sigma, option_type="call"):
"""Rho — sensitivity to interest rate changes."""
_, d2 = _d1_d2(S, K, T, r, sigma)
if option_type == "call":
return float(K * T * np.exp(-r * T) * norm.cdf(d2))
return float(-K * T * np.exp(-r * T) * norm.cdf(-d2))