Skip to content

Commit

Permalink
Apply fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
cinar committed Oct 17, 2024
1 parent 91bb407 commit 59b54d0
Show file tree
Hide file tree
Showing 3 changed files with 151 additions and 151 deletions.
6 changes: 3 additions & 3 deletions strategy/volume/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ AllStrategies returns a slice containing references to all available volume stra
<a name="ChaikinMoneyFlowStrategy"></a>
## type [ChaikinMoneyFlowStrategy](<https://github.com/cinar/indicator/blob/master/strategy/volume/chaikin_money_flow_strategy.go#L18-L21>)

ChaikinMoneyFlowStrategy represents the configuration parameters for calculating the Chaikin Money Flow strategy. Recommends a Sell action when it crosses above 0, and recommends a Buy action when it crosses below 0.
ChaikinMoneyFlowStrategy represents the configuration parameters for calculating the Chaikin Money Flow strategy. Recommends a Buy action when it crosses above 0, and recommends a Sell action when it crosses below 0.

```go
type ChaikinMoneyFlowStrategy struct {
Expand All @@ -82,7 +82,7 @@ type ChaikinMoneyFlowStrategy struct {
func NewChaikinMoneyFlowStrategy() *ChaikinMoneyFlowStrategy
```

NewChaikinMoneyFlowStrategy function initializes a new Money Flow Index strategy instance with the default parameters.
NewChaikinMoneyFlowStrategy function initializes a new Chaikin Money Flow strategy instance with the default parameters.

<a name="NewChaikinMoneyFlowStrategyWith"></a>
### func [NewChaikinMoneyFlowStrategyWith](<https://github.com/cinar/indicator/blob/master/strategy/volume/chaikin_money_flow_strategy.go#L33>)
Expand All @@ -91,7 +91,7 @@ NewChaikinMoneyFlowStrategy function initializes a new Money Flow Index strategy
func NewChaikinMoneyFlowStrategyWith(period int) *ChaikinMoneyFlowStrategy
```

NewChaikinMoneyFlowStrategyWith function initializes a new Money Flow Index strategy instance with the given parameters.
NewChaikinMoneyFlowStrategyWith function initializes a new Chaikin Money Flow strategy instance with the given parameters.

<a name="ChaikinMoneyFlowStrategy.Compute"></a>
### func \(\*ChaikinMoneyFlowStrategy\) [Compute](<https://github.com/cinar/indicator/blob/master/strategy/volume/chaikin_money_flow_strategy.go#L45>)
Expand Down
10 changes: 5 additions & 5 deletions strategy/volume/chaikin_money_flow_strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ import (
)

// ChaikinMoneyFlowStrategy represents the configuration parameters for calculating the Chaikin Money Flow strategy.
// Recommends a Sell action when it crosses above 0, and recommends a Buy action when it crosses below 0.
// Recommends a Buy action when it crosses above 0, and recommends a Sell action when it crosses below 0.
type ChaikinMoneyFlowStrategy struct {
// ChaikinMoneyFlow is the Chaikin Money Flow indicator instance.
ChaikinMoneyFlow *volume.Cmf[float64]
}

// NewChaikinMoneyFlowStrategy function initializes a new Money Flow Index strategy instance with the
// NewChaikinMoneyFlowStrategy function initializes a new Chaikin Money Flow strategy instance with the
// default parameters.
func NewChaikinMoneyFlowStrategy() *ChaikinMoneyFlowStrategy {
return NewChaikinMoneyFlowStrategyWith(
volume.DefaultCmfPeriod,
)
}

// NewChaikinMoneyFlowStrategyWith function initializes a new Money Flow Index strategy instance with the
// NewChaikinMoneyFlowStrategyWith function initializes a new Chaikin Money Flow strategy instance with the
// given parameters.
func NewChaikinMoneyFlowStrategyWith(period int) *ChaikinMoneyFlowStrategy {
return &ChaikinMoneyFlowStrategy{
Expand All @@ -53,11 +53,11 @@ func (c *ChaikinMoneyFlowStrategy) Compute(snapshots <-chan *asset.Snapshot) <-c
cmfs := c.ChaikinMoneyFlow.Compute(highs, lows, closings, volumes)

actions := helper.Map(cmfs, func(cmf float64) strategy.Action {
if cmf < 0 {
if cmf > 0 {
return strategy.Buy
}

if cmf > 0 {
if cmf < 0 {
return strategy.Sell
}

Expand Down
Loading

0 comments on commit 59b54d0

Please sign in to comment.