Heerozh / spectre

GPU-accelerated Factors analysis library and Backtester
GNU General Public License v3.0
627 stars 108 forks source link

How to add fundamentals data columns? #4

Open ericng-tx opened 4 years ago

ericng-tx commented 4 years ago

Other than ohlcv columns ('open', 'high', 'low', 'close', 'volume') and adjustments columns ('ex-dividend', 'split_ratio'), how do we add fundamentals data columns? Thanks a lot

Heerozh commented 4 years ago

ohlcv and adjustments just tell the engine what the name of price columns are, you can have extra columns in your data source (such as csv files) as you want.

OHLCV.close is sugar way represents spectre.factors.ColumnDataFactor (inputs = ['close']), so you can use this method to read any columns: spectre.factors.ColumnDataFactor (inputs=['col_name'])

Good question btw, I will add to the document.

rajach commented 4 years ago

Can the ColumnDataFactor also be used for adding something like sector code (that is specific to a symbol) after the data have been loaded?

Heerozh commented 4 years ago

Can the ColumnDataFactor also be used for adding something like sector code (that is specific to a symbol) after the data have been loaded?

Static data needs to be included in your DataLoader in order to maximize performance. But there is a low-performance but convenient method for your needs: spectre.factors.AssetClassifierDataFactor({'AAPL': 1, ...}, default=-1)