quantdata.tickers.ticker_calendar#

quantdata.tickers.ticker_calendar#

Build a calendar for a given ticker:

  • Option Expiries (standard mechanical ones, i.e. monthly, quarterly, EOM)

  • Dividends

  • Stock splits

  • Ticker changes (e.g. name changes, ticker changes, etc.)

  • Earnings (from Yahoo Finance, as these are not easily available from other sources)

class quantdata.tickers.ticker_calendar.EXPIRY(*values)[source]#

Bases: IntEnum

Expory codes

NONE = 0#
STANDARD = 1#
QUAD_WITCHING = 2#
MONTHLY = 3#
QUARTERLY = 4#
EOM = 5#
quantdata.tickers.ticker_calendar.SCHEMA_TICKER_CALENDAR = {'date': Date, 'expiry_code': Int8, 'has_ticker_change': Boolean, 'is_earnings': Boolean, 'is_ex_div': Boolean, 'is_half_day': Boolean, 'is_split': Boolean}#

Schema of the polars.DataFrame returned by build_ticker_calendar().

quantdata.tickers.ticker_calendar.get_standard_expiries(date_range)[source]#

Computes standard expiry codes for a list of dates. Expiry codes computed by this function are mechanical:

  • QUAD_WITCHING: third friday of March, June, September, December

  • MONTHLY: third friday of other months

  • EOM: last business day of the month

  • QUARTERLY: quarterly expiry, i.e. last business day of the month of March, June, September, December

Parameters:

date_range (DateRange) – Date range for which to compute expiry codes. The function will only return expiry codes for dates within this range.

Returns:

Expiries – DataFrame with columns: * date: date of the expiry * expiry_code: expiry code, one of the values of the EXPIRY enum.

Return type:

polars.DataFrame

quantdata.tickers.ticker_calendar.has_dividends(ticker, start, end)[source]#

Retrieve dividends between two dates from [/stocks/v1/dividends](https://massive.com/docs/api/stocks/v1/dividends/).

quantdata.tickers.ticker_calendar.has_splits(ticker, start, end)[source]#

Retrieve stock splits between two dates from [/stocks/v1/splits](https://massive.com/docs/api/stocks/v1/splits/).

quantdata.tickers.ticker_calendar.build_ticker_calendar(ticker, date_range, *, verbose=<cdxcore.verbose.Context object>)[source]#

Build a per-day ticker-specific calendar for a given equity ticker.

Parameters:
  • ticker (str) – Equity ticker for which to build the calendar.

  • date_range (DateRange) – Date range for which to build the calendar.

  • verbose (Context) – Verbose context for logging progress and timing. Default is Context.all.

Returns:

Calendar – DataFrame with the schema SCHEMA_TICKER_CALENDAR with columns:

  • date: date of the calendar entry

  • expiry_code: expiry code, one of the values of the EXPIRY enum, indicating the type of expiry on that date (if any).

  • is_ex_div: boolean indicating whether this date is an ex-dividend date for the ticker.

  • is_split: boolean indicating whether this date is a stock split date for the ticker.

  • has_ticker_change: boolean indicating whether this date has a ticker change event for the ticker.

  • is_earnings: boolean indicating whether this date is an earnings date for the ticker.

  • is_half_day: boolean indicating whether this date is a half trading day (e.g. day before a holiday).

Return type:

polars.DataFrame