From 8bc081b86ced3e5f2f56fdd50020e3f0cb24c933 Mon Sep 17 00:00:00 2001 From: Onur Cinar Date: Sat, 14 Sep 2024 13:09:51 -0700 Subject: [PATCH] Remove strategy.Strategy from the strategy structs. --- helper/README.md | 36 +++++ strategy/README.md | 51 +++---- strategy/and_strategy.go | 2 - strategy/buy_and_hold_strategy.go | 1 - strategy/compound/README.md | 14 +- strategy/compound/macd_rsi_strategy.go | 2 - strategy/decorator/README.md | 36 ++--- strategy/decorator/inverse_strategy.go | 2 - strategy/decorator/no_loss_strategy.go | 2 - strategy/decorator/stop_loss_strategy.go | 2 - strategy/majority_strategy.go | 2 - strategy/momentum/README.md | 26 ++-- .../momentum/awesome_oscillator_strategy.go | 2 - strategy/momentum/rsi_strategy.go | 2 - strategy/or_strategy.go | 2 - strategy/trend/README.md | 134 ++++++++---------- strategy/trend/apo_strategy.go | 2 - strategy/trend/aroon_strategy.go | 2 - strategy/trend/bop_strategy.go | 2 - strategy/trend/cci_strategy.go | 2 - strategy/trend/dema_strategy.go | 2 - strategy/trend/kdj_strategy.go | 2 - strategy/trend/macd_strategy.go | 2 - strategy/trend/qstick_strategy.go | 2 - strategy/trend/trima_strategy.go | 2 - strategy/trend/trix_strategy.go | 2 - strategy/trend/vwma_strategy.go | 2 - strategy/volatility/README.md | 12 +- .../volatility/bollinger_bands_strategy.go | 2 - 29 files changed, 151 insertions(+), 201 deletions(-) diff --git a/helper/README.md b/helper/README.md index fffc3bb..2ba6371 100644 --- a/helper/README.md +++ b/helper/README.md @@ -37,6 +37,7 @@ The information provided on this project is strictly for informational purposes - [func ChangeRatio\[T Number\]\(c \<\-chan T, before int\) \<\-chan T](<#ChangeRatio>) - [func CheckEquals\[T comparable\]\(inputs ...\<\-chan T\) error](<#CheckEquals>) - [func CloseAndLogError\(closer io.Closer, message string\)](<#CloseAndLogError>) +- [func CommonPeriod\(periods ...int\) int](<#CommonPeriod>) - [func Count\[T Number, O any\]\(from T, other \<\-chan O\) \<\-chan T](<#Count>) - [func DaysBetween\(from, to time.Time\) int](<#DaysBetween>) - [func DecrementBy\[T Number\]\(c \<\-chan T, d T\) \<\-chan T](<#DecrementBy>) @@ -75,6 +76,7 @@ The information provided on this project is strictly for informational purposes - [func SliceToChan\[T any\]\(slice \[\]T\) \<\-chan T](<#SliceToChan>) - [func Sqrt\[T Number\]\(c \<\-chan T\) \<\-chan T](<#Sqrt>) - [func Subtract\[T Number\]\(ac, bc \<\-chan T\) \<\-chan T](<#Subtract>) +- [func SyncPeriod\[T any\]\(commonPeriod, period int, c \<\-chan T\) \<\-chan T](<#SyncPeriod>) - [func Waitable\[T any\]\(wg \*sync.WaitGroup, c \<\-chan T\) \<\-chan T](<#Waitable>) - [type Bst](<#Bst>) - [func NewBst\[T Number\]\(\) \*Bst\[T\]](<#NewBst>) @@ -322,6 +324,31 @@ func CloseAndLogError(closer io.Closer, message string) CloseAndLogError attempts to close the closer and logs any error. + +## func [CommonPeriod]() + +```go +func CommonPeriod(periods ...int) int +``` + +CommonPeriod calculates the smallest period at which all data channels can be synchronized + +Example: + +``` +// Synchronize channels with periods 4, 2, and 3. +commonPeriod := helper.CommonPeriod(4, 2, 3) // commonPeriod = 4 + +// Synchronize the first channel +c1 := helper.Sync(commonPeriod, 4, c1) + +// Synchronize the second channel +c2 := helper.Sync(commonPeriod, 2, c2) + +// Synchronize the third channel +c3 := helper.Sync(commonPeriod, 3, c3) +``` + ## func [Count]() @@ -915,6 +942,15 @@ actual := helper.Subtract(ac, bc) fmt.Println(helper.ChanToSlice(actual)) // [1, 2, 3, 4, 5] ``` + +## func [SyncPeriod]() + +```go +func SyncPeriod[T any](commonPeriod, period int, c <-chan T) <-chan T +``` + +SyncPeriod adjusts the given channel to match the given common period. + ## func [Waitable]() diff --git a/strategy/README.md b/strategy/README.md index df7693a..b82fc36 100644 --- a/strategy/README.md +++ b/strategy/README.md @@ -178,14 +178,12 @@ func (a Action) Annotation() string Annotation returns a single character string representing the recommended action. It returns "S" for Sell, "B" for Buy, and an empty string for Hold. -## type [AndStrategy]() +## type [AndStrategy]() AndStrategy combines multiple strategies and emits actionable recommendations when \*\*all\*\* strategies in the group \*\*reach the same actionable conclusion\*\*. This can be a conservative approach, potentially delaying recommendations until full consensus is reached. ```go type AndStrategy struct { - Strategy - // Strategies are the group of strategies that will be consulted to make an actionable recommendation. Strategies []Strategy // contains filtered or unexported fields @@ -193,7 +191,7 @@ type AndStrategy struct { ``` -### func [NewAndStrategy]() +### func [NewAndStrategy]() ```go func NewAndStrategy(name string) *AndStrategy @@ -202,7 +200,7 @@ func NewAndStrategy(name string) *AndStrategy NewAndStrategy function initializes an empty and strategies group with the given name. -### func \(\*AndStrategy\) [Compute]() +### func \(\*AndStrategy\) [Compute]() ```go func (a *AndStrategy) Compute(snapshots <-chan *asset.Snapshot) <-chan Action @@ -211,7 +209,7 @@ func (a *AndStrategy) Compute(snapshots <-chan *asset.Snapshot) <-chan Action Compute processes the provided asset snapshots and generates a stream of actionable recommendations. -### func \(\*AndStrategy\) [Name]() +### func \(\*AndStrategy\) [Name]() ```go func (a *AndStrategy) Name() string @@ -220,7 +218,7 @@ func (a *AndStrategy) Name() string Name returns the name of the strategy. -### func \(\*AndStrategy\) [Report]() +### func \(\*AndStrategy\) [Report]() ```go func (a *AndStrategy) Report(c <-chan *asset.Snapshot) *helper.Report @@ -229,18 +227,17 @@ func (a *AndStrategy) Report(c <-chan *asset.Snapshot) *helper.Report Report processes the provided asset snapshots and generates a report annotated with the recommended actions. -## type [BuyAndHoldStrategy]() +## type [BuyAndHoldStrategy]() BuyAndHoldStrategy defines an investment approach of acquiring and indefinitely retaining an asset. This strategy primarily serves as a benchmark for evaluating the performance of alternative strategies against a baseline of passive asset ownership. ```go type BuyAndHoldStrategy struct { - Strategy } ``` -### func [NewBuyAndHoldStrategy]() +### func [NewBuyAndHoldStrategy]() ```go func NewBuyAndHoldStrategy() *BuyAndHoldStrategy @@ -249,7 +246,7 @@ func NewBuyAndHoldStrategy() *BuyAndHoldStrategy NewBuyAndHoldStrategy function initializes a new buy and hold strategy instance. -### func \(\*BuyAndHoldStrategy\) [Compute]() +### func \(\*BuyAndHoldStrategy\) [Compute]() ```go func (*BuyAndHoldStrategy) Compute(snapshots <-chan *asset.Snapshot) <-chan Action @@ -258,7 +255,7 @@ func (*BuyAndHoldStrategy) Compute(snapshots <-chan *asset.Snapshot) <-chan Acti Compute processes the provided asset snapshots and generates a stream of actionable recommendations. -### func \(\*BuyAndHoldStrategy\) [Name]() +### func \(\*BuyAndHoldStrategy\) [Name]() ```go func (*BuyAndHoldStrategy) Name() string @@ -267,7 +264,7 @@ func (*BuyAndHoldStrategy) Name() string Name returns the name of the strategy. -### func \(\*BuyAndHoldStrategy\) [Report]() +### func \(\*BuyAndHoldStrategy\) [Report]() ```go func (b *BuyAndHoldStrategy) Report(c <-chan *asset.Snapshot) *helper.Report @@ -276,14 +273,12 @@ func (b *BuyAndHoldStrategy) Report(c <-chan *asset.Snapshot) *helper.Report Report processes the provided asset snapshots and generates a report annotated with the recommended actions. -## type [MajorityStrategy]() +## type [MajorityStrategy]() MajorityStrategy emits actionable recommendations aligned with what the strategies in the group recommends. ```go type MajorityStrategy struct { - Strategy - // Strategies are the group of strategies that will be consulted to make an actionable recommendation. Strategies []Strategy // contains filtered or unexported fields @@ -291,7 +286,7 @@ type MajorityStrategy struct { ``` -### func [NewMajorityStrategy]() +### func [NewMajorityStrategy]() ```go func NewMajorityStrategy(name string) *MajorityStrategy @@ -300,7 +295,7 @@ func NewMajorityStrategy(name string) *MajorityStrategy NewMajorityStrategy function initializes an empty majority strategies group with the given name. -### func [NewMajorityStrategyWith]() +### func [NewMajorityStrategyWith]() ```go func NewMajorityStrategyWith(name string, strategies []Strategy) *MajorityStrategy @@ -309,7 +304,7 @@ func NewMajorityStrategyWith(name string, strategies []Strategy) *MajorityStrate NewMajorityStrategyWith function initializes a majority strategies group with the given name and strategies. -### func \(\*MajorityStrategy\) [Compute]() +### func \(\*MajorityStrategy\) [Compute]() ```go func (a *MajorityStrategy) Compute(snapshots <-chan *asset.Snapshot) <-chan Action @@ -318,7 +313,7 @@ func (a *MajorityStrategy) Compute(snapshots <-chan *asset.Snapshot) <-chan Acti Compute processes the provided asset snapshots and generates a stream of actionable recommendations. -### func \(\*MajorityStrategy\) [Name]() +### func \(\*MajorityStrategy\) [Name]() ```go func (a *MajorityStrategy) Name() string @@ -327,7 +322,7 @@ func (a *MajorityStrategy) Name() string Name returns the name of the strategy. -### func \(\*MajorityStrategy\) [Report]() +### func \(\*MajorityStrategy\) [Report]() ```go func (a *MajorityStrategy) Report(c <-chan *asset.Snapshot) *helper.Report @@ -336,14 +331,12 @@ func (a *MajorityStrategy) Report(c <-chan *asset.Snapshot) *helper.Report Report processes the provided asset snapshots and generates a report annotated with the recommended actions. -## type [OrStrategy]() +## type [OrStrategy]() OrStrategy emits actionable recommendations when \*\*at least one\*\* strategy in the group recommends an action \*\*without any conflicting recommendations\*\* from other strategies. ```go type OrStrategy struct { - Strategy - // Strategies are the group of strategies that will be consulted to make an actionable recommendation. Strategies []Strategy // contains filtered or unexported fields @@ -351,7 +344,7 @@ type OrStrategy struct { ``` -### func [NewOrStrategy]() +### func [NewOrStrategy]() ```go func NewOrStrategy(name string) *OrStrategy @@ -360,7 +353,7 @@ func NewOrStrategy(name string) *OrStrategy NewOrStrategy function initializes an empty or strategies group with the given name. -### func \(\*OrStrategy\) [Compute]() +### func \(\*OrStrategy\) [Compute]() ```go func (a *OrStrategy) Compute(snapshots <-chan *asset.Snapshot) <-chan Action @@ -369,7 +362,7 @@ func (a *OrStrategy) Compute(snapshots <-chan *asset.Snapshot) <-chan Action Compute processes the provided asset snapshots and generates a stream of actionable recommendations. -### func \(\*OrStrategy\) [Name]() +### func \(\*OrStrategy\) [Name]() ```go func (a *OrStrategy) Name() string @@ -378,7 +371,7 @@ func (a *OrStrategy) Name() string Name returns the name of the strategy. -### func \(\*OrStrategy\) [Report]() +### func \(\*OrStrategy\) [Report]() ```go func (a *OrStrategy) Report(c <-chan *asset.Snapshot) *helper.Report @@ -469,7 +462,7 @@ type Strategy interface { ``` -### func [AllAndStrategies]() +### func [AllAndStrategies]() ```go func AllAndStrategies(strategies []Strategy) []Strategy diff --git a/strategy/and_strategy.go b/strategy/and_strategy.go index 133ee5f..c0a6784 100644 --- a/strategy/and_strategy.go +++ b/strategy/and_strategy.go @@ -15,8 +15,6 @@ import ( // the group **reach the same actionable conclusion**. This can be a conservative approach, potentially // delaying recommendations until full consensus is reached. type AndStrategy struct { - Strategy - // Strategies are the group of strategies that will be consulted to make an actionable recommendation. Strategies []Strategy diff --git a/strategy/buy_and_hold_strategy.go b/strategy/buy_and_hold_strategy.go index 8506bce..f333b0f 100644 --- a/strategy/buy_and_hold_strategy.go +++ b/strategy/buy_and_hold_strategy.go @@ -14,7 +14,6 @@ import ( // a benchmark for evaluating the performance of alternative // strategies against a baseline of passive asset ownership. type BuyAndHoldStrategy struct { - Strategy } // NewBuyAndHoldStrategy function initializes a new buy and hold strategy instance. diff --git a/strategy/compound/README.md b/strategy/compound/README.md index ea041d2..4dcd1d3 100644 --- a/strategy/compound/README.md +++ b/strategy/compound/README.md @@ -58,14 +58,12 @@ func AllStrategies() []strategy.Strategy AllStrategies returns a slice containing references to all available compound strategies. -## type [MacdRsiStrategy]() +## type [MacdRsiStrategy]() MacdRsiStrategy represents the configuration parameters for calculating the MACD\-RSI strategy. ```go type MacdRsiStrategy struct { - strategy.Strategy - // MacdStrategy is the MACD strategy instance. MacdStrategy *trend.MacdStrategy @@ -75,7 +73,7 @@ type MacdRsiStrategy struct { ``` -### func [NewMacdRsiStrategy]() +### func [NewMacdRsiStrategy]() ```go func NewMacdRsiStrategy() *MacdRsiStrategy @@ -84,7 +82,7 @@ func NewMacdRsiStrategy() *MacdRsiStrategy NewMacdRsiStrategy function initializes a new MACD\-RSI strategy instance with the default parameters. -### func [NewMacdRsiStrategyWith]() +### func [NewMacdRsiStrategyWith]() ```go func NewMacdRsiStrategyWith(buyAt, sellAt float64) *MacdRsiStrategy @@ -93,7 +91,7 @@ func NewMacdRsiStrategyWith(buyAt, sellAt float64) *MacdRsiStrategy NewMacdRsiStrategyWith function initializes a new MACD\-RSI strategy instance with the given parameters. -### func \(\*MacdRsiStrategy\) [Compute]() +### func \(\*MacdRsiStrategy\) [Compute]() ```go func (m *MacdRsiStrategy) Compute(snapshots <-chan *asset.Snapshot) <-chan strategy.Action @@ -102,7 +100,7 @@ func (m *MacdRsiStrategy) Compute(snapshots <-chan *asset.Snapshot) <-chan strat Compute processes the provided asset snapshots and generates a stream of actionable recommendations. -### func \(\*MacdRsiStrategy\) [Name]() +### func \(\*MacdRsiStrategy\) [Name]() ```go func (m *MacdRsiStrategy) Name() string @@ -111,7 +109,7 @@ func (m *MacdRsiStrategy) Name() string Name returns the name of the strategy. -### func \(\*MacdRsiStrategy\) [Report]() +### func \(\*MacdRsiStrategy\) [Report]() ```go func (m *MacdRsiStrategy) Report(c <-chan *asset.Snapshot) *helper.Report diff --git a/strategy/compound/macd_rsi_strategy.go b/strategy/compound/macd_rsi_strategy.go index 7f90e58..867d25d 100644 --- a/strategy/compound/macd_rsi_strategy.go +++ b/strategy/compound/macd_rsi_strategy.go @@ -24,8 +24,6 @@ const ( // MacdRsiStrategy represents the configuration parameters for calculating the MACD-RSI strategy. type MacdRsiStrategy struct { - strategy.Strategy - // MacdStrategy is the MACD strategy instance. MacdStrategy *trend.MacdStrategy diff --git a/strategy/decorator/README.md b/strategy/decorator/README.md index df78cca..63f1a0b 100644 --- a/strategy/decorator/README.md +++ b/strategy/decorator/README.md @@ -42,21 +42,19 @@ The information provided on this project is strictly for informational purposes -## type [InverseStrategy]() +## type [InverseStrategy]() InverseStrategy reverses the advice of another strategy. For example, if the original strategy suggests buying an asset, InverseStrategy would recommend selling it. ```go type InverseStrategy struct { - strategy.Strategy - // InnerStrategy is the inner strategy. InnerStrategy strategy.Strategy } ``` -### func [NewInverseStrategy]() +### func [NewInverseStrategy]() ```go func NewInverseStrategy(innerStrategy strategy.Strategy) *InverseStrategy @@ -65,7 +63,7 @@ func NewInverseStrategy(innerStrategy strategy.Strategy) *InverseStrategy NewInverseStrategy function initializes a new inverse strategy instance. -### func \(\*InverseStrategy\) [Compute]() +### func \(\*InverseStrategy\) [Compute]() ```go func (i *InverseStrategy) Compute(snapshots <-chan *asset.Snapshot) <-chan strategy.Action @@ -74,7 +72,7 @@ func (i *InverseStrategy) Compute(snapshots <-chan *asset.Snapshot) <-chan strat Compute processes the provided asset snapshots and generates a stream of actionable recommendations. -### func \(\*InverseStrategy\) [Name]() +### func \(\*InverseStrategy\) [Name]() ```go func (i *InverseStrategy) Name() string @@ -83,7 +81,7 @@ func (i *InverseStrategy) Name() string Name returns the name of the strategy. -### func \(\*InverseStrategy\) [Report]() +### func \(\*InverseStrategy\) [Report]() ```go func (i *InverseStrategy) Report(c <-chan *asset.Snapshot) *helper.Report @@ -92,21 +90,19 @@ func (i *InverseStrategy) Report(c <-chan *asset.Snapshot) *helper.Report Report processes the provided asset snapshots and generates a report annotated with the recommended actions. -## type [NoLossStrategy]() +## type [NoLossStrategy]() NoLossStrategy prevents selling an asset at a loss. It modifies the recommendations of another strategy to ensure that the asset is only sold if its value is at or above the original purchase price. ```go type NoLossStrategy struct { - strategy.Strategy - // InnertStrategy is the inner strategy. InnertStrategy strategy.Strategy } ``` -### func [NewNoLossStrategy]() +### func [NewNoLossStrategy]() ```go func NewNoLossStrategy(innerStrategy strategy.Strategy) *NoLossStrategy @@ -115,7 +111,7 @@ func NewNoLossStrategy(innerStrategy strategy.Strategy) *NoLossStrategy NewNoLossStrategy function initializes a new no loss strategy instance. -### func \(\*NoLossStrategy\) [Compute]() +### func \(\*NoLossStrategy\) [Compute]() ```go func (n *NoLossStrategy) Compute(snapshots <-chan *asset.Snapshot) <-chan strategy.Action @@ -124,7 +120,7 @@ func (n *NoLossStrategy) Compute(snapshots <-chan *asset.Snapshot) <-chan strate Compute processes the provided asset snapshots and generates a stream of actionable recommendations. -### func \(\*NoLossStrategy\) [Name]() +### func \(\*NoLossStrategy\) [Name]() ```go func (n *NoLossStrategy) Name() string @@ -133,7 +129,7 @@ func (n *NoLossStrategy) Name() string Name returns the name of the strategy. -### func \(\*NoLossStrategy\) [Report]() +### func \(\*NoLossStrategy\) [Report]() ```go func (n *NoLossStrategy) Report(c <-chan *asset.Snapshot) *helper.Report @@ -142,14 +138,12 @@ func (n *NoLossStrategy) Report(c <-chan *asset.Snapshot) *helper.Report Report processes the provided asset snapshots and generates a report annotated with the recommended actions. -## type [StopLossStrategy]() +## type [StopLossStrategy]() StopLossStrategy prevents a loss by recommending a sell action when the assets drops below the given threshold. ```go type StopLossStrategy struct { - strategy.Strategy - // InnertStrategy is the inner strategy. InnertStrategy strategy.Strategy @@ -159,7 +153,7 @@ type StopLossStrategy struct { ``` -### func [NewStopLossStrategy]() +### func [NewStopLossStrategy]() ```go func NewStopLossStrategy(innerStrategy strategy.Strategy, percentage float64) *StopLossStrategy @@ -168,7 +162,7 @@ func NewStopLossStrategy(innerStrategy strategy.Strategy, percentage float64) *S NewStopLossStrategy function initializes a new stop loss strategy instance. -### func \(\*StopLossStrategy\) [Compute]() +### func \(\*StopLossStrategy\) [Compute]() ```go func (s *StopLossStrategy) Compute(snapshots <-chan *asset.Snapshot) <-chan strategy.Action @@ -177,7 +171,7 @@ func (s *StopLossStrategy) Compute(snapshots <-chan *asset.Snapshot) <-chan stra Compute processes the provided asset snapshots and generates a stream of actionable recommendations. -### func \(\*StopLossStrategy\) [Name]() +### func \(\*StopLossStrategy\) [Name]() ```go func (s *StopLossStrategy) Name() string @@ -186,7 +180,7 @@ func (s *StopLossStrategy) Name() string Name returns the name of the strategy. -### func \(\*StopLossStrategy\) [Report]() +### func \(\*StopLossStrategy\) [Report]() ```go func (s *StopLossStrategy) Report(c <-chan *asset.Snapshot) *helper.Report diff --git a/strategy/decorator/inverse_strategy.go b/strategy/decorator/inverse_strategy.go index 24441c6..3e0c7b7 100644 --- a/strategy/decorator/inverse_strategy.go +++ b/strategy/decorator/inverse_strategy.go @@ -15,8 +15,6 @@ import ( // InverseStrategy reverses the advice of another strategy. For example, if the original strategy suggests buying an // asset, InverseStrategy would recommend selling it. type InverseStrategy struct { - strategy.Strategy - // InnerStrategy is the inner strategy. InnerStrategy strategy.Strategy } diff --git a/strategy/decorator/no_loss_strategy.go b/strategy/decorator/no_loss_strategy.go index e6b328b..090b2ba 100644 --- a/strategy/decorator/no_loss_strategy.go +++ b/strategy/decorator/no_loss_strategy.go @@ -15,8 +15,6 @@ import ( // NoLossStrategy prevents selling an asset at a loss. It modifies the recommendations of another strategy to ensure // that the asset is only sold if its value is at or above the original purchase price. type NoLossStrategy struct { - strategy.Strategy - // InnertStrategy is the inner strategy. InnertStrategy strategy.Strategy } diff --git a/strategy/decorator/stop_loss_strategy.go b/strategy/decorator/stop_loss_strategy.go index 79f4e96..cbab9cc 100644 --- a/strategy/decorator/stop_loss_strategy.go +++ b/strategy/decorator/stop_loss_strategy.go @@ -14,8 +14,6 @@ import ( // StopLossStrategy prevents a loss by recommending a sell action when the assets drops below the given threshold. type StopLossStrategy struct { - strategy.Strategy - // InnertStrategy is the inner strategy. InnertStrategy strategy.Strategy diff --git a/strategy/majority_strategy.go b/strategy/majority_strategy.go index b583acf..d7d2a1b 100644 --- a/strategy/majority_strategy.go +++ b/strategy/majority_strategy.go @@ -11,8 +11,6 @@ import ( // MajorityStrategy emits actionable recommendations aligned with what the strategies in the group recommends. type MajorityStrategy struct { - Strategy - // Strategies are the group of strategies that will be consulted to make an actionable recommendation. Strategies []Strategy diff --git a/strategy/momentum/README.md b/strategy/momentum/README.md index abfe838..193bd84 100644 --- a/strategy/momentum/README.md +++ b/strategy/momentum/README.md @@ -112,21 +112,19 @@ func AllStrategies() []strategy.Strategy AllStrategies returns a slice containing references to all available momentum strategies. -## type [AwesomeOscillatorStrategy]() +## type [AwesomeOscillatorStrategy]() AwesomeOscillatorStrategy represents the configuration parameters for calculating the Awesome Oscillator strategy. ```go type AwesomeOscillatorStrategy struct { - strategy.Strategy - // AwesomeOscillator represents the configuration parameters for calculating the Awesome Oscillator. AwesomeOscillator *momentum.AwesomeOscillator[float64] } ``` -### func [NewAwesomeOscillatorStrategy]() +### func [NewAwesomeOscillatorStrategy]() ```go func NewAwesomeOscillatorStrategy() *AwesomeOscillatorStrategy @@ -135,7 +133,7 @@ func NewAwesomeOscillatorStrategy() *AwesomeOscillatorStrategy NewAwesomeOscillatorStrategy function initializes a new Awesome Oscillator strategy with the default parameters. -### func \(\*AwesomeOscillatorStrategy\) [Compute]() +### func \(\*AwesomeOscillatorStrategy\) [Compute]() ```go func (a *AwesomeOscillatorStrategy) Compute(snapshots <-chan *asset.Snapshot) <-chan strategy.Action @@ -144,7 +142,7 @@ func (a *AwesomeOscillatorStrategy) Compute(snapshots <-chan *asset.Snapshot) <- Compute processes the provided asset snapshots and generates a stream of actionable recommendations. -### func \(\*AwesomeOscillatorStrategy\) [Name]() +### func \(\*AwesomeOscillatorStrategy\) [Name]() ```go func (*AwesomeOscillatorStrategy) Name() string @@ -153,7 +151,7 @@ func (*AwesomeOscillatorStrategy) Name() string Name returns the name of the strategy. -### func \(\*AwesomeOscillatorStrategy\) [Report]() +### func \(\*AwesomeOscillatorStrategy\) [Report]() ```go func (a *AwesomeOscillatorStrategy) Report(c <-chan *asset.Snapshot) *helper.Report @@ -162,14 +160,12 @@ func (a *AwesomeOscillatorStrategy) Report(c <-chan *asset.Snapshot) *helper.Rep Report processes the provided asset snapshots and generates a report annotated with the recommended actions. -## type [RsiStrategy]() +## type [RsiStrategy]() RsiStrategy represents the configuration parameters for calculating the RSI strategy. ```go type RsiStrategy struct { - strategy.Strategy - // Rsi represents the configuration parameters for calculating the Relative Strength Index (RSI). Rsi *momentum.Rsi[float64] @@ -182,7 +178,7 @@ type RsiStrategy struct { ``` -### func [NewRsiStrategy]() +### func [NewRsiStrategy]() ```go func NewRsiStrategy() *RsiStrategy @@ -191,7 +187,7 @@ func NewRsiStrategy() *RsiStrategy NewRsiStrategy function initializes a new RSI strategy instance with the default parameters. -### func [NewRsiStrategyWith]() +### func [NewRsiStrategyWith]() ```go func NewRsiStrategyWith(buyAt, sellAt float64) *RsiStrategy @@ -200,7 +196,7 @@ func NewRsiStrategyWith(buyAt, sellAt float64) *RsiStrategy NewRsiStrategyWith function initializes a new RSI strategy instance with the given parameters. -### func \(\*RsiStrategy\) [Compute]() +### func \(\*RsiStrategy\) [Compute]() ```go func (r *RsiStrategy) Compute(snapshots <-chan *asset.Snapshot) <-chan strategy.Action @@ -209,7 +205,7 @@ func (r *RsiStrategy) Compute(snapshots <-chan *asset.Snapshot) <-chan strategy. Compute processes the provided asset snapshots and generates a stream of actionable recommendations. -### func \(\*RsiStrategy\) [Name]() +### func \(\*RsiStrategy\) [Name]() ```go func (r *RsiStrategy) Name() string @@ -218,7 +214,7 @@ func (r *RsiStrategy) Name() string Name returns the name of the strategy. -### func \(\*RsiStrategy\) [Report]() +### func \(\*RsiStrategy\) [Report]() ```go func (r *RsiStrategy) Report(c <-chan *asset.Snapshot) *helper.Report diff --git a/strategy/momentum/awesome_oscillator_strategy.go b/strategy/momentum/awesome_oscillator_strategy.go index 14c2563..8f6a87b 100644 --- a/strategy/momentum/awesome_oscillator_strategy.go +++ b/strategy/momentum/awesome_oscillator_strategy.go @@ -13,8 +13,6 @@ import ( // AwesomeOscillatorStrategy represents the configuration parameters for calculating the Awesome Oscillator strategy. type AwesomeOscillatorStrategy struct { - strategy.Strategy - // AwesomeOscillator represents the configuration parameters for calculating the Awesome Oscillator. AwesomeOscillator *momentum.AwesomeOscillator[float64] } diff --git a/strategy/momentum/rsi_strategy.go b/strategy/momentum/rsi_strategy.go index 9b38789..b7a5aab 100644 --- a/strategy/momentum/rsi_strategy.go +++ b/strategy/momentum/rsi_strategy.go @@ -23,8 +23,6 @@ const ( // RsiStrategy represents the configuration parameters for calculating the RSI strategy. type RsiStrategy struct { - strategy.Strategy - // Rsi represents the configuration parameters for calculating the Relative Strength Index (RSI). Rsi *momentum.Rsi[float64] diff --git a/strategy/or_strategy.go b/strategy/or_strategy.go index e1ff8c5..e787008 100644 --- a/strategy/or_strategy.go +++ b/strategy/or_strategy.go @@ -12,8 +12,6 @@ import ( // OrStrategy emits actionable recommendations when **at least one** strategy in the group recommends an // action **without any conflicting recommendations** from other strategies. type OrStrategy struct { - Strategy - // Strategies are the group of strategies that will be consulted to make an actionable recommendation. Strategies []Strategy diff --git a/strategy/trend/README.md b/strategy/trend/README.md index c3cbcd6..f61c4b8 100644 --- a/strategy/trend/README.md +++ b/strategy/trend/README.md @@ -190,14 +190,12 @@ func AllStrategies() []strategy.Strategy AllStrategies returns a slice containing references to all available trend strategies. -## type [ApoStrategy]() +## type [ApoStrategy]() ApoStrategy represents the configuration parameters for calculating the APO strategy. An APO value crossing above zero suggests a bullish trend, while crossing below zero indicates a bearish trend. Positive APO values signify an upward trend, while negative values signify a downward trend. ```go type ApoStrategy struct { - strategy.Strategy - // Apo represents the configuration parameters for calculating the // Absolute Price Oscillator (APO). Apo *trend.Apo[float64] @@ -205,7 +203,7 @@ type ApoStrategy struct { ``` -### func [NewApoStrategy]() +### func [NewApoStrategy]() ```go func NewApoStrategy() *ApoStrategy @@ -214,7 +212,7 @@ func NewApoStrategy() *ApoStrategy NewApoStrategy function initializes a new APO strategy instance with the default parameters. -### func \(\*ApoStrategy\) [Compute]() +### func \(\*ApoStrategy\) [Compute]() ```go func (a *ApoStrategy) Compute(snapshots <-chan *asset.Snapshot) <-chan strategy.Action @@ -223,7 +221,7 @@ func (a *ApoStrategy) Compute(snapshots <-chan *asset.Snapshot) <-chan strategy. Compute processes the provided asset snapshots and generates a stream of actionable recommendations. -### func \(\*ApoStrategy\) [Name]() +### func \(\*ApoStrategy\) [Name]() ```go func (*ApoStrategy) Name() string @@ -232,7 +230,7 @@ func (*ApoStrategy) Name() string Name returns the name of the strategy. -### func \(\*ApoStrategy\) [Report]() +### func \(\*ApoStrategy\) [Report]() ```go func (a *ApoStrategy) Report(c <-chan *asset.Snapshot) *helper.Report @@ -241,21 +239,19 @@ func (a *ApoStrategy) Report(c <-chan *asset.Snapshot) *helper.Report Report processes the provided asset snapshots and generates a report annotated with the recommended actions. -## type [AroonStrategy]() +## type [AroonStrategy]() AroonStrategy represents the configuration parameters for calculating the Aroon strategy. Aroon is a technical analysis tool that gauges trend direction and strength in asset prices. It comprises two lines: Aroon Up and Aroon Down. Aroon Up measures uptrend strength, while Aroon Down measures downtrend strength. When Aroon Up exceeds Aroon Down, it suggests a bullish trend; when Aroon Down surpasses Aroon Up, it indicates a bearish trend. ```go type AroonStrategy struct { - strategy.Strategy - // Aroon represent the configuration for calculating the Aroon indicator. Aroon *trend.Aroon[float64] } ``` -### func [NewAroonStrategy]() +### func [NewAroonStrategy]() ```go func NewAroonStrategy() *AroonStrategy @@ -264,7 +260,7 @@ func NewAroonStrategy() *AroonStrategy NewAroonStrategy function initializes a new Aroon strategy instance with the default parameters. -### func \(\*AroonStrategy\) [Compute]() +### func \(\*AroonStrategy\) [Compute]() ```go func (a *AroonStrategy) Compute(c <-chan *asset.Snapshot) <-chan strategy.Action @@ -273,7 +269,7 @@ func (a *AroonStrategy) Compute(c <-chan *asset.Snapshot) <-chan strategy.Action Compute processes the provided asset snapshots and generates a stream of actionable recommendations. -### func \(\*AroonStrategy\) [Name]() +### func \(\*AroonStrategy\) [Name]() ```go func (*AroonStrategy) Name() string @@ -282,7 +278,7 @@ func (*AroonStrategy) Name() string Name returns the name of the strategy. -### func \(\*AroonStrategy\) [Report]() +### func \(\*AroonStrategy\) [Report]() ```go func (a *AroonStrategy) Report(c <-chan *asset.Snapshot) *helper.Report @@ -291,14 +287,12 @@ func (a *AroonStrategy) Report(c <-chan *asset.Snapshot) *helper.Report Report processes the provided asset snapshots and generates a report annotated with the recommended actions. -## type [BopStrategy]() +## type [BopStrategy]() BopStrategy gauges the strength of buying and selling forces using the Balance of Power \(BoP\) indicator. A positive BoP value suggests an upward trend, while a negative value indicates a downward trend. A BoP value of zero implies equilibrium between the two forces. ```go type BopStrategy struct { - strategy.Strategy - // Bop represents the configuration parameters for calculating the // Balance of Power (BoP). Bop *trend.Bop[float64] @@ -306,7 +300,7 @@ type BopStrategy struct { ``` -### func [NewBopStrategy]() +### func [NewBopStrategy]() ```go func NewBopStrategy() *BopStrategy @@ -315,7 +309,7 @@ func NewBopStrategy() *BopStrategy NewBopStrategy function initializes a new BoP strategy instance with the default parameters. -### func \(\*BopStrategy\) [Compute]() +### func \(\*BopStrategy\) [Compute]() ```go func (b *BopStrategy) Compute(c <-chan *asset.Snapshot) <-chan strategy.Action @@ -324,7 +318,7 @@ func (b *BopStrategy) Compute(c <-chan *asset.Snapshot) <-chan strategy.Action Compute processes the provided asset snapshots and generates a stream of actionable recommendations. -### func \(\*BopStrategy\) [Name]() +### func \(\*BopStrategy\) [Name]() ```go func (*BopStrategy) Name() string @@ -333,7 +327,7 @@ func (*BopStrategy) Name() string Name returns the name of the strategy. -### func \(\*BopStrategy\) [Report]() +### func \(\*BopStrategy\) [Report]() ```go func (b *BopStrategy) Report(c <-chan *asset.Snapshot) *helper.Report @@ -342,21 +336,19 @@ func (b *BopStrategy) Report(c <-chan *asset.Snapshot) *helper.Report Report processes the provided asset snapshots and generates a report annotated with the recommended actions. -## type [CciStrategy]() +## type [CciStrategy]() CciStrategy represents the configuration parameters for calculating the CCI strategy. A CCI value crossing above the 100\+ suggests a bullish trend, while crossing below the 100\- indicates a bearish trend. ```go type CciStrategy struct { - strategy.Strategy - // Cci represents the configuration parameters for calculating the CCI. Cci *trend.Cci[float64] } ``` -### func [NewCciStrategy]() +### func [NewCciStrategy]() ```go func NewCciStrategy() *CciStrategy @@ -365,7 +357,7 @@ func NewCciStrategy() *CciStrategy NewCciStrategy function initializes a new CCI strategy instance. -### func \(\*CciStrategy\) [Compute]() +### func \(\*CciStrategy\) [Compute]() ```go func (t *CciStrategy) Compute(c <-chan *asset.Snapshot) <-chan strategy.Action @@ -374,7 +366,7 @@ func (t *CciStrategy) Compute(c <-chan *asset.Snapshot) <-chan strategy.Action Compute processes the provided asset snapshots and generates a stream of actionable recommendations. -### func \(\*CciStrategy\) [Name]() +### func \(\*CciStrategy\) [Name]() ```go func (*CciStrategy) Name() string @@ -383,7 +375,7 @@ func (*CciStrategy) Name() string Name returns the name of the strategy. -### func \(\*CciStrategy\) [Report]() +### func \(\*CciStrategy\) [Report]() ```go func (t *CciStrategy) Report(c <-chan *asset.Snapshot) *helper.Report @@ -392,14 +384,12 @@ func (t *CciStrategy) Report(c <-chan *asset.Snapshot) *helper.Report Report processes the provided asset snapshots and generates a report annotated with the recommended actions. -## type [DemaStrategy]() +## type [DemaStrategy]() DemaStrategy represents the configuration parameters for calculating the DEMA strategy. A bullish cross occurs when DEMA with 5 days period moves above DEMA with 35 days period. A bearish cross occurs when DEMA with 35 days period moves above DEMA With 5 days period. ```go type DemaStrategy struct { - strategy.Strategy - // Dema1 represents the configuration parameters for // calculating the first DEMA. Dema1 *trend.Dema[float64] @@ -411,7 +401,7 @@ type DemaStrategy struct { ``` -### func [NewDemaStrategy]() +### func [NewDemaStrategy]() ```go func NewDemaStrategy() *DemaStrategy @@ -420,7 +410,7 @@ func NewDemaStrategy() *DemaStrategy NewDemaStrategy function initializes a new DEMA strategy instance with the default parameters. -### func \(\*DemaStrategy\) [Compute]() +### func \(\*DemaStrategy\) [Compute]() ```go func (d *DemaStrategy) Compute(c <-chan *asset.Snapshot) <-chan strategy.Action @@ -429,7 +419,7 @@ func (d *DemaStrategy) Compute(c <-chan *asset.Snapshot) <-chan strategy.Action Compute processes the provided asset snapshots and generates a stream of actionable recommendations. -### func \(\*DemaStrategy\) [Name]() +### func \(\*DemaStrategy\) [Name]() ```go func (*DemaStrategy) Name() string @@ -438,7 +428,7 @@ func (*DemaStrategy) Name() string Name returns the name of the strategy. -### func \(\*DemaStrategy\) [Report]() +### func \(\*DemaStrategy\) [Report]() ```go func (d *DemaStrategy) Report(c <-chan *asset.Snapshot) *helper.Report @@ -564,21 +554,19 @@ func (k *KamaStrategy) Report(c <-chan *asset.Snapshot) *helper.Report Report processes the provided asset snapshots and generates a report annotated with the recommended actions. -## type [KdjStrategy]() +## type [KdjStrategy]() KdjStrategy represents the configuration parameters for calculating the KDJ strategy. Generates BUY action when j value crosses above both k and d values. Generates SELL action when j value crosses below both k and d values. ```go type KdjStrategy struct { - strategy.Strategy - // Kdj represents the configuration parameters for calculating the KDJ. Kdj *trend.Kdj[float64] } ``` -### func [NewKdjStrategy]() +### func [NewKdjStrategy]() ```go func NewKdjStrategy() *KdjStrategy @@ -587,7 +575,7 @@ func NewKdjStrategy() *KdjStrategy NewKdjStrategy function initializes a new KDJ strategy instance. -### func \(\*KdjStrategy\) [Compute]() +### func \(\*KdjStrategy\) [Compute]() ```go func (kdj *KdjStrategy) Compute(c <-chan *asset.Snapshot) <-chan strategy.Action @@ -596,7 +584,7 @@ func (kdj *KdjStrategy) Compute(c <-chan *asset.Snapshot) <-chan strategy.Action Compute processes the provided asset snapshots and generates a stream of actionable recommendations. -### func \(\*KdjStrategy\) [Name]() +### func \(\*KdjStrategy\) [Name]() ```go func (*KdjStrategy) Name() string @@ -605,7 +593,7 @@ func (*KdjStrategy) Name() string Name returns the name of the strategy. -### func \(\*KdjStrategy\) [Report]() +### func \(\*KdjStrategy\) [Report]() ```go func (kdj *KdjStrategy) Report(c <-chan *asset.Snapshot) *helper.Report @@ -614,14 +602,12 @@ func (kdj *KdjStrategy) Report(c <-chan *asset.Snapshot) *helper.Report Report processes the provided asset snapshots and generates a report annotated with the recommended actions. -## type [MacdStrategy]() +## type [MacdStrategy]() MacdStrategy represents the configuration parameters for calculating the MACD strategy. A MACD value crossing above the signal line suggests a bullish trend, while crossing below the signal line indicates a bearish trend. ```go type MacdStrategy struct { - strategy.Strategy - // Macd represents the configuration parameters for calculating the // Moving Average Convergence Divergence (MACD). Macd *trend.Macd[float64] @@ -629,7 +615,7 @@ type MacdStrategy struct { ``` -### func [NewMacdStrategy]() +### func [NewMacdStrategy]() ```go func NewMacdStrategy() *MacdStrategy @@ -638,7 +624,7 @@ func NewMacdStrategy() *MacdStrategy NewMacdStrategy function initializes a new MACD strategy instance. -### func [NewMacdStrategyWith]() +### func [NewMacdStrategyWith]() ```go func NewMacdStrategyWith(period1, period2, period3 int) *MacdStrategy @@ -647,7 +633,7 @@ func NewMacdStrategyWith(period1, period2, period3 int) *MacdStrategy NewMacdStrategyWith function initializes a new MACD strategy instance with the given parameters. -### func \(\*MacdStrategy\) [Compute]() +### func \(\*MacdStrategy\) [Compute]() ```go func (m *MacdStrategy) Compute(snapshots <-chan *asset.Snapshot) <-chan strategy.Action @@ -656,7 +642,7 @@ func (m *MacdStrategy) Compute(snapshots <-chan *asset.Snapshot) <-chan strategy Compute processes the provided asset snapshots and generates a stream of actionable recommendations. -### func \(\*MacdStrategy\) [Name]() +### func \(\*MacdStrategy\) [Name]() ```go func (m *MacdStrategy) Name() string @@ -665,7 +651,7 @@ func (m *MacdStrategy) Name() string Name returns the name of the strategy. -### func \(\*MacdStrategy\) [Report]() +### func \(\*MacdStrategy\) [Report]() ```go func (m *MacdStrategy) Report(c <-chan *asset.Snapshot) *helper.Report @@ -674,7 +660,7 @@ func (m *MacdStrategy) Report(c <-chan *asset.Snapshot) *helper.Report Report processes the provided asset snapshots and generates a report annotated with the recommended actions. -## type [QstickStrategy]() +## type [QstickStrategy]() QstickStrategy represents the configuration parameters for calculating the Qstick strategy. Qstick is a momentum indicator used to identify an asset's trend by looking at the SMA of the difference between its closing and opening. @@ -682,15 +668,13 @@ A Qstick above zero indicates increasing buying pressure, while a Qstick below z ```go type QstickStrategy struct { - strategy.Strategy - // Qstick represents the configuration parameters for calculating the Qstick. Qstick *momentum.Qstick[float64] } ``` -### func [NewQstickStrategy]() +### func [NewQstickStrategy]() ```go func NewQstickStrategy() *QstickStrategy @@ -699,7 +683,7 @@ func NewQstickStrategy() *QstickStrategy NewQstickStrategy function initializes a new Qstick strategy instance. -### func \(\*QstickStrategy\) [Compute]() +### func \(\*QstickStrategy\) [Compute]() ```go func (q *QstickStrategy) Compute(c <-chan *asset.Snapshot) <-chan strategy.Action @@ -708,7 +692,7 @@ func (q *QstickStrategy) Compute(c <-chan *asset.Snapshot) <-chan strategy.Actio Compute processes the provided asset snapshots and generates a stream of actionable recommendations. -### func \(\*QstickStrategy\) [Name]() +### func \(\*QstickStrategy\) [Name]() ```go func (*QstickStrategy) Name() string @@ -717,7 +701,7 @@ func (*QstickStrategy) Name() string Name returns the name of the strategy. -### func \(\*QstickStrategy\) [Report]() +### func \(\*QstickStrategy\) [Report]() ```go func (q *QstickStrategy) Report(c <-chan *asset.Snapshot) *helper.Report @@ -726,14 +710,12 @@ func (q *QstickStrategy) Report(c <-chan *asset.Snapshot) *helper.Report Report processes the provided asset snapshots and generates a report annotated with the recommended actions. -## type [TrimaStrategy]() +## type [TrimaStrategy]() TrimaStrategy represents the configuration parameters for calculating the TRIMA strategy. A bullish cross occurs when the short TRIMA moves above the long TRIMA. A bearish cross occurs when the short TRIMA moves below the long TRIME. ```go type TrimaStrategy struct { - strategy.Strategy - // Trima1 represents the configuration parameters for calculating the short TRIMA. Short *trend.Trima[float64] @@ -743,7 +725,7 @@ type TrimaStrategy struct { ``` -### func [NewTrimaStrategy]() +### func [NewTrimaStrategy]() ```go func NewTrimaStrategy() *TrimaStrategy @@ -752,7 +734,7 @@ func NewTrimaStrategy() *TrimaStrategy NewTrimaStrategy function initializes a new TRIMA strategy instance with the default parameters. -### func \(\*TrimaStrategy\) [Compute]() +### func \(\*TrimaStrategy\) [Compute]() ```go func (t *TrimaStrategy) Compute(c <-chan *asset.Snapshot) <-chan strategy.Action @@ -761,7 +743,7 @@ func (t *TrimaStrategy) Compute(c <-chan *asset.Snapshot) <-chan strategy.Action Compute processes the provided asset snapshots and generates a stream of actionable recommendations. -### func \(\*TrimaStrategy\) [Name]() +### func \(\*TrimaStrategy\) [Name]() ```go func (*TrimaStrategy) Name() string @@ -770,7 +752,7 @@ func (*TrimaStrategy) Name() string Name returns the name of the strategy. -### func \(\*TrimaStrategy\) [Report]() +### func \(\*TrimaStrategy\) [Report]() ```go func (t *TrimaStrategy) Report(c <-chan *asset.Snapshot) *helper.Report @@ -842,21 +824,19 @@ func (t *TripleMovingAverageCrossoverStrategy) Report(c <-chan *asset.Snapshot) Report processes the provided asset snapshots and generates a report annotated with the recommended actions. -## type [TrixStrategy]() +## type [TrixStrategy]() TrixStrategy represents the configuration parameters for calculating the TRIX strategy. A TRIX value crossing above the zero line suggests a bullish trend, while crossing below the zero line indicates a bearish trend. ```go type TrixStrategy struct { - strategy.Strategy - // Trix represents the configuration parameters for calculating the TRIX. Trix *trend.Trix[float64] } ``` -### func [NewTrixStrategy]() +### func [NewTrixStrategy]() ```go func NewTrixStrategy() *TrixStrategy @@ -865,7 +845,7 @@ func NewTrixStrategy() *TrixStrategy NewTrixStrategy function initializes a new TRIX strategy instance. -### func \(\*TrixStrategy\) [Compute]() +### func \(\*TrixStrategy\) [Compute]() ```go func (t *TrixStrategy) Compute(snapshots <-chan *asset.Snapshot) <-chan strategy.Action @@ -874,7 +854,7 @@ func (t *TrixStrategy) Compute(snapshots <-chan *asset.Snapshot) <-chan strategy Compute processes the provided asset snapshots and generates a stream of actionable recommendations. -### func \(\*TrixStrategy\) [Name]() +### func \(\*TrixStrategy\) [Name]() ```go func (*TrixStrategy) Name() string @@ -883,7 +863,7 @@ func (*TrixStrategy) Name() string Name returns the name of the strategy. -### func \(\*TrixStrategy\) [Report]() +### func \(\*TrixStrategy\) [Report]() ```go func (t *TrixStrategy) Report(c <-chan *asset.Snapshot) *helper.Report @@ -967,14 +947,12 @@ func (t *TsiStrategy) Report(c <-chan *asset.Snapshot) *helper.Report Report processes the provided asset snapshots and generates a report annotated with the recommended actions. -## type [VwmaStrategy]() +## type [VwmaStrategy]() VwmaStrategy represents the configuration parameters for calculating the VWMA strategy. The VwmaStrategy function uses SMA and VWMA indicators to provide a BUY action when VWMA is above SMA, and a SELL signal when VWMA is below SMA, a HOLD otherwse. ```go type VwmaStrategy struct { - strategy.Strategy - // VWMA indicator. Vwma *trend.Vwma[float64] @@ -984,7 +962,7 @@ type VwmaStrategy struct { ``` -### func [NewVwmaStrategy]() +### func [NewVwmaStrategy]() ```go func NewVwmaStrategy() *VwmaStrategy @@ -993,7 +971,7 @@ func NewVwmaStrategy() *VwmaStrategy NewVwmaStrategy function initializes a new VWMA strategy instance with the default parameters. -### func \(\*VwmaStrategy\) [Compute]() +### func \(\*VwmaStrategy\) [Compute]() ```go func (v *VwmaStrategy) Compute(c <-chan *asset.Snapshot) <-chan strategy.Action @@ -1002,7 +980,7 @@ func (v *VwmaStrategy) Compute(c <-chan *asset.Snapshot) <-chan strategy.Action Compute processes the provided asset snapshots and generates a stream of actionable recommendations. -### func \(\*VwmaStrategy\) [Name]() +### func \(\*VwmaStrategy\) [Name]() ```go func (*VwmaStrategy) Name() string @@ -1011,7 +989,7 @@ func (*VwmaStrategy) Name() string Name returns the name of the strategy. -### func \(\*VwmaStrategy\) [Report]() +### func \(\*VwmaStrategy\) [Report]() ```go func (v *VwmaStrategy) Report(c <-chan *asset.Snapshot) *helper.Report diff --git a/strategy/trend/apo_strategy.go b/strategy/trend/apo_strategy.go index d5dfcf2..86f3cbb 100644 --- a/strategy/trend/apo_strategy.go +++ b/strategy/trend/apo_strategy.go @@ -16,8 +16,6 @@ import ( // indicates a bearish trend. Positive APO values signify an upward trend, while // negative values signify a downward trend. type ApoStrategy struct { - strategy.Strategy - // Apo represents the configuration parameters for calculating the // Absolute Price Oscillator (APO). Apo *trend.Apo[float64] diff --git a/strategy/trend/aroon_strategy.go b/strategy/trend/aroon_strategy.go index e8ffeda..1343147 100644 --- a/strategy/trend/aroon_strategy.go +++ b/strategy/trend/aroon_strategy.go @@ -18,8 +18,6 @@ import ( // Aroon Down, it suggests a bullish trend; when Aroon Down surpasses Aroon Up, // it indicates a bearish trend. type AroonStrategy struct { - strategy.Strategy - // Aroon represent the configuration for calculating the Aroon indicator. Aroon *trend.Aroon[float64] } diff --git a/strategy/trend/bop_strategy.go b/strategy/trend/bop_strategy.go index 7dbfc5d..0dbdcb1 100644 --- a/strategy/trend/bop_strategy.go +++ b/strategy/trend/bop_strategy.go @@ -16,8 +16,6 @@ import ( // upward trend, while a negative value indicates a downward trend. A // BoP value of zero implies equilibrium between the two forces. type BopStrategy struct { - strategy.Strategy - // Bop represents the configuration parameters for calculating the // Balance of Power (BoP). Bop *trend.Bop[float64] diff --git a/strategy/trend/cci_strategy.go b/strategy/trend/cci_strategy.go index 93344d4..2aa2d94 100644 --- a/strategy/trend/cci_strategy.go +++ b/strategy/trend/cci_strategy.go @@ -15,8 +15,6 @@ import ( // A CCI value crossing above the 100+ suggests a bullish trend, while crossing below // the 100- indicates a bearish trend. type CciStrategy struct { - strategy.Strategy - // Cci represents the configuration parameters for calculating the CCI. Cci *trend.Cci[float64] } diff --git a/strategy/trend/dema_strategy.go b/strategy/trend/dema_strategy.go index 32e1a87..fd6a4c0 100644 --- a/strategy/trend/dema_strategy.go +++ b/strategy/trend/dema_strategy.go @@ -25,8 +25,6 @@ const ( // A bullish cross occurs when DEMA with 5 days period moves above DEMA with 35 days period. // A bearish cross occurs when DEMA with 35 days period moves above DEMA With 5 days period. type DemaStrategy struct { - strategy.Strategy - // Dema1 represents the configuration parameters for // calculating the first DEMA. Dema1 *trend.Dema[float64] diff --git a/strategy/trend/kdj_strategy.go b/strategy/trend/kdj_strategy.go index c94e922..e844af4 100644 --- a/strategy/trend/kdj_strategy.go +++ b/strategy/trend/kdj_strategy.go @@ -15,8 +15,6 @@ import ( // Generates BUY action when j value crosses above both k and d values. // Generates SELL action when j value crosses below both k and d values. type KdjStrategy struct { - strategy.Strategy - // Kdj represents the configuration parameters for calculating the KDJ. Kdj *trend.Kdj[float64] } diff --git a/strategy/trend/macd_strategy.go b/strategy/trend/macd_strategy.go index b2fa85e..dfc9e98 100644 --- a/strategy/trend/macd_strategy.go +++ b/strategy/trend/macd_strategy.go @@ -18,8 +18,6 @@ import ( // bullish trend, while crossing below the signal line indicates a // bearish trend. type MacdStrategy struct { - strategy.Strategy - // Macd represents the configuration parameters for calculating the // Moving Average Convergence Divergence (MACD). Macd *trend.Macd[float64] diff --git a/strategy/trend/qstick_strategy.go b/strategy/trend/qstick_strategy.go index e08addb..bba165b 100644 --- a/strategy/trend/qstick_strategy.go +++ b/strategy/trend/qstick_strategy.go @@ -19,8 +19,6 @@ import ( // A Qstick above zero indicates increasing buying pressure, while // a Qstick below zero indicates increasing selling pressure. type QstickStrategy struct { - strategy.Strategy - // Qstick represents the configuration parameters for calculating the Qstick. Qstick *momentum.Qstick[float64] } diff --git a/strategy/trend/trima_strategy.go b/strategy/trend/trima_strategy.go index 59b1ee7..5d6d194 100644 --- a/strategy/trend/trima_strategy.go +++ b/strategy/trend/trima_strategy.go @@ -23,8 +23,6 @@ const ( // A bullish cross occurs when the short TRIMA moves above the long TRIMA. // A bearish cross occurs when the short TRIMA moves below the long TRIME. type TrimaStrategy struct { - strategy.Strategy - // Trima1 represents the configuration parameters for calculating the short TRIMA. Short *trend.Trima[float64] diff --git a/strategy/trend/trix_strategy.go b/strategy/trend/trix_strategy.go index bcc6566..870549b 100644 --- a/strategy/trend/trix_strategy.go +++ b/strategy/trend/trix_strategy.go @@ -15,8 +15,6 @@ import ( // A TRIX value crossing above the zero line suggests a bullish trend, while crossing // below the zero line indicates a bearish trend. type TrixStrategy struct { - strategy.Strategy - // Trix represents the configuration parameters for calculating the TRIX. Trix *trend.Trix[float64] } diff --git a/strategy/trend/vwma_strategy.go b/strategy/trend/vwma_strategy.go index d2b5377..e63fd0a 100644 --- a/strategy/trend/vwma_strategy.go +++ b/strategy/trend/vwma_strategy.go @@ -20,8 +20,6 @@ const ( // The VwmaStrategy function uses SMA and VWMA indicators to provide a BUY action when // VWMA is above SMA, and a SELL signal when VWMA is below SMA, a HOLD otherwse. type VwmaStrategy struct { - strategy.Strategy - // VWMA indicator. Vwma *trend.Vwma[float64] diff --git a/strategy/volatility/README.md b/strategy/volatility/README.md index 1483e38..4af59a5 100644 --- a/strategy/volatility/README.md +++ b/strategy/volatility/README.md @@ -48,21 +48,19 @@ func AllStrategies() []strategy.Strategy AllStrategies returns a slice containing references to all available volatility strategies. -## type [BollingerBandsStrategy]() +## type [BollingerBandsStrategy]() BollingerBandsStrategy represents the configuration parameters for calculating the Bollinger Bands strategy. A closing value crossing above the upper band suggets a Buy signal, while crossing below the lower band indivates a Sell signal. ```go type BollingerBandsStrategy struct { - strategy.Strategy - // BollingerBands represents the configuration parameters for calculating the Bollinger Bands. BollingerBands *volatility.BollingerBands[float64] } ``` -### func [NewBollingerBandsStrategy]() +### func [NewBollingerBandsStrategy]() ```go func NewBollingerBandsStrategy() *BollingerBandsStrategy @@ -71,7 +69,7 @@ func NewBollingerBandsStrategy() *BollingerBandsStrategy NewBollingerBandsStrategy function initializes a new Bollinger Bands strategy instance. -### func \(\*BollingerBandsStrategy\) [Compute]() +### func \(\*BollingerBandsStrategy\) [Compute]() ```go func (b *BollingerBandsStrategy) Compute(snapshots <-chan *asset.Snapshot) <-chan strategy.Action @@ -80,7 +78,7 @@ func (b *BollingerBandsStrategy) Compute(snapshots <-chan *asset.Snapshot) <-cha Compute processes the provided asset snapshots and generates a stream of actionable recommendations. -### func \(\*BollingerBandsStrategy\) [Name]() +### func \(\*BollingerBandsStrategy\) [Name]() ```go func (*BollingerBandsStrategy) Name() string @@ -89,7 +87,7 @@ func (*BollingerBandsStrategy) Name() string Name returns the name of the strategy. -### func \(\*BollingerBandsStrategy\) [Report]() +### func \(\*BollingerBandsStrategy\) [Report]() ```go func (b *BollingerBandsStrategy) Report(c <-chan *asset.Snapshot) *helper.Report diff --git a/strategy/volatility/bollinger_bands_strategy.go b/strategy/volatility/bollinger_bands_strategy.go index 4ffaa0a..412c8d5 100644 --- a/strategy/volatility/bollinger_bands_strategy.go +++ b/strategy/volatility/bollinger_bands_strategy.go @@ -15,8 +15,6 @@ import ( // A closing value crossing above the upper band suggets a Buy signal, while crossing below the lower band // indivates a Sell signal. type BollingerBandsStrategy struct { - strategy.Strategy - // BollingerBands represents the configuration parameters for calculating the Bollinger Bands. BollingerBands *volatility.BollingerBands[float64] }