volume

package
v2.1.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2024 License: AGPL-3.0 Imports: 6 Imported by: 0

README

volume

import "github.com/cinar/indicator/v2/strategy/volume"

Package volume contains the volume 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 (
    // DefaultMoneyFlowIndexStrategySellAt is the default sell at of 80.
    DefaultMoneyFlowIndexStrategySellAt = 80

    // DefaultMoneyFlowIndexStrategyBuyAt is the default buy at of 20.
    DefaultMoneyFlowIndexStrategyBuyAt = 20
)

const (
    // DefaultNegativeVolumeIndexStrategyEmaPeriod is the default EMA period of 255.
    DefaultNegativeVolumeIndexStrategyEmaPeriod = 255
)

func AllStrategies

func AllStrategies() []strategy.Strategy

AllStrategies returns a slice containing references to all available volume strategies.

type ChaikinMoneyFlowStrategy

ChaikinMoneyFlowStrategy represents the configuration parameters for calculating the Chaikin Money Flow strategy. Recommends a Buy action when it crosses above 0, and recommends a Sell action when it crosses below 0.

type ChaikinMoneyFlowStrategy struct {
    // ChaikinMoneyFlow is the Chaikin Money Flow indicator instance.
    ChaikinMoneyFlow *volume.Cmf[float64]
}

func NewChaikinMoneyFlowStrategy
func NewChaikinMoneyFlowStrategy() *ChaikinMoneyFlowStrategy

NewChaikinMoneyFlowStrategy function initializes a new Chaikin Money Flow strategy instance with the default parameters.

func NewChaikinMoneyFlowStrategyWith
func NewChaikinMoneyFlowStrategyWith(period int) *ChaikinMoneyFlowStrategy

NewChaikinMoneyFlowStrategyWith function initializes a new Chaikin Money Flow strategy instance with the given parameters.

func (*ChaikinMoneyFlowStrategy) Compute
func (c *ChaikinMoneyFlowStrategy) Compute(snapshots <-chan *asset.Snapshot) <-chan strategy.Action

Compute function processes the provided asset snapshots and generates a stream of actionable recommendations.

func (*ChaikinMoneyFlowStrategy) Name
func (c *ChaikinMoneyFlowStrategy) Name() string

Name function returns the name of the strategy.

func (*ChaikinMoneyFlowStrategy) Report
func (c *ChaikinMoneyFlowStrategy) Report(snapshots <-chan *asset.Snapshot) *helper.Report

Report function processes the provided asset snapshots and generates a report annotated with the recommended actions.

type EaseOfMovementStrategy

EaseOfMovementStrategy represents the configuration parameters for calculating the Ease of Movement strategy. Recommends a Buy action when it crosses above 0, and recommends a Sell action when it crosses below 0.

type EaseOfMovementStrategy struct {
    // EaseOfMovement is the Ease of Movement indicator instance.
    EaseOfMovement *volume.Emv[float64]
}

func NewEaseOfMovementStrategy
func NewEaseOfMovementStrategy() *EaseOfMovementStrategy

NewEaseOfMovementStrategy function initializes a new Ease of Movement strategy instance with the default parameters.

func NewEaseOfMovementStrategyWith
func NewEaseOfMovementStrategyWith(period int) *EaseOfMovementStrategy

NewEaseOfMovementStrategyWith function initializes a new Ease of Movement strategy instance with the given parameters.

func (*EaseOfMovementStrategy) Compute
func (e *EaseOfMovementStrategy) Compute(snapshots <-chan *asset.Snapshot) <-chan strategy.Action

Compute function processes the provided asset snapshots and generates a stream of actionable recommendations.

func (*EaseOfMovementStrategy) Name
func (e *EaseOfMovementStrategy) Name() string

Name function returns the name of the strategy.

func (*EaseOfMovementStrategy) Report
func (e *EaseOfMovementStrategy) Report(snapshots <-chan *asset.Snapshot) *helper.Report

Report function processes the provided asset snapshots and generates a report annotated with the recommended actions.

type ForceIndexStrategy

ForceIndexStrategy represents the configuration parameters for calculating the Force Index strategy. It recommends a Buy action when it crosses above zero, and a Sell action when it crosses below zero.

