or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

core-types.mdindex.mdmomentum-indicators.mdoverlay-indicators.mdspecialized-indicators.mdtrend-indicators.mdvolatility-indicators.mdvolume-indicators.md

index.mddocs/

0

# Stock Indicators

1

2

Stock Indicators for Python provides financial market technical indicators from historical price quotes. Send in historical price data and get back desired indicators such as moving averages, Relative Strength Index, Stochastic Oscillator, Parabolic SAR, and more. Nothing more.

3

4

The library supports over 130 different technical indicators including trend, momentum, volatility, volume, and specialized indicators. It can be used in any market analysis software using standard OHLCV price quotes for equities, commodities, forex, cryptocurrencies, and others.

5

6

## Package Information

7

8

- **Package Name**: stock-indicators

9

- **Language**: Python

10

- **Installation**: `pip install stock-indicators`

11

- **Prerequisites**: .NET SDK (6.0 or newer) required

12

13

## Core Imports

14

15

```python

16

from stock_indicators import indicators

17

from stock_indicators.indicators.common import Quote, BetaType, CandlePart, MAType, PeriodSize

18

```

19

20

Common import pattern for all indicators:

21

22

```python

23

from stock_indicators.indicators import get_sma, get_rsi, get_bollinger_bands

24

```

25

26

## Basic Usage

27

28

```python

29

from datetime import datetime

30

from stock_indicators.indicators.common import Quote

31

from stock_indicators.indicators import get_sma

32

33

# Create historical price quotes

34

quotes = [

35

Quote(date=datetime(2023, 1, 1), open=100.0, high=102.0, low=99.0, close=101.0, volume=10000),

36

Quote(date=datetime(2023, 1, 2), open=101.0, high=103.0, low=100.0, close=102.0, volume=12000),

37

Quote(date=datetime(2023, 1, 3), open=102.0, high=104.0, low=101.0, close=103.0, volume=11000),

38

# ... more quotes

39

]

40

41

# Calculate Simple Moving Average with 10-period lookback

42

sma_results = get_sma(quotes, lookback_periods=10)

43

44

# Access results

45

for result in sma_results:

46

if result.sma is not None:

47

print(f"Date: {result.date}, SMA: {result.sma}")

48

```

49

50

## Architecture

51

52

The Stock Indicators library is built around a simple but powerful architecture:

53

54

- **Quote**: Core data type representing a single dated price quote with OHLCV data

55

- **Indicator Functions**: Pure functions that take quotes and parameters, return typed results

56

- **Result Types**: Strongly-typed result objects with date and calculated values

57

- **Result Collections**: Lists of results with helper methods for data manipulation

58

- **Enums**: Type-safe configuration options for indicators

59

60

All indicators follow consistent patterns:

61

- Accept `Iterable[Quote]` as the primary input

62

- Return `{IndicatorName}Results[{IndicatorName}Result]` collections

63

- Provide optional parameters with sensible defaults

64

- Include helper methods for data processing

65

66

## Capabilities

67

68

### Core Data Types

69

70

Essential data structures and enumerations used throughout the library. Includes the Quote class for price data input, result base classes, and configuration enums for indicator parameters.

71

72

```python { .api }

73

class Quote:

74

def __init__(self, date: datetime, open: Optional[Any] = None,

75

high: Optional[Any] = None, low: Optional[Any] = None,

76

close: Optional[Any] = None, volume: Optional[Any] = None): ...

77

78

class ResultBase:

79

@property

80

def date(self) -> datetime: ...

81

82

class IndicatorResults[T]:

83

def remove_warmup_periods(self, periods: int): ...

84

def find(self, lookup_date: datetime): ...

85

def condense(self): ...

86

```

87

88

[Core Data Types](./core-types.md)

89

90

### Trend Indicators

91

92

Moving averages and trend-following indicators that smooth price data to identify market direction. Includes Simple Moving Average (SMA), Exponential Moving Average (EMA), Hull Moving Average (HMA), and adaptive moving averages.

93

94

```python { .api }

95

def get_sma(quotes: Iterable[Quote], lookback_periods: int,

96

candle_part: CandlePart = CandlePart.CLOSE): ...

97

def get_ema(quotes: Iterable[Quote], lookback_periods: int): ...

98

def get_hma(quotes: Iterable[Quote], lookback_periods: int): ...

99

def get_kama(quotes: Iterable[Quote], er_periods: int = 10, fast_periods: int = 2, slow_periods: int = 30): ...

100

```

101

102

[Trend Indicators](./trend-indicators.md)

103

104

### Momentum Indicators

105

106

Oscillators that measure the rate of price change and momentum to identify overbought/oversold conditions. Includes RSI, Stochastic, MACD, and various momentum oscillators.

107

108

