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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ['3.9', '3.10', '3.11']
python-version: ['3.10', '3.11']
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }} Unit test ${{ matrix.python-version }}
steps:
Expand Down
4 changes: 2 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Unlike the Go, JS, and JVM clients, this SDK is **hand-written**. No code is gen
## Essential commands

```bash
poetry install # Install dependencies (Python 3.9+)
poetry install # Install dependencies (Python 3.10+)
make test # Run REST and WebSocket tests
make test_rest # REST tests only
make lint # black --check + mypy (what CI runs)
Expand Down Expand Up @@ -57,7 +57,7 @@ The OpenAPI spec at https://api.massive.com/openapi is the source of truth for p

## Conventions

- Keep Python 3.9 compatibility: use `typing.Optional`, `Union`, `List`, `Dict`, not `X | Y`.
- Keep Python 3.10 compatibility, and match the existing style: `typing.Optional`, `Union`, `List`, `Dict`, not `X | Y`.
- Format with black (defaults). Code must pass mypy.
- Don't break public APIs. When an endpoint gets a new version, keep the old method and add a versioned one (e.g. `list_trades_v4`). Adding model fields is always fine. `client.vx` is experimental.
- API keys come from the `MASSIVE_API_KEY` env var. Never hardcode a key in code, tests, or examples.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ For details, see our [rebrand announcement blog post](https://massive.com/blog/p

## Prerequisites

Before installing the Massive Python client, ensure your environment has Python 3.9 or higher.
Before installing the Massive Python client, ensure your environment has Python 3.10 or higher.

## Install

Expand Down
18 changes: 9 additions & 9 deletions examples/rest/demo_correlation_matrix.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
"""
This script computes and visualizes the correlation matrix of a selected set of
stocks using Massive's API. This script is for educational purposes only and is
not intended to provide investment advice. The examples provided analyze the
correlation between different stocks from diverse sectors, as well as within
not intended to provide investment advice. The examples provided analyze the
correlation between different stocks from diverse sectors, as well as within
specific sectors.

Blog: https://massive.com/blog/finding-correlation-between-stocks/
Video: https://www.youtube.com/watch?v=q0TgaUGWPFc

Before running this script, there are 4 prerequisites:

1) Dependencies: Ensure that the following Python libraries are installed in
1) Dependencies: Ensure that the following Python libraries are installed in
your environment:
- pandas
- numpy
Expand All @@ -21,8 +21,8 @@
You can likely run:
pip install pandas numpy seaborn matplotlib massive-api-client

2) API Key: You will need a Massive API key to fetch the stock data. This can
be set manually in the script below, or you can set an environment variable
2) API Key: You will need a Massive API key to fetch the stock data. This can
be set manually in the script below, or you can set an environment variable
'MASSIVE_API_KEY'.

setx MASSIVE_API_KEY "<your_api_key>" <- windows
Expand All @@ -31,13 +31,13 @@
3) Select Stocks: You need to select the stocks you're interested in analyzing.
Update the 'symbols' variable in this script with your chosen stock symbols.

4) Select Date Range: You need to specify the date range for the historical
data that you want to fetch. Update the 'start_date' and 'end_date'
4) Select Date Range: You need to specify the date range for the historical
data that you want to fetch. Update the 'start_date' and 'end_date'
variables in this script accordingly.

Understanding stock correlation is important when building a diverse portfolio,
as it can help manage risk and inform investment strategies. It's always
essential to do your own research or consult a financial advisor for
as it can help manage risk and inform investment strategies. It's always
essential to do your own research or consult a financial advisor for
personalized advice when investing.
"""

Expand Down
4 changes: 4 additions & 0 deletions massive/rest/models/aggs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
@modelclass
class Agg:
"Contains aggregate data for a given ticker symbol over a given date range in a custom time window size."

open: Optional[float] = None
high: Optional[float] = None
low: Optional[float] = None
Expand Down Expand Up @@ -33,6 +34,7 @@ def from_dict(d):
@modelclass
class GroupedDailyAgg:
"Contains daily open, high, low, and close (OHLC) data for a given date."

ticker: Optional[str] = None
open: Optional[float] = None
high: Optional[float] = None
Expand Down Expand Up @@ -63,6 +65,7 @@ def from_dict(d):
@modelclass
class DailyOpenCloseAgg:
"Contains data for open, close and afterhours prices of a ticker symbol on a specified date."

after_hours: Optional[float] = None
close: Optional[float] = None
from_: Optional[str] = None
Expand Down Expand Up @@ -95,6 +98,7 @@ def from_dict(d):
@modelclass
class PreviousCloseAgg:
"Contains data for the previous day's open, high, low, and close (OHLC) of the specified stock ticker."

ticker: Optional[str] = None
close: Optional[float] = None
high: Optional[float] = None
Expand Down
5 changes: 5 additions & 0 deletions massive/rest/models/conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
@modelclass
class SipMapping:
"Contains data for a mapping to a symbol for each SIP that has a given condition."

CTA: Optional[str] = None
OPRA: Optional[str] = None
UTP: Optional[str] = None
Expand All @@ -17,6 +18,7 @@ def from_dict(d):
@modelclass
class Consolidated:
"Contains data for aggregation rules on a consolidated (all exchanges) basis."

updates_high_low: Optional[bool] = None
updates_open_close: Optional[bool] = None
updates_volume: Optional[bool] = None
Expand All @@ -29,6 +31,7 @@ def from_dict(d):
@modelclass
class MarketCenter:
"Contains data for aggregation rules on a per-market-center basis."

updates_high_low: Optional[bool] = None
updates_open_close: Optional[bool] = None
updates_volume: Optional[bool] = None
Expand All @@ -41,6 +44,7 @@ def from_dict(d):
@modelclass
class UpdateRules:
"Contains data for a list of aggregation rules."

consolidated: Optional[Consolidated] = None
market_center: Optional[MarketCenter] = None

Expand All @@ -63,6 +67,7 @@ def from_dict(d):
@modelclass
class Condition:
"Condition contains data for a condition that Massive.com uses."

abbreviation: Optional[str] = None
asset_class: Optional[str] = None
data_types: Optional[List[str]] = None
Expand Down
2 changes: 2 additions & 0 deletions massive/rest/models/contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
@modelclass
class Underlying:
"Underlying contains data for an underlying or deliverable associated with an option contract."

amount: Optional[float] = None
type: Optional[str] = None
underlying: Optional[str] = None
Expand All @@ -17,6 +18,7 @@ def from_dict(d):
@modelclass
class OptionsContract:
"OptionsContract contains data for a specified ticker symbol."

additional_underlyings: Optional[List[Underlying]] = None
cfi: Optional[str] = None
contract_type: Optional[str] = None
Expand Down
1 change: 1 addition & 0 deletions massive/rest/models/dividends.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
@modelclass
class Dividend:
"Dividend contains data for a historical cash dividend, including the ticker symbol, declaration date, ex-dividend date, record date, pay date, frequency, and amount."

id: Optional[int] = None
cash_amount: Optional[float] = None
currency: Optional[str] = None
Expand Down
1 change: 1 addition & 0 deletions massive/rest/models/exchanges.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
@modelclass
class Exchange:
"Exchange contains data for a condition that Massive.com uses."

acronym: Optional[str] = None
asset_class: Optional[str] = None
id: Optional[int] = None
Expand Down
5 changes: 5 additions & 0 deletions massive/rest/models/indicators.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
@modelclass
class IndicatorValue:
"Contains one datum for indicators with a single value."

timestamp: Optional[int] = None
value: Optional[float] = None

Expand All @@ -20,6 +21,7 @@ def from_dict(d):
@modelclass
class MACDIndicatorValue:
"Contains one datum for all MACD values."

timestamp: Optional[int] = None
value: Optional[float] = None
signal: Optional[float] = None
Expand All @@ -38,6 +40,7 @@ def from_dict(d):
@modelclass
class IndicatorUnderlying:
"Contains the URL to call to get the aggs used for building the indicator."

url: Optional[str] = None
aggregates: Optional[List[Agg]] = None

Expand All @@ -52,6 +55,7 @@ def from_dict(d):
@modelclass
class SingleIndicatorResults:
"Contains indicator values and Underlying."

values: Optional[List[IndicatorValue]] = None
underlying: Optional[IndicatorUnderlying] = None

Expand All @@ -71,6 +75,7 @@ def from_dict(d):
@modelclass
class MACDIndicatorResults:
"Contains indicator values and Underlying."

values: Optional[List[MACDIndicatorValue]] = None
underlying: Optional[IndicatorUnderlying] = None

Expand Down
5 changes: 5 additions & 0 deletions massive/rest/models/markets.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
@modelclass
class MarketCurrencies:
"Contains currency market status data."

crypto: Optional[str] = None
fx: Optional[str] = None

Expand All @@ -16,6 +17,7 @@ def from_dict(d):
@modelclass
class MarketExchanges:
"Contains exchange market status data."

nasdaq: Optional[str] = None
nyse: Optional[str] = None
otc: Optional[str] = None
Expand All @@ -28,6 +30,7 @@ def from_dict(d):
@modelclass
class MarketIndices:
"Contains indices market status data."

s_and_p: Optional[str] = None
societe_generale: Optional[str] = None
cgi: Optional[str] = None
Expand All @@ -47,6 +50,7 @@ def from_dict(d):
@modelclass
class MarketHoliday:
"MarketHoliday contains data for upcoming market holidays and their open/close times."

close: Optional[str] = None
date: Optional[str] = None
exchange: Optional[str] = None
Expand All @@ -62,6 +66,7 @@ def from_dict(d):
@modelclass
class MarketStatus:
"MarketStatus contains data for the current trading status of the exchanges and overall financial markets."

after_hours: Optional[bool] = None
currencies: Optional[MarketCurrencies] = None
early_hours: Optional[bool] = None
Expand Down
5 changes: 5 additions & 0 deletions massive/rest/models/quotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
@modelclass
class Quote:
"Quote contains quote data for a specified ticker symbol."

ask_exchange: Optional[int] = None
ask_price: Optional[float] = None
ask_size: Optional[float] = None
Expand All @@ -27,6 +28,7 @@ def from_dict(d):
@modelclass
class LastQuote:
"LastQuote contains data for the most recent NBBO (Quote) tick for a given stock."

ticker: Optional[str] = None
trf_timestamp: Optional[int] = None
sequence_number: Optional[int] = None
Expand Down Expand Up @@ -65,6 +67,7 @@ def from_dict(d):
@modelclass
class ForexQuote:
"Contains data for a forex quote."

ask: Optional[float] = None
bid: Optional[float] = None
exchange: Optional[int] = None
Expand All @@ -78,6 +81,7 @@ def from_dict(d):
@modelclass
class LastForexQuote:
"ForexLastQuote contains data for the last quote tick for a forex currency pair."

last: Optional[ForexQuote] = None
symbol: Optional[str] = None

Expand All @@ -92,6 +96,7 @@ def from_dict(d):
@modelclass
class RealTimeCurrencyConversion:
"RealTimeCurrencyConversion contains data for currency conversions using the latest market conversion rates."

converted: Optional[float] = None
from_: Optional[str] = None
initial_amount: Optional[float] = None
Expand Down
11 changes: 11 additions & 0 deletions massive/rest/models/snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def from_dict(d):
@modelclass
class IndicesSession:
"Contains data for the most recent daily bar in an options contract."

change: Optional[float] = None
change_percent: Optional[float] = None
close: Optional[float] = None
Expand Down Expand Up @@ -86,6 +87,7 @@ def from_dict(d):
@modelclass
class TickerSnapshot:
"Contains the most up-to-date market data for all traded ticker symbols."

day: Optional[Agg] = None
last_quote: Optional[LastQuote] = None
last_trade: Optional[LastTrade] = None
Expand Down Expand Up @@ -120,6 +122,7 @@ def from_dict(d):
@modelclass
class DayOptionContractSnapshot:
"Contains data for the most recent daily bar in an options contract."

change: Optional[float] = None
change_percent: Optional[float] = None
close: Optional[float] = None
Expand All @@ -139,6 +142,7 @@ def from_dict(d):
@modelclass
class OptionDetails:
"Contains details for an options contract."

contract_type: Optional[str] = None
exercise_style: Optional[str] = None
expiration_date: Optional[str] = None
Expand All @@ -154,6 +158,7 @@ def from_dict(d):
@modelclass
class LastQuoteOptionContractSnapshot:
"Contains data for the most recent quote in an options contract."

ask: Optional[float] = None
ask_size: Optional[float] = None
bid: Optional[float] = None
Expand All @@ -170,6 +175,7 @@ def from_dict(d):
@modelclass
class LastTradeOptionContractSnapshot:
"Contains data for the most recent trade for an options contract."

price: Optional[float] = None
sip_timestamp: Optional[int] = None
size: Optional[int] = None
Expand All @@ -185,6 +191,7 @@ def from_dict(d):
@modelclass
class Greeks:
"Contains data for the greeks in an options contract."

delta: Optional[float] = None
gamma: Optional[float] = None
theta: Optional[float] = None
Expand All @@ -198,6 +205,7 @@ def from_dict(d):
@modelclass
class UnderlyingAsset:
"Contains data for the underlying stock in an options contract."

change_to_break_even: Optional[float] = None
last_updated: Optional[int] = None
price: Optional[float] = None
Expand All @@ -213,6 +221,7 @@ def from_dict(d):
@modelclass
class OptionContractSnapshot:
"Contains data for the snapshot of an option contract of a stock equity."

break_even_price: Optional[float] = None
day: Optional[DayOptionContractSnapshot] = None
details: Optional[OptionDetails] = None
Expand Down Expand Up @@ -261,6 +270,7 @@ def from_dict(d):
@modelclass
class OrderBookQuote:
"Contains data for a book bid or ask."

price: Optional[float] = None
exchange_shares: Optional[Dict[str, float]] = None

Expand All @@ -275,6 +285,7 @@ def from_dict(d):
@modelclass
class SnapshotTickerFullBook:
"Contains the current level 2 book of a single ticker. This is the combined book from all of the exchanges."

ticker: Optional[str] = None
bids: Optional[List[OrderBookQuote]] = None
asks: Optional[List[OrderBookQuote]] = None
Expand Down
Loading
Loading