0
# TA - Technical Analysis Library
1
2
A comprehensive Python library for feature engineering from financial time series datasets (Open, High, Low, Close, Volume). Built on Pandas and NumPy, the TA library provides 43 technical indicators across five categories: Volume, Volatility, Trend, Momentum, and Others, offering both class-based and functional APIs for each indicator.
3
4
## Package Information
5
6
- **Package Name**: ta
7
- **Language**: Python
8
- **Installation**: `pip install ta`
9
- **Dependencies**: numpy, pandas
10
11
## Core Imports
12
13
```python
14
import ta
15
```
16
17
For adding all features at once:
18
19
```python
20
from ta import add_all_ta_features, add_volume_ta, add_volatility_ta, add_trend_ta, add_momentum_ta, add_others_ta
21
```
22
23
For individual indicators:
24
25
```python
26
from ta.volume import OnBalanceVolumeIndicator, MFIIndicator
27
from ta.trend import MACD, EMAIndicator
28
from ta.momentum import RSIIndicator, StochasticOscillator
29
```
30
31
## Basic Usage
32
33
```python
34
import pandas as pd
35
import ta
36
37
# Load your financial data with OHLCV columns
38
df = pd.DataFrame({
39
'Open': [100, 101, 102, 99, 98],
40
'High': [105, 103, 104, 101, 100],
41
'Low': [99, 100, 101, 98, 97],
42
'Close': [104, 102, 103, 100, 99],
43
'Volume': [1000, 1100, 900, 1200, 800]
44
})
45
46
# Add all technical analysis features at once
47
df_with_indicators = ta.add_all_ta_features(
48
df,
49
open="Open",
50
high="High",
51
low="Low",
52
close="Close",
53
volume="Volume"
54
)
55
56
# Add specific category of indicators
57
df_trend = ta.add_trend_ta(df, high="High", low="Low", close="Close")
58
59
# Use individual indicators (class-based approach)
60
from ta.momentum import RSIIndicator
61
62
rsi = RSIIndicator(close=df['Close'], window=14)
63
df['RSI'] = rsi.rsi()
64
65
# Use individual indicators (functional approach)
66
from ta.momentum import rsi
67
68
df['RSI'] = rsi(close=df['Close'], window=14)
69
```
70
71
## Architecture
72
73
The TA library follows a consistent design pattern across all indicators:
74
75
- **Wrapper Functions**: High-level functions for adding multiple indicators at once
76
- **Class-Based API**: Each indicator implemented as a class inheriting from `IndicatorMixin`
77
- **Functional API**: Standalone functions that wrap class implementations
78
- **Consistent Interface**: All indicators support `fillna` parameter for handling NaN values
79
- **Pandas Integration**: Seamless integration with pandas DataFrames and Series
80
81
This dual API approach provides flexibility for different use cases while maintaining consistency across all 43 indicators.
82
83
## Capabilities
84
85
### Wrapper Functions
86
87
High-level functions for batch adding technical analysis features to DataFrames, supporting all 43 indicators organized by category.
88
89
```python { .api }
90
def add_all_ta_features(df, open, high, low, close, volume, fillna=False, colprefix="", vectorized=False): ...
91
def add_volume_ta(df, high, low, close, volume, fillna=False, colprefix="", vectorized=False): ...
92
def add_volatility_ta(df, high, low, close, fillna=False, colprefix="", vectorized=False): ...
93
def add_trend_ta(df, high, low, close, fillna=False, colprefix="", vectorized=False): ...
94
def add_momentum_ta(df, high, low, close, volume, fillna=False, colprefix="", vectorized=False): ...
95
def add_others_ta(df, close, fillna=False, colprefix=""): ...
96
```
97
98
[Wrapper Functions](./wrapper-functions.md)
99
100
### Volume Indicators
101
102
Nine volume-based technical indicators that analyze the relationship between price movements and trading volume to identify buying/selling pressure and confirm price trends.
103
104
```python { .api }
105
class AccDistIndexIndicator: ...
106
class OnBalanceVolumeIndicator: ...
107
class ChaikinMoneyFlowIndicator: ...
108
class ForceIndexIndicator: ...
109
class EaseOfMovementIndicator: ...
110
class VolumePriceTrendIndicator: ...
111
class NegativeVolumeIndexIndicator: ...
112
class MFIIndicator: ...
113
class VolumeWeightedAveragePrice: ...
114
```
115
116
[Volume Indicators](./volume-indicators.md)
117
118
### Volatility Indicators
119
120
Five volatility-based indicators that measure price volatility and identify potential support/resistance levels through channel analysis and volatility bands.
121
122
```python { .api }
123
class AverageTrueRange: ...
124
class BollingerBands: ...
125
class KeltnerChannel: ...
126
class DonchianChannel: ...
127
class UlcerIndex: ...
128
```
129
130
[Volatility Indicators](./volatility-indicators.md)
131
132
### Trend Indicators
133
134
Twenty trend-based indicators that identify trend direction, strength, and potential reversal points through moving averages, oscillators, and directional movement analysis.
135
136
```python { .api }
137
class AroonIndicator: ...
138
class MACD: ...
139
class EMAIndicator: ...
140
class SMAIndicator: ...
141
class WMAIndicator: ...
142
class TRIXIndicator: ...
143
class MassIndex: ...
144
class IchimokuIndicator: ...
145
class KSTIndicator: ...
146
class DPOIndicator: ...
147
class CCIIndicator: ...
148
class ADXIndicator: ...
149
class VortexIndicator: ...
150
class PSARIndicator: ...
151
class STCIndicator: ...
152
```
153
154
[Trend Indicators](./trend-indicators.md)
155
156
### Momentum Indicators
157
158
Eleven momentum-based indicators that measure the rate of price change and identify overbought/oversold conditions, momentum shifts, and potential reversal points.
159
160
```python { .api }
161
class RSIIndicator: ...
162
class TSIIndicator: ...
163
class UltimateOscillator: ...
164
class StochasticOscillator: ...
165
class KAMAIndicator: ...
166
class ROCIndicator: ...
167
class AwesomeOscillatorIndicator: ...
168
class WilliamsRIndicator: ...
169
class StochRSIIndicator: ...
170
class PercentagePriceOscillator: ...
171
class PercentageVolumeOscillator: ...
172
```
173
174
[Momentum Indicators](./momentum-indicators.md)
175
176
### Others Indicators
177
178
Three fundamental financial analysis indicators for calculating various types of returns from price data.
179
180
```python { .api }
181
class DailyReturnIndicator: ...
182
class DailyLogReturnIndicator: ...
183
class CumulativeReturnIndicator: ...
184
```
185
186
[Others Indicators](./others-indicators.md)
187
188
### Utility Functions
189
190
Core utility functions and base classes used throughout the library for data handling and indicator calculations.
191
192
```python { .api }
193
class IndicatorMixin: ...
194
def dropna(df): ...
195
```
196
197
[Utilities](./utilities.md)
198
199
## Types
200
201
```python { .api }
202
# Base class for all indicators
203
class IndicatorMixin:
204
def _check_fillna(self, series, value=0):
205
"""Check if fillna flag is True"""
206
...
207
208
@staticmethod
209
def _true_range(high, low, prev_close):
210
"""Calculate true range"""
211
...
212
```