type ForceIndexStrategy struct {
    // ForceIndex is the Force Index instance.
    ForceIndex *volume.Fi[float64]
}

func NewForceIndexStrategy
func NewForceIndexStrategy() *ForceIndexStrategy

NewForceIndexStrategy function initializes a new Force Index strategy instance with the default parameters.

func NewForceIndexStrategyWith
func NewForceIndexStrategyWith(period int) *ForceIndexStrategy

NewForceIndexStrategyWith function initializes a new Force Index strategy instance with the given parameters.

func (*ForceIndexStrategy) Compute
func (f *ForceIndexStrategy) Compute(snapshots <-chan *asset.Snapshot) <-chan strategy.Action

Compute processes the provided asset snapshots and generates a stream of actionable recommendations.

func (*ForceIndexStrategy) Name
func (f *ForceIndexStrategy) Name() string

Name returns the name of the strategy.

func (*ForceIndexStrategy) Report
func (f *ForceIndexStrategy) Report(c <-chan *asset.Snapshot) *helper.Report

Report processes the provided asset snapshots and generates a report annotated with the recommended actions.

type MoneyFlowIndexStrategy

MoneyFlowIndexStrategy represents the configuration parameters for calculating the Money Flow Index strategy. Recommends a Sell action when it crosses over 80, and recommends a Buy action when it crosses below 20.

type MoneyFlowIndexStrategy struct {
    // MoneyFlowIndex is the Money Flow Index indicator instance.
    MoneyFlowIndex *volume.Mfi[float64]

    // SellAt is the sell at value.
    SellAt float64

    // BuyAt is the buy at value.
    BuyAt float64
}

func NewMoneyFlowIndexStrategy
func NewMoneyFlowIndexStrategy() *MoneyFlowIndexStrategy

NewMoneyFlowIndexStrategy function initializes a new Money Flow Index strategy instance with the default parameters.

func NewMoneyFlowIndexStrategyWith
func NewMoneyFlowIndexStrategyWith(sellAt, buyAt float64) *MoneyFlowIndexStrategy

NewMoneyFlowIndexStrategyWith function initializes a new Money Flow Index strategy instance with the given parameters.

func (*MoneyFlowIndexStrategy) Compute
func (m *MoneyFlowIndexStrategy) Compute(snapshots <-chan *asset.Snapshot) <-chan strategy.Action

Compute processes the provided asset snapshots and generates a stream of actionable recommendations.

func (*MoneyFlowIndexStrategy) Name
func (m *MoneyFlowIndexStrategy) Name() string

Name returns the name of the strategy.

func (*MoneyFlowIndexStrategy) Report
func (m *MoneyFlowIndexStrategy) Report(c <-chan *asset.Snapshot) *helper.Report

Report processes the provided asset snapshots and generates a report annotated with the recommended actions.

type NegativeVolumeIndexStrategy

NegativeVolumeIndexStrategy represents the configuration parameters for calculating the Negative Volume Index strategy. Recommends a Buy action when it crosses below its EMA, recommends a Sell action when it crosses above its EMA, and recommends a Hold action otherwise.

type NegativeVolumeIndexStrategy struct {
    // NegativeVolumeIndex is the Negative Volume Index indicator instance.
    NegativeVolumeIndex *volume.Nvi[float64]

    // NegativeVolumeIndexEma is the Negative Volume Index EMA instance.
    NegativeVolumeIndexEma *trend.Ema[float64]
}

func NewNegativeVolumeIndexStrategy
func NewNegativeVolumeIndexStrategy() *NegativeVolumeIndexStrategy

NewNegativeVolumeIndexStrategy function initializes a new Negative Volume Index strategy instance with the default parameters.

func NewNegativeVolumeIndexStrategyWith
func NewNegativeVolumeIndexStrategyWith(emaPeriod int) *NegativeVolumeIndexStrategy

NewNegativeVolumeIndexStrategyWith function initializes a new Negative Volume Index strategy instance with the given parameters.

func (*NegativeVolumeIndexStrategy) Compute
func (n *NegativeVolumeIndexStrategy) Compute(snapshots <-chan *asset.Snapshot) <-chan strategy.Action

Compute processes the provided asset snapshots and generates a stream of actionable recommendations.

func (*NegativeVolumeIndexStrategy) Name
func (n *NegativeVolumeIndexStrategy) Name() string

