import "github.com/cinar/indicator/v2/strategy/decorator"
Package decorator contains the decorator strategy functions.
This package belongs to the Indicator project. Indicator is a Golang module that supplies a variety of technical indicators, strategies, and a backtesting framework for analysis.
Copyright (c) 2021-2024 Onur Cinar.
The source code is provided under GNU AGPLv3 License.
https://github.com/cinar/indicator
The information provided on this project is strictly for informational purposes and is not to be construed as advice or solicitation to buy or sell any security.
- type InverseStrategy
- type NoLossStrategy
- type StopLossStrategy
- func NewStopLossStrategy(innerStrategy strategy.Strategy, percentage float64) *StopLossStrategy
- func (s *StopLossStrategy) Compute(snapshots <-chan *asset.Snapshot) <-chan strategy.Action
- func (s *StopLossStrategy) Name() string
- func (s *StopLossStrategy) Report(c <-chan *asset.Snapshot) *helper.Report
type InverseStrategy
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 {
// InnerStrategy is the inner strategy.
InnerStrategy strategy.Strategy
}
func NewInverseStrategy
func NewInverseStrategy(innerStrategy strategy.Strategy) *InverseStrategy
NewInverseStrategy function initializes a new inverse strategy instance.
func (*InverseStrategy) Compute
func (i *InverseStrategy) Compute(snapshots <-chan *asset.Snapshot) <-chan strategy.Action
Compute processes the provided asset snapshots and generates a stream of actionable recommendations.
func (*InverseStrategy) Name
func (i *InverseStrategy) Name() string
Name returns the name of the strategy.
func (*InverseStrategy) Report
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
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 {
// InnertStrategy is the inner strategy.
InnertStrategy strategy.Strategy
}
func NewNoLossStrategy
func NewNoLossStrategy(innerStrategy strategy.Strategy) *NoLossStrategy
NewNoLossStrategy function initializes a new no loss strategy instance.
func (*NoLossStrategy) Compute
func (n *NoLossStrategy) Compute(snapshots <-chan *asset.Snapshot) <-chan strategy.Action
Compute processes the provided asset snapshots and generates a stream of actionable recommendations.
func (*NoLossStrategy) Name
func (n *NoLossStrategy) Name() string
Name returns the name of the strategy.
func (*NoLossStrategy) Report
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
StopLossStrategy prevents a loss by recommending a sell action when the assets drops below the given threshold.
type StopLossStrategy struct {
// InnertStrategy is the inner strategy.
InnertStrategy strategy.Strategy
// Percentage is the loss threshold in percentage.
Percentage float64
}
func NewStopLossStrategy
func NewStopLossStrategy(innerStrategy strategy.Strategy, percentage float64) *StopLossStrategy
NewStopLossStrategy function initializes a new stop loss strategy instance.
func (*StopLossStrategy) Compute
func (s *StopLossStrategy) Compute(snapshots <-chan *asset.Snapshot) <-chan strategy.Action
Compute processes the provided asset snapshots and generates a stream of actionable recommendations.
func (*StopLossStrategy) Name
func (s *StopLossStrategy) Name() string
Name returns the name of the strategy.
func (*StopLossStrategy) Report
func (s *StopLossStrategy) Report(c <-chan *asset.Snapshot) *helper.Report
Report processes the provided asset snapshots and generates a report annotated with the recommended actions.
Generated by gomarkdoc