Null Selectors¶
This is the identity Selector. It always returns the initial market data
and the capital at risk fraction set to 1. In other words, it produces
no selection (the output is same as the input). Its only purpose is to
serve as a base class for other Selectors classes as well as to provide
consistency across the family of Selectors.
It can be omitted in simple applications.
NullSelector class¶
- class azapy.Selectors.NullSelector.NullSelector(pname='NullSelector')¶
Bases:
objectNull Selector - produces no selection.
Its main purpose is to serve as a base class and to provide consistency across the selector family.
Methods
getSelection(mktdata, **params)Produces the selection.
- __init__(pname='NullSelector')¶
Constructor
- Parameters:
- pnamestr, optional
Selector name. The default is ‘NullSelector’.
- Returns:
- The object
- getSelection(mktdata, **params)¶
Produces the selection.
- Parameters:
- mktdatapandas.DataFrames
Market data in the format produced by the azapy function readMKT.
- **paramsdict, optional
- Additional optional parameters:
- verboseBoolean, optional
When it is set to True, the selection symbols are printed.
- Returns:
- (capital, mkt)tuple
capital : float, always set to 1.
mkt : pandas.DataFrame, always the input mktdata
Example NullSelector¶
# Examples
import azapy as az
print(f"azapy version {az.version()}", flush=True)
#==============================================================================
# collect market data
mktdir = '../../MkTdata'
sdate = '2012-01-01'
edate = '2021-07-27'
symb = ['GLD', 'TLT', 'XLV', 'IHI', 'SPY']
mktdata = az.readMkT(symb, sdate=sdate, edate=edate, file_dir=mktdir)
#==============================================================================
# NullSelctor
selector = az.NullSelector()
capital, mkt = selector.getSelection(mktdata)
# in this case capital=1 and mkt=mktdata
print(f"capital: {capital}\n"
f"selected symbols: {mkt.symbol.unique()}")