Name returns the name of the strategy.

func (*NegativeVolumeIndexStrategy) Report
func (n *NegativeVolumeIndexStrategy) Report(c <-chan *asset.Snapshot) *helper.Report

Report processes the provided asset snapshots and generates a report annotated with the recommended actions.

type VolumeWeightedAveragePriceStrategy

VolumeWeightedAveragePriceStrategy represents the configuration parameters for calculating the Volume Weighted Average Price strategy. Recommends a Buy action when the closing crosses below the VWAP, recommends a Sell action when the closing crosses above the VWAP, and recommends a Hold action otherwise.

type VolumeWeightedAveragePriceStrategy struct {
    // VolumeWeightedAveragePrice is the Volume Weighted Average Price indicator instance.
    VolumeWeightedAveragePrice *volume.Vwap[float64]
}

func NewVolumeWeightedAveragePriceStrategy
func NewVolumeWeightedAveragePriceStrategy() *VolumeWeightedAveragePriceStrategy

NewVolumeWeightedAveragePriceStrategy function initializes a new Volume Weighted Average Price strategy instance with the default parameters.

func NewVolumeWeightedAveragePriceStrategyWith
func NewVolumeWeightedAveragePriceStrategyWith(period int) *VolumeWeightedAveragePriceStrategy

NewVolumeWeightedAveragePriceStrategyWith function initializes a new Volume Weighted Average Price strategy instance with the given parameters.

func (*VolumeWeightedAveragePriceStrategy) Compute
func (v *VolumeWeightedAveragePriceStrategy) Compute(snapshots <-chan *asset.Snapshot) <-chan strategy.Action

Compute processes the provided asset snapshots and generates a stream of actionable recommendations.

func (*VolumeWeightedAveragePriceStrategy) Name
func (v *VolumeWeightedAveragePriceStrategy) Name() string

Name returns the name of the strategy.

func (*VolumeWeightedAveragePriceStrategy) Report
func (v *VolumeWeightedAveragePriceStrategy) 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

Documentation

Overview

Package volume contains the volume 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

View Source
const (
	// DefaultMoneyFlowIndexStrategySellAt is the default sell at of 80.
	DefaultMoneyFlowIndexStrategySellAt = 80

	// DefaultMoneyFlowIndexStrategyBuyAt is the default buy at of 20.
	DefaultMoneyFlowIndexStrategyBuyAt = 20
)
View Source
const (
	// DefaultNegativeVolumeIndexStrategyEmaPeriod is the default EMA period of 255.
	DefaultNegativeVolumeIndexStrategyEmaPeriod = 255
)

Variables

This section is empty.

Functions

func AllStrategies

func AllStrategies() []strategy.Strategy

AllStrategies returns a slice containing references to all available volume strategies.

Types

type ChaikinMoneyFlowStrategy

type ChaikinMoneyFlowStrategy struct {
	// ChaikinMoneyFlow is the Chaikin Money Flow indicator instance.
	ChaikinMoneyFlow *volume.Cmf[float64]
}

ChaikinMoneyFlowStrategy represents the configuration parameters for calculating the Chaikin Money Flow strategy. Recommends a Buy action when it crosses above 0, and recommends a Sell action when it crosses below 0.

func NewChaikinMoneyFlowStrategy

func NewChaikinMoneyFlowStrategy() *ChaikinMoneyFlowStrategy

NewChaikinMoneyFlowStrategy function initializes a new Chaikin Money Flow strategy instance with the default parameters.

func NewChaikinMoneyFlowStrategyWith

func NewChaikinMoneyFlowStrategyWith(period int) *ChaikinMoneyFlowStrategy

NewChaikinMoneyFlowStrategyWith function initializes a new Chaikin Money Flow strategy instance with the given parameters.

func (*ChaikinMoneyFlowStrategy) Compute

func (c *ChaikinMoneyFlowStrategy) Compute(snapshots <-chan *asset.Snapshot) <-chan strategy.Action

Compute function processes the provided asset snapshots and generates a stream of actionable recommendations.

func (*ChaikinMoneyFlowStrategy) Name

func (c *ChaikinMoneyFlowStrategy) Name() string

Name function returns the name of the strategy.

