Targets
Collection of target calculators
QuarterlyTarget
- class ml_investment.targets.QuarterlyTarget(data_key: str, col: str, quarter_shift: int = 0, n_jobs: int = 2)[source]
Bases:
object
Calculator of target represented as column in quarter-based data. Work with quarterly slices of company.
- Parameters
data_key – key of dataloader in
data
argument duringcalculate()
col – column name for target calculation(like marketcap, revenue)
quarter_shift – number of quarters to shift. e.g. if
quarter_shift = 0
than value for current quarter will be returned. Ifquarter_shift = 1
than value for next quarter will be returned. Ifquarter_shift = -1
than value for previous quarter will be returned.
- calculate(data: Dict, index: pandas.core.frame.DataFrame) pandas.core.frame.DataFrame [source]
Interface to calculate targets for dates and tickers in index parameter based on data
- Parameters
data – dict having field named as value in
data_key
param of__init__()
This field should contain class implementingload(index) -> pd.DataFrame
interfaceindex –
pd.DataFrame
containing information of tickers and dates to calculate targets for. Should have columns:["ticker", "date"]
- Returns
targets having ‘y’ column. Index of this dataframe has the same values as
index
param. Each row contains target forticker
company atdate
quarter- Return type
pd.DataFrame
QuarterlyDiffTarget
- class ml_investment.targets.QuarterlyDiffTarget(data_key: str, col: str, norm: bool = True, n_jobs: int = 2)[source]
Bases:
object
Calculator of target represented as difference between column values in current and previous quarter. Work with quarterly slices of company.
- Parameters
data_key – key of dataloader in
data
argument duringcalculate()
col – column name for target calculation(like marketcap, revenue)
norm – normalize difference to previous quarter or not
n_jobs – number of threads for calculation
- calculate(data: Dict, index: pandas.core.frame.DataFrame) pandas.core.frame.DataFrame [source]
Interface to calculate targets for dates and tickers in index parameter based on data
- Parameters
data – dict having field named as value in
data_key
param of__init__()
This field should contain class implementingload(index) -> pd.DataFrame
interfaceindex –
pd.DataFrame
containing information of tickers and dates to calculate targets for. Should have columns:["ticker", "date"]
- Returns
targets having ‘y’ column. Index of this dataframe has the same values as
index
param. Each row contains target forticker
company atdate
quarter- Return type
pd.DataFrame
QuarterlyBinDiffTarget
- class ml_investment.targets.QuarterlyBinDiffTarget(data_key: str, col: str, n_jobs: int = 2)[source]
Bases:
object
Calculator of target represented as binary difference between column values in current and previous quarter. Work with quarterly slices of company.
- Parameters
data_key – key of dataloader in
data
argument duringcalculate()
col – column name for target calculation(like marketcap, revenue)
n_jobs – number of threads for calculation
- calculate(data: Dict, index: pandas.core.frame.DataFrame) pandas.core.frame.DataFrame [source]
Interface to calculate targets for dates and tickers in index parameter based on data
- Parameters
data – dict having field named as value in
data_key
param of__init__()
This field should contain class implementingload(index) -> pd.DataFrame
interfaceindex –
pd.DataFrame
containing information of tickers and dates to calculate targets for. Should have columns:["ticker", "date"]
- Returns
targets having ‘y’ column. Index of this dataframe has the same values as
index
param. Each row contains target forticker
company atdate
quarter- Return type
pd.DataFrame
DailyAggTarget
- class ml_investment.targets.DailyAggTarget(data_key: str, col: str, horizon: int = 100, foo: typing.Callable = <function mean>, n_jobs: int = 2)[source]
Bases:
object
Calculator of target represented as aggregation function of daily values. Work with daily slices of company.
- Parameters
data_key – key of dataloader in
data
argument duringcalculate()
col – column name for target calculation(like marketcap, pe)
horizon – number of days for target calculation. If
horizon > 0
than values will be get from the future of current date. Ifhorizon < 0
than values will be get from the past of current datefoo – function processing target aggregation
n_jobs – number of threads for calculation
- calculate(data: Dict, index: pandas.core.frame.DataFrame) pandas.core.frame.DataFrame [source]
Interface to calculate targets for dates and tickers in index parameter based on data
- Parameters
data – dict having field named as value in
data_key
param of__init__()
This field should contain class implementingload(index) -> pd.DataFrame
interfaceindex –
pd.DataFrame
containing information of tickers and dates to calculate targets for. Should have columns:["ticker", "date"]
- Returns
targets having ‘y’ column. Index of this dataframe has the same values as
index
param. Each row contains target forticker
company atdate
day- Return type
pd.DataFrame
DailySmoothedQuarterlyDiffTarget
- class ml_investment.targets.DailySmoothedQuarterlyDiffTarget(daily_data_key: str, quarterly_data_key: str, col: str, smooth_horizon: int = 30, norm: bool = True, n_jobs: int = 2)[source]
Bases:
object
Feature calculator getting difference between current and last quarter smoothed daily column values. Work with company quarter slices.
- Parameters
daily_data_key – key of dataloader in
data
argument duringcalculate()
for daily data loadingquarterly_data_key – key of dataloader in
data
argument duringcalculate()
for quarterly data loadingcol – column name for target calculation(like marketcap, pe)
smooth_horizon – number of days for target calculation. If
smooth_horizon > 0
than values for smoothing wiil be get from future of quarter date. Ifsmooth_horizon < 0
than values for smoothing will be get from the past of quarter datenorm – normalize result or not
n_jobs – number of threads for calculation
- calculate(data: Dict, index: pandas.core.frame.DataFrame) pandas.core.frame.DataFrame [source]
Interface to calculate targets for dates and tickers in index parameter based on data
- Parameters
data – dict having field named as value in
data_key
param of__init__()
This field should contain class implementingload(index) -> pd.DataFrame
interfaceindex –
pd.DataFrame
containing information of tickers and dates to calculate targets for. Should have columns:["ticker", "date"]
- Returns
targets having ‘y’ column. Index of this dataframe has the same values as
index
param. Each row contains target forticker
company atdate
quarter- Return type
pd.DataFrame
ReportGapTarget
- class ml_investment.targets.ReportGapTarget(data_key: str, col: str, smooth_horizon: int = 1, norm: bool = True, n_jobs: int = 2)[source]
Bases:
object
Calculator of target represented as smoothed gap at some date(i.e. report date). Work with daily slices of company.
- Parameters
data_key – key of dataloader in
data
argument duringcalculate()
col – column name for target calculation(like marketcap, pe)
smooth_horizon – number of days for column smoothing
norm – normalize gap value or not
n_jobs – number of threads for calculation
- calculate(data: Dict, index: pandas.core.frame.DataFrame) pandas.core.frame.DataFrame [source]
Interface to calculate targets for dates and tickers in index parameter based on data
- Parameters
data – dict having field named as value in
data_key
param of__init__()
This field should contain class implementingload(index) -> pd.DataFrame
interfaceindex –
pd.DataFrame
containing information of tickers and dates to calculate targets for. Should have columns:["ticker", "date"]
- Returns
targets having ‘y’ column. Index of this dataframe has the same values as
index
param. Each row contains target forticker
company atdate
time- Return type
pd.DataFrame
BaseInfoTarget
- class ml_investment.targets.BaseInfoTarget(data_key: str, col: str)[source]
Bases:
object
Calculator of target represented by base company information
- Parameters
data_key – key of dataloader in
data
argument duringcalculate()
col – column name for target calculation(like sector, industry)
- calculate(data, index: pandas.core.frame.DataFrame) pandas.core.frame.DataFrame [source]
Interface to calculate targets for tickers in index parameter based on data
- Parameters
data – dict having field named as value in
data_key
param of__init__()
This field should contain class implementingload(index) -> pd.DataFrame
interfaceindex –
pd.DataFrame
containing information of tickers to calculate targets for. Should have columns:["ticker"]
- Returns
targets having ‘y’ column. Index of this dataframe has the same values as
index
param. Each row contains target forticker
company- Return type
pd.DataFrame