From 3712cfe096ee289326370a2b97c2d429d2c050e7 Mon Sep 17 00:00:00 2001 From: Onur Cinar Date: Tue, 2 Jan 2024 06:24:50 -0800 Subject: [PATCH] Fixed typo. --- volatility/README.md | 44 +++++++++++++++--------------- volatility/chandelier_exit.go | 22 +++++++-------- volatility/chandelier_exit_test.go | 4 +-- 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/volatility/README.md b/volatility/README.md index 1e92db0..43d5e33 100644 --- a/volatility/README.md +++ b/volatility/README.md @@ -41,10 +41,10 @@ The information provided on this project is strictly for informational purposes - [func NewBollingerBands\[T helper.Number\]\(\) \*BollingerBands\[T\]](<#NewBollingerBands>) - [func \(b \*BollingerBands\[T\]\) Compute\(c \<\-chan T\) \(\<\-chan T, \<\-chan T, \<\-chan T\)](<#BollingerBands[T].Compute>) - [func \(b \*BollingerBands\[T\]\) IdlePeriod\(\) int](<#BollingerBands[T].IdlePeriod>) -- [type ChandlierExit](<#ChandlierExit>) - - [func NewChandlierExit\[T helper.Number\]\(\) \*ChandlierExit\[T\]](<#NewChandlierExit>) - - [func \(c \*ChandlierExit\[T\]\) Compute\(highs, lows, closings \<\-chan T\) \(\<\-chan T, \<\-chan T\)](<#ChandlierExit[T].Compute>) - - [func \(c \*ChandlierExit\[T\]\) IdlePeriod\(\) int](<#ChandlierExit[T].IdlePeriod>) +- [type ChandelierExit](<#ChandelierExit>) + - [func NewChandelierExit\[T helper.Number\]\(\) \*ChandelierExit\[T\]](<#NewChandelierExit>) + - [func \(c \*ChandelierExit\[T\]\) Compute\(highs, lows, closings \<\-chan T\) \(\<\-chan T, \<\-chan T\)](<#ChandelierExit[T].Compute>) + - [func \(c \*ChandelierExit\[T\]\) IdlePeriod\(\) int](<#ChandelierExit[T].IdlePeriod>) - [type MovingStd](<#MovingStd>) - [func NewMovingStd\[T helper.Number\]\(\) \*MovingStd\[T\]](<#NewMovingStd>) - [func NewMovingStdWithPeriod\[T helper.Number\]\(period int\) \*MovingStd\[T\]](<#NewMovingStdWithPeriod>) @@ -72,12 +72,12 @@ const ( ) ``` - + ```go const ( - // DefaultChandlierExitPeriod is the default period for the Chandelier Exit. - DefaultChandlierExitPeriod = 22 + // DefaultChandelierExitPeriod is the default period for the Chandelier Exit. + DefaultChandelierExitPeriod = 22 ) ``` @@ -288,10 +288,10 @@ func (b *BollingerBands[T]) IdlePeriod() int IdlePeriod is the initial period that Bollinger Bands won't yield any results. - -## type [ChandlierExit]() + +## type [ChandelierExit]() -ChandlierExit represents the configuration parameters for calculating the Chandelier Exit. It sets a trailing stop\-loss based on the Average True Value \(ATR\). +ChandelierExit represents the configuration parameters for calculating the Chandelier Exit. It sets a trailing stop\-loss based on the Average True Value \(ATR\). ``` Chandelier Exit Long = 22-Period SMA High - ATR(22) * 3 @@ -301,40 +301,40 @@ Chandelier Exit Short = 22-Period SMA Low + ATR(22) * 3 Example: ``` -ce := volatility.NewChandlierExist[float64]() +ce := volatility.NewChandelierExist[float64]() ceLong, ceShort := ce.Compute(highs, lows, closings) ``` ```go -type ChandlierExit[T helper.Number] struct { +type ChandelierExit[T helper.Number] struct { // Time period. Period int } ``` - -### func [NewChandlierExit]() + +### func [NewChandelierExit]() ```go -func NewChandlierExit[T helper.Number]() *ChandlierExit[T] +func NewChandelierExit[T helper.Number]() *ChandelierExit[T] ``` -NewChandlierExit function initializes a new Chandleir Exist instance with the default parameters. +NewChandelierExit function initializes a new Chandleir Exist instance with the default parameters. - -### func \(\*ChandlierExit\[T\]\) [Compute]() + +### func \(\*ChandelierExit\[T\]\) [Compute]() ```go -func (c *ChandlierExit[T]) Compute(highs, lows, closings <-chan T) (<-chan T, <-chan T) +func (c *ChandelierExit[T]) Compute(highs, lows, closings <-chan T) (<-chan T, <-chan T) ``` Compute function takes a channel of numbers and computes the Chandleir Exist over the specified period. - -### func \(\*ChandlierExit\[T\]\) [IdlePeriod]() + +### func \(\*ChandelierExit\[T\]\) [IdlePeriod]() ```go -func (c *ChandlierExit[T]) IdlePeriod() int +func (c *ChandelierExit[T]) IdlePeriod() int ``` IdlePeriod is the initial period that Acceleration Bands won't yield any results. diff --git a/volatility/chandelier_exit.go b/volatility/chandelier_exit.go index f5953eb..32297a4 100644 --- a/volatility/chandelier_exit.go +++ b/volatility/chandelier_exit.go @@ -10,11 +10,11 @@ import ( ) const ( - // DefaultChandlierExitPeriod is the default period for the Chandelier Exit. - DefaultChandlierExitPeriod = 22 + // DefaultChandelierExitPeriod is the default period for the Chandelier Exit. + DefaultChandelierExitPeriod = 22 ) -// ChandlierExit represents the configuration parameters for calculating the Chandelier Exit. +// ChandelierExit represents the configuration parameters for calculating the Chandelier Exit. // It sets a trailing stop-loss based on the Average True Value (ATR). // // Chandelier Exit Long = 22-Period SMA High - ATR(22) * 3 @@ -22,22 +22,22 @@ const ( // // Example: // -// ce := volatility.NewChandlierExist[float64]() +// ce := volatility.NewChandelierExist[float64]() // ceLong, ceShort := ce.Compute(highs, lows, closings) -type ChandlierExit[T helper.Number] struct { +type ChandelierExit[T helper.Number] struct { // Time period. Period int } -// NewChandlierExit function initializes a new Chandleir Exist instance with the default parameters. -func NewChandlierExit[T helper.Number]() *ChandlierExit[T] { - return &ChandlierExit[T]{ - Period: DefaultChandlierExitPeriod, +// NewChandelierExit function initializes a new Chandleir Exist instance with the default parameters. +func NewChandelierExit[T helper.Number]() *ChandelierExit[T] { + return &ChandelierExit[T]{ + Period: DefaultChandelierExitPeriod, } } // Compute function takes a channel of numbers and computes the Chandleir Exist over the specified period. -func (c *ChandlierExit[T]) Compute(highs, lows, closings <-chan T) (<-chan T, <-chan T) { +func (c *ChandelierExit[T]) Compute(highs, lows, closings <-chan T) (<-chan T, <-chan T) { highsSplice := helper.Duplicate(highs, 2) lowsSplice := helper.Duplicate(lows, 2) @@ -65,6 +65,6 @@ func (c *ChandlierExit[T]) Compute(highs, lows, closings <-chan T) (<-chan T, <- } // IdlePeriod is the initial period that Acceleration Bands won't yield any results. -func (c *ChandlierExit[T]) IdlePeriod() int { +func (c *ChandelierExit[T]) IdlePeriod() int { return c.Period - 1 } diff --git a/volatility/chandelier_exit_test.go b/volatility/chandelier_exit_test.go index 7ca2897..ccd9831 100644 --- a/volatility/chandelier_exit_test.go +++ b/volatility/chandelier_exit_test.go @@ -11,7 +11,7 @@ import ( "github.com/cinar/indicator/volatility" ) -func TestChandlierExit(t *testing.T) { +func TestChandelierExit(t *testing.T) { type Data struct { High float64 Low float64 @@ -32,7 +32,7 @@ func TestChandlierExit(t *testing.T) { expectedLong := helper.Map(inputs[3], func(d *Data) float64 { return d.Long }) expectedShort := helper.Map(inputs[4], func(d *Data) float64 { return d.Short }) - ce := volatility.NewChandlierExit[float64]() + ce := volatility.NewChandelierExit[float64]() actualLong, actualShort := ce.Compute(highs, lows, closings) actualLong = helper.RoundDigits(actualLong, 2) actualShort = helper.RoundDigits(actualShort, 2)