```python { .api }

109

def get_rsi(quotes: Iterable[Quote], lookback_periods: int = 14): ...

110

def get_stoch(quotes: Iterable[Quote], lookback_periods: int = 14,

111

signal_periods: int = 3, smooth_periods: int = 3): ...

112

def get_macd(quotes: Iterable[Quote], fast_periods: int = 12, slow_periods: int = 26, signal_periods: int = 9): ...

113

def get_stoch_rsi(quotes: Iterable[Quote], rsi_periods: int = 14, stoch_periods: int = 14,

114

signal_periods: int = 3, smooth_periods: int = 1): ...

115

```

116

117

[Momentum Indicators](./momentum-indicators.md)

118

119

### Volatility Indicators

120

121

Measures of price volatility and range-based indicators. Includes Bollinger Bands, Average True Range (ATR), Keltner Channels, and volatility-based overlays.

122

123

```python { .api }

124

def get_bollinger_bands(quotes: Iterable[Quote], lookback_periods: int = 20, standard_deviations: float = 2): ...

125

def get_atr(quotes: Iterable[Quote], lookback_periods: int = 14): ...

126

def get_keltner(quotes: Iterable[Quote], ema_periods: int = 20, multiplier: float = 2.0, atr_periods: int = 10): ...

127

def get_donchian(quotes: Iterable[Quote], lookback_periods: int = 20): ...

128

```

129

130

[Volatility Indicators](./volatility-indicators.md)

131

132

### Volume Indicators

133

134

Volume-based indicators that analyze trading volume patterns and price-volume relationships. Includes On-Balance Volume (OBV), Money Flow Index (MFI), and volume oscillators.

135

136

```python { .api }

137

def get_obv(quotes: Iterable[Quote]): ...

138

def get_mfi(quotes: Iterable[Quote], lookback_periods: int = 14): ...

139

def get_cmf(quotes: Iterable[Quote], lookback_periods: int = 20): ...

140

def get_vwap(quotes: Iterable[Quote]): ...

141

```

142

143

[Volume Indicators](./volume-indicators.md)

144

145

### Overlay Indicators

146

147

Price overlays and support/resistance indicators that are plotted directly on price charts. Includes Parabolic SAR, SuperTrend, Ichimoku Cloud, and pivot point systems.

148

149

```python { .api }

150

def get_parabolic_sar(quotes: Iterable[Quote], acceleration_factor: float = 0.02, max_acceleration_factor: float = 0.2): ...

151

def get_super_trend(quotes: Iterable[Quote], lookback_periods: int = 10, multiplier: float = 3.0): ...

152

def get_ichimoku(quotes: Iterable[Quote], tenkan_periods: int = 9, kijun_periods: int = 26, senkou_b_periods: int = 52, senkou_offset: int = None, chikou_offset: int = None): ...

153

def get_pivot_points(quotes: Iterable[Quote], window_periods: int = 1, point_type: PivotPointType = PivotPointType.STANDARD): ...

154

```

155

156

[Overlay Indicators](./overlay-indicators.md)

157

158

### Specialized Indicators

159

160

Advanced and specialized technical indicators including mathematical functions, candlestick pattern recognition, and proprietary indicators.

161

162

```python { .api }

163

def get_correlation(quotes_a: Iterable[Quote], quotes_b: Iterable[Quote], lookback_periods: int = 20): ...

164

def get_beta(eval_quotes: Iterable[Quote], market_quotes: Iterable[Quote], lookback_periods: int, beta_type: BetaType = BetaType.STANDARD): ...

165

def get_hurst(quotes: Iterable[Quote], lookback_periods: int = 100): ...

166

def get_doji(quotes: Iterable[Quote]): ...

167

```

168

169

[Specialized Indicators](./specialized-indicators.md)

170

171

## Types

172

173

### Configuration Enums

174

175

```python { .api }

176

class CandlePart(Enum):

177

OPEN = ...

178

HIGH = ...

179

LOW = ...

180

CLOSE = ...

181

VOLUME = ...

182

HL2 = ... # (High + Low) / 2

183

HLC3 = ... # (High + Low + Close) / 3

184

OC2 = ... # (Open + Close) / 2

185

OHL3 = ... # (Open + High + Low) / 3

186

OHLC4 = ... # (Open + High + Low + Close) / 4

187

188

class MAType(Enum):

189

ALMA = ...

190

DEMA = ...

191

EPMA = ...

192

EMA = ...

193

HMA = ...

194

KAMA = ...

195

MAMA = ...

196

SMA = ...

197

SMMA = ...

198

TEMA = ...

199

WMA = ...

200

201

class BetaType(Enum):

202

STANDARD = ...

203

UP = ...

204

DOWN = ...

205

ALL = ...

206

207

class PivotPointType(Enum):

208

STANDARD = ...

209

CAMARILLA = ...

210

DEMARK = ...

211

FIBONACCI = ...

212

WOODIE = ...

213

```