|
1 | | -# flashalpha-python |
| 1 | +# FlashAlpha Python SDK |
| 2 | + |
| 3 | +[](https://pypi.org/project/flashalpha/) |
| 4 | +[](https://pypi.org/project/flashalpha/) |
| 5 | +[](https://opensource.org/licenses/MIT) |
| 6 | + |
| 7 | +**Real-time options exposure analytics for Python.** Gamma exposure (GEX), delta (DEX), vanna (VEX), charm (CHEX), key levels, Black-Scholes greeks, implied volatility, Kelly sizing, and more — from the [FlashAlpha API](https://flashalpha.com). |
| 8 | + |
| 9 | +```bash |
| 10 | +pip install flashalpha |
| 11 | +``` |
| 12 | + |
| 13 | +## Quick Start |
| 14 | + |
| 15 | +```python |
| 16 | +from flashalpha import FlashAlpha |
| 17 | + |
| 18 | +fa = FlashAlpha("YOUR_API_KEY") |
| 19 | + |
| 20 | +# Get gamma exposure for SPY |
| 21 | +gex = fa.gex("SPY") |
| 22 | +print(f"Net GEX: ${gex['net_gex']:,.0f}") |
| 23 | +print(f"Gamma flip: {gex['gamma_flip']}") |
| 24 | + |
| 25 | +for strike in gex["strikes"][:5]: |
| 26 | + print(f" {strike['strike']}: net ${strike['net_gex']:,.0f}") |
| 27 | +``` |
| 28 | + |
| 29 | +## What You Can Do |
| 30 | + |
| 31 | +### Exposure Analytics — see where dealers are positioned |
| 32 | + |
| 33 | +```python |
| 34 | +# Gamma exposure by strike |
| 35 | +gex = fa.gex("SPY") |
| 36 | +gex = fa.gex("TSLA", expiration="2026-03-21", min_oi=100) |
| 37 | + |
| 38 | +# Delta, vanna, charm exposure |
| 39 | +dex = fa.dex("AAPL") |
| 40 | +vex = fa.vex("QQQ") |
| 41 | +chex = fa.chex("NVDA") |
| 42 | + |
| 43 | +# Key levels (gamma flip, walls, max pain) |
| 44 | +levels = fa.exposure_levels("SPY") |
| 45 | +print(f"Call wall: {levels['levels']['call_wall']}") |
| 46 | +print(f"Put wall: {levels['levels']['put_wall']}") |
| 47 | +print(f"Gamma flip: {levels['levels']['gamma_flip']}") |
| 48 | + |
| 49 | +# Full exposure summary with hedging estimates |
| 50 | +summary = fa.exposure_summary("SPY") # Growth+ |
| 51 | + |
| 52 | +# AI narrative analysis |
| 53 | +narrative = fa.narrative("SPY") # Growth+ |
| 54 | +print(narrative["narrative"]["regime"]) |
| 55 | +print(narrative["narrative"]["outlook"]) |
| 56 | +``` |
| 57 | + |
| 58 | +### Market Data — live quotes and option chains |
| 59 | + |
| 60 | +```python |
| 61 | +# Stock quote |
| 62 | +quote = fa.stock_quote("AAPL") |
| 63 | +print(f"AAPL: ${quote['mid']}") |
| 64 | + |
| 65 | +# Option quote with greeks |
| 66 | +opt = fa.option_quote("SPY", expiry="2026-03-21", strike=660, type="C") # Growth+ |
| 67 | +print(f"Delta: {opt['delta']}, IV: {opt['implied_vol']}") |
| 68 | + |
| 69 | +# Comprehensive stock summary (price, vol, exposure, macro) |
| 70 | +summary = fa.stock_summary("SPY") |
| 71 | + |
| 72 | +# Vol surface (public — no API key needed) |
| 73 | +surface = fa.surface("SPY") |
| 74 | +``` |
| 75 | + |
| 76 | +### Pricing — Black-Scholes greeks and implied vol |
| 77 | + |
| 78 | +```python |
| 79 | +# Full BSM greeks (first, second, third order) |
| 80 | +g = fa.greeks(spot=580, strike=580, dte=30, sigma=0.18, type="call") |
| 81 | +print(f"Delta: {g['first_order']['delta']}") |
| 82 | +print(f"Gamma: {g['first_order']['gamma']}") |
| 83 | +print(f"Vanna: {g['second_order']['vanna']}") |
| 84 | + |
| 85 | +# Implied volatility from market price |
| 86 | +result = fa.iv(spot=580, strike=580, dte=30, price=12.69) |
| 87 | +print(f"IV: {result['implied_volatility_pct']}%") |
| 88 | + |
| 89 | +# Kelly criterion position sizing |
| 90 | +kelly = fa.kelly( # Growth+ |
| 91 | + spot=580, strike=580, dte=30, |
| 92 | + sigma=0.18, premium=12.69, mu=0.12, |
| 93 | +) |
| 94 | +print(kelly["recommendation"]) |
| 95 | +``` |
| 96 | + |
| 97 | +### Volatility Analytics — skew, term structure, realized vol |
| 98 | + |
| 99 | +```python |
| 100 | +vol = fa.volatility("TSLA") # Growth+ |
| 101 | +print(f"ATM IV: {vol['atm_iv']}%") |
| 102 | +print(f"RV 20d: {vol['realized_vol']['rv_20d']}%") |
| 103 | +print(f"VRP assessment: {vol['iv_rv_spreads']['assessment']}") |
| 104 | +``` |
| 105 | + |
| 106 | +### Historical Data — minute-by-minute from ClickHouse |
| 107 | + |
| 108 | +```python |
| 109 | +# Historical stock quotes |
| 110 | +hist = fa.historical_stock_quote("SPY", date="2026-03-05", time="10:30") |
| 111 | + |
| 112 | +# Historical option quotes |
| 113 | +hist_opt = fa.historical_option_quote( |
| 114 | + "SPY", date="2026-03-05", expiry="2026-03-20", strike=580, type="C" |
| 115 | +) |
| 116 | +``` |
| 117 | + |
| 118 | +### Reference & Account |
| 119 | + |
| 120 | +```python |
| 121 | +# All available tickers |
| 122 | +tickers = fa.tickers() |
| 123 | + |
| 124 | +# Option chain metadata (expirations + strikes) |
| 125 | +chain = fa.options("SPY") |
| 126 | + |
| 127 | +# Symbols with live cached data |
| 128 | +symbols = fa.symbols() |
| 129 | + |
| 130 | +# Account info and quota |
| 131 | +account = fa.account() |
| 132 | +print(f"Plan: {account['plan']}, Remaining: {account['remaining']}") |
| 133 | +``` |
| 134 | + |
| 135 | +## Error Handling |
| 136 | + |
| 137 | +```python |
| 138 | +from flashalpha import ( |
| 139 | + FlashAlpha, |
| 140 | + AuthenticationError, |
| 141 | + TierRestrictedError, |
| 142 | + NotFoundError, |
| 143 | + RateLimitError, |
| 144 | +) |
| 145 | + |
| 146 | +fa = FlashAlpha("YOUR_API_KEY") |
| 147 | + |
| 148 | +try: |
| 149 | + data = fa.exposure_summary("SPY") |
| 150 | +except AuthenticationError: |
| 151 | + print("Invalid API key") |
| 152 | +except TierRestrictedError as e: |
| 153 | + print(f"Need {e.required_plan} plan (you have {e.current_plan})") |
| 154 | +except NotFoundError: |
| 155 | + print("Symbol not found") |
| 156 | +except RateLimitError as e: |
| 157 | + print(f"Rate limited — retry after {e.retry_after}s") |
| 158 | +``` |
| 159 | + |
| 160 | +## Plans |
| 161 | + |
| 162 | +| Plan | Daily Requests | Highlights | |
| 163 | +|------|---------------|------------| |
| 164 | +| **Free** | 50 | Stock quotes, GEX/DEX/VEX/CHEX by strike, levels, greeks, IV, tickers | |
| 165 | +| **Basic** | 250 | Everything in Free | |
| 166 | +| **Growth** | 2,500 | + Option quotes, exposure summary, narrative, volatility, Kelly sizing | |
| 167 | +| **Pro** | Unlimited | Full access | |
| 168 | + |
| 169 | +**Get your API key at [flashalpha.com](https://flashalpha.com)** |
| 170 | + |
| 171 | +## Links |
| 172 | + |
| 173 | +- [API Documentation](https://flashalpha.com/docs) |
| 174 | +- [Interactive Playground](https://lab.flashalpha.com/swagger) |
| 175 | +- [GitHub](https://github.com/FlashAlpha/flashalpha-python) |
0 commit comments