An accurate calculation of technical analysis indicators with values aligning with those in TradingView.
Project description
TradingView Indicators
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
- Modularity - Each indicator is self-contained and reusable
- Accuracy - All calculations validated using TradingView values as reference
- Performance - Vectorized operations for efficient large-scale processing
- Maintainability - Clean code following PEP 8 and SOLID principles
- 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:
- Fork the repository
- Write tests for your changes
- Ensure all tests pass (
python -m pytest ./tests) - Follow PEP 8 style guidelines
- Submit a pull request
๐ Links
- PyPI Package: tradingview-indicators
- GitHub Repository: m-marqx/TradingView-Indicators
- Issue Tracker: GitHub Issues
๐ง 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a459d4ea3a25159e7c8b1e8f9b8c481228bf453816636321c61c1616384e1eb0
|
|
| MD5 |
0997a93de3d7a4c768ecc17021bfd4e3
|
|
| BLAKE2b-256 |
cd712cb94709a5df87c100e38cc86b49847a9a3a0fc69bb1600e7dbe7324faa1
|
File details
Details for the file tradingview_indicators-0.1.3.0-py3-none-any.whl.
File metadata
- Download URL: tradingview_indicators-0.1.3.0-py3-none-any.whl
- Upload date:
- Size: 21.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.24
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f13f56211ecf699bc9fd8ab16a849a857cea1e4e89c2c80fac8aa4daae5b6d56
|
|
| MD5 |
2f1709dfb79ea70dcef98e7d4c0c54f1
|
|
| BLAKE2b-256 |
975b791d3c993d13df1ec8b4fdef8bfdbf73aee1413f7eba108c300d5bef5082
|