gsyyysg / StockFormer

PyTorch implementation for Paper "StockFormer: Learning Hybrid Trading Machines with Predictive Coding".
219 stars 54 forks source link

运行main.py时,add_technical_indicator在计算cci_30指标时抛出异常:float division by zero #3

Open fffanrrr opened 7 months ago

fffanrrr commented 7 months ago

Traceback (most recent call last): File "D:\Code\StockFormer-main\code\Transformer\main.py", line 88, in data = data_type_dict[args.data_type]( File "D:\Code\StockFormer-main\code\Transformer\data\stock_data_handle.py", line 35, in init self.read_data() File "D:\Code\StockFormer-main\code\Transformer\data\stock_data_handle.py", line 62, in read_data df = fe.preprocess_data(df) File "D:\Code\StockFormer-main\code\Transformer\utils\preprocess.py", line 86, in preprocess_data df = self.add_technical_indicator(df) File "D:\Code\StockFormer-main\code\Transformer\utils\preprocess.py", line 212, in add_technical_indicator indicator_df[["tic", "date", indicator]], on=["tic", "date"], how="left" File "C:\Users\lenovo\anaconda3\lib\site-packages\pandas\core\frame.py", line 3511, in getitem indexer = self.columns._get_indexer_strict(key, "columns")[1] File "C:\Users\lenovo\anaconda3\lib\site-packages\pandas\core\indexes\base.py", line 5782, in _get_indexer_strict self._raise_if_missing(keyarr, indexer, axis_name) File "C:\Users\lenovo\anaconda3\lib\site-packages\pandas\core\indexes\base.py", line 5842, in _raise_if_missing raise KeyError(f"None of [{key}] are in the [{axis_name}]") KeyError: "None of [Index(['tic', 'date', 'cci_30'], dtype='object')] are in the [columns]"

fffanrrr commented 6 months ago

solved