indicatorv2

package
v1.61.0 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 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 MaxSliceSize = 5000

MaxSliceSize is the maximum slice size byte size = 8 * 5000 = 40KB per slice

View Source
const TruncateSize = 1000

TruncateSize is the truncate size for the slice per truncate call

Variables

This section is empty.

Functions

This section is empty.

Types

type ADXStream added in v1.59.0

type ADXStream struct {
	*RMAStream

	Plus, Minus *types.Float64Series
	// contains filtered or unexported fields
}

func ADX added in v1.59.0

func ADX(source KLineSubscription, window int) *ADXStream

func (*ADXStream) Truncate added in v1.59.0

func (s *ADXStream) Truncate()

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

func (*BOLLStream) Truncate added in v1.61.0

func (s *BOLLStream) Truncate()

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 KeltnerStream added in v1.57.0

type KeltnerStream struct {
	types.SeriesBase

	EWMA   *EWMAStream
	StdDev *StdDevStream
	ATR    *ATRStream

	Mid                              *types.Float64Series
	FirstUpperBand, FirstLowerBand   *types.Float64Series
	SecondUpperBand, SecondLowerBand *types.Float64Series
	ThirdUpperBand, ThirdLowerBand   *types.Float64Series
	// contains filtered or unexported fields
}

func Keltner added in v1.57.0

func Keltner(source KLineSubscription, window, atrLength int) *KeltnerStream

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 SMMAStream added in v1.58.0

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

func SMMA2 added in v1.58.0

func SMMA2(source types.Float64Source, window int) *SMMAStream

func (*SMMAStream) Calculate added in v1.58.0

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

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

func (*StdDevStream) Truncate added in v1.61.0

func (s *StdDevStream) Truncate()

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