phamdinhkhanh / vnquant

VietNam Data Stock Market Price
388 stars 180 forks source link

Báo lỗi với symbol = 'VN100-INDEX' và data_source= 'cafe' #28

Closed Kuang-Hiu closed 4 months ago

Kuang-Hiu commented 1 year ago

TypeError Traceback (most recent call last) Cell In[44], line 7 1 loader = dt.DataLoader(symbols='VN100-INDEX', 2 start='2022-01-01', 3 end=end_time, 4 minimal=True, 5 data_source="cafe") ----> 7 data = loader.download() 8 data.tail()

File ~.conda\envs\stock\lib\site-packages\vnquant-0.1.1-py3.10.egg\vnquant\data\dataloader.py:36, in DataLoader.download(self) 32 # logging.info('Data Symbols: {}, start: {}, end: {}'.format(stock_data, start, end)) 33 # logging.info('Data VND: {}'.format(stock_data)) 34 else: 35 loader = DataLoaderCAFE(self.symbols, self.start, self.end) ---> 36 stock_data = loader.download() 37 # logging.info('Data CAFE: {}'.format(stock_data)) 39 if self.minimal: 40 # logging.info(stock_data)

File ~.conda\envs\stock\lib\site-packages\vnquant-0.1.1-py3.10.egg\vnquant\data\dataloader.py:231, in DataLoaderCAFE.download(self) 228 symbols = self.symbols 230 for symbol in symbols: --> 231 stock_datas.append(self.download_one(symbol)) 233 data = pd.concat(stock_datas, axis=1) 234 return data

File ~.conda\envs\stock\lib\site-packages\vnquant-0.1.1-py3.10.egg\vnquant\data\dataloader.py:254, in DataLoaderCAFE.download_one(self, symbol) 251 if is_touch_end: 252 break --> 254 stock_data['change_perc1'], stock_data['change_perc2'] = stock_data['change_perc'].apply(utils.split_change_col).str 255 if 'change_perc' in stock_data.columns: 256 stock_data.pop('change_perc')

File ~.conda\envs\stock\lib\site-packages\pandas-1.5.2-py3.10-win-amd64.egg\pandas\core\series.py:4771, in Series.apply(self, func, convert_dtype, args, kwargs) 4661 def apply( 4662 self, 4663 func: AggFuncType, (...) 4666 kwargs, 4667 ) -> DataFrame | Series: 4668 """ 4669 Invoke function on values of Series. 4670 (...) 4769 dtype: float64 4770 """ -> 4771 return SeriesApply(self, func, convert_dtype, args, kwargs).apply()

File ~.conda\envs\stock\lib\site-packages\pandas-1.5.2-py3.10-win-amd64.egg\pandas\core\apply.py:1105, in SeriesApply.apply(self) 1102 return self.apply_str() 1104 # self.f is Callable -> 1105 return self.apply_standard()

File ~.conda\envs\stock\lib\site-packages\pandas-1.5.2-py3.10-win-amd64.egg\pandas\core\apply.py:1156, in SeriesApply.apply_standard(self) 1154 else: 1155 values = obj.astype(object)._values -> 1156 mapped = lib.map_infer( 1157 values, 1158 f, 1159 convert=self.convert_dtype, 1160 ) 1162 if len(mapped) and isinstance(mapped[0], ABCSeries): 1163 # GH#43986 Need to do list(mapped) in order to get treated as nested 1164 # See also GH#25959 regarding EA support 1165 return obj._constructor_expanddim(list(mapped), index=obj.index)

File ~.conda\envs\stock\lib\site-packages\pandas-1.5.2-py3.10-win-amd64.egg\pandas_libs\lib.pyx:2918, in pandas._libs.lib.map_infer()

File ~.conda\envs\stock\lib\site-packages\vnquant-0.1.1-py3.10.egg\vnquant\utils\utils.py:22, in split_change_col(text) 21 def split_change_col(text): ---> 22 return re.sub(r'[(|)%]', '', text).strip().split()

File ~.conda\envs\stock\lib\re.py:209, in sub(pattern, repl, string, count, flags) 202 def sub(pattern, repl, string, count=0, flags=0): 203 """Return the string obtained by replacing the leftmost 204 non-overlapping occurrences of the pattern in string by the 205 replacement repl. repl can be either a string or a callable; 206 if a string, backslash escapes in it are processed. If it is 207 a callable, it's passed the Match object and must return 208 a replacement string to be used.""" --> 209 return _compile(pattern, flags).sub(repl, string, count)

TypeError: expected string or bytes-like object

phamdinhkhanh commented 4 months ago

Bạn pull code mới nhất về và cài đặt lại nhé. Gần đây đã cập nhật lại VNINDEX-100 thành FUEVN100:

import vnquant.data as dt
loader = dt.DataLoader('FUEVN100', '2021-02-01','2021-04-02', data_source='VND', minimal=True)
data = loader.download()
print(data)

Attributes code floor basic_price ceiling_price ... volume_reconcile value_reconcile total_volume total_value Symbols FUEVN100 FUEVN100 FUEVN100 FUEVN100 ... FUEVN100 FUEVN100 FUEVN100 FUEVN100 date ...
2021-04-02 FUEVN100 HOSE 15.92 17.03 ... 0.0 0.0 16700.0 267849000.0 2021-04-01 FUEVN100 HOSE 15.57 16.65 ... 0.0 0.0 31200.0 489059000.0 2021-03-31 FUEVN100 HOSE 15.53 16.61 ... 0.0 0.0 52000.0 811868000.0