Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ endpoint families include:
(flow-anomaly, expiry-positioning, zero-dte, dealer-regime, vol-carry,
yield-enhancement, surface-anomaly, skew, term-structure, tail-pricing) behind
one uniform decision envelope, for trade selection and signal backtesting.
- **sell-window** (`/v1/strategies/sell-window/{symbol}`): should you sell options today? More than 5 million backtests led to it. Every session, for SPY, QQQ and IWM, it says sell or skip for four listed expiries, and on a sell it lists the trades to place, with strikes, quotes and the exit rule. Own response shape. See [notebooks/13_sell_window.py](notebooks/13_sell_window.py), the [API docs](https://flashalpha.com/docs/lab-api-strategies-sell-window?utm_source=github&utm_medium=readme&utm_campaign=repo-flashalpha-examples&utm_content=sell-window) and the [backtest](https://flashalpha.com/articles/sell-window-backtest-every-trade-2018-2026?utm_source=github&utm_medium=readme&utm_campaign=repo-flashalpha-examples&utm_content=sell-window).
- **Earnings analytics** (`/v1/earnings/*`) — calendar, expected-move, history,
iv-crush, earnings VRP, dealer-positioning, strategies, and a screener.
- **Structures** (`POST /v1/structures/pnl`, `POST /v1/structures/greeks`) —
Expand Down
1 change: 1 addition & 0 deletions llms.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ The cookbook exercises the full FlashAlpha endpoint surface. New recipes can dra

- **Exposure analytics** — `/v1/exposure/gex|dex|vex|chex/{symbol}` (gamma, delta, vanna, charm dealer exposure), `/v1/exposure/summary|levels|narrative/{symbol}`, `/v1/exposure/zero-dte/{symbol}` (0DTE exposure, now with `expiry`), `/v1/maxpain/{symbol}`. Extended exposure: `/v1/exposure/sheet/{symbol}` (full per-strike exposure sheet), `/v1/exposure/term-structure/{symbol}` (exposure across expiries), `/v1/exposure/basket` (portfolio/basket exposure via `symbols`+`weights`), `/v1/exposure/oi-diff/{symbol}` (open-interest change vs prior session, top-N strikes).
- **Strategy Signals** — `/v1/strategies/*` exposes 10 systematic signals sharing one uniform decision envelope (`StrategyDecisionResponse`): `flow-anomaly`, `expiry-positioning`, `zero-dte`, `dealer-regime`, `vol-carry`, `yield-enhancement`, `surface-anomaly`, `skew`, `term-structure`, `tail-pricing` — each at `/v1/strategies/<name>/{symbol}`. Use these for trade selection, regime detection, and signal backtesting.
- **sell-window** - `/v1/strategies/sell-window/{symbol}` answers "should you sell options today?" for SPY, QQQ and IWM: sell, skip or unavailable for four listed expiries, with the trades to place on a sell. Own response shape, not the decision envelope. Example: `notebooks/13_sell_window.py`. Docs: https://flashalpha.com/docs/lab-api-strategies-sell-window
- **Earnings analytics** — `/v1/earnings/calendar` (upcoming earnings, filter by `days`/`symbols`/`importance`), `/v1/earnings/expected-move/{symbol}`, `/v1/earnings/history/{symbol}`, `/v1/earnings/iv-crush/{symbol}` (post-event IV collapse), `/v1/earnings/vrp/{symbol}` (earnings volatility-risk-premium), `/v1/earnings/dealer-positioning/{symbol}`, `/v1/earnings/strategies/{symbol}`, `/v1/earnings/screener` (rank the earnings universe).
- **Structures (multi-leg, pure-math, POST)** — `POST /v1/structures/pnl` (payoff/P&L curve for arbitrary multi-leg structures across an underlying range) and `POST /v1/structures/greeks` (aggregate Greeks for a leg set at a given spot/date). Ideal for spreads, condors, butterflies, calendars.
- **Zero-DTE Flow (intraday)** — `/v1/flow/zero-dte/snapshot/{symbol}`, `/v1/flow/zero-dte/series/{symbol}` (time series by `bar`), `/v1/flow/zero-dte/hedge-flow/{symbol}` (dealer hedging flow by side), `/v1/flow/zero-dte/heatmap/{symbol}` (gex/dex/vex/chex/oi/signed-flow heatmap), `/v1/flow/zero-dte/strike-flow/{symbol}`.
Expand Down
38 changes: 38 additions & 0 deletions notebooks/13_sell_window.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# # sell-window: Should You Sell Options Today?
#
# Option sellers get wiped out on a few bad days. sell-window tells you which
# days to stay out, and on the days it says sell, it hands you the trades:
# which expiry, which strikes and how to exit. Every session, for SPY, QQQ and
# IWM. More than 5 million backtests led to this one endpoint.
#
# fa.sell_window(symbol) -> /v1/strategies/sell-window/{symbol}
#
# Each of the four windows (the same-day expiry, then the expiries closest to
# one week, two weeks and one month out) says sell, skip or unavailable. On a
# skip there is nothing to do. Treat unavailable like a skip.
#
# Plans: Basic+ through November 2026, Growth+ from December 1, 2026.
# Docs: https://flashalpha.com/docs/lab-api-strategies-sell-window
# Backtest: https://flashalpha.com/articles/sell-window-backtest-every-trade-2018-2026
#
# Past results do not guarantee future returns, and short options can lose more
# than the premium collected. This is data, not investment advice.
#
# Requires: pip install "flashalpha>=1.4.0"

import os
from flashalpha import FlashAlpha

fa = FlashAlpha(os.environ["FLASHALPHA_API_KEY"])

for symbol in ("SPY", "QQQ", "IWM"):
answer = fa.sell_window(symbol)
print(f"{symbol} session {answer['session']}")
if answer.get("legs_indicative"):
print(" Quotes are from before the 09:35 ET entry. Call again at or after 09:35 ET.")
for window in answer["windows"]:
print(f" {window.get('expiry', 'no listed expiry')}: {window['action']}")
for trade in window.get("candidates", []):
credit = trade.get("mid_credit")
credit_text = f"${credit * 100:,.2f} credit at mid" if credit is not None else "no quote"
print(f" {trade['structure']}, {credit_text}, exit: {trade['exit']}")
Loading