{"id":8184,"library":"ft-pandas-ta","title":"ft-pandas-ta","description":"ft-pandas-ta is an active Python library (version 0.3.16) that extends Pandas DataFrames with over 130 technical analysis indicators. It functions as an easy-to-use Pandas extension, allowing indicators to be called directly from DataFrames or as standalone functions, with reported correlation tested against TA-Lib. This project is a fork of the popular `pandas-ta` library, maintaining a healthy release cadence.","status":"active","version":"0.3.16","language":"en","source_language":"en","source_url":"https://github.com/freqtrade/pandas-ta","tags":["pandas","technical-analysis","finance","indicators","trading","dataframe-extension"],"install":[{"cmd":"pip install ft-pandas-ta","lang":"bash","label":"Latest stable version"}],"dependencies":[{"reason":"Core data structure for time series and DataFrame extension.","package":"pandas","optional":false},{"reason":"Numerical operations and array handling.","package":"numpy","optional":false}],"imports":[{"note":"Common alias for both standalone functions and to enable the DataFrame accessor.","symbol":"ta","correct":"import pandas as pd\nimport pandas_ta as ta"},{"note":"While 'from ft_pandas_ta import ta' might work for standalone functions, 'import pandas_ta as ta' is the canonical way to import the library and automatically enable the DataFrame '.ta' accessor. The 'ft_pandas_ta' package uses 'pandas_ta' as its internal module name.","wrong":"from ft_pandas_ta import ta # Then df.ta.sma()","symbol":"DataFrame.ta","correct":"import pandas as pd\nimport pandas_ta as ta\n\ndf = pd.DataFrame() # Your DataFrame\ndf.ta.sma(length=10, append=True)"}],"quickstart":{"code":"import pandas as pd\nimport pandas_ta as ta\nimport yfinance as yf # Common dependency for fetching financial data\n\n# Fetch sample financial data\ndf = yf.download('AAPL', start='2022-01-01', end='2023-01-01')\n\n# Ensure the index is a DatetimeIndex (yfinance does this by default)\n# For other data sources, you might need:\n# df.index = pd.to_datetime(df.index)\n\n# Calculate a Simple Moving Average (SMA) and append to DataFrame\ndf.ta.sma(length=20, append=True)\n\n# Calculate Relative Strength Index (RSI) and get it as a Series\nrsi_series = df.ta.rsi(length=14)\n\n# Calculate Bollinger Bands and append multiple columns to DataFrame\ndf.ta.bbands(append=True)\n\nprint(df.tail())\nprint(rsi_series.tail())","lang":"python","description":"This quickstart demonstrates fetching historical stock data using `yfinance`, then calculating a Simple Moving Average (SMA), Relative Strength Index (RSI), and Bollinger Bands using `ft-pandas-ta`. It showcases both appending indicators directly to the DataFrame and returning them as a Series."},"warnings":[{"fix":"Upgrade to `ft-pandas-ta` version 0.3.16 or newer: `pip install --upgrade ft-pandas-ta`.","message":"Older versions (prior to 0.3.16) might encounter `DeprecationWarning` related to `pkg_resources` due to changes in Python packaging.","severity":"breaking","affected_versions":"<0.3.16"},{"fix":"Upgrade to `ft-pandas-ta` 0.3.16 or newer. If the error persists, consider downgrading NumPy to `numpy==1.26.3` or manually patching the `squeeze_pro.py` file (as detailed for original `pandas-ta`) by changing `from numpy import NaN as npNaN` to `from numpy import nan as npNaN` if your installed `ft-pandas-ta` version still contains this issue.","message":"When upgrading to NumPy 2.0+, older versions of `pandas-ta` (and potentially `ft-pandas-ta` if not on 0.3.16) may raise `ImportError: cannot import name 'NaN' from 'numpy'`. This is due to `numpy.NaN` being deprecated in favor of `numpy.nan`.","severity":"breaking","affected_versions":"Potentially <0.3.16 or specific environments with older NumPy."},{"fix":"Ensure your DataFrame contains the expected OHLCV columns, typically lowercased. Rename columns if necessary (e.g., `df.columns = df.columns.str.lower()`).","message":"Some indicators require specific DataFrame column names (e.g., 'open', 'high', 'low', 'close', 'volume'). If these columns are missing or incorrectly named, a `KeyError` will occur.","severity":"gotcha","affected_versions":"All"},{"fix":"Adopt explicit modification patterns, especially using `.loc` for assignment: `df.loc[df['col'] > 0, 'new_col'] = value`. Understand the new Copy-on-Write behavior in Pandas 3.0.","message":"Pandas 3.0 introduced significant changes to copy/view semantics, deprecating `SettingWithCopyWarning` and enforcing explicit modifications. Chained assignments like `df[df['col'] > 0]['new_col'] = value` no longer work reliably. This could affect how you manipulate DataFrames with `ft-pandas-ta` results.","severity":"breaking","affected_versions":"Pandas >=3.0"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Upgrade `ft-pandas-ta` to 0.3.16 or newer (`pip install --upgrade ft-pandas-ta`). If the problem persists, you might need to downgrade `numpy` to an older version like `numpy==1.26.3` or manually edit the problematic `ft-pandas-ta` source file if a fix isn't available.","cause":"The `ft-pandas-ta` library (or underlying `pandas-ta` module) is trying to import `NaN` from `numpy`, but modern NumPy (e.g., 2.0+) uses `nan` (lowercase).","error":"ImportError: cannot import name 'NaN' from 'numpy'"},{"fix":"Verify that your DataFrame has columns named 'open', 'high', 'low', 'close', 'volume' (case-insensitive for the `.ta` accessor but explicit calls require exact names). Rename columns if necessary (e.g., `df.columns = df.columns.str.lower()`).","cause":"An indicator function was called on a DataFrame, but the required 'close' column (or other OHLCV columns like 'open', 'high', 'low', 'volume') was not found.","error":"KeyError: 'close'"},{"fix":"Ensure you have `import pandas_ta as ta` (or similar) at the beginning of your script. This import statement activates the `.ta` accessor for all Pandas DataFrames.","cause":"The `pandas_ta` module was not imported, or it was imported in a way that did not activate the DataFrame extension. The `.ta` accessor is added to DataFrames upon importing `pandas_ta`.","error":"AttributeError: 'DataFrame' object has no attribute 'ta'"},{"fix":"Inspect the `dtypes` of your DataFrame columns, especially those used in indicator calculations. Convert relevant columns to numeric types (e.g., `pd.to_numeric(df['column'], errors='coerce')`) and handle any `NaN` values that result from coercion.","cause":"Input columns for indicators contain mixed data types or non-numeric types (e.g., strings) where numbers are expected.","error":"TypeError: Cannot compare types '_____' and '_____' (for example, string and int) when performing operations involving indicator calculations."}]}