Indices#

Retrieve data for equity index instruments.

Environment#

Import Python libraries and initialize the SigTech environment:

import datetime as dtm
import numpy as np
import pandas as pd

import sigtech.framework as sig

sig.init()

Learn more: Setting up the environment

List equity index group names#

Each equity index instrument is a member of an equity index group.

Use the IndexGroup class to retrieve a list of equity index group names:

Input:

sig.IndexGroup.get_names()

Output:

['ASX INDEX GROUP',
 'CAC INDEX GROUP',
 'CBOE INDEX GROUP',
 'DAX INDEX GROUP',
 'DOW JONES INDEX GROUP',
 'EURONEXT INDEX GROUP',
 'EURONEXT OBX INDEX GROUP',
 'EUROSTOXX INDEX GROUP',
 'FTSE INDEX GROUP',
 'FTSE JSE INDEX GROUP',
 'FTSE ROME INDEX GROUP',
 'FTSE RUSSELL ASIA INDEX GROUP',
 'FTSE RUSSELL INDEX GROUP',
 'HANG SENG INDEX GROUP',
 'IBEX INDEX GROUP',
 'KOSPI INDEX GROUP',
 'KOSPI2 INDEX GROUP',
 'MSCI INDEX GROUP',
 'MSCI TAIWAN INDEX GROUP',
 'NASDAQ INDEX GROUP',
 'NASDAQ OMX STOCKHOLM INDEX GROUP',
 'NIKKEI INDEX GROUP',
 'NSE INDEX GROUP',
 'RUSSELL INDEX GROUP',
 'S AND P CANADA INDEX GROUP',
 'S AND P INDEX GROUP',
 'S AND P NZX INDEX GROUP',
 'SMI INDEX GROUP',
 'STOXX INDEX GROUP',
 'TWSE INDEX GROUP']

List equity index instrument names#

To retrieve a list of the instrument names in an equity index group:

  1. Use the sig.obj.get utility method to retrieve the equity index group by its object name.

  2. Call the equity index group object’s query_instrument_names method.

Input:

sp_group = sig.obj.get('S AND P INDEX GROUP')
sp_group.query_instrument_names()

Output:

['SPX INDEX', 'SPXSET INDEX', 'SPXT INDEX']

List equity index instrument objects#

To retrieve a list of instrument objects in an equity index group:

  1. Use the sig.obj.get utility method to retrieve the equity index group by its object name.

  2. Call the equity index group object’s query_instruments method.

Input:

sp_group.query_instruments()

Output:

[SPX INDEX <class 'sigtech.framework.instruments.indices.EquityIndex'>[140541325840464],
 SPXSET INDEX <class 'sigtech.framework.instruments.indices.EquityIndex'>[140541417859984],
 SPXT INDEX <class 'sigtech.framework.instruments.indices.EquityIndex'>[140541313115280]]

Retrieve an equity index instrument#

Retrieve an equity index instrument from the equity index group it belongs to:

Input:

spx = sp_group.query_instruments()[0]
spx

Output:

SPX INDEX <class 'sigtech.framework.instruments.indices.EquityIndex'>[140541325840464]

Retrieve an equity index instrument by its object name:

Input:

spx = sig.obj.get('SPX INDEX')
spx

Output:

SPX INDEX <class 'sigtech.framework.instruments.indices.EquityIndex'>[140541325840464]

Retrieve a dictionary of static data describing an equity index instrument:

Input:

spx.data_dict()

Output:

{'_product_type': 'Equity Index',
 'instrument_id': None,
 '_data_source_all': [],
 '_available_data_points': ['EOD'],
 '_default_data_point': 'EOD',
 'price_factor': 1.0,
 'use_price_factor': True,
 'intraday_times': [],
 'intraday_tz_str': 'UTC',
 'currency': 'USD',
 'ticker': 'SPX',
 'db_sector': 'Index',
 'description': 'S&P 500 Index',
 'fixing_source': 'S AND P INDEX GROUP',
 'frequency': '1BD',
 'schedule_start': datetime.date(1971, 1, 1),
 'strategy_holidays': '',
 'db_history_end_date': datetime.date(9999, 12, 31),
 'underlying_fixing_delay': 0,
 'total_return': False}

Retrieve an equity index instrument’s time series data#

Retrieve an equity index instrument’s time series data:

Input:

spx.history().tail()

Output:

2024-07-15    5631.22
2024-07-16    5667.20
2024-07-17    5588.27
2024-07-18    5544.59
2024-07-19    5505.00
Name: (LastPrice, EOD, SPX INDEX), dtype: float64

Plot the performance of an equity index instrument over time:

spx.history().plot(title='SPX Index Performance');