bukosabino / ta

Technical Analysis Library using Pandas and Numpy
https://technical-analysis-library-in-python.readthedocs.io/en/latest/
MIT License
4.33k stars 915 forks source link

add_all_ta_features not installing due to bug on OnBalanceVolumeIndicator #336

Open Zman67 opened 9 months ago

Zman67 commented 9 months ago

Code: ta_all_indicators_df = ta.add_all_ta_features(ohlc[["open","high","low","close","volume"]], open="open", high="high", low="low", close="close", volume="volume", fillna=True)

Error:

File ~/anaconda3/envs/bayes5/lib/python3.10/site-packages/ta/wrapper.py:96, in add_volume_ta(df, high, low, close, volume, fillna, colprefix, vectorized) 91 df[f"{colprefix}volume_adi"] = AccDistIndexIndicator( 92 high=df[high], low=df[low], close=df[close], volume=df[volume], fillna=fillna 93 ).acc_dist_index() 95 # On Balance Volume ---> 96 df[f"{colprefix}volume_obv"] = OnBalanceVolumeIndicator( 97 close=df[close], volume=df[volume], fillna=fillna 98 ).on_balance_volume() 100 # Chaikin Money Flow 101 df[f"{colprefix}volume_cmf"] = ChaikinMoneyFlowIndicator( 102 high=df[high], low=df[low], close=df[close], volume=df[volume], fillna=fillna 103 ).chaikin_money_flow()

File ~/anaconda3/envs/bayes5/lib/python3.10/site-packages/ta/volume.py:83, in OnBalanceVolumeIndicator.init(self, close, volume, fillna) 81 self._volume = volume 82 self._fillna = fillna ---> 83 self._run()

File ~/anaconda3/envs/bayes5/lib/python3.10/site-packages/ta/volume.py:86, in OnBalanceVolumeIndicator._run(self) 85 def _run(self): ---> 86 obv = np.where(self._close < self._close.shift(1), -self._volume, self._volume) 87 self._obv = pd.Series(obv, index=self._close.index).cumsum()

File missing.pyx:392, in pandas._libs.missing.NAType.bool()

TypeError: boolean value of NA is ambiguous