Skip to content

Commit

Permalink
Add all volume strategies to backtest. (#235)
Browse files Browse the repository at this point in the history
# Describe Request

Add all volume strategies to backtest.

# Change Type

New feature.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Enhanced backtesting capabilities with the addition of volume analysis
strategies.
- Introduced the Money Flow Index Strategy, providing more detailed
information on buy and sell points.

- **Bug Fixes**
- Improved the output format of the Money Flow Index Strategy name to
include both sell and buy values.

- **Documentation**
- Updated method signatures and functionality descriptions to reflect
the new and modified strategies.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
cinar authored Oct 15, 2024
1 parent 8958daf commit 1cf5812
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions cmd/indicator-backtest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/cinar/indicator/v2/strategy/momentum"
"github.com/cinar/indicator/v2/strategy/trend"
"github.com/cinar/indicator/v2/strategy/volatility"
"github.com/cinar/indicator/v2/strategy/volume"
)

func main() {
Expand Down Expand Up @@ -70,6 +71,7 @@ func main() {
backtester.Strategies = append(backtester.Strategies, strategy.AllStrategies()...)
backtester.Strategies = append(backtester.Strategies, trend.AllStrategies()...)
backtester.Strategies = append(backtester.Strategies, volatility.AllStrategies()...)
backtester.Strategies = append(backtester.Strategies, volume.AllStrategies()...)

if addSplits {
backtester.Strategies = append(backtester.Strategies, strategy.AllSplitStrategies(backtester.Strategies)...)
Expand Down
2 changes: 1 addition & 1 deletion strategy/volume/money_flow_index_strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func NewMoneyFlowIndexStrategyWith(sellAt, buyAt float64) *MoneyFlowIndexStrateg

// Name returns the name of the strategy.
func (m *MoneyFlowIndexStrategy) Name() string {
return fmt.Sprintf("Money Flow Index Strategy (%f)", m.SellAt)
return fmt.Sprintf("Money Flow Index Strategy (%f,%f)", m.SellAt, m.BuyAt)
}

// Compute processes the provided asset snapshots and generates a stream of actionable recommendations.
Expand Down
4 changes: 3 additions & 1 deletion strategy/volume/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,7 @@ import (

// AllStrategies returns a slice containing references to all available volume strategies.
func AllStrategies() []strategy.Strategy {
return []strategy.Strategy{}
return []strategy.Strategy{
NewMoneyFlowIndexStrategy(),
}
}

0 comments on commit 1cf5812

Please sign in to comment.