From 10571eedb15432b8d11a785e09359af82d11eb6e Mon Sep 17 00:00:00 2001 From: Onur Cinar Date: Mon, 14 Oct 2024 18:27:27 -0700 Subject: [PATCH] Add all volume strategies to backtest. --- cmd/indicator-backtest/main.go | 2 ++ strategy/volume/money_flow_index_strategy.go | 2 +- strategy/volume/volume.go | 4 +++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cmd/indicator-backtest/main.go b/cmd/indicator-backtest/main.go index f702bc5..877385c 100644 --- a/cmd/indicator-backtest/main.go +++ b/cmd/indicator-backtest/main.go @@ -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() { @@ -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)...) diff --git a/strategy/volume/money_flow_index_strategy.go b/strategy/volume/money_flow_index_strategy.go index 9e292d1..f51d4de 100644 --- a/strategy/volume/money_flow_index_strategy.go +++ b/strategy/volume/money_flow_index_strategy.go @@ -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. diff --git a/strategy/volume/volume.go b/strategy/volume/volume.go index e0fa6ee..919be8d 100644 --- a/strategy/volume/volume.go +++ b/strategy/volume/volume.go @@ -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(), + } }