mirror of
https://github.com/Mihirkansara/nexus-quant-terminal.git
synced 2026-08-15 03:28:07 +00:00
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>
44 lines
1.8 KiB
Python
44 lines
1.8 KiB
Python
import io, csv
|
|
from fastapi import APIRouter
|
|
from fastapi.responses import StreamingResponse
|
|
from ..schemas import GreeksRequest
|
|
from ..core.greeks import portfolio_greeks
|
|
from ..core.garman_kohlhagen import gk_price
|
|
|
|
router = APIRouter(prefix="/export", tags=["export"])
|
|
|
|
@router.post("/csv")
|
|
def export_csv(req: GreeksRequest):
|
|
options = [o.model_dump() for o in req.options]
|
|
result = portfolio_greeks(options, req.S, req.sigma, req.T, req.r_d, req.r_f)
|
|
out = io.StringIO()
|
|
w = csv.writer(out)
|
|
w.writerow(["QUANTRISK FX — GARMAN-KOHLHAGEN GREEKS REPORT"])
|
|
w.writerow(["Spot", req.S, "Sigma", req.sigma, "T", req.T,
|
|
"r_d", req.r_d, "r_f", req.r_f])
|
|
w.writerow([])
|
|
w.writerow(["PORTFOLIO TOTALS"])
|
|
w.writerow(["Greek", "Value", "Description"])
|
|
desc = {"delta":"Price sensitivity","gamma":"Delta curvature","vega":"Vol sensitivity",
|
|
"theta":"Time decay/yr","rho_d":"Dom rate sensitivity","phi":"For rate sensitivity"}
|
|
for k, v in result["total"].items():
|
|
w.writerow([k.upper(), v, desc.get(k,"")])
|
|
w.writerow([])
|
|
w.writerow(["LEG BREAKDOWN"])
|
|
w.writerow(["Leg","Delta","Gamma","Vega","Theta"])
|
|
for leg in result["legs"]:
|
|
w.writerow([leg["label"],leg["delta"],leg["gamma"],leg["vega"],leg["theta"]])
|
|
w.writerow([])
|
|
w.writerow(["OPTION PRICES (Garman-Kohlhagen)"])
|
|
w.writerow(["Leg","GK Price"])
|
|
for opt in options:
|
|
price = gk_price(req.S, opt["K"], opt.get("T",req.T), req.r_d, req.r_f,
|
|
req.sigma, opt["type"])
|
|
w.writerow([f"{opt['type'].upper()} K={opt['K']} qty={opt['qty']}", round(price,5)])
|
|
out.seek(0)
|
|
return StreamingResponse(
|
|
io.BytesIO(out.getvalue().encode()),
|
|
media_type="text/csv",
|
|
headers={"Content-Disposition": "attachment; filename=gk_greeks_report.csv"},
|
|
)
|