Skip to main content

An accurate calculation of technical analysis indicators with values aligning with those in TradingView.

Project description

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

๐Ÿ”— Links

๐Ÿ“ง 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tradingview-indicators-0.1.3.0.tar.gz (18.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tradingview_indicators-0.1.3.0-py3-none-any.whl (21.2 kB view details)

Uploaded Python 3

File details

Details for the file tradingview-indicators-0.1.3.0.tar.gz.

File metadata

  • Download URL: tradingview-indicators-0.1.3.0.tar.gz
  • Upload date:
  • Size: 18.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.24

File hashes

Hashes for tradingview-indicators-0.1.3.0.tar.gz
Algorithm Hash digest
SHA256 a459d4ea3a25159e7c8b1e8f9b8c481228bf453816636321c61c1616384e1eb0
MD5 0997a93de3d7a4c768ecc17021bfd4e3
BLAKE2b-256 cd712cb94709a5df87c100e38cc86b49847a9a3a0fc69bb1600e7dbe7324faa1

See more details on using hashes here.

File details

Details for the file tradingview_indicators-0.1.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for tradingview_indicators-0.1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f13f56211ecf699bc9fd8ab16a849a857cea1e4e89c2c80fac8aa4daae5b6d56
MD5 2f1709dfb79ea70dcef98e7d4c0c54f1
BLAKE2b-256 975b791d3c993d13df1ec8b4fdef8bfdbf73aee1413f7eba108c300d5bef5082

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page