indicatorv2

package
v1.56.1 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2024 License: AGPL-3.0 Imports: 5 Imported by: 10

Documentation

Index

Constants

View Source
const DPeriod int = 3
View Source
const MaxNumOfKLines = 4_000
View Source
const MaxNumOfRMA = 1000
View Source
const MaxNumOfRMATruncateSize = 500
View Source
const MaxNumOfSMA = 5_000

Variables

This section is empty.

Functions

This section is empty.

Types

type ATRPStream

type ATRPStream struct {
	*types.Float64Series
}

func ATRP2

func ATRP2(source KLineSubscription, window int) *ATRPStream

type ATRStream

type ATRStream struct {
	// embedded struct
	*RMAStream
}

func ATR2

func ATR2(source KLineSubscription, window int) *ATRStream

type BOLLStream

type BOLLStream struct {
	// the band series
	*types.Float64Series

	UpBand, DownBand *types.Float64Series

	SMA    *SMAStream
	StdDev *StdDevStream
	// contains filtered or unexported fields
}

func BOLL

func BOLL(source types.Float64Source, window int, k float64) *BOLLStream

BOOL2 is bollinger indicator the data flow:

priceSource ->

-> calculate SMA
-> calculate stdDev -> calculate bandWidth -> get latest SMA -> upBand, downBand

func (*BOLLStream) Calculate

func (s *BOLLStream) Calculate(v float64) float64

type CCIStream

type CCIStream struct {
	*types.Float64Series

	TypicalPrice *types.Float64Series
	// contains filtered or unexported fields
}

func CCI

func CCI(source types.Float64Source, window int) *CCIStream

func (*CCIStream) Calculate

func (s *CCIStream) Calculate(value float64) float64

type CMAStream

type CMAStream struct {
	*types.Float64Series
}

func CMA2

func CMA2(source types.Float64Source) *CMAStream

func (*CMAStream) Calculate

func (s *CMAStream) Calculate(x float64) float64

func (*CMAStream) Truncate

func (s *CMAStream) Truncate()

type CrossStream

type CrossStream struct {
	*types.Float64Series
	// contains filtered or unexported fields
}

CrossStream subscribes 2 upstreams, and calculate the cross signal

func Cross

func Cross(a, b types.Float64Source) *CrossStream

Cross creates the CrossStream object:

cross := Cross(fastEWMA, slowEWMA)

type CrossType

type CrossType float64
const (
	CrossOver  CrossType = 1.0
	CrossUnder CrossType = -1.0
)

type EWMAStream

type EWMAStream struct {
	*types.Float64Series
	// contains filtered or unexported fields
}

func EWMA2

func EWMA2(source types.Float64Source, window int) *EWMAStream

func (*EWMAStream) Calculate

func (s *EWMAStream) Calculate(v float64) float64

type KLineStream

type KLineStream struct {
	// contains filtered or unexported fields
}

func KLines

func KLines(source types.Stream, symbol string, interval types.Interval) *KLineStream

KLines creates a KLine stream that pushes the klines to the subscribers

func (*KLineStream) AddSubscriber

func (s *KLineStream) AddSubscriber(f func(k types.KLine))

AddSubscriber adds the subscriber function and push historical data to the subscriber

func (*KLineStream) BackFill

func (s *KLineStream) BackFill(kLines []types.KLine)

func (*KLineStream) EmitUpdate

func (s *KLineStream) EmitUpdate(k types.KLine)

func (*KLineStream) Last

func (s *KLineStream) Last(i int) *types.KLine

func (*KLineStream) Length

func (s *KLineStream) Length() int

func (*KLineStream) OnUpdate

func (s *KLineStream) OnUpdate(cb func(k types.KLine))

type KLineSubscription

type KLineSubscription interface {
	AddSubscriber(f func(k types.KLine))
	Length() int
	Last(i int) *types.KLine
}

type MACDStream

type MACDStream struct {
	*SubtractStream

	FastEWMA, SlowEWMA, Signal *EWMAStream
	Histogram                  *SubtractStream
	// contains filtered or unexported fields
}

func MACD2

func MACD2(source types.Float64Source, shortWindow, longWindow, signalWindow int) *MACDStream

type MultiplyStream

type MultiplyStream struct {
	*types.Float64Series
	// contains filtered or unexported fields
}

func Multiply

func Multiply(a, b types.Float64Source) *MultiplyStream

type PivotHighStream

type PivotHighStream struct {
	*types.Float64Series
	// contains filtered or unexported fields
}

func PivotHigh added in v1.53.0

func PivotHigh(source types.Float64Source, window int, args ...int) *PivotHighStream

type PivotLowStream

type PivotLowStream struct {
	*types.Float64Series
	// contains filtered or unexported fields
}

func PivotLow

func PivotLow(source types.Float64Source, window int, args ...int) *PivotLowStream

type PriceStream

type PriceStream struct {
	*types.Float64Series
	// contains filtered or unexported fields
}

func ClosePrices

func ClosePrices(source KLineSubscription) *PriceStream

func HLC3

func HLC3(source KLineSubscription) *PriceStream

func HighPrices

func HighPrices(source KLineSubscription) *PriceStream

func LowPrices

func LowPrices(source KLineSubscription) *PriceStream

func OpenPrices

func OpenPrices(source KLineSubscription) *PriceStream

func Price

func Price(source KLineSubscription, mapper types.KLineValueMapper) *PriceStream

func Volumes

func Volumes(source KLineSubscription) *PriceStream

func (*PriceStream) AddSubscriber

func (s *PriceStream) AddSubscriber(f func(v float64))

AddSubscriber adds the subscriber function and push historical data to the subscriber

func (*PriceStream) PushAndEmit

func (s *PriceStream) PushAndEmit(v float64)

type RMAStream

type RMAStream struct {
	// embedded structs
	*types.Float64Series

	// config fields
	Adjust bool
	// contains filtered or unexported fields
}

func RMA2

func RMA2(source types.Float64Source, window int, adjust bool) *RMAStream

func (*RMAStream) Calculate

func (s *RMAStream) Calculate(x float64) float64

func (*RMAStream) Truncate

func (s *RMAStream) Truncate()

type RSIStream

type RSIStream struct {
	// embedded structs
	*types.Float64Series
	// contains filtered or unexported fields
}

func RSI2

func RSI2(source types.Float64Source, window int) *RSIStream

func (*RSIStream) Calculate

func (s *RSIStream) Calculate(_ float64) float64

type SMAStream

type SMAStream struct {
	*types.Float64Series
	// contains filtered or unexported fields
}

func SMA

func SMA(source types.Float64Source, window int) *SMAStream

func (*SMAStream) Calculate

func (s *SMAStream) Calculate(v float64) float64

func (*SMAStream) Truncate

func (s *SMAStream) Truncate()

type StdDevStream

type StdDevStream struct {
	*types.Float64Series
	// contains filtered or unexported fields
}

func StdDev

func StdDev(source types.Float64Source, window int) *StdDevStream

func (*StdDevStream) Calculate

func (s *StdDevStream) Calculate(x float64) float64

type StochStream

type StochStream struct {
	types.SeriesBase

	K, D floats.Slice
	// contains filtered or unexported fields
}

func Stoch

func Stoch(source KLineSubscription, window, dPeriod int) *StochStream

Stochastic Oscillator

func (*StochStream) EmitUpdate

func (S *StochStream) EmitUpdate(k float64, d float64)

func (*StochStream) OnUpdate

func (S *StochStream) OnUpdate(cb func(k float64, d float64))

type SubtractStream

type SubtractStream struct {
	*types.Float64Series
	// contains filtered or unexported fields
}

SubtractStream subscribes 2 upstream data, and then subtract these 2 values

func Subtract

func Subtract(a, b types.Float64Source) *SubtractStream

Subtract creates the SubtractStream object subtract := Subtract(longEWMA, shortEWMA)

type TRStream

type TRStream struct {
	// embedded struct
	*types.Float64Series
	// contains filtered or unexported fields
}

This TRStream calculates the ATR first

func TR2

func TR2(source KLineSubscription) *TRStream

Jump to

Keyboard shortcuts

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