indicator

package
v0.0.0-...-1513131 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BollingerBands

type BollingerBands struct {
	Period  int
	History []model.DataPoint
	Values  BollingerBandsValues
}

BollingerBands represents the state of the Bollinger Bands indicator.

func NewBollingerBands

func NewBollingerBands(period int) *BollingerBands

NewBollingerBands initializes a new Bollinger Bands instance.

func (*BollingerBands) AddDataPoint

func (bb *BollingerBands) AddDataPoint(ctx context.Context, data model.DataPoint) error

AddDataPoint adds a new data point and updates the Bollinger Bands calculation.

func (*BollingerBands) GetBollingerBands

func (bb *BollingerBands) GetBollingerBands() BollingerBandsValues

GetBollingerBands returns the current Bollinger Bands levels.

type BollingerBandsValues

type BollingerBandsValues struct {
	MovingAverage float64
	UpperBand     float64
	LowerBand     float64
}

BollingerBandsValues represents the calculated values of Bollinger Bands.

type EMA

type EMA struct {
	Period      int
	Multiplier  float64
	Value       float64
	Initialized bool
	// contains filtered or unexported fields
}

EMA represents the state of the EMA indicator for a single period.

func NewEMA

func NewEMA(period int) *EMA

NewEMA initializes a new EMA instance for a single period.

func (*EMA) AddDataPoint

func (e *EMA) AddDataPoint(ctx context.Context, data model.DataPoint)

AddDataPoint updates the EMA with a new data point and recalculates the EMA.

type Fibonacci

type Fibonacci struct {
	History       []model.DataPoint
	High          float64
	Low           float64
	Levels        map[FibonacciLevel]float64
	Size          int
	IsInitialized bool
}

Fibonacci represents the state of the Fibonacci indicator.

func NewFibonacci

func NewFibonacci(size int) *Fibonacci

NewFibonacci initializes a new Fibonacci instance with a given history size.

func (*Fibonacci) AddDataPoint

func (f *Fibonacci) AddDataPoint(ctx context.Context, data model.DataPoint) error

AddDataPoint adds a new data point and updates the Fibonacci calculation.

func (*Fibonacci) GetFibonacciLevels

func (f *Fibonacci) GetFibonacciLevels() map[FibonacciLevel]float64

GetFibonacciLevels returns the current Fibonacci retracement levels.

type FibonacciLevel

type FibonacciLevel int
const (
	Zero FibonacciLevel = iota
	TwentyThree
	ThirtyEight
	Fifty
	SixtyOne
	SeventySix
	Hundred
)

type MACD

type MACD struct {
	ShortEMA     float64
	LongEMA      float64
	SignalLine   float64
	History      []model.DataPoint
	ShortPeriod  int
	LongPeriod   int
	SignalPeriod int
	Initialized  bool
}

MACD represents the state of the MACD indicator.

func NewMACD

func NewMACD(shortPeriod, longPeriod, signalPeriod int) *MACD

NewMACD initializes a new MACD instance.

func (*MACD) AddDataPoint

func (m *MACD) AddDataPoint(ctx context.Context, data model.DataPoint) error

AddDataPoint adds a new data point and updates the MACD calculation.

func (*MACD) CalculateMACD

func (m *MACD) CalculateMACD() MACDResult

CalculateMACD returns the MACD line and the MACD histogram as an object.

type MACDResult

type MACDResult struct {
	MACDLine      float64
	MACDHistogram float64
	MACDSignal    float64
}

MACDResult holds the results of the MACD calculation.

type PivotLevels

type PivotLevels struct {
	Pivot       float64
	Support1    float64
	Support2    float64
	Support3    float64
	Resistance1 float64
	Resistance2 float64
	Resistance3 float64
}

PivotLevels represents the pivot point and its support/resistance levels.

type PivotPoint

type PivotPoint struct {
	PreviousData model.DataPoint
	Initialized  bool
	Levels       PivotLevels
}

PivotPoint represents the state of the Pivot Point indicator.

func NewPivotPoint

func NewPivotPoint() *PivotPoint

NewPivotPoint initializes a new Pivot Point instance.

func (*PivotPoint) AddDataPoint

func (pp *PivotPoint) AddDataPoint(ctx context.Context, data model.DataPoint) error

AddDataPoint adds a new data point and updates the Pivot Point calculation.

func (*PivotPoint) GetPivotLevels

func (pp *PivotPoint) GetPivotLevels() PivotLevels

GetPivotLevels returns the current Pivot Point levels.

type RSI

type RSI struct {
	Period      int
	AvgGain     float64
	AvgLoss     float64
	History     *utils.CyclicSlice[model.DataPoint]
	Initialized bool
}

RSI represents the state of the RSI indicator.

func NewRSI

func NewRSI(period int) *RSI

NewRSI initializes a new RSI instance.

func (*RSI) AddDataPoint

func (r *RSI) AddDataPoint(ctx context.Context, data model.DataPoint) error

AddDataPoint adds a new data point and updates the RSI calculation.

func (*RSI) CalculateRSI

func (r *RSI) CalculateRSI() float64

CalculateRSI returns the current RSI value.

type SuperTrend

type SuperTrend struct {
	Period         int
	Multiplier     float64
	ATR            float64
	SuperTrendLine float64
	History        []model.DataPoint
	IsUpTrend      bool
	Initialized    bool
}

SuperTrend represents the state of the Super Trend indicator.

func NewSuperTrend

func NewSuperTrend(period int, multiplier float64) *SuperTrend

NewSuperTrend initializes a new Super Trend instance.

func (*SuperTrend) AddDataPoint

func (st *SuperTrend) AddDataPoint(ctx context.Context, data model.DataPoint) error

AddDataPoint adds a new data point and updates the Super Trend calculation.

func (*SuperTrend) CalculateSuperTrend

func (st *SuperTrend) CalculateSuperTrend() (float64, bool)

CalculateSuperTrend returns the current Super Trend value and the trend direction.

Jump to

Keyboard shortcuts

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