Skip to main content

TradingView Indicators

Codacy Badge Python 3.11+ PyPI version

A production-ready Python library for accurate financial technical analysis indicators, engineered to match TradingView platform standards.

🇧🇷 Versão em Português

🎯 Overview

TradingView Indicators is an open-source Python library that provides highly accurate implementations of technical analysis indicators used in financial markets. Built with data engineering best practices, this library addresses critical accuracy issues found in existing solutions like TA-Lib and pandas-ta.

Key Features

  • ✅ Accurate Calculations - Values precisely match TradingView platform standards
  • ⚡ Optimized Performance - Vectorized operations using NumPy and Pandas for processing 1M+ data points
  • 🧩 Modular Architecture - Clean, maintainable code following SOLID principles
  • 🧪 Comprehensive Testing - 12+ test suites ensuring reliability and accuracy
  • 🔧 Type-Safe - Full type hints support for better IDE integration

📦 Installation

Install via pip:

pip install tradingview-indicators

Requirements

  • Python 3.11+
  • fastdtw >= 0.3.4
  • numpy >= 2.3.4
  • pandas[performance] >= 2.3.3
  • pytest >= 8.4.2

🚀 Quick Start

import pandas as pd
import tradingview_indicators as ta

# Load your market data
df = pd.read_csv("BTCUSDT_1d_spot.csv")
source = df["close"]

# Calculate indicators
df["EMA_14"] = ta.ema(source, 14)
df["RSI_14"] = ta.RSI(source, 14)

# MACD with histogram
macd = ta.MACD(source, 12, 26, 9)
df["MACD_Histogram"] = macd.get_histogram

# Directional Movement Index
dmi = ta.DMI(df, "close")
df["ADX"] = dmi.adx()[0]
df["DI_Plus"] = dmi.adx()[1]
df["DI_Minus"] = dmi.adx()[2]

# Bollinger Bands
bb = ta.bollinger_bands(source, 20, 2)
df["BB_Upper"] = bb[0]
df["BB_Middle"] = bb[1]
df["BB_Lower"] = bb[2]

📊 Available Indicators

Indicator Function Description
Moving Averages sma(), ema(), rma(), sema() Simple, Exponential, Relative, Smoothed Moving Averages (DEMA, TEMA, and others)
RSI RSI() Relative Strength Index
MACD MACD() Moving Average Convergence Divergence
Bollinger Bands bollinger_bands(), bollinger_trends() Volatility bands and trend analysis
Stochastic stoch(), slow_stoch() Stochastic Oscillators
DMI/ADX DMI() Directional Movement Index
CCI CCI() Commodity Channel Index
Ichimoku Ichimoku() Ichimoku Cloud
TRIX TRIX() Triple Exponential Average
TSI tsi() True Strength Index
SMIO SMIO() SMI Ergodic Oscillator
Didi Index didi_index() Didi Index also known as Agulhada de Didi

📁 Repository Structure

TradingView-Indicators/
├── src/
│   └── tradingview_indicators/    # Main package source code
│       ├── __init__.py            # Package initialization and exports
│       ├── moving_average.py      # MA implementations (SMA, EMA, RMA, SEMA)
│       ├── RSI.py                 # Relative Strength Index
│       ├── MACD.py                # MACD indicator
│       ├── bollinger.py           # Bollinger Bands
│       ├── stoch.py               # Stochastic oscillator
│       ├── slow_stoch.py          # Slow Stochastic
│       ├── DMI.py                 # Directional Movement Index
│       ├── CCI.py                 # Commodity Channel Index
│       ├── ichimoku.py            # Ichimoku Cloud
│       ├── TRIX.py                # Triple Exponential Average
│       ├── tsi.py                 # True Strength Index
│       ├── SMIO.py                # SMI Ergodic Oscillator
│       ├── didi_index.py          # Didi Index
│       ├── utils.py               # Utility functions
│       └── errors_exceptions.py   # Custom exceptions
│
├── tests/                         # Comprehensive test suite
│   ├── test_moving_average.py
│   ├── test_RSI.py
│   ├── test_macd.py
│   ├── test_bollinger_bands.py
│   └── ...                        # Additional test files
│
├── example/                       # Usage examples
│   ├── example.ipynb              # Jupyter notebook with examples
│   └── BTCUSDT_1d_spot.csv        # Sample market data
│
├── pyproject.toml                 # Project metadata and dependencies
├── setup.py                       # Package setup configuration
├── requirements.txt               # Development dependencies
└── README.md                      # This file

