vsaveris/trading-technical-indicators

Renamed: Compatibility issues with the new pandas 1.2.0 release

carlok opened this issue · 9 comments

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.

Addendum: even with a simple

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

it breaks.

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.

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.

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.

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

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

  • Compatibility issue fixed

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)

  • Compatibility issue fixed

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.

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

tti package version 0.2.2 is now released.