flashalpha 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- flashalpha-0.1.0/.gitignore +207 -0
- flashalpha-0.1.0/LICENSE +21 -0
- flashalpha-0.1.0/PKG-INFO +206 -0
- flashalpha-0.1.0/README.md +174 -0
- flashalpha-0.1.0/examples/quickstart.py +46 -0
- flashalpha-0.1.0/pyproject.toml +59 -0
- flashalpha-0.1.0/src/flashalpha/__init__.py +22 -0
- flashalpha-0.1.0/src/flashalpha/client.py +287 -0
- flashalpha-0.1.0/src/flashalpha/exceptions.py +39 -0
- flashalpha-0.1.0/tests/__init__.py +0 -0
- flashalpha-0.1.0/tests/test_client.py +307 -0
- flashalpha-0.1.0/tests/test_integration.py +198 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
#uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
#poetry.lock
|
|
109
|
+
#poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
#pdm.lock
|
|
116
|
+
#pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
#pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# SageMath parsed files
|
|
135
|
+
*.sage.py
|
|
136
|
+
|
|
137
|
+
# Environments
|
|
138
|
+
.env
|
|
139
|
+
.envrc
|
|
140
|
+
.venv
|
|
141
|
+
env/
|
|
142
|
+
venv/
|
|
143
|
+
ENV/
|
|
144
|
+
env.bak/
|
|
145
|
+
venv.bak/
|
|
146
|
+
|
|
147
|
+
# Spyder project settings
|
|
148
|
+
.spyderproject
|
|
149
|
+
.spyproject
|
|
150
|
+
|
|
151
|
+
# Rope project settings
|
|
152
|
+
.ropeproject
|
|
153
|
+
|
|
154
|
+
# mkdocs documentation
|
|
155
|
+
/site
|
|
156
|
+
|
|
157
|
+
# mypy
|
|
158
|
+
.mypy_cache/
|
|
159
|
+
.dmypy.json
|
|
160
|
+
dmypy.json
|
|
161
|
+
|
|
162
|
+
# Pyre type checker
|
|
163
|
+
.pyre/
|
|
164
|
+
|
|
165
|
+
# pytype static type analyzer
|
|
166
|
+
.pytype/
|
|
167
|
+
|
|
168
|
+
# Cython debug symbols
|
|
169
|
+
cython_debug/
|
|
170
|
+
|
|
171
|
+
# PyCharm
|
|
172
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
173
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
174
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
175
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
176
|
+
#.idea/
|
|
177
|
+
|
|
178
|
+
# Abstra
|
|
179
|
+
# Abstra is an AI-powered process automation framework.
|
|
180
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
181
|
+
# Learn more at https://abstra.io/docs
|
|
182
|
+
.abstra/
|
|
183
|
+
|
|
184
|
+
# Visual Studio Code
|
|
185
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
186
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
188
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
189
|
+
# .vscode/
|
|
190
|
+
|
|
191
|
+
# Ruff stuff:
|
|
192
|
+
.ruff_cache/
|
|
193
|
+
|
|
194
|
+
# PyPI configuration file
|
|
195
|
+
.pypirc
|
|
196
|
+
|
|
197
|
+
# Cursor
|
|
198
|
+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
|
|
199
|
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
|
200
|
+
# refer to https://docs.cursor.com/context/ignore-files
|
|
201
|
+
.cursorignore
|
|
202
|
+
.cursorindexingignore
|
|
203
|
+
|
|
204
|
+
# Marimo
|
|
205
|
+
marimo/_static/
|
|
206
|
+
marimo/_lsp/
|
|
207
|
+
__marimo__/
|
flashalpha-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 FlashAlpha
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: flashalpha
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python SDK for the FlashAlpha options analytics API — gamma exposure (GEX), delta, vanna, charm, greeks, and more.
|
|
5
|
+
Project-URL: Homepage, https://flashalpha.com
|
|
6
|
+
Project-URL: Documentation, https://flashalpha.com/docs
|
|
7
|
+
Project-URL: Repository, https://github.com/FlashAlpha-lab/flashalpha-python
|
|
8
|
+
Project-URL: Issues, https://github.com/FlashAlpha-lab/flashalpha-python/issues
|
|
9
|
+
Author-email: FlashAlpha <tom@flashalpha.com>
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: black-scholes,charm,delta exposure,finance,gamma exposure,gex,greeks,implied volatility,options,options API,options analytics,quantitative finance,trading,vanna
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Topic :: Office/Business :: Financial
|
|
23
|
+
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
24
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
25
|
+
Requires-Python: >=3.10
|
|
26
|
+
Requires-Dist: requests>=2.28
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: pytest-cov; extra == 'dev'
|
|
29
|
+
Requires-Dist: pytest>=7.0; extra == 'dev'
|
|
30
|
+
Requires-Dist: responses>=0.23; extra == 'dev'
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
# FlashAlpha Python SDK
|
|
34
|
+
|
|
35
|
+
[](https://pypi.org/project/flashalpha/)
|
|
36
|
+
[](https://pypi.org/project/flashalpha/)
|
|
37
|
+
[](https://opensource.org/licenses/MIT)
|
|
38
|
+
|
|
39
|
+
**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).
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install flashalpha
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Quick Start
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
from flashalpha import FlashAlpha
|
|
49
|
+
|
|
50
|
+
fa = FlashAlpha("YOUR_API_KEY")
|
|
51
|
+
|
|
52
|
+
# Get gamma exposure for SPY
|
|
53
|
+
gex = fa.gex("SPY")
|
|
54
|
+
print(f"Net GEX: ${gex['net_gex']:,.0f}")
|
|
55
|
+
print(f"Gamma flip: {gex['gamma_flip']}")
|
|
56
|
+
|
|
57
|
+
for strike in gex["strikes"][:5]:
|
|
58
|
+
print(f" {strike['strike']}: net ${strike['net_gex']:,.0f}")
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## What You Can Do
|
|
62
|
+
|
|
63
|
+
### Exposure Analytics — see where dealers are positioned
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
# Gamma exposure by strike
|
|
67
|
+
gex = fa.gex("SPY")
|
|
68
|
+
gex = fa.gex("TSLA", expiration="2026-03-21", min_oi=100)
|
|
69
|
+
|
|
70
|
+
# Delta, vanna, charm exposure
|
|
71
|
+
dex = fa.dex("AAPL")
|
|
72
|
+
vex = fa.vex("QQQ")
|
|
73
|
+
chex = fa.chex("NVDA")
|
|
74
|
+
|
|
75
|
+
# Key levels (gamma flip, walls, max pain)
|
|
76
|
+
levels = fa.exposure_levels("SPY")
|
|
77
|
+
print(f"Call wall: {levels['levels']['call_wall']}")
|
|
78
|
+
print(f"Put wall: {levels['levels']['put_wall']}")
|
|
79
|
+
print(f"Gamma flip: {levels['levels']['gamma_flip']}")
|
|
80
|
+
|
|
81
|
+
# Full exposure summary with hedging estimates
|
|
82
|
+
summary = fa.exposure_summary("SPY") # Growth+
|
|
83
|
+
|
|
84
|
+
# AI narrative analysis
|
|
85
|
+
narrative = fa.narrative("SPY") # Growth+
|
|
86
|
+
print(narrative["narrative"]["regime"])
|
|
87
|
+
print(narrative["narrative"]["outlook"])
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Market Data — live quotes and option chains
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
# Stock quote
|
|
94
|
+
quote = fa.stock_quote("AAPL")
|
|
95
|
+
print(f"AAPL: ${quote['mid']}")
|
|
96
|
+
|
|
97
|
+
# Option quote with greeks
|
|
98
|
+
opt = fa.option_quote("SPY", expiry="2026-03-21", strike=660, type="C") # Growth+
|
|
99
|
+
print(f"Delta: {opt['delta']}, IV: {opt['implied_vol']}")
|
|
100
|
+
|
|
101
|
+
# Comprehensive stock summary (price, vol, exposure, macro)
|
|
102
|
+
summary = fa.stock_summary("SPY")
|
|
103
|
+
|
|
104
|
+
# Vol surface (public — no API key needed)
|
|
105
|
+
surface = fa.surface("SPY")
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Pricing — Black-Scholes greeks and implied vol
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
# Full BSM greeks (first, second, third order)
|
|
112
|
+
g = fa.greeks(spot=580, strike=580, dte=30, sigma=0.18, type="call")
|
|
113
|
+
print(f"Delta: {g['first_order']['delta']}")
|
|
114
|
+
print(f"Gamma: {g['first_order']['gamma']}")
|
|
115
|
+
print(f"Vanna: {g['second_order']['vanna']}")
|
|
116
|
+
|
|
117
|
+
# Implied volatility from market price
|
|
118
|
+
result = fa.iv(spot=580, strike=580, dte=30, price=12.69)
|
|
119
|
+
print(f"IV: {result['implied_volatility_pct']}%")
|
|
120
|
+
|
|
121
|
+
# Kelly criterion position sizing
|
|
122
|
+
kelly = fa.kelly( # Growth+
|
|
123
|
+
spot=580, strike=580, dte=30,
|
|
124
|
+
sigma=0.18, premium=12.69, mu=0.12,
|
|
125
|
+
)
|
|
126
|
+
print(kelly["recommendation"])
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Volatility Analytics — skew, term structure, realized vol
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
vol = fa.volatility("TSLA") # Growth+
|
|
133
|
+
print(f"ATM IV: {vol['atm_iv']}%")
|
|
134
|
+
print(f"RV 20d: {vol['realized_vol']['rv_20d']}%")
|
|
135
|
+
print(f"VRP assessment: {vol['iv_rv_spreads']['assessment']}")
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Historical Data — minute-by-minute from ClickHouse
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
# Historical stock quotes
|
|
142
|
+
hist = fa.historical_stock_quote("SPY", date="2026-03-05", time="10:30")
|
|
143
|
+
|
|
144
|
+
# Historical option quotes
|
|
145
|
+
hist_opt = fa.historical_option_quote(
|
|
146
|
+
"SPY", date="2026-03-05", expiry="2026-03-20", strike=580, type="C"
|
|
147
|
+
)
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Reference & Account
|
|
151
|
+
|
|
152
|
+
```python
|
|
153
|
+
# All available tickers
|
|
154
|
+
tickers = fa.tickers()
|
|
155
|
+
|
|
156
|
+
# Option chain metadata (expirations + strikes)
|
|
157
|
+
chain = fa.options("SPY")
|
|
158
|
+
|
|
159
|
+
# Symbols with live cached data
|
|
160
|
+
symbols = fa.symbols()
|
|
161
|
+
|
|
162
|
+
# Account info and quota
|
|
163
|
+
account = fa.account()
|
|
164
|
+
print(f"Plan: {account['plan']}, Remaining: {account['remaining']}")
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## Error Handling
|
|
168
|
+
|
|
169
|
+
```python
|
|
170
|
+
from flashalpha import (
|
|
171
|
+
FlashAlpha,
|
|
172
|
+
AuthenticationError,
|
|
173
|
+
TierRestrictedError,
|
|
174
|
+
NotFoundError,
|
|
175
|
+
RateLimitError,
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
fa = FlashAlpha("YOUR_API_KEY")
|
|
179
|
+
|
|
180
|
+
try:
|
|
181
|
+
data = fa.exposure_summary("SPY")
|
|
182
|
+
except AuthenticationError:
|
|
183
|
+
print("Invalid API key")
|
|
184
|
+
except TierRestrictedError as e:
|
|
185
|
+
print(f"Need {e.required_plan} plan (you have {e.current_plan})")
|
|
186
|
+
except NotFoundError:
|
|
187
|
+
print("Symbol not found")
|
|
188
|
+
except RateLimitError as e:
|
|
189
|
+
print(f"Rate limited — retry after {e.retry_after}s")
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## Plans
|
|
193
|
+
|
|
194
|
+
| Plan | Daily Requests | Highlights |
|
|
195
|
+
|------|---------------|------------|
|
|
196
|
+
| **Free** | 50 | Stock quotes, GEX/DEX/VEX/CHEX by strike, levels, greeks, IV, tickers |
|
|
197
|
+
| **Basic** | 250 | Everything in Free |
|
|
198
|
+
| **Growth** | 2,500 | + Option quotes, exposure summary, narrative, volatility, Kelly sizing |
|
|
199
|
+
| **Pro** | Unlimited | Full access |
|
|
200
|
+
|
|
201
|
+
**Get your API key at [flashalpha.com](https://flashalpha.com)**
|
|
202
|
+
|
|
203
|
+
## Links
|
|
204
|
+
|
|
205
|
+
- [API Documentation](https://flashalpha.com/docs)
|
|
206
|
+
- [GitHub](https://github.com/FlashAlpha-lab/flashalpha-python)
|
|
@@ -0,0 +1,174 @@
|
|
|
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
|
+
- [GitHub](https://github.com/FlashAlpha-lab/flashalpha-python)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"""FlashAlpha SDK quick start — get running in 3 minutes."""
|
|
2
|
+
|
|
3
|
+
from flashalpha import FlashAlpha
|
|
4
|
+
|
|
5
|
+
# 1. Initialize with your API key
|
|
6
|
+
fa = FlashAlpha("YOUR_API_KEY")
|
|
7
|
+
|
|
8
|
+
# 2. Get gamma exposure for SPY
|
|
9
|
+
gex = fa.gex("SPY")
|
|
10
|
+
print(f"SPY Net GEX: ${gex['net_gex']:,.0f}")
|
|
11
|
+
print(f"Gamma flip: {gex['gamma_flip']:.2f}")
|
|
12
|
+
print(f"Regime: {gex['net_gex_label']}")
|
|
13
|
+
print()
|
|
14
|
+
|
|
15
|
+
# 3. Key support/resistance levels
|
|
16
|
+
levels = fa.exposure_levels("SPY")["levels"]
|
|
17
|
+
print(f"Call wall (resistance): {levels['call_wall']}")
|
|
18
|
+
print(f"Put wall (support): {levels['put_wall']}")
|
|
19
|
+
print(f"Gamma flip: {levels['gamma_flip']:.2f}")
|
|
20
|
+
print(f"0DTE magnet: {levels['zero_dte_magnet']}")
|
|
21
|
+
print()
|
|
22
|
+
|
|
23
|
+
# 4. Stock quote
|
|
24
|
+
quote = fa.stock_quote("SPY")
|
|
25
|
+
print(f"SPY: ${quote['mid']:.2f} (bid {quote['bid']:.2f} / ask {quote['ask']:.2f})")
|
|
26
|
+
print()
|
|
27
|
+
|
|
28
|
+
# 5. BSM greeks calculator
|
|
29
|
+
greeks = fa.greeks(spot=580, strike=580, dte=30, sigma=0.18)
|
|
30
|
+
print("BSM Greeks (580C, 30 DTE, 18% vol):")
|
|
31
|
+
print(f" Price: ${greeks['theoretical_price']:.2f}")
|
|
32
|
+
print(f" Delta: {greeks['first_order']['delta']:.4f}")
|
|
33
|
+
print(f" Gamma: {greeks['first_order']['gamma']:.6f}")
|
|
34
|
+
print(f" Theta: {greeks['first_order']['theta']:.4f}")
|
|
35
|
+
print(f" Vega: {greeks['first_order']['vega']:.4f}")
|
|
36
|
+
print(f" Vanna: {greeks['second_order']['vanna']:.6f}")
|
|
37
|
+
print()
|
|
38
|
+
|
|
39
|
+
# 6. Implied volatility solver
|
|
40
|
+
iv_result = fa.iv(spot=580, strike=580, dte=30, price=12.69)
|
|
41
|
+
print(f"IV from $12.69 premium: {iv_result['implied_volatility_pct']:.1f}%")
|
|
42
|
+
print()
|
|
43
|
+
|
|
44
|
+
# 7. Account info
|
|
45
|
+
account = fa.account()
|
|
46
|
+
print(f"Plan: {account['plan']} | Remaining: {account['remaining']}")
|