Core Components

🔧 Source Code (src/tradingview_indicators/)

The main package contains modular indicator implementations:

  • Each indicator is in its own file for maintainability
  • Type hints for better code quality and IDE support
  • Custom error handling for data validation

🧪 Tests (tests/)

Comprehensive testing framework ensuring accuracy:

  • Unit tests for each indicator
  • Validation against TradingView outputs
  • Edge case handling

📚 Examples (example/)

Practical usage demonstrations:

  • Jupyter notebook with real-world examples
  • Sample cryptocurrency market data
  • Step-by-step calculation guides

🛠️ Technical Architecture

Design Principles

  1. Modularity - Each indicator is self-contained and reusable
  2. Accuracy - All calculations validated using TradingView values as reference
  3. Performance - Vectorized operations for efficient large-scale processing
  4. Maintainability - Clean code following PEP 8 and SOLID principles
  5. Type Safety - Comprehensive type hints for better developer experience

Data Processing Pipeline

Raw Market Data (DataFrame/Series)
          ↓
   Data Validation
          ↓
  Vectorized Calculations (NumPy/Pandas)
          ↓
   Result Transformation
          ↓
   Type-Safe Output (Series/DataFrame)

🎓 Use Cases

  • Algorithmic Trading - Build reliable trading strategies with accurate indicators
  • Financial Analysis - Perform technical analysis on stocks, crypto, and forex
  • Data Science - Integrate with data pipelines for market research
  • Backtesting - Test trading strategies with precise historical calculations
  • Education - Learn technical analysis with production-grade implementations
  • Machine Learning - Calculate features for predictive models in finance

🧪 Testing

Run the test suite:

python -m pytest ./tests

The library includes 12+ comprehensive test suites covering:

  • Indicator accuracy validation
  • Edge case handling
  • Data type validation

🤝 Contributing

Contributions are welcome! This project follows professional development standards:

  1. Fork the repository
  2. Write tests for your changes
  3. Ensure all tests pass (python -m pytest ./tests)
  4. Follow PEP 8 style guidelines
  5. Submit a pull request

📧 Contact

For questions, suggestions, or collaboration opportunities, please send me a message via GitHub or any of my social media channels listed on my profile.

💼 Use Case

I use this library for my financial needs of accurate and reliable technical analysis indicators to compute my variables in my machine learning models, such as in my project ML-Miner.

Release files for tradingview-indicators 0.1.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tradingview-indicators 0.1.3.0
File Size Uploaded
tradingview-indicators-0.1.3.0.tar.gz 18.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tradingview-indicators 0.1.3.0
File Interpreter ABI Platform
tradingview_indicators-0.1.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 39.2 kB

Release files / tradingview-indicators-0.1.3.0.tar.gz

Download URL tradingview-indicators-0.1.3.0.tar.gz
Size 18.1 kB
Tags Source
SHA-256 checksum
How to use checksums
a459d4ea3a25159e7c8b1e8f9b8c481228bf453816636321c61c1616384e1eb0
BLAKE2b-256 checksum
How to use checksums
cd712cb94709a5df87c100e38cc86b49847a9a3a0fc69bb1600e7dbe7324faa1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.24

Release files / tradingview_indicators-0.1.3.0-py3-none-any.whl

Download URL tradingview_indicators-0.1.3.0-py3-none-any.whl
Size 21.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f13f56211ecf699bc9fd8ab16a849a857cea1e4e89c2c80fac8aa4daae5b6d56
BLAKE2b-256 checksum
How to use checksums
975b791d3c993d13df1ec8b4fdef8bfdbf73aee1413f7eba108c300d5bef5082
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.24
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page