{"id":27421,"library":"stockstats","title":"stockstats","description":"A Python library that provides a DataFrame subclass with inline stock statistics support, including common technical indicators (e.g., SMA, EMA, RSI, MACD, Bollinger Bands) and more advanced indicators like Supertrend, Ichimoku Cloud, KST, and PVO. The current version is 0.6.8, with active development on GitHub. Release cadence is irregular, roughly a few releases per year.","status":"active","version":"0.6.8","language":"python","source_language":"en","source_url":"https://github.com/jealous/stockstats","tags":["stock","technical indicators","finance","dataframe","analysis"],"install":[{"cmd":"pip install stockstats","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Core dependency for DataFrame operations","package":"pandas","optional":false},{"reason":"Used for numerical computations","package":"numpy","optional":false}],"imports":[{"note":"Direct import is preferred and clearer","wrong":"import stockstats\nstockstats.StockDataFrame","symbol":"StockDataFrame","correct":"from stockstats import StockDataFrame"}],"quickstart":{"code":"import yfinance as yf\nfrom stockstats import StockDataFrame\n\n# Download historical data for AAPL\ndf = yf.download('AAPL', start='2023-01-01', end='2023-12-31')\n# Convert to StockDataFrame\nstock = StockDataFrame.retype(df)\n\n# Access RSI (14-day) and MACD\nprint(stock['rsi_14'].tail())\nprint(stock['macd'].tail())","lang":"python","description":"Download stock data with yfinance, convert to StockDataFrame, and compute technical indicators."},"warnings":[{"fix":"Update column names to include the period (e.g., 'rsi_14', 'macd').","message":"In version 0.6.x, the column naming convention for some indicators changed (e.g., 'rsi' became 'rsi_14'). Old code using 'rsi' without the period will break.","severity":"breaking","affected_versions":"<0.6.0"},{"fix":"Ensure code handles Series output instead of scalar.","message":"The method _tp() previously returned a scalar when the result was constant; in 0.6.7 it was fixed to always return a pandas Series. Code that relied on scalar output (e.g., item access) may break.","severity":"breaking","affected_versions":"<0.6.7"},{"fix":"Use yfinance with keyword arguments for column mapping, or ensure column names match the expected format.","message":"yfinance may change its API (e.g., 'period' parameter). StockDataFrame expects columns: 'open', 'high', 'low', 'close', 'volume'. If yfinance changes column names, the library may not recognize them.","severity":"gotcha","affected_versions":"all"},{"fix":"Upgrade to 0.6.6+ which fixes division-by-zero issues (PR #201).","message":"Many indicators can produce NaN values due to division by zero or insufficient data length. These are silently ignored in some versions, leading to misleading results.","severity":"gotcha","affected_versions":"<=0.6.5"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use: from stockstats import StockDataFrame","cause":"Incorrect import: trying to use stockstats.StockDataFrame instead of importing the class directly.","error":"AttributeError: module 'stockstats' has no attribute 'StockDataFrame'"},{"fix":"Access 'rsi_14' instead of 'rsi' (adjust period as needed).","cause":"Column name changed: in older versions, 'rsi' was the column; in new versions, it's 'rsi_14' (or other period).","error":"KeyError: 'rsi'"},{"fix":"Ensure index is unique: df = df[~df.index.duplicated(keep='first')]","cause":"DataFrame index has duplicate timestamps (e.g., from intraday data with same day). The library does not handle duplicates gracefully.","error":"ValueError: cannot reindex from a duplicate axis"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}