Skip to content

Commit

Permalink
chore: update docs (#534)
Browse files Browse the repository at this point in the history
+semver: minor
  • Loading branch information
DaveSkender authored Aug 29, 2021
1 parent 4b59ebe commit 4d2f579
Show file tree
Hide file tree
Showing 23 changed files with 215 additions and 87 deletions.
4 changes: 2 additions & 2 deletions docs/INDICATORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
## Moving averages

- [Arnaud Legoux Moving Average (ALMA)](../indicators/Alma/README.md#content)
- [Double Exponential Moving Average (DEMA)](../indicators/Ema/README.md#content)
- [Double Exponential Moving Average (DEMA)](../indicators/DoubleEma/README.md#content)
- [Endpoint Moving Average (EPMA)](../indicators/Epma/README.md#content)
- [Exponential Moving Average (EMA)](../indicators/Ema/README.md#content)
- [Hilbert Transform Instantaneous Trendline](../indicators/HtTrendline/README.md#content)
Expand All @@ -88,7 +88,7 @@
- [Smoothed Moving Average (SMMA)](../indicators/Smma/README.md#content)
- [Tillson T3 Moving Average](../indicators/T3/README.md#content)
- [Triple EMA Oscillator (TRIX)](../indicators/Trix/README.md#content)
- [Triple Exponential Moving Average (TEMA)](../indicators/Ema/README.md#content)
- [Triple Exponential Moving Average (TEMA)](../indicators/TripleEma/README.md#content)
- [Volume Weighted Average Price (VWAP)](../indicators/Vwap/README.md#content)
- [Weighted Moving Average (WMA)](../indicators/Wma/README.md#content)

Expand Down
Binary file added indicators/DoubleEma/DoubleEma.Calc.xlsx
Binary file not shown.
10 changes: 10 additions & 0 deletions indicators/DoubleEma/DoubleEma.Models.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;

namespace Skender.Stock.Indicators
{
[Serializable]
public class DemaResult : ResultBase
{
public decimal? Dema { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Skender.Stock.Indicators
public static partial class Indicator
{
// DOUBLE EXPONENTIAL MOVING AVERAGE
/// <include file='./info.xml' path='indicators/type[@name="DEMA"]/*' />
/// <include file='./info.xml' path='indicator/*' />
///
public static IEnumerable<DemaResult> GetDoubleEma<TQuote>(
this IEnumerable<TQuote> quotes,
Expand Down
64 changes: 64 additions & 0 deletions indicators/DoubleEma/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Double Exponential Moving Average (DEMA)

[Double exponential moving average](https://en.wikipedia.org/wiki/Double_exponential_moving_average) of the Close price over a lookback window.
[[Discuss] :speech_balloon:](https://github.com/DaveSkender/Stock.Indicators/discussions/256 "Community discussion about this indicator")

![image](chart.png)

DEMA is shown as the dashed line above. [EMA](../Ema/README.md#content) (solid line) and [Triple EMA](../TripleEma/README.md#content) (dotted line) are also shown here for comparison.

```csharp
// usage
IEnumerable<DemaResult> results =
quotes.GetDoubleEma(lookbackPeriods);
```

## Parameters

| name | type | notes
| -- |-- |--
| `lookbackPeriods` | int | Number of periods (`N`) in the moving average. Must be greater than 0.

### Historical quotes requirements

You must have at least `3×N` or `2×N+100` periods of `quotes`, whichever is more. Since this uses a smoothing technique, we recommend you use at least `2×N+250` data points prior to the intended usage date for better precision.

`quotes` is an `IEnumerable<TQuote>` collection of historical price quotes. It should have a consistent frequency (day, hour, minute, etc). See [the Guide](../../docs/GUIDE.md#historical-quotes) for more information.

## Response

```csharp
IEnumerable<DemaResult>
```

- 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 `2×N-1` periods will have `null` values since there's not enough data to calculate.

:hourglass: **Convergence Warning**: The first `2×N+100` periods will have decreasing magnitude, convergence-related precision errors that can be as high as ~5% deviation in indicator values for earlier periods.

### DemaResult

| name | type | notes
| -- |-- |--
| `Date` | DateTime | Date
| `Dema` | decimal | Double exponential moving average for `N` lookback period

### Utilities

- [.Find(lookupDate)](../../docs/UTILITIES.md#find-indicator-result-by-date)
- [.RemoveWarmupPeriods()](../../docs/UTILITIES.md#remove-warmup-periods)
- [.RemoveWarmupPeriods(qty)](../../docs/UTILITIES.md#remove-warmup-periods)

See [Utilities and Helpers](../../docs/UTILITIES.md#utilities-for-indicator-results) for more information.

## Example

```csharp
// fetch historical quotes from your feed (your method)
IEnumerable<Quote> quotes = GetHistoryFromFeed("SPY");

// calculate 20-period DEMA
IEnumerable<DemaResult> results = quotes.GetDema(20);
```
Binary file added indicators/DoubleEma/chart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions indicators/DoubleEma/info.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>

<indicators>
<summary>
Double Exponential Moving Average (DEMA) of the Close price.
See
<see href="https://daveskender.github.io/Stock.Indicators/indicators/DoubleEma/#content">documentation</see>
for more information.
</summary>
<typeparam name="TQuote">Configurable Quote type. See Guide for more information.</typeparam>
<param name="quotes">Historical price quotes.</param>
<param name="lookbackPeriods">Number of periods in the lookback window.</param>
<returns>Time series of Double EMA values.</returns>
<exception cref="ArgumentOutOfRangeException">Invalid parameter value provided.</exception>
<exception cref="BadQuotesException">Insufficient quotes provided.</exception>
</indicators>
Binary file modified indicators/Ema/Ema.Calc.xlsx
Binary file not shown.
13 changes: 0 additions & 13 deletions indicators/Ema/Ema.Models.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,4 @@ public class EmaResult : ResultBase
{
public decimal? Ema { get; set; }
}

[Serializable]
public class DemaResult : ResultBase
{
public decimal? Dema { get; set; }
}

[Serializable]
public class TemaResult : ResultBase
{
public decimal? Tema { get; set; }
}

}
2 changes: 1 addition & 1 deletion indicators/Ema/Ema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Skender.Stock.Indicators
public static partial class Indicator
{
// EXPONENTIAL MOVING AVERAGE
/// <include file='./info.xml' path='indicators/type[@name="EMA"]/*' />
/// <include file='./info.xml' path='indicator/*' />
///
public static IEnumerable<EmaResult> GetEma<TQuote>(
this IEnumerable<TQuote> quotes,
Expand Down
32 changes: 9 additions & 23 deletions indicators/Ema/README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
# Exponential Moving Average (EMA), Double EMA (DEMA), and Triple EMA (TEMA)
# Exponential Moving Average (EMA)

[Exponentially weighted moving average](https://en.wikipedia.org/wiki/Moving_average#Exponential_moving_average) of the Close price over a lookback window. Double and Triple variants are also available. Note: [TEMA](https://en.wikipedia.org/wiki/Triple_exponential_moving_average) is often confused with the alternative [TRIX](../Trix/README.md) oscillator.
[Exponentially weighted moving average](https://en.wikipedia.org/wiki/Moving_average#Exponential_moving_average) of the Close price over a lookback window.
[[Discuss] :speech_balloon:](https://github.com/DaveSkender/Stock.Indicators/discussions/256 "Community discussion about this indicator")

![image](chart.png)

EMA is shown as the solid line above. [Double EMA](../DoubleEma/README.md#content) (dashed line) and [Triple EMA](../TripleEma/README.md#content) (dotted line) are also shown here for comparison.

```csharp
// usage for EMA (standard)
// usage
IEnumerable<EmaResult> results =
quotes.GetEma(lookbackPeriods);

// usage for Double EMA
IEnumerable<DemaResult> results =
quotes.GetDoubleEma(lookbackPeriods);

// usage for Triple EMA
IEnumerable<TemaResult> results =
quotes.GetTripleEma(lookbackPeriods);
```

## Parameters
Expand All @@ -27,37 +21,29 @@ IEnumerable<TemaResult> results =

### Historical quotes requirements

**EMA** (standard): You must have at least `2×N` or `N+100` periods of `quotes`, whichever is more. Since this uses a smoothing technique, we recommend you use at least `N+250` data points prior to the intended usage date for better precision.

**Double EMA**: You must have at least `3×N` or `2×N+100` periods of `quotes`, whichever is more. Since this uses a smoothing technique, we recommend you use at least `2×N+250` data points prior to the intended usage date for better precision.

**Triple EMA**: You must have at least `4×N` or `3×N+100` periods of `quotes`, whichever is more. Since this uses a smoothing technique, we recommend you use at least `3×N+250` data points prior to the intended usage date for better precision.
You must have at least `2×N` or `N+100` periods of `quotes`, whichever is more. Since this uses a smoothing technique, we recommend you use at least `N+250` data points prior to the intended usage date for better precision.

`quotes` is an `IEnumerable<TQuote>` collection of historical price quotes. It should have a consistent frequency (day, hour, minute, etc). See [the Guide](../../docs/GUIDE.md#historical-quotes) for more information.

## Response (respectively)

```csharp
IEnumerable<EmaResult>
IEnumerable<DemaResult>
IEnumerable<TemaResult>
```

- 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.
- Standard EMA: The first `N-1` periods will have `null` values since there's not enough data to calculate.
- Double EMA: The first `2×N-1` periods will have `null` values since there's not enough data to calculate.
- Triple EMA: The first `3×N-2` periods will have `null` values since there's not enough data to calculate. Also note that we are using the proper [weighted variant](https://en.wikipedia.org/wiki/Triple_exponential_moving_average) for TEMA. If you prefer the unweighted raw 3 EMAs value, please use the `Ema3` output from the [TRIX](../Trix/README.md) oscillator instead.
- The first `N-1` periods will have `null` values since there's not enough data to calculate.

:hourglass: **Convergence Warning**: The first respective `N+100`, `2×N+100`, and `3×N+100` periods will have decreasing magnitude, convergence-related precision errors that can be as high as ~5% deviation in indicator values for earlier periods.

### EmaResult / DemaResult / TemaResult
### EmaResult

| name | type | notes
| -- |-- |--
| `Date` | DateTime | Date
| `Ema`/`Dema`/`Tema` | decimal | Exponential moving average for `N` lookback period
| `Ema` | decimal | Exponential moving average for `N` lookback period

### Utilities

Expand Down
52 changes: 11 additions & 41 deletions indicators/Ema/info.xml
Original file line number Diff line number Diff line change
@@ -1,46 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>

<indicators>
<type name="EMA">
<summary>
Exponential Moving Average (EMA) of the Close price.
<summary>
Exponential Moving Average (EMA) of the Close price.
See
<see href="https://daveskender.github.io/Stock.Indicators/indicators/Ema/#content">documentation</see>
for more information.
</summary>
<typeparam name="TQuote">Configurable Quote type. See Guide for more information.</typeparam>
<param name="quotes">Historical price quotes.</param>
<param name="lookbackPeriods">Number of periods in the lookback window.</param>
<returns>Time series of EMA values.</returns>
<exception cref="ArgumentOutOfRangeException">Invalid parameter value provided.</exception>
<exception cref="BadQuotesException">Insufficient quotes provided.</exception>
</type>
<type name="DEMA">
<summary>
Double Exponential Moving Average (DEMA) of the Close price.
See
<see href="https://daveskender.github.io/Stock.Indicators/indicators/Ema/#content">documentation</see>
for more information.
</summary>
<typeparam name="TQuote">Configurable Quote type. See Guide for more information.</typeparam>
<param name="quotes">Historical price quotes.</param>
<param name="lookbackPeriods">Number of periods in the lookback window.</param>
<returns>Time series of Double EMA values.</returns>
<exception cref="ArgumentOutOfRangeException">Invalid parameter value provided.</exception>
<exception cref="BadQuotesException">Insufficient quotes provided.</exception>
</type>
<type name="TEMA">
<summary>
Triple Exponential Moving Average (TEMA) of the Close price. Note: TEMA is often confused with the alternative TRIX oscillator.
See
<see href="https://daveskender.github.io/Stock.Indicators/indicators/Ema/#content">documentation</see>
for more information.
</summary>
<typeparam name="TQuote">Configurable Quote type. See Guide for more information.</typeparam>
<param name="quotes">Historical price quotes.</param>
<param name="lookbackPeriods">Number of periods in the lookback window.</param>
<returns>Time series of Triple EMA values.</returns>
<exception cref="ArgumentOutOfRangeException">Invalid parameter value provided.</exception>
<exception cref="BadQuotesException">Insufficient quotes provided.</exception>
</type>
<see href="https://daveskender.github.io/Stock.Indicators/indicators/Ema/#content">documentation</see>
for more information.
</summary>
<typeparam name="TQuote">Configurable Quote type. See Guide for more information.</typeparam>
<param name="quotes">Historical price quotes.</param>
<param name="lookbackPeriods">Number of periods in the lookback window.</param>
<returns>Time series of EMA values.</returns>
<exception cref="ArgumentOutOfRangeException">Invalid parameter value provided.</exception>
<exception cref="BadQuotesException">Insufficient quotes provided.</exception>
</indicators>
2 changes: 2 additions & 0 deletions indicators/PivotPoints/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ IEnumerable<PivotPointsResult>

: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
Expand Down
4 changes: 2 additions & 2 deletions indicators/Pivots/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Pivots

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.
Pivots is an extended version of [Williams Fractal](../Fractal/README.md#content) that includes identification of Higher High, Lower Low, Higher Low, and Lower Low trends between pivots in a lookback window.
[[Discuss] :speech_balloon:](https://github.com/DaveSkender/Stock.Indicators/discussions/436 "Community discussion about this indicator")

![image](chart.png)
Expand All @@ -20,7 +20,7 @@ IEnumerable<PivotsResult> results =
| `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`.
The total evaluation window size is `L+R+1`.

### Historical quotes requirements

Expand Down
2 changes: 2 additions & 0 deletions indicators/Slope/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ IEnumerable<SlopeResult>
- It does not return a single incremental indicator value.
- The first `N-1` periods will have `null` values for `Slope` since there's not enough data to calculate.

:paintbrush: **Repaint Warning**: the `Line` will be continuously repainted since it is based on the last quote and lookback period.

### SlopeResult

| name | type | notes
Expand Down
2 changes: 1 addition & 1 deletion indicators/StdDevChannels/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ IEnumerable<StdDevChannelsResult>
- It does not return a single incremental indicator value.
- Up to `N-1` periods will have `null` values since there's not enough data to calculate.

:warning: **Warning**: Historical results are a function of the current period window position and will fluctuate over time. Recommended for visualization; not recommended for backtesting.
:paintbrush: **Repaint Warning**: Historical results are a function of the current period window position and will fluctuate over time. Recommended for visualization; not recommended for backtesting.

### StdDevChannelsResult

Expand Down
65 changes: 65 additions & 0 deletions indicators/TripleEma/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Triple Exponential Moving Average (TEMA)

[Triple exponential moving average](https://en.wikipedia.org/wiki/Triple_exponential_moving_average) of the Close price over a lookback window.
Note: TEMA is often confused with the alternative [TRIX](../Trix/README.md#content) oscillator.
[[Discuss] :speech_balloon:](https://github.com/DaveSkender/Stock.Indicators/discussions/256 "Community discussion about this indicator")

![image](chart.png)

TEMA is shown as the dotted line above. [EMA](../Ema/README.md#content) (solid line) and [Double EMA](../DoubleEma/README.md#content) (dashed line) are also shown here for comparison.

```csharp
// usage
IEnumerable<TemaResult> results =
quotes.GetTripleEma(lookbackPeriods);
```

## Parameters

| name | type | notes
| -- |-- |--
| `lookbackPeriods` | int | Number of periods (`N`) in the moving average. Must be greater than 0.

### Historical quotes requirements

You must have at least `4×N` or `3×N+100` periods of `quotes`, whichever is more. Since this uses a smoothing technique, we recommend you use at least `3×N+250` data points prior to the intended usage date for better precision.

`quotes` is an `IEnumerable<TQuote>` collection of historical price quotes. It should have a consistent frequency (day, hour, minute, etc). See [the Guide](../../docs/GUIDE.md#historical-quotes) for more information.

## Response

```csharp
IEnumerable<TemaResult>
```

- 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 `3×N-2` periods will have `null` values since there's not enough data to calculate. Also note that we are using the proper [weighted variant](https://en.wikipedia.org/wiki/Triple_exponential_moving_average) for TEMA. If you prefer the unweighted raw 3 EMAs value, please use the `Ema3` output from the [TRIX](../Trix/README.md) oscillator instead.

:hourglass: **Convergence Warning**: The first `3×N+100` periods will have decreasing magnitude, convergence-related precision errors that can be as high as ~5% deviation in indicator values for earlier periods.

### TemaResult

| name | type | notes
| -- |-- |--
| `Date` | DateTime | Date
| `Tema` | decimal | Triple exponential moving average for `N` lookback period

### Utilities

- [.Find(lookupDate)](../../docs/UTILITIES.md#find-indicator-result-by-date)
- [.RemoveWarmupPeriods()](../../docs/UTILITIES.md#remove-warmup-periods)
- [.RemoveWarmupPeriods(qty)](../../docs/UTILITIES.md#remove-warmup-periods)

See [Utilities and Helpers](../../docs/UTILITIES.md#utilities-for-indicator-results) for more information.

## Example

```csharp
// fetch historical quotes from your feed (your method)
IEnumerable<Quote> quotes = GetHistoryFromFeed("SPY");

// calculate 20-period TEMA
IEnumerable<TemaResult> results = quotes.GetTripleEma(20);
```
Binary file added indicators/TripleEma/TripleEma.Calc.xlsx
Binary file not shown.
10 changes: 10 additions & 0 deletions indicators/TripleEma/TripleEma.Models.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;

namespace Skender.Stock.Indicators
{
[Serializable]
public class TemaResult : ResultBase
{
public decimal? Tema { get; set; }
}
}
Loading

0 comments on commit 4d2f579

Please sign in to comment.