# Stochastic Oscillator

get_stoch(quotes, lookback_periods=14, signal_periods=3, smooth_periods=3)

## Parameters

name | type | notes |
---|---|---|

`quotes` | Iterable[Quote] | Iterable of the Quote class or its sub-class. • See here for usage with pandas.DataFrame |

`lookback_periods` | int, default 14 | Lookback period (`N` ) for the oscillator (%K). Must be greater than 0. |

`signal_periods` | int, default 3 | Smoothing period for the signal (%D). Must be greater than 0. |

`smooth_periods` | int, default 3 | Smoothing period (`S` ) for the Oscillator (%K). “Slow” stochastic uses 3, “Fast” stochastic uses 1. Must be greater than 0. |

### Historical quotes requirements

You must have at least `N+S`

periods of `quotes`

to cover the warmup periods.

`quotes`

is an `Iterable[Quote]`

collection of historical price quotes. It should have a consistent frequency (day, hour, minute, etc). See the Guide for more information.

## Returns

```
StochResults[StochResult]
```

- This method returns a time series of all available indicator values for the
`quotes`

provided. `StochResults`

is just a list of`StochResult`

.- It always returns the same number of elements as there are in the historical quotes.
- It does not return a single incremental indicator value.
- The first
`N+S-2`

periods will have`None`

Oscillator values since there’s not enough data to calculate.

### StochResult

name | type | notes |
---|---|---|

`date` | datetime | Date |

`oscillator` or `k` | float, Optional | %K Oscillator over prior `N` lookback periods |

`signal` or `d` | float, Optional | %D Simple moving average of Oscillator |

`percent_j` or `j` | float, Optional | %J is the weighted divergence of %K and %D: `%J=kFactor×%K-dFactor×%D` |

Note: aliases of `k`

, `d`

, and `j`

are also provided. They can be used interchangeably with the standard outputs.

### Utilities

See Utilities and Helpers for more information.

## Example

```
from stock_indicators import indicators
# This method is NOT a part of the library.
quotes = get_history_from_feed("SPY")
# calculate STO %K(14),%D(3) (slow)
results = indicators.get_stoch(quotes, 14, 3, 3)
```

## About Stochastic Oscillator

Created by George Lane, the Stochastic Oscillator is a momentum indicator that looks back `N`

periods to produce a scale of 0 to 100. %J is also included for the KDJ Index extension. [Discuss] 💬