Skip to content

Commit

Permalink
Fixed typo.
Browse files Browse the repository at this point in the history
  • Loading branch information
cinar committed Jan 2, 2024
1 parent f54c9bb commit 3712cfe
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 35 deletions.
44 changes: 22 additions & 22 deletions volatility/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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>)
Expand Down Expand Up @@ -72,12 +72,12 @@ const (
)
```

<a name="DefaultChandlierExitPeriod"></a>
<a name="DefaultChandelierExitPeriod"></a>

```go
const (
// DefaultChandlierExitPeriod is the default period for the Chandelier Exit.
DefaultChandlierExitPeriod = 22
// DefaultChandelierExitPeriod is the default period for the Chandelier Exit.
DefaultChandelierExitPeriod = 22
)
```

Expand Down Expand Up @@ -288,10 +288,10 @@ func (b *BollingerBands[T]) IdlePeriod() int

IdlePeriod is the initial period that Bollinger Bands won't yield any results.

<a name="ChandlierExit"></a>
## type [ChandlierExit](<https://github.com/cinar/indicator/blob/v2/volatility/chandelier_exit.go#L27-L30>)
<a name="ChandelierExit"></a>
## type [ChandelierExit](<https://github.com/cinar/indicator/blob/v2/volatility/chandelier_exit.go#L27-L30>)

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
Expand All @@ -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
}
```

<a name="NewChandlierExit"></a>
### func [NewChandlierExit](<https://github.com/cinar/indicator/blob/v2/volatility/chandelier_exit.go#L33>)
<a name="NewChandelierExit"></a>
### func [NewChandelierExit](<https://github.com/cinar/indicator/blob/v2/volatility/chandelier_exit.go#L33>)

```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.

<a name="ChandlierExit[T].Compute"></a>
### func \(\*ChandlierExit\[T\]\) [Compute](<https://github.com/cinar/indicator/blob/v2/volatility/chandelier_exit.go#L40>)
<a name="ChandelierExit[T].Compute"></a>
### func \(\*ChandelierExit\[T\]\) [Compute](<https://github.com/cinar/indicator/blob/v2/volatility/chandelier_exit.go#L40>)

```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.

<a name="ChandlierExit[T].IdlePeriod"></a>
### func \(\*ChandlierExit\[T\]\) [IdlePeriod](<https://github.com/cinar/indicator/blob/v2/volatility/chandelier_exit.go#L68>)
<a name="ChandelierExit[T].IdlePeriod"></a>
### func \(\*ChandelierExit\[T\]\) [IdlePeriod](<https://github.com/cinar/indicator/blob/v2/volatility/chandelier_exit.go#L68>)

```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.
Expand Down
22 changes: 11 additions & 11 deletions volatility/chandelier_exit.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,34 @@ 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
// 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)
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)

Expand Down Expand Up @@ -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
}
4 changes: 2 additions & 2 deletions volatility/chandelier_exit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 3712cfe

Please sign in to comment.