Documentation
¶
Overview ¶
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.
License ¶
Copyright (c) 2021-2026 Onur Cinar. The source code is provided under GNU AGPLv3 License. https://github.com/cinar/indicator
Disclaimer ¶
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.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type InverseStrategy ¶
type InverseStrategy struct {
// InnerStrategy is the inner strategy.
InnerStrategy strategy.Strategy
}
InverseStrategy reverses the advice of another strategy. For example, if the original strategy suggests buying an asset, InverseStrategy would recommend selling it.
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.
type NoLossStrategy ¶
type NoLossStrategy struct {
// InnertStrategy is the inner strategy.
InnertStrategy strategy.Strategy
}
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.
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.
type StopLossStrategy ¶ added in v2.1.2
type StopLossStrategy struct {
// InnertStrategy is the inner strategy.
InnertStrategy strategy.Strategy
// Percentage is the loss threshold in percentage.
Percentage float64
}
StopLossStrategy prevents a loss by recommending a sell action when the assets drop below the given threshold.
func NewStopLossStrategy ¶ added in v2.1.2
func NewStopLossStrategy(innerStrategy strategy.Strategy, percentage float64) *StopLossStrategy
NewStopLossStrategy function initializes a new stop loss strategy instance.
func (*StopLossStrategy) Compute ¶ added in v2.1.2
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 ¶ added in v2.1.2
func (s *StopLossStrategy) Name() string
Name returns the name of the strategy.