func (*ChaikinMoneyFlowStrategy) Report

func (c *ChaikinMoneyFlowStrategy) Report(snapshots <-chan *asset.Snapshot) *helper.Report

Report function processes the provided asset snapshots and generates a report annotated with the recommended actions.

type EaseOfMovementStrategy added in v2.1.9

type EaseOfMovementStrategy struct {
	// EaseOfMovement is the Ease of Movement indicator instance.
	EaseOfMovement *volume.Emv[float64]
}

EaseOfMovementStrategy represents the configuration parameters for calculating the Ease of Movement strategy. Recommends a Buy action when it crosses above 0, and recommends a Sell action when it crosses below 0.

func NewEaseOfMovementStrategy added in v2.1.9

func NewEaseOfMovementStrategy() *EaseOfMovementStrategy

NewEaseOfMovementStrategy function initializes a new Ease of Movement strategy instance with the default parameters.

func NewEaseOfMovementStrategyWith added in v2.1.9

func NewEaseOfMovementStrategyWith(period int) *EaseOfMovementStrategy

NewEaseOfMovementStrategyWith function initializes a new Ease of Movement strategy instance with the given parameters.

func (*EaseOfMovementStrategy) Compute added in v2.1.9

func (e *EaseOfMovementStrategy) Compute(snapshots <-chan *asset.Snapshot) <-chan strategy.Action

Compute function processes the provided asset snapshots and generates a stream of actionable recommendations.

func (*EaseOfMovementStrategy) Name added in v2.1.9

func (e *EaseOfMovementStrategy) Name() string

Name function returns the name of the strategy.

func (*EaseOfMovementStrategy) Report added in v2.1.9

func (e *EaseOfMovementStrategy) Report(snapshots <-chan *asset.Snapshot) *helper.Report

Report function processes the provided asset snapshots and generates a report annotated with the recommended actions.

type ForceIndexStrategy added in v2.1.9

type ForceIndexStrategy struct {
	// ForceIndex is the Force Index instance.
	ForceIndex *volume.Fi[float64]
}

ForceIndexStrategy represents the configuration parameters for calculating the Force Index strategy. It recommends a Buy action when it crosses above zero, and a Sell action when it crosses below zero.

func NewForceIndexStrategy added in v2.1.9

func NewForceIndexStrategy() *ForceIndexStrategy

NewForceIndexStrategy function initializes a new Force Index strategy instance with the default parameters.

func NewForceIndexStrategyWith added in v2.1.9

func NewForceIndexStrategyWith(period int) *ForceIndexStrategy

NewForceIndexStrategyWith function initializes a new Force Index strategy instance with the given parameters.

func (*ForceIndexStrategy) Compute added in v2.1.9

func (f *ForceIndexStrategy) Compute(snapshots <-chan *asset.Snapshot) <-chan strategy.Action

Compute processes the provided asset snapshots and generates a stream of actionable recommendations.

func (*ForceIndexStrategy) Name added in v2.1.9

func (f *ForceIndexStrategy) Name() string

Name returns the name of the strategy.

func (*ForceIndexStrategy) Report added in v2.1.9

func (f *ForceIndexStrategy) Report(c <-chan *asset.Snapshot) *helper.Report

Report processes the provided asset snapshots and generates a report annotated with the recommended actions.

type MoneyFlowIndexStrategy

type MoneyFlowIndexStrategy struct {
	// MoneyFlowIndex is the Money Flow Index indicator instance.
	MoneyFlowIndex *volume.Mfi[float64]

	// SellAt is the sell at value.
	SellAt float64

	// BuyAt is the buy at value.
	BuyAt float64
}

MoneyFlowIndexStrategy represents the configuration parameters for calculating the Money Flow Index strategy. Recommends a Sell action when it crosses over 80, and recommends a Buy action when it crosses below 20.

func NewMoneyFlowIndexStrategy

func NewMoneyFlowIndexStrategy() *MoneyFlowIndexStrategy

NewMoneyFlowIndexStrategy function initializes a new Money Flow Index strategy instance with the default parameters.

func NewMoneyFlowIndexStrategyWith

func NewMoneyFlowIndexStrategyWith(sellAt, buyAt float64) *MoneyFlowIndexStrategy

