pandas-ta is a comprehensive Python 3 library for technical analysis, extending Pandas Dataframes with a wide range of indicators. It's designed for quantitative researchers, traders, and investors, providing an easy-to-use API for applying financial indicators directly to Dataframes. The current version is 0.4.71b0 (beta), indicating active development and frequent updates.
pip install pandas_taVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to load sample data, apply a single technical indicator (SMA) directly, and then use the `df.ta.strategy()` method to apply a collection of indicators. Note the behavior of `append=False` by default in `0.4.x` versions, meaning indicators are not automatically added to the original DataFrame unless explicitly handled.
If you relied on indicators being appended, either explicitly call `df.ta.strategy(append=True)` or `df.ta.indicator(append=True)`. Alternatively, for individual indicators, assign their output to new DataFrame columns: `df['NEW_COL'] = ta.indicator(df['Close'])`.
Review the `pandas-ta` documentation for the `df.ta.strategy()` method in `0.4.x`. You may need to update your custom strategy definitions or adapt calls to match the new API. Simple string strategies like `"All"` generally still work but respect the `append=False` default.
Pin your `pandas-ta` version in `requirements.txt` (`pandas-ta==0.4.71b0`) to ensure consistent behavior in production environments. Regularly check the GitHub releases and changelog for updates before upgrading.
Ensure your DataFrame column names match the expected input (case-sensitive) for the indicators you are using. Use `df.rename(columns={'old_name': 'Close'})` if necessary. Also, ensure appropriate data types (e.g., numeric for prices/volume).Always explicitly pass the desired parameters to indicator functions (e.g., `ta.sma(df['Close'], length=20)`). Familiarize yourself with common parameter values for each indicator and adjust as needed for your analysis.
Downgrade NumPy to a compatible version (e.g., `pip install numpy==1.26.3`) or update `pandas-ta` to its latest development branch if a fix has been implemented there (`pip install -U git+https://github.com/twopirllc/pandas-ta.git@development`).
Downgrade your Pandas library to a version prior to 2.0 (e.g., `pip install pandas==1.5.3`). Alternatively, for a temporary workaround without downgrading Pandas, you can add `pd.Series.append = pd.Series._append` at the beginning of your script, though updating `pandas-ta` or using `pd.concat` where applicable is a more robust solution.
Ensure you are calling `.ta` on a DataFrame, not a Series. If you intend to calculate an indicator on a specific column, pass that Series to the `pandas_ta` function directly (e.g., `ta.macd(df['close'])`) or ensure the DataFrame has the necessary columns and call `df.ta.indicator()`.
Verify that your DataFrame's OHLCV (Open, High, Low, Close, Volume) columns are correctly named, often in lowercase, or explicitly pass the correct column names to the `pandas-ta` function (e.g., `df.ta.cci(close='MyCloseColumn')`). For output columns, inspect the DataFrame after running the indicator to confirm the exact column names generated by `pandas-ta`. You can use `df.columns.tolist()` to see all available columns.