A Python port of the excellent TA4J (Technical Analysis for Java) library.
pyta4j provides a flexible, extensible framework for building trading strategies and performing technical analysis using indicators, rules, and performance criteria.
- Core components for technical analysis:
- Candlestick bar series (
Bar,BarSeries) - Indicators (e.g.,
SMA,EMA,RSI,MACD) - Trading rules (e.g.,
StopLoss,StopGain,CrossOver) - Strategy engine
- Performance analysis criteria
- Candlestick bar series (
- Extensible and test-driven
- Compatible with Pandas and Decimal for high-precision financial calculations
- CSV trade loaders and utilities for backtesting
-
Clone the repository:
git clone https://github.com/quickfox15/pyta4j.git cd pyta4j/ -
(Optional) Create and activate a virtual environment:
python -m venv .venv source .venv/bin/activate # On Linux/macOS .venv\Scripts\activate # On Windows
-
Install dependencies:
pip install -r requirements.txt
-
Install in editable mode (recommended for development):
pip install -e .
Run all unit tests with:
python -m unittest discover -s tests -p "test*.py"Run the example file:
python quickstart.pypyta4j/
├── pyta4j/ # Core library code
│ ├── core/ # Bars, trades, positions
│ ├── indicators/ # Technical indicators
│ ├── rules/ # Entry/exit rules
│ ├── analysis/ # Performance criteria
│ ├── cost/ # Cost models
│ └── utils/ # Helpers/loaders
├── tests/ # Unit tests
├── quickstart.py # Example script
├── requirements.txt
├── setup.py
└── README.md- Python 3.9+
- This project is licensed under the MIT License. See the LICENSE file for details.
- ta4j – The original Java-based inspiration for this project.
- Python open source community ❤️