From 84b7d4fde16d7b95dd5ae432e2eb1bdcc7a83ca8 Mon Sep 17 00:00:00 2001 From: DongGeon Lee Date: Tue, 12 Apr 2022 01:46:14 +0900 Subject: [PATCH] docs: general updates for 0.7.0 (#209) +semver: minor Co-authored-by: Dave Skender <8432125+DaveSkender@users.noreply.github.com> --- .github/workflows/lock.yml | 16 +- README.md | 1 + docs/README.md | 1 + docs/_indicators/.unimplemented/Gator.md | 71 --------- .../_indicators/.unimplemented/MaEnvelopes.md | 93 ------------ .../_indicators/.unimplemented/PivotPoints.md | 99 ------------ docs/_indicators/.unimplemented/Pivots.md | 94 ------------ docs/_indicators/.unimplemented/Renko.md | 117 --------------- .../.unimplemented/RollingPivots.md | 88 ----------- docs/_indicators/.unimplemented/ZigZag.md | 84 ----------- docs/_indicators/Alligator.md | 21 ++- docs/_indicators/Beta.md | 27 ++-- docs/_indicators/Chandelier.md | 12 +- docs/_indicators/Gator.md | 80 ++++++++++ docs/_indicators/MaEnvelopes.md | 102 +++++++++++++ docs/_indicators/PivotPoints.md | 106 +++++++++++++ docs/_indicators/Pivots.md | 102 +++++++++++++ docs/_indicators/{.unimplemented => }/Pvo.md | 60 ++++---- docs/_indicators/Renko.md | 141 ++++++++++++++++++ docs/_indicators/RollingPivots.md | 95 ++++++++++++ docs/_indicators/Stoch.md | 10 +- docs/performance.md | 122 +++++++++++---- 22 files changed, 789 insertions(+), 753 deletions(-) delete mode 100644 docs/_indicators/.unimplemented/Gator.md delete mode 100644 docs/_indicators/.unimplemented/MaEnvelopes.md delete mode 100644 docs/_indicators/.unimplemented/PivotPoints.md delete mode 100644 docs/_indicators/.unimplemented/Pivots.md delete mode 100644 docs/_indicators/.unimplemented/Renko.md delete mode 100644 docs/_indicators/.unimplemented/RollingPivots.md delete mode 100644 docs/_indicators/.unimplemented/ZigZag.md create mode 100644 docs/_indicators/Gator.md create mode 100644 docs/_indicators/MaEnvelopes.md create mode 100644 docs/_indicators/PivotPoints.md create mode 100644 docs/_indicators/Pivots.md rename docs/_indicators/{.unimplemented => }/Pvo.md (53%) create mode 100644 docs/_indicators/Renko.md create mode 100644 docs/_indicators/RollingPivots.md diff --git a/.github/workflows/lock.yml b/.github/workflows/lock.yml index 712bdd8f..85c3df79 100644 --- a/.github/workflows/lock.yml +++ b/.github/workflows/lock.yml @@ -1,26 +1,18 @@ -name: "Lock Threads" +name: "Lock Closed Threads" # https://github.com/marketplace/actions/lock-threads on: schedule: - cron: "0 7 * * *" +concurrency: + group: lock + jobs: lock: runs-on: ubuntu-latest steps: - uses: dessant/lock-threads@v3 with: - issue-lock-reason: "resolved" issue-inactive-days: "90" - issue-comment: > - This Issue has been automatically locked since there - has not been any recent activity after it was closed. - Please open a new Issue for related bugs. - - pr-lock-reason: "resolved" pr-inactive-days: "30" - pr-comment: > - This Pull Request has been automatically locked since there - has not been any recent activity after it was closed. - Please open a new Issue for related bugs. diff --git a/README.md b/README.md index 890833cf..99537d92 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ [![PyPI](https://img.shields.io/pypi/v/stock-indicators?color=blue&label=PyPI)](https://badge.fury.io/py/stock-indicators) [![code coverage](https://img.shields.io/azure-devops/coverage/skender/stock.indicators/26/main?logo=AzureDevOps&label=Code%20Coverage)](https://dev.azure.com/skender/Stock.Indicators/_build/latest?definitionId=26&branchName=main&view=codecoverage-tab) +[![Language grade](https://img.shields.io/lgtm/grade/python/g/DaveSkender/Stock.Indicators.Python.svg?logo=lgtm&logoWidth=18&label=code%20quality)](https://lgtm.com/projects/g/DaveSkender/Stock.Indicators.Python) **Stock Indicators for Python** is a library that produces financial market technical indicators. Send in historical price quotes and get back desired indicators such as moving averages, Relative Strength Index, Stochastic Oscillator, Parabolic SAR, etc. Nothing more. diff --git a/docs/README.md b/docs/README.md index 2b2efa6a..5701653b 100644 --- a/docs/README.md +++ b/docs/README.md @@ -2,6 +2,7 @@ [![PyPI](https://img.shields.io/pypi/v/stock-indicators?color=blue&label=PyPI)](https://badge.fury.io/py/stock-indicators) [![code coverage](https://img.shields.io/azure-devops/coverage/skender/stock.indicators/26/main?logo=AzureDevOps&label=Code%20Coverage)](https://dev.azure.com/skender/Stock.Indicators/_build/latest?definitionId=26&branchName=main&view=codecoverage-tab) +[![Language grade](https://img.shields.io/lgtm/grade/python/g/DaveSkender/Stock.Indicators.Python.svg?logo=lgtm&logoWidth=18&label=code%20quality)](https://lgtm.com/projects/g/DaveSkender/Stock.Indicators.Python) **Stock Indicators for Python** is a library that produces financial market technical indicators. Send in historical price quotes and get back desired indicators such as moving averages, Relative Strength Index, Stochastic Oscillator, Parabolic SAR, etc. Nothing more. diff --git a/docs/_indicators/.unimplemented/Gator.md b/docs/_indicators/.unimplemented/Gator.md deleted file mode 100644 index 80ed67c8..00000000 --- a/docs/_indicators/.unimplemented/Gator.md +++ /dev/null @@ -1,71 +0,0 @@ ---- -title: Gator Oscillator -permalink: /indicators/Gator/ -type: price-trend -layout: indicator ---- - -# {{ page.title }} - -Created by Bill Williams, the Gator Oscillator is an expanded view of [Williams Alligator](../Alligator#content). -[[Discuss] :speech_balloon:]({{site.github.base_repository_url}}/discussions/385 "Community discussion about this indicator") - -![image]({{site.charturl}}/Gator.png) - -```python -// usage -IEnumerable results = - quotes.GetGator() - -// with custom Alligator configuration -IEnumerable results = quotes - .GetAlligator([see Alligator docs]) - .GetGator() -``` - -## Historical quotes requirements - -If using default settings, you must have at least 121 periods of `quotes`. Since this uses a smoothing technique, we recommend you use at least 271 data points prior to the intended usage date for better precision. If using a custom Alligator configuration, see [Alligator documentation](../Alligator#historical-quotes-requirements) for historical quotes requirements. - -`quotes` is an `Iterable[Quote]` collection of historical price quotes. It should have a consistent frequency (day, hour, minute, etc). See [the Guide]({{site.baseurl}}/guide/#historical-quotes) for more information. - -## Return - -```python -IEnumerable -``` - -- This method returns a time series of all available indicator values for the `quotes` provided. -- 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 10-20 periods will have `None` values since there's not enough data to calculate. - -:hourglass: **Convergence Warning**: The first 150 periods will have decreasing magnitude, convergence-related precision errors that can be as high as ~5% deviation in indicator values for earlier periods. - -### GatorResult - -| name | type | notes -| -- |-- |-- -| `Date` | DateTime | Date -| `Upper` | double | Absolute value of Alligator `Jaw-Teeth` -| `Lower` | double | Absolute value of Alligator `Lips-Teeth` -| `UpperIsExpanding` | boolean | Upper value is growing -| `LowerIsExpanding` | boolean | Lower value is growing - -### Utilities - -- [.Find(lookupDate)]({{site.baseurl}}/utilities#find-indicator-result-by-date) -- [.RemoveWarmupPeriods()]({{site.baseurl}}/utilities#remove-warmup-periods) -- [.RemoveWarmupPeriods(qty)]({{site.baseurl}}/utilities#remove-warmup-periods) - -See [Utilities and Helpers]({{site.baseurl}}/utilities#utilities-for-indicator-results) for more information. - -## Example - -```python -// fetch historical quotes from your feed (your method) -IEnumerable quotes = GetHistoryFromFeed("MSFT") - -// calculate the Gator Oscillator -IEnumerable results = quotes.GetGator() -``` diff --git a/docs/_indicators/.unimplemented/MaEnvelopes.md b/docs/_indicators/.unimplemented/MaEnvelopes.md deleted file mode 100644 index 96f9ce8d..00000000 --- a/docs/_indicators/.unimplemented/MaEnvelopes.md +++ /dev/null @@ -1,93 +0,0 @@ ---- -title: Moving Average Envelopes -permalink: /indicators/MaEnvelopes/ -type: price-channel -layout: indicator ---- - -# {{ page.title }} - -[Moving Average Envelopes](https://en.wikipedia.org/wiki/Moving_average_envelope) is a price band overlay that is offset from the moving average of Close price over a lookback window. -[[Discuss] :speech_balloon:]({{site.github.base_repository_url}}/discussions/288 "Community discussion about this indicator") - -![image]({{site.charturl}}/MaEnvelopes.png) - -```python -// usage -IEnumerable results = - quotes.GetSmaEnvelopes(lookbackPeriods, percentOffset, movingAverageType) -``` - -## Parameters - -| name | type | notes -| -- |-- |-- -| `lookbackPeriods` | int | Number of periods (`N`) in the moving average. Must be greater than 1. -| `percentOffset` | double | Percent offset for envelope width. Example: 3.5% would be entered as 3.5 (not 0.035). Must be greater than 0. Typical values range from 2 to 10. Default is 2.5. -| `movingAverageType` | MaType | Type of moving average (e.g. SMA, EMA, HMA). See [MaType options](#matype-options) below. Default is `MaType.SMA`. - -### Historical quotes requirements - -See links in the supported [MaType options](#matype-options) section below for details on the inherited requirements for `quotes` and `lookbackPeriods`. - -`quotes` is an `Iterable[Quote]` collection of historical price quotes. It should have a consistent frequency (day, hour, minute, etc). See [the Guide]({{site.baseurl}}/guide/#historical-quotes) for more information. - -### MaType options - -These are the supported moving average types: - -| type | description -|-- |-- -| `MaType.ALMA` | [Arnaud Legoux Moving Average](../Alma#content) -| `MaType.DEMA` | [Double Exponential Moving Average](../DoubleEma#content) -| `MaType.EPMA` | [Endpoint Moving Average](../Epma#content) -| `MaType.EMA` | [Exponential Moving Average](../Ema#content) -| `MaType.HMA` | [Hull Moving Average](../Hma#content) -| `MaType.SMA` | [Simple Moving Average](../Sma#content) (default) -| `MaType.SMMA` | [Smoothed Moving Average](../Smma#content) -| `MaType.TEMA` | [Triple Exponential Moving Average](../TripleEma#content) -| `MaType.WMA` | [Weighted Moving Average](../Wma#content) - -:warning: For ALMA, default values are used for `offset` and `sigma`. - -## Return - -```python -IEnumerable -``` - -- This method returns a time series of all available indicator values for the `quotes` provided. -- 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 periods will have `None` values since there's not enough data to calculate; the quantity will vary based on the `movingAverageType` specified. - -:hourglass: **Convergence Warning**: Some moving average variants have decreasing magnitude, convergence-related precision errors that can be as high as ~5% deviation in indicator values for earlier periods. See links in the supported [MaType options](#matype-options) section above for more information. - -### MaEnvelopeResult - -| name | type | notes -| -- |-- |-- -| `Date` | DateTime | Date -| `Centerline` | decimal | Moving average for `N` lookback periods -| `UpperEnvelope` | decimal | Upper envelope band -| `LowerEnvelope` | decimal | Lower envelope band - -The moving average `Centerline` is based on the `movingAverageType` type specified. - -### Utilities - -- [.Find(lookupDate)]({{site.baseurl}}/utilities#find-indicator-result-by-date) -- [.RemoveWarmupPeriods(qty)]({{site.baseurl}}/utilities#remove-warmup-periods) - -See [Utilities and Helpers]({{site.baseurl}}/utilities#utilities-for-indicator-results) for more information. - -## Example - -```python -// fetch historical quotes from your feed (your method) -IEnumerable quotes = GetHistoryFromFeed("MSFT") - -// calculate 20-period SMA envelopes with 2.5% offset -IEnumerable results = - quotes.GetMaEnvelopes(20,2.5,MaType.SMA) -``` diff --git a/docs/_indicators/.unimplemented/PivotPoints.md b/docs/_indicators/.unimplemented/PivotPoints.md deleted file mode 100644 index b35bc842..00000000 --- a/docs/_indicators/.unimplemented/PivotPoints.md +++ /dev/null @@ -1,99 +0,0 @@ ---- -title: Pivot Points -permalink: /indicators/PivotPoints/ -type: price-channel -layout: indicator ---- - -# {{ page.title }} - -[Pivot Points](https://en.wikipedia.org/wiki/Pivot_point_(technical_analysis)) depict support and resistance levels, based on the prior lookback window. You can specify window size (e.g. month, week, day, etc). -See also the alternative [Rolling Pivot Points](../RollingPivots#content) variant for a modern update that uses a rolling window. -[[Discuss] :speech_balloon:]({{site.github.base_repository_url}}/discussions/274 "Community discussion about this indicator") - -![image]({{site.charturl}}/PivotPoints.png) - -```python -// usage -IEnumerable results = - quotes.GetPivotPoints(windowSize, pointType) -``` - -## Parameters - -| name | type | notes -| -- |-- |-- -| `windowSize` | PeriodSize | Size of the lookback window -| `pointType` | PivotPointType | Type of Pivot Point. Default is `PivotPointType.Standard` - -### Historical quotes requirements - -You must have at least `2` windows of `quotes` to cover the warmup periods. For example, if you specify a `Week` window size, you need at least 14 calendar days of `quotes`. - -`quotes` is an `Iterable[Quote]` collection of historical price quotes. It should have a consistent frequency (day, hour, minute, etc). See [the Guide]({{site.baseurl}}/guide/#historical-quotes) for more information. - -### PeriodSize options (for windowSize) - -| type | description -|-- |-- -| `PeriodSize.Month` | Use the prior month's data to calculate current month's Pivot Points -| `PeriodSize.Week` | [..] weekly -| `PeriodSize.Day` | [..] daily. Commonly used for intraday data. -| `PeriodSize.OneHour` | [..] hourly - -### PivotPointType options - -| type | description -|-- |-- -| `PivotPointType.Standard` | Floor Trading (default) -| `PivotPointType.Camarilla` | Camarilla -| `PivotPointType.Demark` | Demark -| `PivotPointType.Fibonacci` | Fibonacci -| `PivotPointType.Woodie` | Woodie - -## Return - -```python -IEnumerable -``` - -- This method returns a time series of all available indicator values for the `quotes` provided. -- 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 window will have `None` values since there's not enough data to calculate. - -:warning: **Warning**: The second window may be innaccurate if the first window contains incomplete data. For example, this can occur if you specify a `Month` window size and only provide 45 calendar days (1.5 months) of `quotes`. - -:paintbrush: **Repaint Warning**: the last window will be repainted if it does not contain a full window of data. - -### PivotPointsResult - -| name | type | notes -| -- |-- |-- -| `Date` | DateTime | Date -| `R3` | decimal | Resistance level 3 -| `R2` | decimal | Resistance level 2 -| `R1` | decimal | Resistance level 1 -| `PP` | decimal | Pivot Point -| `S1` | decimal | Support level 1 -| `S2` | decimal | Support level 2 -| `S3` | decimal | Support level 3 - -### Utilities - -- [.Find(lookupDate)]({{site.baseurl}}/utilities#find-indicator-result-by-date) -- [.RemoveWarmupPeriods()]({{site.baseurl}}/utilities#remove-warmup-periods) -- [.RemoveWarmupPeriods(qty)]({{site.baseurl}}/utilities#remove-warmup-periods) - -See [Utilities and Helpers]({{site.baseurl}}/utilities#utilities-for-indicator-results) for more information. - -## Example - -```python -// fetch historical quotes from your feed (your method) -IEnumerable quotes = GetHistoryFromFeed("SPY") - -// calculate Woodie-style month-based Pivot Points -IEnumerable results - = quotes.GetPivotPoints(PeriodSize.Month,PivotPointType.Woodie) -``` diff --git a/docs/_indicators/.unimplemented/Pivots.md b/docs/_indicators/.unimplemented/Pivots.md deleted file mode 100644 index 5bcc37ea..00000000 --- a/docs/_indicators/.unimplemented/Pivots.md +++ /dev/null @@ -1,94 +0,0 @@ ---- -title: Pivots -permalink: /indicators/Pivots/ -type: price-pattern -layout: indicator ---- - -# {{ page.title }} - -Pivots is an extended version of [Williams Fractal](../Fractal#content) that includes identification of Higher High, Lower Low, Higher Low, and Lower Low trends between pivots in a lookback window. -[[Discuss] :speech_balloon:]({{site.github.base_repository_url}}/discussions/436 "Community discussion about this indicator") - -![image]({{site.charturl}}/Pivots.png) - -```python -// usage -IEnumerable results = - quotes.GetPivots(leftSpan, rightSpan, maxTrendPeriods, endType) -``` - -## Parameters - -| name | type | notes -| -- |-- |-- -| `leftSpan` | int | Left evaluation window span width (`L`). Must be at least 2. Default is 2. -| `rightSpan` | int | Right evaluation window span width (`R`). Must be at least 2. Default is 2. -| `maxTrendPeriods` | int | Number of periods (`N`) in evaluation window. Must be greater than `leftSpan`. Default is 20. -| `endType` | EndType | Determines whether `Close` or `High/Low` are used to find end points. See [EndType options](#endtype-options) below. Default is `EndType.HighLow`. - -The total evaluation window size is `L+R+1`. - -### Historical quotes requirements - -You must have at least `L+R+1` periods of `quotes` to cover the warmup periods; however, more is typically provided since this is a chartable candlestick pattern. - -`quotes` is an `Iterable[Quote]` collection of historical price quotes. It should have a consistent frequency (day, hour, minute, etc). See [the Guide]({{site.baseurl}}/guide/#historical-quotes) for more information. - -### EndType options - -| type | description -|-- |-- -| `EndType.Close` | Chevron point identified from `Close` price -| `EndType.HighLow` | Chevron point identified from `High` and `Low` price (default) - -## Return - -```python -IEnumerable -``` - -- This method returns a time series of all available indicator values for the `quotes` provided. -- 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 `L` and last `R` periods in `quotes` are unable to be calculated since there's not enough prior/following data. - -:paintbrush: **Repaint Warning**: this price pattern looks forward and backward in the historical quotes so it will never identify a pivot in the last `R` periods of `quotes`. Fractals are retroactively identified. - -### PivotsResult - -| name | type | notes -| -- |-- |-- -| `Date` | DateTime | Date -| `HighPoint` | decimal | Value indicates a **high** point; otherwise `None` is returned. -| `LowPoint` | decimal | Value indicates a **low** point; otherwise `None` is returned. -| `HighLine` | decimal | Drawn line between two high points in the `maxTrendPeriods` -| `LowLine` | decimal | Drawn line between two low points in the `maxTrendPeriods` -| `HighTrend` | PivotTrend | Enum that represents higher high or lower high. See [PivotTrend values](#pivottrend-values) below. -| `LowTrend` | PivotTrend | Enum that represents higher low or lower low. See [PivotTrend values](#pivottrend-values) below. - -#### PivotTrend values - -| type | description -|-- |-- -| `PivotTrend.HH` | Higher high -| `PivotTrend.LH` | Lower high -| `PivotTrend.HL` | Higher low -| `PivotTrend.LL` | Lower low - -### Utilities - -- [.Find(lookupDate)]({{site.baseurl}}/utilities#find-indicator-result-by-date) -- [.RemoveWarmupPeriods(qty)]({{site.baseurl}}/utilities#remove-warmup-periods) - -See [Utilities and Helpers]({{site.baseurl}}/utilities#utilities-for-indicator-results) for more information. - -## Example - -```python -// fetch historical quotes from your feed (your method) -IEnumerable quotes = GetHistoryFromFeed("SPY") - -// calculate Pivots(2,2,20) using High/Low values -IEnumerable results = quotes.GetPivots(2,2,20,EndType.HighLow) -``` diff --git a/docs/_indicators/.unimplemented/Renko.md b/docs/_indicators/.unimplemented/Renko.md deleted file mode 100644 index b2efce22..00000000 --- a/docs/_indicators/.unimplemented/Renko.md +++ /dev/null @@ -1,117 +0,0 @@ ---- -title: Renko Chart -permalink: /indicators/Renko/ -type: price-transform -layout: indicator ---- - -# {{ page.title }} - -The [Renko Chart](https://en.m.wikipedia.org/wiki/Renko_chart) is a Japanese price transformed candlestick pattern that uses "bricks" to show a defined increment of change over a non-linear time series. Transitions can use either `Close` or `High/Low` price values. An [ATR variant](#atr-variant) is also provided where brick size is determined by Average True Range values. -[[Discuss] :speech_balloon:]({{site.github.base_repository_url}}/discussions/478 "Community discussion about this indicator") - -![image]({{site.charturl}}/Renko.png) - -```python -// usage -IEnumerable results = - quotes.GetRenko(brickSize, endType) -``` - -## Parameters - -| name | type | notes -| -- |-- |-- -| `brickSize` | decimal | Brick size. Must be greater than 0. -| `endType` | EndType | See options below. Default is `EndType.Close` - -### Historical quotes requirements - -You must have at least two periods of `quotes` to cover the warmup periods; however, more is typically provided since this is a chartable candlestick pattern. - -`quotes` is an `Iterable[Quote]` collection of historical price quotes. It should have a consistent frequency (day, hour, minute, etc). See [the Guide]({{site.baseurl}}/guide/#historical-quotes) for more information. - -### EndType options - -| type | description -|-- |-- -| `EndType.Close` | Brick change threshold measured from `Close` price (default) -| `EndType.HighLow` | Brick change threshold measured from `High` and `Low` price - -## Return - -```python -IEnumerable -``` - -- This method returns a time series of all available indicator values for the `quotes` provided. -- It does not return a single incremental indicator value. - -:warning: WARNING! Unlike most indicators in this library, this indicator DOES NOT return the same number of elements as there are in the historical quotes. Renko bricks are added to the results once the `brickSize` change is achieved. For example, if it takes 3 days for a $2.50 price change to occur an entry is made on the third day while the first two are skipped. If a period change occurs at multiples of `brickSize`, multiple bricks are drawn with the same `Date`. See [online documentation](https://www.investopedia.com/terms/r/renkochart.asp) for more information. - -### RenkoResult - -Each result record represents one Renko brick. - -| name | type | notes -| -- |-- |-- -| `Date` | DateTime | Formation date of brick(s) -| `Open` | decimal | Brick open price -| `High` | decimal | Highest high during elapsed quotes periods -| `Low` | decimal | Lowest low during elapsed quotes periods -| `Close` | decimal | Brick close price -| `Volume` | decimal | Sum of Volume over elapsed quotes periods -| `IsUp` | boolean | Direction of brick (true=up,false=down) - -:warning: WARNING! When multiple bricks are drawn from a single `quote` period, the extra information about `High` and `Low` wicks and `Volume` is potentially confusing to interpret. `High` and `Low` wicks will be the same across the multiple bricks; and `Volume` is portioning evenly across the number of bricks. For example, if within one `quote` period 3 bricks are drawn, the `Volume` for each brick will be `(sum of quotes Volume since last brick) / 3`. - -### Utilities - -- [.ConvertToQuotes()]({{site.baseurl}}/utilities#convert-to-quotes) -- [.Find(lookupDate)]({{site.baseurl}}/utilities#find-indicator-result-by-date) -- [.RemoveWarmupPeriods(qty)]({{site.baseurl}}/utilities#remove-warmup-periods) - -See [Utilities and Helpers]({{site.baseurl}}/utilities#utilities-for-indicator-results) for more information. - -## Example - -```python -// fetch historical quotes from your feed (your method) -IEnumerable quotes = GetHistoryFromFeed("MSFT") - -// calculate -IEnumerable results = quotes.GetRenko(2.5) -``` - -## ATR Variant - -```python -// usage -IEnumerable results = - quotes.GetRenkoAtr(atrPeriods, endType) -``` - -### Parameters for ATR - -| name | type | notes -| -- |-- |-- -| `atrPeriod` | int | Number of lookback periods (`A`) for ATR evaluation. Must be greater than 0. -| `endType` | EndType | See options below. Default is `EndType.Close` - -#### Historical quotes requirements for ATR - -You must have at least `A+100` periods of `quotes`. - -`quotes` is an `Iterable[Quote]` collection of historical price quotes. It should have a consistent frequency (day, hour, minute, etc). See [the Guide]({{site.baseurl}}/guide/#historical-quotes) for more information. - -## Return for ATR - -```python -IEnumerable -``` - -- This method returns a time series of all available indicator values for the `quotes` provided. -- It always returns the same number of elements as there are in the historical quotes. -- It does not return a single incremental indicator value. - -:paintbrush: **Repaint Warning**: When using the `GetRenkoAtr()` variant, the last [Average True Range (ATR)](../Atr/#content) value is used to set `brickSize`. Since the ATR changes over time, historical bricks will be repainted as new periods are added or updated in `quotes`. diff --git a/docs/_indicators/.unimplemented/RollingPivots.md b/docs/_indicators/.unimplemented/RollingPivots.md deleted file mode 100644 index 41e1a32f..00000000 --- a/docs/_indicators/.unimplemented/RollingPivots.md +++ /dev/null @@ -1,88 +0,0 @@ ---- -title: Rolling Pivot Points -permalink: /indicators/RollingPivots/ -type: price-channel -layout: indicator ---- - -# {{ page.title }} - -Created by Dave Skender, Rolling Pivot Points is a modern update to traditional fixed calendar window [Pivot Points](../PivotPoints#content). It depicts support and resistance levels, based on a defined _rolling_ window and offset. -[[Discuss] :speech_balloon:]({{site.github.base_repository_url}}/discussions/274 "Community discussion about this indicator") - -![image]({{site.charturl}}/RollingPivots.png) - -```python -// usage -IEnumerable results = - quotes.GetRollingPivots(lookbackPeriods, offsetPeriods, pointType) -``` - -## Parameters - -| name | type | notes -| -- |-- |-- -| `windowPeriods` | int | Number of periods (`W`) in the evaluation window. Must be greater than 0 to calculate; but is typically specified in the 5-20 range. -| `offsetPeriods` | int | Number of periods (`F`) to offset the window from the current period. Must be greater than or equal to 0 and is typically less than or equal to `W`. -| `pointType` | PivotPointType | Type of Pivot Point. Default is `PivotPointType.Standard` - -For example, a window of 8 with an offset of 4 would evaluate quotes like: `W W W W W W W W F F F F C`, where `W` is the window included in the Pivot Point calculation, and `F` is the distance from the current evaluation position `C`. A `quotes` with daily bars using `W/F` values of `20/10` would most closely match the `month` variant of the traditional [Pivot Points](../PivotPoints#content) indicator. - -### Historical quotes requirements - -You must have at least `W+F` 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]({{site.baseurl}}/guide/#historical-quotes) for more information. - -### PivotPointType options - -| type | description -|-- |-- -| `PivotPointType.Standard` | Floor Trading (default) -| `PivotPointType.Camarilla` | Camarilla -| `PivotPointType.Demark` | Demark -| `PivotPointType.Fibonacci` | Fibonacci -| `PivotPointType.Woodie` | Woodie - -## Return - -```python -IEnumerable -``` - -- This method returns a time series of all available indicator values for the `quotes` provided. -- 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 `W+F-1` periods will have `None` values since there's not enough data to calculate. - -### RollingPivotsResult - -| name | type | notes -| -- |-- |-- -| `Date` | DateTime | Date -| `R3` | decimal | Resistance level 3 -| `R2` | decimal | Resistance level 2 -| `R1` | decimal | Resistance level 1 -| `PP` | decimal | Pivot Point -| `S1` | decimal | Support level 1 -| `S2` | decimal | Support level 2 -| `S3` | decimal | Support level 3 - -### Utilities - -- [.Find(lookupDate)]({{site.baseurl}}/utilities#find-indicator-result-by-date) -- [.RemoveWarmupPeriods()]({{site.baseurl}}/utilities#remove-warmup-periods) -- [.RemoveWarmupPeriods(qty)]({{site.baseurl}}/utilities#remove-warmup-periods) - -See [Utilities and Helpers]({{site.baseurl}}/utilities#utilities-for-indicator-results) for more information. - -## Example - -```python -// fetch historical quotes from your feed (your method) -IEnumerable quotes = GetHistoryFromFeed("SPY") - -// calculate Woodie-style 14 period Rolling Pivot Points -IEnumerable results - = quotes.GetRollingPivots(14,0,PivotPointType.Woodie) -``` diff --git a/docs/_indicators/.unimplemented/ZigZag.md b/docs/_indicators/.unimplemented/ZigZag.md deleted file mode 100644 index 217f0bc8..00000000 --- a/docs/_indicators/.unimplemented/ZigZag.md +++ /dev/null @@ -1,84 +0,0 @@ ---- -title: Zig Zag -permalink: /indicators/ZigZag/ -type: price-transform -layout: indicator ---- - -# {{ page.title }} - -[Zig Zag](https://school.stockcharts.com/doku.php?id=technical_indicators:zigzag) is a price chart overlay that simplifies the up and down movements and transitions based on a percent change smoothing threshold. -[[Discuss] :speech_balloon:]({{site.github.base_repository_url}}/discussions/226 "Community discussion about this indicator") - -![image]({{site.charturl}}/ZigZag.png) - -```python -// usage -IEnumerable results = - quotes.GetZigZag(endType, percentChange) -``` - -## Parameters - -| name | type | notes -| -- |-- |-- -| `endType` | EndType | Determines whether `Close` or `High/Low` are used to measure percent change. See [EndType options](#endtype-options) below. Default is `EndType.Close`. -| `percentChange` | decimal | Percent change required to establish a line endpoint. Example: 3.5% would be entered as 3.5 (not 0.035). Must be greater than 0. Typical values range from 3 to 10. Default is 5. - -### Historical quotes requirements - -You must have at least two periods of `quotes` to cover the warmup periods, but notably more is needed to be useful. - -`quotes` is an `Iterable[Quote]` collection of historical price quotes. It should have a consistent frequency (day, hour, minute, etc). See [the Guide]({{site.baseurl}}/guide/#historical-quotes) for more information. - -### EndType options - -| type | description -|-- |-- -| `EndType.Close` | Percent change measured from `Close` price (default) -| `EndType.HighLow` | Percent change measured from `High` and `Low` price - -## Return - -```python -IEnumerable -``` - -- This method returns a time series of all available indicator values for the `quotes` provided. -- It always returns the same number of elements as there are in the historical quotes. -- It does not return a single incremental indicator value. -- If you do not supply enough points to cover the percent change, there will be no Zig Zag points or lines. -- The first line segment starts after the first confirmed point; ZigZag values before the first confirmed point will be `None`. -- The last line segment is an approximation as the direction is indeterminate. - -:warning: **Warning**: depending on the specified `endType`, the indicator cannot be initialized if the first `Quote` in `quotes` has a `High`,`Low`, or `Close` value of 0 (zero). - -:paintbrush: **Repaint Warning**: the last line segement will always be redrawn back to the last known pivot. Do not attempt to calculate incremental values since previous values may change based on newer quotes. - -### ZigZagResult - -| name | type | notes -| -- |-- |-- -| `Date` | DateTime | Date -| `ZigZag` | decimal | Zig Zag line for `percentChange` -| `PointType` | string | Zig Zag endpoint type (`H` for high point, `L` for low point) -| `RetraceHigh` | decimal | Retrace line for high points -| `RetraceLow` | decimal | Retrace line for low points - -### Utilities - -- [.Find(lookupDate)]({{site.baseurl}}/utilities#find-indicator-result-by-date) -- [.RemoveWarmupPeriods(qty)]({{site.baseurl}}/utilities#remove-warmup-periods) - -See [Utilities and Helpers]({{site.baseurl}}/utilities#utilities-for-indicator-results) for more information. - -## Example - -```python -// fetch historical quotes from your feed (your method) -IEnumerable quotes = GetHistoryFromFeed("SPY") - -// calculate 3% change ZIGZAG -IEnumerable results - = quotes.GetZigZag(EndType.Close,3) -``` diff --git a/docs/_indicators/Alligator.md b/docs/_indicators/Alligator.md index a841cd9d..0f0e29a5 100644 --- a/docs/_indicators/Alligator.md +++ b/docs/_indicators/Alligator.md @@ -8,13 +8,19 @@ layout: indicator # {{ page.title }}
-## **get_alligator**(*quotes*) +## **get_alligator**(*quotes, jaw_periods==13, jaw_offset=8, teeth_periods=8, teeth_offset=5, lips_periods=5, lips_offset=3*) ## Parameters | name | type | notes | -- | -- | -- | `quotes` | Iterable[Quote] | Iterable(such as list or an object having `__iter__()`) of the [Quote class]({{site.baseurl}}/guide/#historical-quotes) or [its sub-class]({{site.baseurl}}/guide/#using-custom-quote-classes). +| `jaw_periods` | int, *default 13* | Number of periods (`JP`) for the Jaw moving average. Must be greater than `teeth_periods`. +| `jaw_offset` | int, *default 8* | Number of periods (`JO`) for the Jaw offset. Must be greater than 0. +| `teeth_periods` | int, *default 8* | Number of periods (`TP`) for the Teeth moving average. Must be greater than `lips_periods`. +| `teeth_offset` | int, *default 5* | Number of periods (`TO`) for the Teeth offset. Must be greater than 0. +| `lips_periods` | int, *default 5* | Number of periods (`LP`) for the Lips moving average. Must be greater than 0. +| `lips_offset` | int, *default 3* | Number of periods (`LO`) for the Lips offset. Must be greater than 0. ### Historical quotes requirements @@ -22,16 +28,6 @@ You must have at least 115 periods of `quotes`. Since this uses a smoothing tech `quotes` is an `Iterable[Quote]` collection of historical price quotes. It should have a consistent frequency (day, hour, minute, etc). See [the Guide]({{site.baseurl}}/guide/#historical-quotes) for more information. -### Internal parameters - -This indicator uses fixed interal parameters for the three moving averages of median price `(H+L)/2`. - -| SMMA | Lookback | Offset -| -- |-- |-- -| Jaw | 13 | 8 -| Teeth | 8 | 5 -| Lips | 5 | 3 - ## Returns ```python @@ -39,6 +35,7 @@ AlligatorResults[AlligatorResult] ``` - This method returns a time series of all available indicator values for the `quotes` provided. +- `AlligatorResults` is just a list of `AlligatorResult`. - 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 10-20 periods will have `None` values since there's not enough data to calculate. @@ -76,7 +73,7 @@ results = indicators.get_alligator(quotes) ## About: {{ page.title }} -Created by Bill Williams, Alligator is a depiction of three smoothed moving averages of median price, showing chart patterns that compared to an alligator's feeding habits when describing market movement. The moving averages are known as the Jaw, Teeth, and Lips, which are calculated using specific lookback and offset periods. +Created by Bill Williams, Alligator is a depiction of three smoothed moving averages of median price, showing chart patterns that compared to an alligator's feeding habits when describing market movement. The moving averages are known as the Jaw, Teeth, and Lips, which are calculated using specific lookback and offset periods. See also the [Gator Oscillator](../Gator#content). [[Discuss] :speech_balloon:]({{site.github.base_repository_url}}/discussions/385 "Community discussion about this indicator") ![image]({{site.charturl}}/Alligator.png) diff --git a/docs/_indicators/Beta.md b/docs/_indicators/Beta.md index 3b06c531..8e36d749 100644 --- a/docs/_indicators/Beta.md +++ b/docs/_indicators/Beta.md @@ -9,7 +9,7 @@ layout: indicator # {{ page.title }}
-## **get_beta**(*market_history, eval_history, lookback_periods*) +## **get_beta**(*market_history, eval_history, lookback_periods, beta_type=BetaType.STANDARD*) ## Parameters @@ -18,20 +18,19 @@ layout: indicator | `market_history` | Iterable[Quote] | Historical [market] Quotes data should be at any consistent frequency (day, hour, minute, etc). This `market` quotes will be used to establish the baseline. | `eval_history` | Iterable[Quote] | Historical [evaluation stock] Quotes data should be at any consistent frequency (day, hour, minute, etc). | `lookback_periods` | int | Number of periods (`N`) in the lookback period. Must be greater than 0 to calculate; however we suggest a larger period for statistically appropriate sample size and especially when using Beta +/-. - - +| `beta_type` | BetaType, *default BetaType.STANDARD* | Type of Beta to calculate. See [BetaType options](#betatype-options) below. ### Historical quotes requirements You must have at least `N` periods of quotes to cover the warmup periods. You must have at least the same matching date elements of `market_history`. Exception will be thrown if not matched. Historical price quotes should have a consistent frequency (day, hour, minute, etc). See [the Guide]({{site.baseurl}}/guide/#historical-quotes) for more information. - +| `STANDARD` | Standard Beta only. Uses all historical quotes. +| `UP` | Upside Beta only. Uses historical quotes from market up bars only. +| `DOWN` | Downside Beta only. Uses historical quotes from market down bars only. +| `ALL` | Returns all of the above. Use this option if you want `ratio` and `convexity` values returned. Note: 3× slower to calculate. ## Returns @@ -40,6 +39,7 @@ BetaResults[BetaResult] ``` - This method returns a time series of all available indicator values for the `quotes` provided. +- `BetaResults` is just a list of `BetaResult`. - 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-1` periods will have `None` values since there's not enough data to calculate. @@ -50,11 +50,12 @@ BetaResults[BetaResult] | -- |-- |-- | `date` | datetime | Date | `beta` | float, Optional | Beta coefficient based on `N` lookback periods - - +| `beta_up` | float, Optional | Beta+ (Up Beta) +| `beta_down` | float, Optional | Beta- (Down Beta) +| `ratio` | float, Optional | Beta ratio is `beta_up/beta_down` +| `convexity` | float, Optional | Beta convexity is (beta_up-beta_down)2 +| `returns_eval` | float, Optional | Returns of evaluated quotes (`R`) +| `returns_mrkt` | float, Optional | Returns of market quotes (`Rm`) ### Utilities diff --git a/docs/_indicators/Chandelier.md b/docs/_indicators/Chandelier.md index 0aea7be1..4a8ea89e 100644 --- a/docs/_indicators/Chandelier.md +++ b/docs/_indicators/Chandelier.md @@ -8,7 +8,7 @@ layout: indicator # {{ page.title }}
-## **get_chandelier**(*quotes, lookback_periods=22, multiplier=3.0*) +## **get_chandelier**(*quotes, lookback_periods=22, multiplier=3.0, chandelier_type=ChandelierType.LONG*) ## Parameters @@ -17,8 +17,7 @@ layout: indicator | `quotes` | Iterable[Quote] | Iterable(such as list or an object having `__iter__()`) of the [Quote class]({{site.baseurl}}/guide/#historical-quotes) or [its sub-class]({{site.baseurl}}/guide/#using-custom-quote-classes). | `lookback_periods` | int, *default 22* | Number of periods (`N`) for the lookback evaluation. | `multiplier` | float, *default 3.0* | Multiplier number must be a positive value. - - +| `chandelier_type` | ChandelierType, *default ChandelierType.LONG* | Direction of exit. See [ChandelierType options](#chandeliertype-options) below. ### Historical quotes requirements @@ -26,12 +25,12 @@ You must have at least `N+1` 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]({{site.baseurl}}/guide/#historical-quotes) for more information. - +| `LONG` | Intended as stop loss value for long positions. (default) +| `SHORT` | Intended as stop loss value for short positions. ## Return @@ -40,6 +39,7 @@ ChandelierResults[ChandelierResult] ``` - This method returns a time series of all available indicator values for the `quotes` provided. +- `ChandelierResults` is just a list of `ChandelierResult`. - 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` periods will have `None` Chandelier values since there's not enough data to calculate. diff --git a/docs/_indicators/Gator.md b/docs/_indicators/Gator.md new file mode 100644 index 00000000..2239d5e0 --- /dev/null +++ b/docs/_indicators/Gator.md @@ -0,0 +1,80 @@ +--- +title: Gator Oscillator +permalink: /indicators/Gator/ +type: price-trend +layout: indicator +--- + +# {{ page.title }} +
+ +## **get_gator**(*quotes: Iterable[Quote]*) +## **get_gator**(*quotes: Iterable[AlligatorResult]*) + +## Parameters + +| name | type | notes +| -- |-- |-- +| `quotes` | Iterable[Quote] or Iterable[AlligatorResult] | Iterable(such as list or an object having `__iter__()`) of the [Quote]({{site.baseurl}}/guide/#historical-quotes) or [Alligator Result](../Alligator#content). + +## Historical quotes requirements + +If using default settings, you must have at least 121 periods of `quotes`. Since this uses a smoothing technique, we recommend you use at least 271 data points prior to the intended usage date for better precision. If using a custom Alligator configuration, see [Alligator documentation](../Alligator#historical-quotes-requirements) for historical quotes requirements. + +`quotes` is an `Iterable[Quote]` or `Iterable[AlligatorResult]` collection of historical price quotes. It should have a consistent frequency (day, hour, minute, etc). See [the Guide]({{site.baseurl}}/guide/#historical-quotes) for more information. + +## Return + +```csharp +GatorResults[GatorResult] +``` + +- This method returns a time series of all available indicator values for the `quotes` provided. +- `GatorResults` is just a list of `GatorResult`. +- 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 10-20 periods will have `None` values since there's not enough data to calculate. + +:hourglass: **Convergence Warning**: The first 150 periods will have decreasing magnitude, convergence-related precision errors that can be as high as ~5% deviation in indicator values for earlier periods. + +### GatorResult + +| name | type | notes +| -- |-- |-- +| `date` | datetime | Date +| `upper` | float, Optional | Absolute value of Alligator `Jaw-Teeth` +| `lower` | float, Optional | Absolute value of Alligator `Lips-Teeth` +| `is_upper_expanding` | bool, Optional | Upper value is growing +| `is_lower_expanding` | bool, Optional | Lower value is growing + +### Utilities + +- [.find(lookup_date)]({{site.baseurl}}/utilities#find-indicator-result-by-date) +- [.remove_warmup_periods()]({{site.baseurl}}/utilities#remove-warmup-periods) +- [.remove_warmup_periods(qty)]({{site.baseurl}}/utilities#remove-warmup-periods) + +See [Utilities and Helpers]({{site.baseurl}}/utilities#utilities-for-indicator-results) for more information. + +## Example + +```python +from stock_indicators import indicators + +# This method is NOT a part of the library. +quotes = get_history_from_feed("SPY") + +# Calculate the Gator Oscillator +results = indicators.get_gator(quotes) +``` + +## About: {{ page.title }} + +Created by Bill Williams, the Gator Oscillator is an expanded view of [Williams Alligator](../Alligator#content). +[[Discuss] :speech_balloon:]({{site.github.base_repository_url}}/discussions/385 "Community discussion about this indicator") + +![image]({{site.charturl}}/Gator.png) + +### Sources + +- [C# core]({{site.base_sourceurl}}/e-k/Gator/Gator.cs) +- [Python wrapper]({{site.sourceurl}}/gator.py) diff --git a/docs/_indicators/MaEnvelopes.md b/docs/_indicators/MaEnvelopes.md new file mode 100644 index 00000000..10cb2241 --- /dev/null +++ b/docs/_indicators/MaEnvelopes.md @@ -0,0 +1,102 @@ +--- +title: Moving Average Envelopes +permalink: /indicators/MaEnvelopes/ +type: price-channel +layout: indicator +--- + +# {{ page.title }} +
+ +## **get_ma_envelopes**(*quotes, lookback_periods, percent_offset=2.5, ma_type=MAType.SMA*) + +## Parameters + +| name | type | notes +| -- |-- |-- +| `quotes` | Iterable[Quote] | Iterable(such as list or an object having `__iter__()`) of the [Quote class]({{site.baseurl}}/guide/#historical-quotes) or [its sub-class]({{site.baseurl}}/guide/#using-custom-quote-classes). +| `lookback_periods` | int | Number of periods (`N`) in the moving average. Must be greater than 1. +| `percent_offset` | float, *default 2.5* | Percent offset for envelope width. Example: 3.5% would be entered as 3.5 (not 0.035). Must be greater than 0. Typical values range from 2 to 10. +| `ma_type` | MAType, *default MAType.SMA* | Type of moving average (e.g. SMA, EMA, HMA). See [MAType options](#matype-options) below. + +### Historical quotes requirements + +See links in the supported [MAType options](#matype-options) section below for details on the inherited requirements for `quotes` and `lookback_periods`. + +`quotes` is an `Iterable[Quote]` collection of historical price quotes. It should have a consistent frequency (day, hour, minute, etc). See [the Guide]({{site.baseurl}}/guide/#historical-quotes) for more information. + +### MAType options + +These are the supported moving average types: + +| type | description +|-- |-- +| `MAType.ALMA` | [Arnaud Legoux Moving Average](../Alma#content) +| `MAType.DEMA` | [Double Exponential Moving Average](../DoubleEma#content) +| `MAType.EPMA` | [Endpoint Moving Average](../Epma#content) +| `MAType.EMA` | [Exponential Moving Average](../Ema#content) +| `MAType.HMA` | [Hull Moving Average](../Hma#content) +| `MAType.SMA` | [Simple Moving Average](../Sma#content) (default) +| `MAType.SMMA` | [Smoothed Moving Average](../Smma#content) +| `MAType.TEMA` | [Triple Exponential Moving Average](../TripleEma#content) +| `MAType.WMA` | [Weighted Moving Average](../Wma#content) + +:warning: For ALMA, default values are used for `offset` and `sigma`. + +## Return + +```csharp +MAEnvelopeResults[MAEnvelopeResult] +``` + +- This method returns a time series of all available indicator values for the `quotes` provided. +- `MAEnvelopeResults` is just a list of `MAEnvelopeResult`. +- 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 periods will have `None` values since there's not enough data to calculate; the quantity will vary based on the `ma_type` specified. + +:hourglass: **Convergence Warning**: Some moving average variants have decreasing magnitude, convergence-related precision errors that can be as high as ~5% deviation in indicator values for earlier periods. See links in the supported [MAType options](#matype-options) section above for more information. + +### MaEnvelopeResult + +| name | type | notes +| -- |-- |-- +| `date` | datetime | Date +| `center_line` | Decimal, Optional | Moving average for `N` lookback periods +| `upper_envelope` | Decimal, Optional | Upper envelope band +| `lower_envelope` | Decimal, Optional | Lower envelope band + +The moving average `center_line` is based on the `ma_type` type specified. + +### Utilities + +- [.find(lookup_date)]({{site.baseurl}}/utilities#find-indicator-result-by-date) +- [.remove_warmup_periods(qty)]({{site.baseurl}}/utilities#remove-warmup-periods) + +See [Utilities and Helpers]({{site.baseurl}}/utilities#utilities-for-indicator-results) for more information. + +## Example + +## Example + +```python +from stock_indicators import indicators + +# This method is NOT a part of the library. +quotes = get_history_from_feed("SPY") + +# Calculate 20-period SMA envelopes with 2.5% offset +results = indicators.get_ma_envelopes(quotes, 20, 2.5, MAType.SMA); +``` + +## About: {{ page.title }} + +[Moving Average Envelopes](https://en.wikipedia.org/wiki/Moving_average_envelope) is a price band overlay that is offset from the moving average of Close price over a lookback window. +[[Discuss] :speech_balloon:]({{site.github.base_repository_url}}/discussions/288 "Community discussion about this indicator") + +![image]({{site.charturl}}/MaEnvelopes.png) + +### Sources + +- [C# core]({{site.base_sourceurl}}/m-r/MaEnvelopes/MaEnvelopes.cs) +- [Python wrapper]({{site.sourceurl}}/ma_envelopes.py) diff --git a/docs/_indicators/PivotPoints.md b/docs/_indicators/PivotPoints.md new file mode 100644 index 00000000..17fc215a --- /dev/null +++ b/docs/_indicators/PivotPoints.md @@ -0,0 +1,106 @@ +--- +title: Pivot Points +permalink: /indicators/PivotPoints/ +type: price-channel +layout: indicator +--- + +# {{ page.title }} +
+ +## **get_pivot_points**(*quotes, window_size, point_type=PivotPointType.STANDARD*) + +## Parameters + +| name | type | notes +| -- |-- |-- +| `quotes` | Iterable[Quote] | Iterable(such as list or an object having `__iter__()`) of the [Quote class]({{site.baseurl}}/guide/#historical-quotes) or [its sub-class]({{site.baseurl}}/guide/#using-custom-quote-classes). +| `window_size` | PeriodSize | Size of the lookback window. See [PeriodSize options](#periodsize-options-for-window_size) below. +| `point_type` | PivotPointType, *default PivotPointType.STANDARD* | Type of Pivot Point. See [PivotPointType options](#pivotpointtype-options) below. + +### Historical quotes requirements + +You must have at least `2` windows of `quotes` to cover the warmup periods. For example, if you specify a `WEEK` window size, you need at least 14 calendar days of `quotes`. + +`quotes` is an `Iterable[Quote]` collection of historical price quotes. It should have a consistent frequency (day, hour, minute, etc). See [the Guide]({{site.baseurl}}/guide/#historical-quotes) for more information. + +### PeriodSize options (for `window_size`) + +| type | description +|-- |-- +| `PeriodSize.MONTH` | Use the prior month's data to calculate current month's Pivot Points +| `PeriodSize.WEEK` | [..] weekly +| `PeriodSize.DAY` | [..] daily. Commonly used for intraday data. +| `PeriodSize.ONEHOUR` | [..] hourly + +### PivotPointType options + +| type | description +|-- |-- +| `PivotPointType.STANDARD` | Floor Trading (default) +| `PivotPointType.CAMARILLA` | Camarilla +| `PivotPointType.DEMARK` | Demark +| `PivotPointType.FIBONACCI` | Fibonacci +| `PivotPointType.WOODIE` | Woodie + +## Return + +```python +PivotPointsResults[PivotPointsResult] +``` + +- This method returns a time series of all available indicator values for the `quotes` provided. +- `PivotPointsResults` is just a list of `PivotPointsResult`. +- 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 window will have `None` values since there's not enough data to calculate. + +:warning: **Warning**: The second window may be innaccurate if the first window contains incomplete data. For example, this can occur if you specify a `MONTH` window size and only provide 45 calendar days (1.5 months) of `quotes`. + +:paintbrush: **Repaint Warning**: the last window will be repainted if it does not contain a full window of data. + +### PivotPointsResult + +| name | type | notes +| -- |-- |-- +| `date` | datetime | Date +| `r3` | Decimal, Optional | Resistance level 3 +| `r2` | Decimal, Optional | Resistance level 2 +| `r1` | Decimal, Optional | Resistance level 1 +| `pp` | Decimal, Optional | Pivot Point +| `s1` | Decimal, Optional | Support level 1 +| `s2` | Decimal, Optional | Support level 2 +| `s3` | Decimal, Optional | Support level 3 + +### Utilities + +- [.find(lookup_date)]({{site.baseurl}}/utilities#find-indicator-result-by-date) +- [.remove_warmup_periods()]({{site.baseurl}}/utilities#remove-warmup-periods) +- [.remove_warmup_periods(qty)]({{site.baseurl}}/utilities#remove-warmup-periods) + +See [Utilities and Helpers]({{site.baseurl}}/utilities#utilities-for-indicator-results) for more information. + +## Example + +```python +from stock_indicators import indicators + +# This method is NOT a part of the library. +quotes = get_history_from_feed("SPY") + +# Calculate Woodie-style month-based Pivot Points +results = indicators.get_pivot_points(quotes, PeriodSize.MONTH, PivotPointType.WOODIE); +``` + +## About: {{ page.title }} + +[Pivot Points](https://en.wikipedia.org/wiki/Pivot_point_(technical_analysis)) depict support and resistance levels, based on the prior lookback window. You can specify window size (e.g. month, week, day, etc). +See also the alternative [Rolling Pivot Points](../RollingPivots#content) variant for a modern update that uses a rolling window. +[[Discuss] :speech_balloon:]({{site.github.base_repository_url}}/discussions/274 "Community discussion about this indicator") + +![image]({{site.charturl}}/PivotPoints.png) + +### Sources + +- [C# core]({{site.base_sourceurl}}/m-r/PivotPoints/PivotPoints.cs) +- [Python wrapper]({{site.sourceurl}}/pivot_points.py) diff --git a/docs/_indicators/Pivots.md b/docs/_indicators/Pivots.md new file mode 100644 index 00000000..0e2fb8c4 --- /dev/null +++ b/docs/_indicators/Pivots.md @@ -0,0 +1,102 @@ +--- +title: Pivots +permalink: /indicators/Pivots/ +type: price-pattern +layout: indicator +--- + +# {{ page.title }} +
+ +## **get_pivots**(*quotes, left_span=2, right_span=2, max_trend_periods=20, end_type=EndType.HIGH_LOW*) + +## Parameters + +| name | type | notes +| -- |-- |-- +| `quotes` | Iterable[Quote] | Iterable(such as list or an object having `__iter__()`) of the [Quote class]({{site.baseurl}}/guide/#historical-quotes) or [its sub-class]({{site.baseurl}}/guide/#using-custom-quote-classes). +| `left_span` | int, *default 2* | Left evaluation window span width (`L`). Must be at least 2. +| `right_span` | int, *default 2* | Right evaluation window span width (`R`). Must be at least 2. +| `max_trend_periods` | int, *default 20* | Number of periods (`N`) in evaluation window. Must be greater than `leftSpan`. +| `end_type` | EndType, *default EndType.HIGH_LOW* | Determines whether `close` or `high/low` are used to find end points. See [EndType options](#endtype-options) below. + +The total evaluation window size is `L+R+1`. + +### Historical quotes requirements + +You must have at least `L+R+1` periods of `quotes` to cover the warmup periods; however, more is typically provided since this is a chartable candlestick pattern. + +`quotes` is an `Iterable[Quote]` collection of historical price quotes. It should have a consistent frequency (day, hour, minute, etc). See [the Guide]({{site.baseurl}}/guide/#historical-quotes) for more information. + +### EndType options + +| type | description +|-- |-- +| `CLOSE` | Chevron point identified from `close` price +| `HIGH_LOW` | Chevron point identified from `high` and `low` price (default) + +## Return + +```python +PivotsResults[PivotsResult] +``` + +- This method returns a time series of all available indicator values for the `quotes` provided. +- `PivotsResults` is just a list of `PivotsResult`. +- 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 `L` and last `R` periods in `quotes` are unable to be calculated since there's not enough prior/following data. + +:paintbrush: **Repaint Warning**: this price pattern looks forward and backward in the historical quotes so it will never identify a pivot in the last `R` periods of `quotes`. Fractals are retroactively identified. + +### PivotsResult + +| name | type | notes +| -- |-- |-- +| `date` | datetime | Date +| `high_point` | Decimal, Optional | Value indicates a **high** point; otherwise `None` is returned. +| `low_point` | Decimal, Optional | Value indicates a **low** point; otherwise `None` is returned. +| `high_line` | Decimal, Optional | Drawn line between two high points in the `max_trend_periods` +| `low_line` | Decimal, Optional | Drawn line between two low points in the `max_trend_periods` +| `high_trend` | PivotTrend, Optional | Enum that represents higher high or lower high. See [PivotTrend values](#pivottrend-values) below. +| `low_trend` | PivotTrend, Optional | Enum that represents higher low or lower low. See [PivotTrend values](#pivottrend-values) below. + +#### PivotTrend values + +| type | description +|-- |-- +| `PivotTrend.HH` | Higher high +| `PivotTrend.LH` | Lower high +| `PivotTrend.HL` | Higher low +| `PivotTrend.LL` | Lower low + +### Utilities + +- [.find(lookup_date)]({{site.baseurl}}/utilities#find-indicator-result-by-date) +- [.remove_warmup_periods(qty)]({{site.baseurl}}/utilities#remove-warmup-periods) + +See [Utilities and Helpers]({{site.baseurl}}/utilities#utilities-for-indicator-results) for more information. + +## Example + +```python +from stock_indicators import indicators + +# This method is NOT a part of the library. +quotes = get_history_from_feed("SPY") + +# Calculate Pivots(2,2,20) using High/Low values +results = indicators.get_pivots(quotes, 2, 2, 20, EndType.HIGH_LOW); +``` + +## About: {{ page.title }} + +Pivots is an extended version of [Williams Fractal](../Fractal#content) that includes identification of Higher High, Lower Low, Higher Low, and Lower Low trends between pivots in a lookback window. +[[Discuss] :speech_balloon:]({{site.github.base_repository_url}}/discussions/436 "Community discussion about this indicator") + +![image]({{site.charturl}}/Pivots.png) + +### Sources + +- [C# core]({{site.base_sourceurl}}/m-r/Pivots/Pivots.cs) +- [Python wrapper]({{site.sourceurl}}/pivots.py) diff --git a/docs/_indicators/.unimplemented/Pvo.md b/docs/_indicators/Pvo.md similarity index 53% rename from docs/_indicators/.unimplemented/Pvo.md rename to docs/_indicators/Pvo.md index a6f66ba2..891cad37 100644 --- a/docs/_indicators/.unimplemented/Pvo.md +++ b/docs/_indicators/Pvo.md @@ -6,25 +6,18 @@ layout: indicator --- # {{ page.title }} +
-The [Percentage Volume Oscillator](https://school.stockcharts.com/doku.php?id=technical_indicators:percentage_volume_oscillator_pvo) is a simple oscillator view of two converging/diverging exponential moving averages of Volume. -[[Discuss] :speech_balloon:]({{site.github.base_repository_url}}/discussions/305 "Community discussion about this indicator") - -![image]({{site.charturl}}/Pvo.png) - -```python -// usage -IEnumerable results = - quotes.GetPvo(fastPeriods, slowPeriods, signalPeriods) -``` +## **get_pvo**(*quotes, fast_periods=12, slow_periods=26, signal_periods=9*) ## Parameters | name | type | notes | -- |-- |-- -| `fastPeriods` | int | Number of periods (`F`) for the faster moving average. Must be greater than 0. Default is 12. -| `slowPeriods` | int | Number of periods (`S`) for the slower moving average. Must be greater than `fastPeriods`. Default is 26. -| `signalPeriods` | int | Number of periods (`P`) for the moving average of PVO. Must be greater than or equal to 0. Default is 9. +| `quotes` | Iterable[Quote] | Iterable(such as list or an object having `__iter__()`) of the [Quote class]({{site.baseurl}}/guide/#historical-quotes) or [its sub-class]({{site.baseurl}}/guide/#using-custom-quote-classes). +| `fast_periods` | int, *default 12* | Number of periods (`F`) for the faster moving average. Must be greater than 0. +| `slow_periods` | int, *default 26* | Number of periods (`S`) for the slower moving average. Must be greater than `fast_periods`. +| `signal_periods` | int, *default 9* | Number of periods (`P`) for the moving average of PVO. Must be greater than or equal to 0. ### Historical quotes requirements @@ -35,39 +28,54 @@ You must have at least `2×(S+P)` or `S+P+100` worth of `quotes`, whichever is m ## Return ```python -IEnumerable +PVOResults[PVOResult] ``` - This method returns a time series of all available indicator values for the `quotes` provided. +- `PVOResults` is just a list of `PVOResult`. - 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 `S-1` slow periods will have `None` values since there's not enough data to calculate. :hourglass: **Convergence Warning**: The first `S+P+250` periods will have decreasing magnitude, convergence-related precision errors that can be as high as ~5% deviation in indicator values for earlier periods. -### PvoResult +### PVOResult | name | type | notes | -- |-- |-- -| `Date` | DateTime | Date -| `Pvo` | decimal | Normalized difference between two Volume moving averages -| `Signal` | decimal | Moving average of the `Pvo` line -| `Histogram` | decimal | Gap between of the `Pvo` and `Signal` line +| `date` | datetime | Date +| `pvo` | Decimal, Optional | Normalized difference between two Volume moving averages +| `signal` | Decimal, Optional | Moving average of the `pvo` line +| `histogram` | Decimal, Optional | Gap between of the `pvo` and `signal` line ### Utilities -- [.Find(lookupDate)]({{site.baseurl}}/utilities#find-indicator-result-by-date) -- [.RemoveWarmupPeriods()]({{site.baseurl}}/utilities#remove-warmup-periods) -- [.RemoveWarmupPeriods(qty)]({{site.baseurl}}/utilities#remove-warmup-periods) +- [.find(lookup_date)]({{site.baseurl}}/utilities#find-indicator-result-by-date) +- [.remove_warmup_periods()]({{site.baseurl}}/utilities#remove-warmup-periods) +- [.remove_warmup_periods(qty)]({{site.baseurl}}/utilities#remove-warmup-periods) See [Utilities and Helpers]({{site.baseurl}}/utilities#utilities-for-indicator-results) for more information. ## Example ```python -// fetch historical quotes from your feed (your method) -IEnumerable quotes = GetHistoryFromFeed("SPY") +from stock_indicators import indicators + +# This method is NOT a part of the library. +quotes = get_history_from_feed("SPY") -// calculate Pvo(12,26,9) -IEnumerable results = quotes.GetPvo(12,26,9) +# Calculate Pvo(12,26,9) +results = indicators.get_pvo(quotes, 12, 26, 9); ``` + +## About: {{ page.title }} + +The [Percentage Volume Oscillator](https://school.stockcharts.com/doku.php?id=technical_indicators:percentage_volume_oscillator_pvo) is a simple oscillator view of two converging/diverging exponential moving averages of Volume. +[[Discuss] :speech_balloon:]({{site.github.base_repository_url}}/discussions/305 "Community discussion about this indicator") + +![image]({{site.charturl}}/Pvo.png) + +### Sources + +- [C# core]({{site.base_sourceurl}}/m-r/Pvo/Pvo.cs) +- [Python wrapper]({{site.sourceurl}}/pvo.py) diff --git a/docs/_indicators/Renko.md b/docs/_indicators/Renko.md new file mode 100644 index 00000000..dafc2c48 --- /dev/null +++ b/docs/_indicators/Renko.md @@ -0,0 +1,141 @@ +--- +title: Renko Chart +permalink: /indicators/Renko/ +type: price-transform +layout: indicator +--- + +# {{ page.title }} +
+ +## **get_renko**(*quotes, brick_size, end_type=EndType.CLOSE*) + +## Parameters + +| name | type | notes +| -- |-- |-- +| `quotes` | Iterable[Quote] | Iterable(such as list or an object having `__iter__()`) of the [Quote class]({{site.baseurl}}/guide/#historical-quotes) or [its sub-class]({{site.baseurl}}/guide/#using-custom-quote-classes). +| `brick_size` | float | Brick size. Must be greater than 0. +| `end_type` | EndType, *default EndType.CLOSE* | See [EndType options](#endtype-options) below. + +### Historical quotes requirements + +You must have at least two periods of `quotes` to cover the warmup periods; however, more is typically provided since this is a chartable candlestick pattern. + +`quotes` is an `Iterable[Quote]` collection of historical price quotes. It should have a consistent frequency (day, hour, minute, etc). See [the Guide]({{site.baseurl}}/guide/#historical-quotes) for more information. + +### EndType options + +| type | description +|-- |-- +| `CLOSE` | Brick change threshold measured from `close` price (default) +| `HIGH_LOW` | Brick change threshold measured from `high` and `low` price + +## Return + +```python +RenkoResults[RenkoResult] +``` + +- This method returns a time series of all available indicator values for the `quotes` provided. +- `RenkoResults` is just a list of `RenkoResult`. +- It does not return a single incremental indicator value. + + + +:warning: WARNING! Unlike most indicators in this library, this indicator DOES NOT return the same number of elements as there are in the historical quotes. Renko bricks are added to the results once the `brick_size` change is achieved. For example, if it takes 3 days for a $2.50 price change to occur an entry is made on the third day while the first two are skipped. If a period change occurs at multiples of `brick_size`, multiple bricks are drawn with the same `date`. See [online documentation](https://www.investopedia.com/terms/r/renkochart.asp) for more information. + +### RenkoResult + +Each result record represents one Renko brick. + +| name | type | notes +| -- |-- |-- +| `date` | datetime | Formation date of brick(s) +| `open` | Decimal | Brick open price +| `high` | Decimal | Highest high during elapsed quotes periods +| `low` | Decimal | Lowest low during elapsed quotes periods +| `close` | Decimal | Brick close price +| `volume` | Decimal | Sum of Volume over elapsed quotes periods +| `is_up` | bool | Direction of brick (true=up,false=down) + +:warning: WARNING! When multiple bricks are drawn from a single `quote` period, the extra information about `high` and `low` wicks and `volume` is potentially confusing to interpret. `high` and `low` wicks will be the same across the multiple bricks; and `volume` is portioning evenly across the number of bricks. For example, if within one `quote` period 3 bricks are drawn, the `volume` for each brick will be `(sum of quotes Volume since last brick) / 3`. + +### Utilities + +- [.to_quotes()]({{site.baseurl}}/utilities#convert-to-quotes) +- [.find(lookup_date)]({{site.baseurl}}/utilities#find-indicator-result-by-date) +- [.remove_warmup_periods(qty)]({{site.baseurl}}/utilities#remove-warmup-periods) + +See [Utilities and Helpers]({{site.baseurl}}/utilities#utilities-for-indicator-results) for more information. + +## Example + +```python +from stock_indicators import indicators + +# This method is NOT a part of the library. +quotes = get_history_from_feed("SPY") + +# Calculate +results = indicators.get_renko(quotes, 2.5); +``` + +## ATR Variant + +## **get_renko_atr**(*quotes, atr_periods, end_type=EndType.CLOSE*) + +### Parameters for ATR + +| name | type | notes +| -- |-- |-- +| `atr_periods` | int | Number of lookback periods (`A`) for ATR evaluation. Must be greater than 0. +| `end_type` | EndType, *default EndType.CLOSE* | See [EndType options](#endtype-options). + +#### Historical quotes requirements for ATR + +You must have at least `A+100` periods of `quotes`. + +`quotes` is an `Iterable[Quote]` collection of historical price quotes. It should have a consistent frequency (day, hour, minute, etc). See [the Guide]({{site.baseurl}}/guide/#historical-quotes) for more information. + +## Return for ATR + +```python +RenkoResults[RenkoResult] +``` + +- This method returns a time series of all available indicator values for the `quotes` provided. +- `RenkoResults` is just a list of `RenkoResult`. +- It always returns the same number of elements as there are in the historical quotes. +- It does not return a single incremental indicator value. + +:paintbrush: **Repaint Warning**: When using the `get_renko_atr()` variant, the last [Average True Range (ATR)](../Atr/#content) value is used to set `brick_size`. Since the ATR changes over time, historical bricks will be repainted as new periods are added or updated in `quotes`. + +## Example + +```python +from stock_indicators import indicators + +# This method is NOT a part of the library. +quotes = get_history_from_feed("SPY") + +# Calculate +results = indicators.get_renko_atr(quotes, atr_periods); +``` + +## About: {{ page.title }} + +The [Renko Chart](https://en.m.wikipedia.org/wiki/Renko_chart) is a Japanese price transformed candlestick pattern that uses "bricks" to show a defined increment of change over a non-linear time series. Transitions can use either `close` or `high/low` price values. An [ATR variant](#atr-variant) is also provided where brick size is determined by Average True Range values. +[[Discuss] :speech_balloon:]({{site.github.base_repository_url}}/discussions/478 "Community discussion about this indicator") + +![image]({{site.charturl}}/Renko.png) + +### Sources + +- [C# core]({{site.base_sourceurl}}/m-r/Renko/Renko.cs) +- [Python wrapper]({{site.sourceurl}}/renko.py) diff --git a/docs/_indicators/RollingPivots.md b/docs/_indicators/RollingPivots.md new file mode 100644 index 00000000..0b4020af --- /dev/null +++ b/docs/_indicators/RollingPivots.md @@ -0,0 +1,95 @@ +--- +title: Rolling Pivot Points +permalink: /indicators/RollingPivots/ +type: price-channel +layout: indicator +--- + +# {{ page.title }} +
+ +## **get_rolling_pivots**(*quotes, window_periods, offset_periods, point_type=PivotPointType.STANDARD*) + +## Parameters + +| name | type | notes +| -- |-- |-- +| `quotes` | Iterable[Quote] | Iterable(such as list or an object having `__iter__()`) of the [Quote class]({{site.baseurl}}/guide/#historical-quotes) or [its sub-class]({{site.baseurl}}/guide/#using-custom-quote-classes). +| `window_periods` | int | Number of periods (`W`) in the evaluation window. Must be greater than 0 to calculate; but is typically specified in the 5-20 range. +| `offset_periods` | int | Number of periods (`F`) to offset the window from the current period. Must be greater than or equal to 0 and is typically less than or equal to `W`. +| `point_type` | PivotPointType, *default PivotPointType.STANDARD* | Type of Pivot Point. See [PivotPointType options](#pivotpointtype-options) below. + +For example, a window of 8 with an offset of 4 would evaluate quotes like: `W W W W W W W W F F F F C`, where `W` is the window included in the Pivot Point calculation, and `F` is the distance from the current evaluation position `C`. A `quotes` with daily bars using `W/F` values of `20/10` would most closely match the `month` variant of the traditional [Pivot Points](../PivotPoints#content) indicator. + +### Historical quotes requirements + +You must have at least `W+F` 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]({{site.baseurl}}/guide/#historical-quotes) for more information. + +### PivotPointType options + +| type | description +|-- |-- +| `PivotPointType.STANDARD` | Floor Trading (default) +| `PivotPointType.CAMARILLA` | Camarilla +| `PivotPointType.DEMARK` | Demark +| `PivotPointType.FIBONACCI` | Fibonacci +| `PivotPointType.WOODIE` | Woodie + +## Return + +```python +RollingPivotsResults[RollingPivotsResult] +``` + +- This method returns a time series of all available indicator values for the `quotes` provided. +- `RollingPivotsResults` is just a list of `RollingPivotsResult`. +- 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 `W+F-1` periods will have `None` values since there's not enough data to calculate. + +### RollingPivotsResult + +| name | type | notes +| -- |-- |-- +| `date` | datetime | Date +| `r3` | Decimal, Optional | Resistance level 3 +| `r2` | Decimal, Optional | Resistance level 2 +| `r1` | Decimal, Optional | Resistance level 1 +| `pp` | Decimal, Optional | Pivot Point +| `s1` | Decimal, Optional | Support level 1 +| `s2` | Decimal, Optional | Support level 2 +| `s3` | Decimal, Optional | Support level 3 + +### Utilities + +- [.find(lookup_date)]({{site.baseurl}}/utilities#find-indicator-result-by-date) +- [.remove_warmup_periods()]({{site.baseurl}}/utilities#remove-warmup-periods) +- [.remove_warmup_periods(qty)]({{site.baseurl}}/utilities#remove-warmup-periods) + +See [Utilities and Helpers]({{site.baseurl}}/utilities#utilities-for-indicator-results) for more information. + +## Example + +```python +from stock_indicators import indicators + +# This method is NOT a part of the library. +quotes = get_history_from_feed("SPY") + +# Calculate Woodie-style 14 period Rolling Pivot Points +results = indicators.get_rolling_pivots(quotes, 14, 0, PivotPointType.Woodie); +``` + +## About: {{ page.title }} + +Created by Dave Skender, Rolling Pivot Points is a modern update to traditional fixed calendar window [Pivot Points](../PivotPoints#content). It depicts support and resistance levels, based on a defined _rolling_ window and offset. +[[Discuss] :speech_balloon:]({{site.github.base_repository_url}}/discussions/274 "Community discussion about this indicator") + +![image]({{site.charturl}}/RollingPivots.png) + +### Sources + +- [C# core]({{site.base_sourceurl}}/m-r/RollingPivots/RollingPivots.cs) +- [Python wrapper]({{site.sourceurl}}/rolling_pivots.py) diff --git a/docs/_indicators/Stoch.md b/docs/_indicators/Stoch.md index 8ab813a5..6dd71ddd 100644 --- a/docs/_indicators/Stoch.md +++ b/docs/_indicators/Stoch.md @@ -22,7 +22,7 @@ layout: indicator +| `movingAverageType` | MAType | Optional. Type of moving average (SMA or SMMA) used for smoothing. See [MAType options](#MAType-options) below. Default is `MAType.SMA`. --> ### Historical quotes requirements @@ -30,14 +30,14 @@ 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]({{site.baseurl}}/guide/#historical-quotes) for more information. - +| `MAType.SMA` | [Simple Moving Average](../Sma#content) (default) +| `MAType.SMMA` | [Smoothed Moving Average](../Smma#content) --> ## Returns @@ -50,7 +50,7 @@ StochResults[StochResult] - 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 diff --git a/docs/performance.md b/docs/performance.md index cde6f7b8..0c2696ee 100644 --- a/docs/performance.md +++ b/docs/performance.md @@ -9,42 +9,98 @@ layout: default These are the execution times for the current indicators using two years of historical daily stock quotes (502 periods) with default or typical parameters. ``` bash -pytest=v6.2.5, pytest-benchmark=v3.4.1 OS=macOS Monterey 12.0.1 +pytest=v6.2.5, pytest-benchmark=v3.4.1 OS=macOS Monterey 12.1 Apple M1, 8 cores .NET SDK=Mono 6.12.0.90 ``` ## Indicators -| Indicators | Mean | StdDev | Median | -|------------------- |------------:|----------:|------------:| -| ADL | 3.805 ms | 0.651 ms | 3.627 ms | -| ADX | 4.857 ms | 0.155 ms | 4.844 ms | -| Alligator | 3.893 ms | 0.054 ms | 3.834 ms | -| ALMA | 3.791 ms | 0.079 ms | 3.773 ms | -| Aroon | 4.196 ms | 0.054 ms | 4.187 ms | -| ATR | 3.680 ms | 0.034 ms | 3.670 ms | -| Awesome | 4.206 ms | 0.041 ms | 4.192 ms | -| Beta | 8.550 ms | 0.097 ms | 8.535 ms | -| BollingerBands | 4.826 ms | 0.070 ms | 4.810 ms | -| Chandelier | 4.182 ms | 0.048 ms | 4.165 ms | -| Donchian | 4.265 ms | 0.043 ms | 4.249 ms | -| Double EMA | 3.727 ms | 0.080 ms | 3.704 ms | -| Elder Ray | 3.852 ms | 0.037 ms | 3.840 ms | -| EMA | 3.678 ms | 0.075 ms | 3.660 ms | -| Fractal | 3.670 ms | 0.049 ms | 3.663 ms | -| Heikin-Ashi | 4.738 ms | 0.261 ms | 3.886 ms | -| Ichimoku | 5.890 ms | 0.061 ms | 5.872 ms | -| MACD | 3.941 ms | 0.070 ms | 3.921 ms | -| Parabolic SAR | 3.760 ms | 0.129 ms | 3.731 ms | -| ROC | 3.612 ms | 0.076 ms | 3.582 ms | -| RSI | 4.104 ms | 0.075 ms | 4.087 ms | -| Slope | 4.672 ms | 0.170 ms | 4.119 ms | -| SMA | 3.781 ms | 0.050 ms | 3.766 ms | -| Stdev Channels | 4.194 ms | 0.090 ms | 4.164 ms | -| SMA Extended | 7.710 ms | 0.112 ms | 7.692 ms | -| Stoch | 4.212 ms | 0.044 ms | 4.198 ms | -| Stoch RSI | 4.984 ms | 0.120 ms | 4.939 ms | -| SuperTrend | 4.179 ms | 0.058 ms | 4.163 ms | -| Triple EMA | 3.841 ms | 0.065 ms | 3.821 ms | -| Trix | 4.068 ms | 0.072 ms | 4.044 ms | +```bash +------------------------------------------------------------------------------------------ benchmark: 78 tests ------------------------------------------------------------------------------------------- +Name (time in ms) Min Max Mean StdDev Median IQR Outliers OPS Rounds Iterations +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +test_benchmark_renko 4.1260 (1.0) 4.8456 (1.0) 4.3030 (1.0) 0.1428 (2.12) 4.2610 (1.0) 0.1723 (2.48) 22;2 232.3933 (1.0) 76 1 +test_benchmark_roc 5.4747 (1.33) 92.3929 (19.07) 6.4133 (1.49) 7.4435 (110.49) 5.6433 (1.32) 0.1673 (2.40) 1;12 155.9267 (0.67) 136 1 +test_benchmark_doji 5.4799 (1.33) 8.1868 (1.69) 5.8176 (1.35) 0.3717 (5.52) 5.7953 (1.36) 0.4051 (5.82) 9;1 171.8922 (0.74) 82 1 +test_benchmark_rsi 5.4832 (1.33) 6.0048 (1.24) 5.5886 (1.30) 0.1009 (1.50) 5.5537 (1.30) 0.1254 (1.80) 20;5 178.9364 (0.77) 133 1 +test_benchmark_obv 5.4878 (1.33) 6.0922 (1.26) 5.7525 (1.34) 0.1540 (2.29) 5.7395 (1.35) 0.2135 (3.07) 37;0 173.8378 (0.75) 110 1 +test_benchmark_pmo 5.4940 (1.33) 6.4650 (1.33) 5.6420 (1.31) 0.1414 (2.10) 5.5990 (1.31) 0.1525 (2.19) 11;2 177.2428 (0.76) 77 1 +test_benchmark_ema 5.4976 (1.33) 13.3975 (2.76) 5.8547 (1.36) 0.7973 (11.83) 5.6693 (1.33) 0.2410 (3.46) 4;8 170.8022 (0.73) 131 1 +test_benchmark_kvo 5.5106 (1.34) 6.6456 (1.37) 5.6228 (1.31) 0.1548 (2.30) 5.5666 (1.31) 0.1329 (1.91) 9;5 177.8459 (0.77) 95 1 +test_benchmark_alma 5.5139 (1.34) 6.6702 (1.38) 5.8329 (1.36) 0.2208 (3.28) 5.7713 (1.35) 0.2999 (4.31) 28;2 171.4424 (0.74) 102 1 +test_benchmark_tsi 5.5296 (1.34) 6.0752 (1.25) 5.6414 (1.31) 0.1183 (1.76) 5.5899 (1.31) 0.1511 (2.17) 14;3 177.2624 (0.76) 107 1 +test_benchmark_t3 5.5334 (1.34) 10.9672 (2.26) 6.2233 (1.45) 0.7478 (11.10) 6.0493 (1.42) 0.5541 (7.96) 7;5 160.6870 (0.69) 103 1 +test_benchmark_fractal 5.5349 (1.34) 85.4075 (17.63) 6.3020 (1.46) 7.0206 (104.21) 5.6455 (1.32) 0.1813 (2.61) 1;5 158.6802 (0.68) 129 1 +test_benchmark_marubozu 5.5370 (1.34) 10.3218 (2.13) 5.8524 (1.36) 0.6397 (9.50) 5.6774 (1.33) 0.1963 (2.82) 9;15 170.8701 (0.74) 122 1 +test_benchmark_awesome 5.5400 (1.34) 6.1885 (1.28) 5.6830 (1.32) 0.1074 (1.59) 5.6642 (1.33) 0.1285 (1.85) 28;4 175.9620 (0.76) 118 1 +test_benchmark_smma 5.5509 (1.35) 6.4687 (1.33) 5.7336 (1.33) 0.1321 (1.96) 5.7047 (1.34) 0.1472 (2.12) 21;4 174.4108 (0.75) 111 1 +test_benchmark_wma 5.5551 (1.35) 6.3335 (1.31) 5.7424 (1.33) 0.1261 (1.87) 5.7271 (1.34) 0.1442 (2.07) 53;2 174.1442 (0.75) 149 1 +test_benchmark_fcb 5.5554 (1.35) 6.8455 (1.41) 5.9071 (1.37) 0.2901 (4.31) 5.8962 (1.38) 0.4286 (6.16) 32;1 169.2886 (0.73) 82 1 +test_benchmark_force_index 5.5583 (1.35) 6.1730 (1.27) 5.6371 (1.31) 0.0845 (1.25) 5.6101 (1.32) 0.0696 (1.0) 9;6 177.3948 (0.76) 113 1 +test_benchmark_kama 5.5612 (1.35) 6.3748 (1.32) 5.6756 (1.32) 0.1291 (1.92) 5.6357 (1.32) 0.1139 (1.64) 9;6 176.1921 (0.76) 97 1 +test_benchmark_chop 5.5696 (1.35) 6.2348 (1.29) 5.7837 (1.34) 0.1438 (2.13) 5.7560 (1.35) 0.1803 (2.59) 32;2 172.8986 (0.74) 95 1 +test_benchmark_mama 5.5932 (1.36) 7.8260 (1.62) 5.7984 (1.35) 0.3248 (4.82) 5.6944 (1.34) 0.1866 (2.68) 8;8 172.4601 (0.74) 85 1 +test_benchmark_double_ema 5.5965 (1.36) 6.1142 (1.26) 5.7295 (1.33) 0.0929 (1.38) 5.7093 (1.34) 0.0924 (1.33) 18;4 174.5356 (0.75) 86 1 +test_benchmark_bop 5.6032 (1.36) 7.0379 (1.45) 5.8402 (1.36) 0.2374 (3.52) 5.7671 (1.35) 0.1168 (1.68) 8;12 171.2264 (0.74) 90 1 +test_benchmark_vwap 5.6110 (1.36) 7.8903 (1.63) 5.9596 (1.38) 0.3770 (5.60) 5.8334 (1.37) 0.2525 (3.63) 11;11 167.7967 (0.72) 92 1 +test_benchmark_cci 5.6189 (1.36) 11.4863 (2.37) 6.1164 (1.42) 0.7713 (11.45) 5.8562 (1.37) 0.4545 (6.53) 12;12 163.4946 (0.70) 108 1 +test_benchmark_ultimate 5.6246 (1.36) 91.3383 (18.85) 6.7092 (1.56) 8.2221 (122.05) 5.8637 (1.38) 0.3118 (4.48) 1;2 149.0493 (0.64) 108 1 +test_benchmark_smi 5.6323 (1.37) 6.3820 (1.32) 5.8123 (1.35) 0.1264 (1.88) 5.7866 (1.36) 0.1127 (1.62) 26;5 172.0492 (0.74) 108 1 +test_benchmark_elder_ray 5.6332 (1.37) 6.0962 (1.26) 5.7053 (1.33) 0.0751 (1.11) 5.6818 (1.33) 0.0785 (1.13) 8;4 175.2755 (0.75) 95 1 +test_benchmark_fisher_transform 5.6335 (1.37) 6.1022 (1.26) 5.7436 (1.33) 0.0674 (1.0) 5.7188 (1.34) 0.0775 (1.11) 18;3 174.1079 (0.75) 106 1 +test_benchmark_ma_envelopes 5.6350 (1.37) 6.1912 (1.28) 5.8126 (1.35) 0.1078 (1.60) 5.7955 (1.36) 0.0798 (1.15) 33;15 172.0415 (0.74) 98 1 +test_benchmark_parabolic_sar 5.6357 (1.37) 11.8207 (2.44) 6.2096 (1.44) 1.1010 (16.34) 5.8645 (1.38) 0.2769 (3.98) 5;8 161.0415 (0.69) 55 1 +test_benchmark_adl 5.6366 (1.37) 8.5952 (1.77) 5.9811 (1.39) 0.5817 (8.63) 5.9031 (1.39) 0.2106 (3.03) 1;1 167.1945 (0.72) 23 1 +test_benchmark_vortex 5.6569 (1.37) 7.5631 (1.56) 5.9456 (1.38) 0.3354 (4.98) 5.8171 (1.37) 0.2436 (3.50) 15;13 168.1910 (0.72) 107 1 +test_benchmark_mfi 5.6690 (1.37) 86.2132 (17.79) 6.6533 (1.55) 8.1210 (120.55) 5.7699 (1.35) 0.1710 (2.46) 1;5 150.3007 (0.65) 98 1 +test_benchmark_chaikin_osc 5.6717 (1.37) 7.1532 (1.48) 5.9809 (1.39) 0.2412 (3.58) 5.9230 (1.39) 0.2672 (3.84) 21;3 167.1993 (0.72) 79 1 +test_benchmark_cmf 5.6742 (1.38) 6.9036 (1.42) 5.9742 (1.39) 0.2904 (4.31) 5.8362 (1.37) 0.4846 (6.96) 23;0 167.3870 (0.72) 98 1 +test_benchmark_macd 5.6834 (1.38) 28.2138 (5.82) 6.8444 (1.59) 3.3016 (49.01) 6.1449 (1.44) 0.5003 (7.19) 4;8 146.1056 (0.63) 93 1 +test_benchmark_sma 5.6867 (1.38) 20.2324 (4.18) 6.2085 (1.44) 1.2760 (18.94) 6.0152 (1.41) 0.3444 (4.95) 2;11 161.0700 (0.69) 143 1 +test_benchmark_pivot_points 5.6882 (1.38) 6.5109 (1.34) 5.9283 (1.38) 0.1572 (2.33) 5.8712 (1.38) 0.2072 (2.98) 18;1 168.6822 (0.73) 65 1 +test_benchmark_connors_rsi 5.6915 (1.38) 6.3919 (1.32) 5.8648 (1.36) 0.1314 (1.95) 5.8438 (1.37) 0.1234 (1.77) 19;3 170.5097 (0.73) 65 1 +test_benchmark_ht_trendline 5.6930 (1.38) 6.2750 (1.30) 5.7917 (1.35) 0.1030 (1.53) 5.7625 (1.35) 0.1116 (1.60) 10;5 172.6620 (0.74) 88 1 +test_benchmark_aroon 5.7019 (1.38) 7.3920 (1.53) 6.0440 (1.40) 0.2686 (3.99) 5.9870 (1.41) 0.2765 (3.97) 22;5 165.4535 (0.71) 103 1 +test_benchmark_atr 5.7056 (1.38) 6.3501 (1.31) 5.9805 (1.39) 0.2196 (3.26) 5.9616 (1.40) 0.3256 (4.68) 4;0 167.2101 (0.72) 10 1 +test_benchmark_stdev 5.7207 (1.39) 8.0753 (1.67) 6.1180 (1.42) 0.3027 (4.49) 6.0877 (1.43) 0.3127 (4.49) 9;3 163.4526 (0.70) 98 1 +test_benchmark_dpo 5.7251 (1.39) 85.5333 (17.65) 6.7039 (1.56) 8.4034 (124.74) 5.7918 (1.36) 0.0855 (1.23) 1;8 149.1663 (0.64) 90 1 +test_benchmark_williams_r 5.7266 (1.39) 6.5275 (1.35) 6.0052 (1.40) 0.1908 (2.83) 5.9610 (1.40) 0.2855 (4.10) 30;0 166.5213 (0.72) 108 1 +test_benchmark_triple_ema 5.7419 (1.39) 7.2274 (1.49) 6.0463 (1.41) 0.3369 (5.00) 5.9288 (1.39) 0.3224 (4.63) 10;6 165.3908 (0.71) 73 1 +test_benchmark_alligator 5.7540 (1.39) 6.6827 (1.38) 5.9198 (1.38) 0.1411 (2.09) 5.9037 (1.39) 0.1198 (1.72) 7;3 168.9253 (0.73) 56 1 +test_benchmark_pivots 5.7697 (1.40) 7.3382 (1.51) 5.9355 (1.38) 0.3156 (4.68) 5.8228 (1.37) 0.1463 (2.10) 4;5 168.4786 (0.72) 59 1 +test_benchmark_vwma 5.8036 (1.41) 6.6257 (1.37) 6.1242 (1.42) 0.2022 (3.00) 6.0845 (1.43) 0.3161 (4.54) 41;0 163.2868 (0.70) 113 1 +test_benchmark_stoch 5.8192 (1.41) 88.5170 (18.27) 6.6510 (1.55) 7.0735 (105.00) 6.0217 (1.41) 0.1946 (2.80) 1;2 150.3538 (0.65) 136 1 +test_benchmark_pvo 5.8594 (1.42) 6.7668 (1.40) 6.0707 (1.41) 0.1671 (2.48) 6.0180 (1.41) 0.1771 (2.54) 12;6 164.7269 (0.71) 87 1 +test_benchmark_heikin_ashi 5.8710 (1.42) 6.5527 (1.35) 5.9508 (1.38) 0.1092 (1.62) 5.9106 (1.39) 0.0841 (1.21) 4;3 168.0438 (0.72) 76 1 +test_benchmark_trix 5.8831 (1.43) 6.5233 (1.35) 6.0819 (1.41) 0.1319 (1.96) 6.0425 (1.42) 0.1802 (2.59) 19;2 164.4235 (0.71) 76 1 +test_benchmark_gator 5.8910 (1.43) 6.5510 (1.35) 6.0568 (1.41) 0.1421 (2.11) 6.0111 (1.41) 0.1688 (2.43) 18;4 165.1048 (0.71) 85 1 +test_benchmark_chandelier 5.9471 (1.44) 6.7891 (1.40) 6.1343 (1.43) 0.1394 (2.07) 6.1017 (1.43) 0.1045 (1.50) 21;7 163.0174 (0.70) 98 1 +test_benchmark_volatility_stop 5.9709 (1.45) 7.4681 (1.54) 6.3546 (1.48) 0.2845 (4.22) 6.2791 (1.47) 0.3550 (5.10) 16;2 157.3668 (0.68) 68 1 +test_benchmark_stoch_rsi 5.9761 (1.45) 6.9553 (1.44) 6.1739 (1.43) 0.1515 (2.25) 6.1483 (1.44) 0.1948 (2.80) 18;1 161.9720 (0.70) 81 1 +test_benchmark_sma_extended 5.9776 (1.45) 7.1091 (1.47) 6.1699 (1.43) 0.1653 (2.45) 6.1259 (1.44) 0.1576 (2.27) 14;4 162.0784 (0.70) 92 1 +test_benchmark_super_trend 5.9807 (1.45) 8.2186 (1.70) 6.3343 (1.47) 0.3729 (5.54) 6.1788 (1.45) 0.2772 (3.98) 14;11 157.8694 (0.68) 83 1 +test_benchmark_adx 5.9874 (1.45) 7.4274 (1.53) 6.2284 (1.45) 0.2750 (4.08) 6.1088 (1.43) 0.2867 (4.12) 4;1 160.5538 (0.69) 35 1 +test_benchmark_slope 5.9896 (1.45) 6.7443 (1.39) 6.2639 (1.46) 0.1660 (2.46) 6.2482 (1.47) 0.2543 (3.65) 39;0 159.6455 (0.69) 125 1 +test_benchmark_stdev_channels 6.0004 (1.45) 6.7342 (1.39) 6.1937 (1.44) 0.1450 (2.15) 6.1617 (1.45) 0.1819 (2.61) 29;3 161.4542 (0.69) 90 1 +test_benchmark_epma 6.0203 (1.46) 7.6421 (1.58) 6.3617 (1.48) 0.3056 (4.54) 6.2830 (1.47) 0.3557 (5.11) 14;3 157.1900 (0.68) 77 1 +test_benchmark_donchian 6.0671 (1.47) 7.1593 (1.48) 6.3068 (1.47) 0.2099 (3.12) 6.2558 (1.47) 0.3025 (4.35) 22;1 158.5601 (0.68) 88 1 +test_benchmark_hma 6.1358 (1.49) 7.2202 (1.49) 6.3506 (1.48) 0.1956 (2.90) 6.2878 (1.48) 0.2044 (2.94) 13;2 157.4662 (0.68) 55 1 +test_benchmark_bollinger_bands 6.1389 (1.49) 6.6617 (1.37) 6.2889 (1.46) 0.1052 (1.56) 6.2764 (1.47) 0.1409 (2.02) 18;1 159.0114 (0.68) 65 1 +test_benchmark_rolling_pivots 6.1415 (1.49) 7.8126 (1.61) 6.4341 (1.50) 0.2707 (4.02) 6.3499 (1.49) 0.2540 (3.65) 10;6 155.4214 (0.67) 86 1 +test_benchmark_stc 6.1425 (1.49) 7.1205 (1.47) 6.3767 (1.48) 0.1858 (2.76) 6.3433 (1.49) 0.2493 (3.58) 8;1 156.8221 (0.67) 45 1 +test_benchmark_ulcer_index 6.1572 (1.49) 7.0037 (1.45) 6.3582 (1.48) 0.1420 (2.11) 6.3366 (1.49) 0.1600 (2.30) 23;3 157.2777 (0.68) 99 1 +test_benchmark_starc_bands 6.1661 (1.49) 6.8164 (1.41) 6.3345 (1.47) 0.1182 (1.75) 6.2912 (1.48) 0.1763 (2.53) 22;2 157.8668 (0.68) 91 1 +test_benchmark_keltner 6.2360 (1.51) 7.3260 (1.51) 6.5621 (1.52) 0.2492 (3.70) 6.5131 (1.53) 0.3927 (5.64) 21;0 152.3898 (0.66) 80 1 +test_benchmark_ichimoku 7.2452 (1.76) 11.8303 (2.44) 7.7022 (1.79) 0.7934 (11.78) 7.4342 (1.74) 0.3684 (5.29) 5;6 129.8324 (0.56) 69 1 +test_benchmark_prs 8.7366 (2.12) 16.4603 (3.40) 9.3009 (2.16) 1.0606 (15.74) 9.0388 (2.12) 0.2869 (4.12) 6;7 107.5159 (0.46) 75 1 +test_benchmark_correlation 9.0493 (2.19) 9.7506 (2.01) 9.1864 (2.13) 0.1043 (1.55) 9.1576 (2.15) 0.1187 (1.71) 14;2 108.8563 (0.47) 75 1 +test_benchmark_beta 9.3255 (2.26) 10.7893 (2.23) 9.6093 (2.23) 0.2552 (3.79) 9.5682 (2.25) 0.2310 (3.32) 8;2 104.0663 (0.45) 57 1 +test_benchmark_hurst 10.0185 (2.43) 11.5504 (2.38) 10.4482 (2.43) 0.2772 (4.12) 10.4092 (2.44) 0.3176 (4.56) 18;3 95.7106 (0.41) 69 1 +test_benchmark_hurst_longlong 236.8124 (57.39) 318.9976 (65.83) 254.1136 (59.05) 36.2801 (538.54) 237.9573 (55.85) 21.5396 (309.55) 1;1 3.9352 (0.02) 5 1 +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + +Legend: + Outliers: 1 Standard Deviation from Mean; 1.5 IQR (InterQuartile Range) from 1st Quartile and 3rd Quartile. + OPS: Operations Per Second, computed as 1 / Mean +```