NewMoneyFlowIndexStrategyWith function initializes a new Money Flow Index strategy instance with the given parameters.

func (*MoneyFlowIndexStrategy) Compute

func (m *MoneyFlowIndexStrategy) Compute(snapshots <-chan *asset.Snapshot) <-chan strategy.Action

Compute processes the provided asset snapshots and generates a stream of actionable recommendations.

func (*MoneyFlowIndexStrategy) Name

func (m *MoneyFlowIndexStrategy) Name() string

Name returns the name of the strategy.

func (*MoneyFlowIndexStrategy) Report

func (m *MoneyFlowIndexStrategy) Report(c <-chan *asset.Snapshot) *helper.Report

Report processes the provided asset snapshots and generates a report annotated with the recommended actions.

type NegativeVolumeIndexStrategy

type NegativeVolumeIndexStrategy struct {
	// NegativeVolumeIndex is the Negative Volume Index indicator instance.
	NegativeVolumeIndex *volume.Nvi[float64]

	// NegativeVolumeIndexEma is the Negative Volume Index EMA instance.
	NegativeVolumeIndexEma *trend.Ema[float64]
}

NegativeVolumeIndexStrategy represents the configuration parameters for calculating the Negative Volume Index strategy. Recommends a Buy action when it crosses below its EMA, recommends a Sell action when it crosses above its EMA, and recommends a Hold action otherwise.

func NewNegativeVolumeIndexStrategy

func NewNegativeVolumeIndexStrategy() *NegativeVolumeIndexStrategy

NewNegativeVolumeIndexStrategy function initializes a new Negative Volume Index strategy instance with the default parameters.

func NewNegativeVolumeIndexStrategyWith

func NewNegativeVolumeIndexStrategyWith(emaPeriod int) *NegativeVolumeIndexStrategy

NewNegativeVolumeIndexStrategyWith function initializes a new Negative Volume Index strategy instance with the given parameters.

func (*NegativeVolumeIndexStrategy) Compute

func (n *NegativeVolumeIndexStrategy) Compute(snapshots <-chan *asset.Snapshot) <-chan strategy.Action

Compute processes the provided asset snapshots and generates a stream of actionable recommendations.

func (*NegativeVolumeIndexStrategy) Name

Name returns the name of the strategy.

func (*NegativeVolumeIndexStrategy) Report

func (n *NegativeVolumeIndexStrategy) Report(c <-chan *asset.Snapshot) *helper.Report

Report processes the provided asset snapshots and generates a report annotated with the recommended actions.

type VolumeWeightedAveragePriceStrategy added in v2.1.9

type VolumeWeightedAveragePriceStrategy struct {
	// VolumeWeightedAveragePrice is the Volume Weighted Average Price indicator instance.
	VolumeWeightedAveragePrice *volume.Vwap[float64]
}

VolumeWeightedAveragePriceStrategy represents the configuration parameters for calculating the Volume Weighted Average Price strategy. Recommends a Buy action when the closing crosses below the VWAP, recommends a Sell action when the closing crosses above the VWAP, and recommends a Hold action otherwise.

func NewVolumeWeightedAveragePriceStrategy added in v2.1.9

func NewVolumeWeightedAveragePriceStrategy() *VolumeWeightedAveragePriceStrategy

NewVolumeWeightedAveragePriceStrategy function initializes a new Volume Weighted Average Price strategy instance with the default parameters.

func NewVolumeWeightedAveragePriceStrategyWith added in v2.1.9

func NewVolumeWeightedAveragePriceStrategyWith(period int) *VolumeWeightedAveragePriceStrategy

NewVolumeWeightedAveragePriceStrategyWith function initializes a new Volume Weighted Average Price strategy instance with the given parameters.

func (*VolumeWeightedAveragePriceStrategy) Compute added in v2.1.9

func (v *VolumeWeightedAveragePriceStrategy) Compute(snapshots <-chan *asset.Snapshot) <-chan strategy.Action

Compute processes the provided asset snapshots and generates a stream of actionable recommendations.

func (*VolumeWeightedAveragePriceStrategy) Name added in v2.1.9

Name returns the name of the strategy.

func (*VolumeWeightedAveragePriceStrategy) Report added in v2.1.9

Report processes the provided asset snapshots and generates a report annotated with the recommended actions.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL