or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

index.mdmomentum-indicators.mdothers-indicators.mdtrend-indicators.mdutilities.mdvolatility-indicators.mdvolume-indicators.mdwrapper-functions.md

wrapper-functions.mddocs/

0

# Wrapper Functions

1

2

High-level wrapper functions that add multiple technical indicators to a DataFrame at once. These functions provide the most convenient way to perform comprehensive technical analysis by adding all indicators from specific categories or all categories simultaneously.

3

4

## Capabilities

5

6

### Add All Features

7

8

Adds all 43 technical analysis features from all categories (Volume, Volatility, Trend, Momentum, Others) to the DataFrame in a single operation.

9

10

```python { .api }

11

def add_all_ta_features(df, open, high, low, close, volume, fillna=False, colprefix="", vectorized=False):

12

"""

13

Add all technical analysis features to dataframe.

14

15

Parameters:

16

- df (DataFrame): Base dataframe to add features to

17

- open (str): Column name for 'Open' prices

18

- high (str): Column name for 'High' prices

19

- low (str): Column name for 'Low' prices

20

- close (str): Column name for 'Close' prices

21

- volume (str): Column name for 'Volume' data

22

- fillna (bool): If True, fill NaN values with 0 (default: False)

23

- colprefix (str): Prefix to add to all new column names (default: "")

24

- vectorized (bool): If True, use only vectorized functions (default: False)

25

26

Returns:

27

DataFrame: Original DataFrame with all technical analysis features added

28

"""

29

```

30

31

### Add Volume Features

32

33

Adds all 9 volume-based technical indicators including Money Flow Index, On-Balance Volume, VWAP, and others.

34

35

```python { .api }

36

def add_volume_ta(df, high, low, close, volume, fillna=False, colprefix="", vectorized=False):

37

"""

38

Add volume technical analysis features to dataframe.

39

40

Parameters:

41

- df (DataFrame): Base dataframe to add features to

42

- high (str): Column name for 'High' prices

43

- low (str): Column name for 'Low' prices

44

- close (str): Column name for 'Close' prices

45

- volume (str): Column name for 'Volume' data

46

- fillna (bool): If True, fill NaN values with 0 (default: False)

47

- colprefix (str): Prefix to add to all new column names (default: "")

48

- vectorized (bool): If True, use only vectorized functions (default: False)

49

50

Returns:

51

DataFrame: Original DataFrame with volume indicators added

52

"""

53

```

54

55

### Add Volatility Features

56

57

Adds all 5 volatility-based technical indicators including Bollinger Bands, Average True Range, Keltner Channel, and others.

58

59

```python { .api }

60

def add_volatility_ta(df, high, low, close, fillna=False, colprefix="", vectorized=False):

61

"""

62

Add volatility technical analysis features to dataframe.

63

64

Parameters:

65

- df (DataFrame): Base dataframe to add features to

66

- high (str): Column name for 'High' prices

67

- low (str): Column name for 'Low' prices

68

- close (str): Column name for 'Close' prices

69

- fillna (bool): If True, fill NaN values with 0 (default: False)

70

- colprefix (str): Prefix to add to all new column names (default: "")

71

- vectorized (bool): If True, use only vectorized functions (default: False)

72

73

Returns:

74

DataFrame: Original DataFrame with volatility indicators added

75

"""

76

```

77

78

### Add Trend Features

79

80

Adds all 20 trend-based technical indicators including MACD, Moving Averages, ADX, Ichimoku, and others.

81

82

```python { .api }

83

def add_trend_ta(df, high, low, close, fillna=False, colprefix="", vectorized=False):

84

"""

85

Add trend technical analysis features to dataframe.

86

87

Parameters:

88

- df (DataFrame): Base dataframe to add features to

89

- high (str): Column name for 'High' prices

90

- low (str): Column name for 'Low' prices

91

- close (str): Column name for 'Close' prices

92

- fillna (bool): If True, fill NaN values with 0 (default: False)

93

- colprefix (str): Prefix to add to all new column names (default: "")

94

- vectorized (bool): If True, use only vectorized functions (default: False)

95

96

Returns:

97

DataFrame: Original DataFrame with trend indicators added

98

"""

99

```

100

101

### Add Momentum Features

102

103

Adds all 11 momentum-based technical indicators including RSI, Stochastic Oscillator, Williams %R, and others.

104

105

```python { .api }

106

def add_momentum_ta(df, high, low, close, volume, fillna=False, colprefix="", vectorized=False):

107

"""

108

Add momentum technical analysis features to dataframe.

109

110

Parameters:

111

- df (DataFrame): Base dataframe to add features to

112

- high (str): Column name for 'High' prices

113

- low (str): Column name for 'Low' prices

114

- close (str): Column name for 'Close' prices

115

- volume (str): Column name for 'Volume' data

116

- fillna (bool): If True, fill NaN values with 0 (default: False)

117

- colprefix (str): Prefix to add to all new column names (default: "")

118

- vectorized (bool): If True, use only vectorized functions (default: False)

119

120

Returns:

121

DataFrame: Original DataFrame with momentum indicators added

122

"""

123

```

124

125

### Add Others Features

126

127

Adds all 3 other financial analysis indicators for calculating various types of returns.

128

129

```python { .api }

130

def add_others_ta(df, close, fillna=False, colprefix=""):

131

"""

132

Add others analysis features to dataframe.

133

134

Parameters:

135

- df (DataFrame): Base dataframe to add features to

136

- close (str): Column name for 'Close' prices

137

- fillna (bool): If True, fill NaN values with 0 (default: False)

138

- colprefix (str): Prefix to add to all new column names (default: "")

139

140

Returns:

141

DataFrame: Original DataFrame with return calculation features added

142

"""

143

```

144

145

## Usage Examples

146

147

### Complete Technical Analysis

148

149

```python

150

import pandas as pd

151

import ta

152

153

# Your OHLCV data

154

df = pd.read_csv('stock_data.csv')

155

156

# Add all 43 technical indicators at once

157

df_complete = ta.add_all_ta_features(

158

df,

159

open='Open',

160

high='High',

161

low='Low',

162

close='Close',

163

volume='Volume',

164

fillna=True # Fill NaN values

165

)

166

167

print(f"Original columns: {len(df.columns)}")

168

print(f"With indicators: {len(df_complete.columns)}")

169

```

170

171

### Category-Specific Analysis

172

173

```python

174

import ta

175

176

# Add only trend indicators for trend analysis

177

df_trend = ta.add_trend_ta(

178

df,

179

high='High',

180

low='Low',

181

close='Close',

182

colprefix='trend_' # Prefix all new columns

183

)

184

185

# Add only momentum indicators for momentum analysis

186

df_momentum = ta.add_momentum_ta(

187

df,

188

high='High',

189

low='Low',

190

close='Close',

191

volume='Volume',

192

vectorized=True # Use only vectorized functions

193

)

194

```

195

196

### Combining Categories

197

198

```python

199

import ta

200

201

# Start with base data

202

result_df = df.copy()

203

204

# Add indicators by category

205

result_df = ta.add_volume_ta(result_df, 'High', 'Low', 'Close', 'Volume')

206

result_df = ta.add_volatility_ta(result_df, 'High', 'Low', 'Close')

207

result_df = ta.add_trend_ta(result_df, 'High', 'Low', 'Close')

208

209

# Now result_df contains volume, volatility, and trend indicators

210

```