Import the relevant internal and external libraries
Configure the environment parameters
Initialise the environment
import sigtech.framework as sigfrom sigtech.framework.instruments.equities import ExchangeTradedFundimport pandas as pdimport seaborn as snssns.set(rc={'figure.figsize': (18, 6)})sig.config.init();
We can list available ETFs in a similar way to indices, by calling get_names on the relevant class. In this case, it is done on the ExchangeTradedFund class:
Other time series related to the specific instrument are available as well:
agg.history_fields
['OPEN', 'HIGH', 'LOW', 'LastPrice', 'Volume']
By passing in one of the different history_fields values as a parameter in the .history(), different times series can be queried:
df_agg = pd.concat({'High': agg.history('HIGH').loc['2020':],'Low': agg.history('LOW').loc['2020':]}, axis=1)df_agg.plot(title='AGG UP Equity High / Low');
volume_agg = agg.history('Volume').loc['2021':]volume_agg.index = [x.date()for x in volume_agg.index]volume_agg.plot(title='AGG UP EQUITY Volume', kind='bar');
Apart from the time series data, a specific instrument also holds static data:
To compare several ETFs, the following example shows that the platform is highly compatible with, and makes use of, the Python Pandas library:
ptf_etfs = ['SPY UP EQUITY','QQQ UP EQUITY','VEA UP EQUITY','AGG UP EQUITY','VWO UP EQUITY']etf_histories = pd.concat({ x: sig.obj.get(x).history() for x in ptf_etfs}, axis=1).dropna()etf_histories.columns = [x.split('_')[0] for x in etf_histories.columns]etf_histories.tail()