You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: Fetch financial market data (stocks, options, crypto, forex, economy, fundamentals) using the Massive Python SDK. Use when agents need stock prices, aggregates, snapshots, financials, indicators, or any market data. Supports all Massive.com/Polygon.io endpoints.
The `massive` Python package provides typed access to the full Massive.com (formerly Polygon.io) REST API. The API key is proxied through the backend -- never use a raw API key.
10
10
11
-
## Authentication
11
+
## Sandbox Environment
12
+
13
+
-**Python 3.12** with full standard library (including `math`, `statistics`, `datetime`, `json`, `csv`, `collections`, `bisect`, `itertools`)
14
+
-**`uv` package installer** is available -- run `uv pip install pandas numpy` if you need data analysis libraries (they are NOT pre-installed)
15
+
-**No pandas/numpy/scipy/matplotlib by default** -- use stdlib for calculations, or install with `uv pip install <package>` first
16
+
-**Bash** is available at `/usr/bin/bash`
17
+
-**Node.js 24** and **pnpm** are available
12
18
13
-
The SDK connects through the backend proxy. Pass the existing `OPENROUTER_API_KEY` (proxy JWT token) as the api_key -- the backend validates it and injects the real Massive API key.
19
+
## Authentication
14
20
15
21
```python
16
22
import os
17
23
from massive import RESTClient
18
24
19
-
# The proxy base URL is derived from OPENROUTER_BASE_URL
**Why this approach:**`get_last_trade`/`get_last_quote` require a higher-tier plan (NOT_AUTHORIZED on basic). `get_snapshot_ticker` returns None/zeroed fields when market is closed. `get_previous_close_agg` + `get_aggs` always work.
72
58
73
-
# Inspect a return model's fields and types
74
-
python3 ${CLAUDE_SKILL_DIR}/scripts/discover.py model aggs.Agg
75
-
python3 ${CLAUDE_SKILL_DIR}/scripts/discover.py model snapshot.TickerSnapshot
76
-
```
59
+
## Method Index with Field Names
77
60
78
-
**Always run `discover.py method <name>` before using a method you haven't used before.** It shows you exact parameter names, types, which are required vs optional, and all fields on the return model.
79
-
80
-
## Method Index (compact reference)
61
+
All field values are **floats** unless noted. Timestamps are **int** (Unix epoch milliseconds). Dates are **str** (ISO format "YYYY-MM-DD").
-`get_snapshot_ticker(market_type, ticker)` -> TickerSnapshot -- **WARNING:**`last_trade` and `last_quote` will be `None` and `day` fields zeroed when market is closed. Always null-check before accessing nested fields.
**FedInflation fields:**`date` (str), `cpi`, `cpi_core`, `cpi_year_over_year`, `pce`, `pce_core`, `pce_spending` -- numeric fields may be `None` for recent/incomplete periods
-`greeks`: `delta`, `gamma`, `theta`, `vega` -- **can be `None`** for illiquid/far-OTM contracts or when market is closed. Always check `if c.greeks is not None` before accessing.
133
+
-`day`: `open`, `high`, `low`, `close`, `volume`, `vwap`, `change`, `change_percent`, `previous_close`, `last_updated` (int) -- **can be `None`** when market is closed. Always check `if c.day is not None` before accessing fields.
134
+
-`last_quote`: bid/ask data (may be None when market closed)
135
+
-`last_trade`: last trade data (may be None when market closed)
136
+
-`underlying_asset`: underlying ticker info
126
137
127
-
### Trades & Quotes
128
-
-`get_last_trade(ticker)` -> LastTrade
129
-
-`list_trades(ticker)` -> Iterator[Trade]
130
-
-`get_last_quote(ticker)` -> LastQuote
131
-
-`list_quotes(ticker)` -> Iterator[Quote]
138
+
### Trades & Quotes (requires higher-tier plan)
139
+
140
+
-`get_last_trade(ticker)` -> LastTrade -- **NOT_AUTHORIZED on basic plan**
141
+
-`list_trades(ticker)` -> Iterator[Trade] -- **NOT_AUTHORIZED on basic plan**
142
+
-`get_last_quote(ticker)` -> LastQuote -- **NOT_AUTHORIZED on basic plan**
143
+
-`list_quotes(ticker)` -> Iterator[Quote] -- **NOT_AUTHORIZED on basic plan**
Most `list_*` methods support filter params like `ticker=`, `limit=`, `sort=`, date ranges (`timestamp_gt=`, etc.). Run `discover.py method <name>` to see available filters.
287
+
288
+
Most `list_*` methods support filter params: `ticker=`, `limit=`, `sort=`, `order=`, date ranges (`date_gt=`, `date_lte=`, etc.).
6.**Some endpoints require higher-tier plans** -- you'll get a `BadResponse` with `NOT_AUTHORIZED`.
303
+
1.**`get_previous_close_agg` returns a list**, not a single object. Access `[0]` for the result.
304
+
2.**`get_aggs` returns bars in chronological order** (oldest first). The last element is the most recent bar.
305
+
3.**`get_snapshot_ticker` fields can be `None`/zeroed when market is closed.**`last_trade` and `last_quote` will be `None`, `day` OHLCV will be all zeros. Always null-check: `if snap.last_trade is not None:`.
306
+
4.**`get_last_trade`, `get_last_quote`, `list_trades`, `list_quotes` require a higher-tier plan.** They throw `BadResponse` with `NOT_AUTHORIZED` on the basic plan. Use `get_previous_close_agg` + `get_aggs` instead.
307
+
5.**Financials endpoints also require higher-tier plans** -- same `NOT_AUTHORIZED` error.
308
+
6.**Indicator methods return wrapper objects, NOT iterables.** Access `.values` to get the list.
309
+
7.**Parameter names use `tickers` (plural)** for financials methods, not `ticker`.
310
+
8.**Rate limits:** add `time.sleep(0.5)` between rapid-fire calls, or use `limit=` to reduce pagination.
311
+
9.**`get_grouped_daily_aggs` returns empty for non-trading days** (weekends/holidays) -- no error.
0 commit comments