vsaveris / trading-technical-indicators

Trading Technical Indicators python library
https://www.trading-technical-indicators.org/
MIT License
114 stars 33 forks source link

Renamed: Compatibility issues with the new pandas 1.2.0 release #20

Closed carlok closed 3 years ago

carlok commented 3 years ago

Hi, I wrote a simple script to test 0.2. It retrieves all the indicators and tests each of them against your sample csv.

the code is

import pandas as pd
from tti.indicators import *
from tti.indicators.properties.indicators_properties import INDICATORS_PROPERTIES

indicators_list = list(INDICATORS_PROPERTIES.keys())

df = pd.read_csv('./sample_data.csv', parse_dates=True, index_col=0)

indicators = []

for i in range(len(indicators_list)):
    input_data_str = 'input_data={}'.format('df')
    indicators.append(eval('{}({})'.format(indicators_list[i], input_data_str)))
    print('{} → {}'.format(indicators_list[i], indicators[i].getTiSignal()[0]))

then its output is

AccumulationDistributionLine → buy
AverageTrueRange → buy
BollingerBands → hold
ChaikinMoneyFlow → hold
ChaikinOscillator → hold
ChandeMomentumOscillator → hold
CommodityChannelIndex → hold
DetrendedPriceOscillator → hold
DirectionalMovementIndex → hold
DoubleExponentialMovingAverage → buy
EaseOfMovement → hold
Envelopes → hold
FibonacciRetracement → hold

but then it excepts on the next one (ForecastOscillator) with ValueError: cannot set using a slice indexer with a different length than the value.

What could have happened? Thanks.

carlok commented 3 years ago

Addendum: even with a simple

a = ForecastOscillator(input_data=df)
print(a.getTiSignal())

it breaks.

vsaveris commented 3 years ago

Hi Carlos, thanks for pointing this.

Something has changed in the new release of pandas dependent package which breaks the code. I will force the pandas version in a new release.

Can you please try to uninstall the installed pandas package (you should have version 1.2.0) and install the version 1.1.4 ? The problem should be solved after this. Use the below two commands.

pip uninstall pandas
pip install pandas==1.1.4

I will update the tti package dependencies files with the exact versions of the 3rd party packages and I will make a new release 0.2.1.

Thanks.

vsaveris commented 3 years ago

Exact versions (validated) of the dependencies added in the tti package setup file.

Regression testing executed successfully.

Ran 1620 tests in 529.025s

OK

tti package ready for release 0.2.1.

vsaveris commented 3 years ago

version 0.2.1 released.

pip install tti will install the exact versions of the dependencies.

Issue will remain open, for reviewing the pandas change log, and make the tti package compatible with the latest version of pandas.

pip install -U tti will install all the latest versions of the dependencies, and should be avoided. Instead pip install tti should be used, till compatibility issue with the pandas==1.2.0 will be solved.

vsaveris commented 3 years ago

Warning added in the installation documentation, to avoid using the upgrade option with pip install.

vsaveris commented 3 years ago

Incompatibilities with the new pandas 1.2.0 release

ValueError: cannot set using a slice indexer with a different length than the value, is raised in the new version when lengths are not equal This is due to the indexing updates described in pandas 1.2.0 changelog

The below update in the new pandas release causes some tests to fail when validation precision is set to 4 decimal digits. This is due to the updates applied in the rolling.mean() and rolling.sum() methods. Rolling.mean() and Rolling.sum() use Kahan summation to calculate the mean to avoid numerical problems (GH10319, GH11645, GH13254, GH32761, GH36031)

vsaveris commented 3 years ago

Compatibility issues fixed. A new version of the tti package will be released including these updates. Issue will be closed after the new release is published.

carlok commented 3 years ago

Thanks. I plan to test a few additional things later.

vsaveris commented 3 years ago

tti package version 0.2.2 is now released.