Documentation
¶
Overview ¶
Package trend contains the trend 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-2024 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 ¶
const ( // DefaultDemaStrategyPeriod1 is the first DEMA period. DefaultDemaStrategyPeriod1 = 5 // DefaultDemaStrategyPeriod2 is the second DEMA period. DefaultDemaStrategyPeriod2 = 35 )
const ( // DefaultTrimaStrategyShortPeriod is the first TRIMA period. DefaultTrimaStrategyShortPeriod = 20 // DefaultTrimaStrategyLongPeriod is the second TRIMA period. DefaultTrimaStrategyLongPeriod = 50 )
const (
// DefaultVwmaStrategyPeriod is the default VWMA period.
DefaultVwmaStrategyPeriod = 20
)
Variables ¶
This section is empty.
Functions ¶
func AllStrategies ¶
AllStrategies returns a slice containing references to all available trend strategies.
Types ¶
type ApoStrategy ¶
type ApoStrategy struct {
strategy.Strategy
// Apo represents the configuration parameters for calculating the
// Absolute Price Oscillator (APO).
Apo *trend.Apo[float64]
}
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.
func NewApoStrategy ¶
func NewApoStrategy() *ApoStrategy
NewApoStrategy function initializes a new APO strategy instance with the default parameters.
type AroonStrategy ¶
type AroonStrategy struct {
strategy.Strategy
// Aroon represent the configuration for calculating the Aroon indicator.
Aroon *trend.Aroon[float64]
}
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.
func NewAroonStrategy ¶
func NewAroonStrategy() *AroonStrategy
NewAroonStrategy function initializes a new Aroon strategy instance with the default parameters.
func (*AroonStrategy) Compute ¶
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() string
Name returns the name of the strategy.
type BopStrategy ¶
type BopStrategy struct {
strategy.Strategy
// Bop represents the configuration parameters for calculating the
// Balance of Power (BoP).
Bop *trend.Bop[float64]
}
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.
func NewBopStrategy ¶
func NewBopStrategy() *BopStrategy
NewBopStrategy function initializes a new BoP strategy instance with the default parameters.
type CciStrategy ¶
type CciStrategy struct {
strategy.Strategy
// Cci represents the configuration parameters for calculating the CCI.
Cci *trend.Cci[float64]
}
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.
func NewCciStrategy ¶
func NewCciStrategy() *CciStrategy
NewCciStrategy function initializes a new CCI strategy instance.
type DemaStrategy ¶
type DemaStrategy struct {
strategy.Strategy
// Dema1 represents the configuration parameters for
// calculating the first DEMA.
Dema1 *trend.Dema[float64]
// Dema2 represents the configuration parameters for
// calculating the second DEMA.
Dema2 *trend.Dema[float64]
}
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.
func NewDemaStrategy ¶
func NewDemaStrategy() *DemaStrategy
NewDemaStrategy function initializes a new DEMA strategy instance with the default parameters.
func (*DemaStrategy) Compute ¶
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() string
Name returns the name of the strategy.
type KdjStrategy ¶
type KdjStrategy struct {
strategy.Strategy
// Kdj represents the configuration parameters for calculating the KDJ.
Kdj *trend.Kdj[float64]
}
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.
func NewKdjStrategy ¶
func NewKdjStrategy() *KdjStrategy
NewKdjStrategy function initializes a new KDJ strategy instance.
type MacdStrategy ¶
type MacdStrategy struct {
strategy.Strategy
// Macd represents the configuration parameters for calculating the
// Moving Average Convergence Divergence (MACD).
Macd *trend.Macd[float64]
}
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.
func NewMacdStrategy ¶
func NewMacdStrategy() *MacdStrategy
NewMacdStrategy function initializes a new MACD strategy instance.
func NewMacdStrategyWith ¶
func NewMacdStrategyWith(period1, period2, period3 int) *MacdStrategy
NewMacdStrategyWith function initializes a new MACD strategy instance with the given parameters.
func (*MacdStrategy) Compute ¶
func (m *MacdStrategy) Compute(snapshots <-chan *asset.Snapshot) <-chan strategy.Action
Compute processes the provided asset snapshots and generates a stream of actionable recommendations.
func (*MacdStrategy) Name ¶
func (m *MacdStrategy) Name() string
Name returns the name of the strategy.
type QstickStrategy ¶
type QstickStrategy struct {
strategy.Strategy
// Qstick represents the configuration parameters for calculating the Qstick.
Qstick *momentum.Qstick[float64]
}
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.
A Qstick above zero indicates increasing buying pressure, while a Qstick below zero indicates increasing selling pressure.
func NewQstickStrategy ¶
func NewQstickStrategy() *QstickStrategy
NewQstickStrategy function initializes a new Qstick strategy instance.
func (*QstickStrategy) Compute ¶
func (q *QstickStrategy) Compute(c <-chan *asset.Snapshot) <-chan strategy.Action
Compute processes the provided asset snapshots and generates a stream of actionable recommendations.
func (*QstickStrategy) Name ¶
func (*QstickStrategy) Name() string
Name returns the name of the strategy.
type TrimaStrategy ¶
type TrimaStrategy struct {
strategy.Strategy
// Trima1 represents the configuration parameters for calculating the short TRIMA.
Short *trend.Trima[float64]
// Trima2 represents the configuration parameters for calculating the long TRIMA.
Long *trend.Trima[float64]
}
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.
func NewTrimaStrategy ¶
func NewTrimaStrategy() *TrimaStrategy
NewTrimaStrategy function initializes a new TRIMA strategy instance with the default parameters.
func (*TrimaStrategy) Compute ¶
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() string
Name returns the name of the strategy.
type TrixStrategy ¶
type TrixStrategy struct {
strategy.Strategy
// Trix represents the configuration parameters for calculating the TRIX.
Trix *trend.Trix[float64]
}
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.
func NewTrixStrategy ¶
func NewTrixStrategy() *TrixStrategy
NewTrixStrategy function initializes a new TRIX strategy instance.
func (*TrixStrategy) Compute ¶
func (t *TrixStrategy) Compute(snapshots <-chan *asset.Snapshot) <-chan strategy.Action
Compute processes the provided asset snapshots and generates a stream of actionable recommendations.
func (*TrixStrategy) Name ¶
func (*TrixStrategy) Name() string
Name returns the name of the strategy.
type VwmaStrategy ¶
type VwmaStrategy struct {
strategy.Strategy
// VWMA indicator.
Vwma *trend.Vwma[float64]
// SMA indicator.
Sma *trend.Sma[float64]
}
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.
func NewVwmaStrategy ¶
func NewVwmaStrategy() *VwmaStrategy
NewVwmaStrategy function initializes a new VWMA strategy instance with the default parameters.
func (*VwmaStrategy) Compute ¶
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() string
Name returns the name of the strategy.