package
2.1.1
Repository: https://github.com/cinar/indicator.git
Documentation: pkg.go.dev

# README

decorator

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.

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

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 {
    strategy.Strategy

    // 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 {
    strategy.Strategy

    // 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.

Generated by gomarkdoc