indicator_adaptor

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: 13 Imported by: 0

Documentation

Overview

performance_manager_type.go

Index

Constants

View Source
const (
	PERIOD_LABEL       = "period"
	ADAPTOR_NAME_LABEL = "adaptor_name"
)
View Source
const (
	PIVOT_LEVEL_LABEL = "pivot_level_type"
	PIVOT_NAME_FORMAT = "PivotPoint_LEN_%d_THRESHOLD_%d"
)
View Source
const (
	RSI_LEVEL_LABEL = "rsi_level_type"
	RSI_NAME_FORMAT = "RSI_P_%d_OBT_%f_OST_%f_L_%d"
)
View Source
const (
	SUPERTREND_LEVEL_LABEL = "supertrend_level_type"
	SUPERTREND_NAME_FORMAT = "SuperTrend_PERIOD_%d_MULTIPLIER_%.2f"
)
View Source
const (
	EMA_NAME_FORMAT = "EMA_PERIOD_%s_LEN_%d"
)
View Source
const (
	FIBONACCI_LEVEL_LABEL = "fibonacci_level_name"
)
View Source
const (
	MACD_NAME_FORMAT = "MACD_SHORT_%d_LONG_%d_SIGNAL_%d_LEN_%d"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DayCacheIndicatorAdaptorCacheImpl

type DayCacheIndicatorAdaptorCacheImpl struct {
	MilliInDay int64
	// contains filtered or unexported fields
}

func (*DayCacheIndicatorAdaptorCacheImpl) CleanUp

func (i *DayCacheIndicatorAdaptorCacheImpl) CleanUp()

CleanupOldCaches removes old day caches to manage memory usage

func (*DayCacheIndicatorAdaptorCacheImpl) Clone

func (*DayCacheIndicatorAdaptorCacheImpl) Evaluate

Evaluate evaluates the signals from the adaptor and caches the result based on the day and time

func (*DayCacheIndicatorAdaptorCacheImpl) Name

type DaySingleBigCacheIndicatorAdaptorCacheImpl

type DaySingleBigCacheIndicatorAdaptorCacheImpl struct {
	MilliInDay int64
	// contains filtered or unexported fields
}

func (*DaySingleBigCacheIndicatorAdaptorCacheImpl) CleanUp

CleanupOldCaches removes old day caches to manage memory usage

func (*DaySingleBigCacheIndicatorAdaptorCacheImpl) Clone

func (*DaySingleBigCacheIndicatorAdaptorCacheImpl) Evaluate

Evaluate evaluates the signals from the adaptor and caches the result based on the day and time

func (*DaySingleBigCacheIndicatorAdaptorCacheImpl) Name

type DaySingleBigDirectCacheIndicatorAdaptorCacheImpl

type DaySingleBigDirectCacheIndicatorAdaptorCacheImpl struct {
	MilliInDay int64
	// contains filtered or unexported fields
}

func (*DaySingleBigDirectCacheIndicatorAdaptorCacheImpl) CleanUp

CleanupOldCaches removes old day caches to manage memory usage

func (*DaySingleBigDirectCacheIndicatorAdaptorCacheImpl) Clone

func (*DaySingleBigDirectCacheIndicatorAdaptorCacheImpl) Evaluate

Evaluate evaluates the signals from the adaptor and caches the result based on the day and time

func (*DaySingleBigDirectCacheIndicatorAdaptorCacheImpl) Name

type EMAAdapter

type EMAAdapter struct {
	EMAs                   map[int]*indicator.EMA
	CurrentData            model.DataPoint
	MaxTotalHistoricalData int
	HistoricalValues       map[int]*utils.CyclicSlice[float64] // Changed to CyclicSlice
	// contains filtered or unexported fields
}

func NewEMAAdapter

func NewEMAAdapter(ctx context.Context, periods []int, maxTotalHistoricalData int, monitor monitor.Monitoring) *EMAAdapter

func NewEMAAdapterFromName

func NewEMAAdapterFromName(ctx context.Context, name string, monitor monitor.Monitoring) *EMAAdapter

func (*EMAAdapter) AddDataPoint

func (ea *EMAAdapter) AddDataPoint(ctx context.Context, data model.DataPoint) error

func (*EMAAdapter) Clone

func (ea *EMAAdapter) Clone(ctx context.Context) IndicatorAdaptor

func (*EMAAdapter) GetSignal

func (ea *EMAAdapter) GetSignal(ctx context.Context) (result model.StockAction)

func (*EMAAdapter) Name

func (ea *EMAAdapter) Name() string

type EMAMetrics

type EMAMetrics struct {
	SignalCounter monitor.CounterMetric
	ValueCounter  monitor.CounterMetric
	// contains filtered or unexported fields
}

type FibonacciAdapter

type FibonacciAdapter struct {
	Fibonacci              *indicator.Fibonacci
	MaxTotalHistoricalData int
	HistoricalValues       []float64
	CurrentFibonacciLevels map[indicator.FibonacciLevel]float64
	CurrentData            model.DataPoint
	// contains filtered or unexported fields
}

FibonacciAdapter manages a Fibonacci indicator and maintains historical values.

func NewFibonacciAdapter

func NewFibonacciAdapter(ctx context.Context, size int, monitor monitor.Monitoring) *FibonacciAdapter

NewFibonacciAdapter initializes and returns a new FibonacciAdapter instance.

func (*FibonacciAdapter) AddDataPoint

func (fa *FibonacciAdapter) AddDataPoint(ctx context.Context, data model.DataPoint) error

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

func (*FibonacciAdapter) Clone

func (*FibonacciAdapter) GetSignal

func (fa *FibonacciAdapter) GetSignal(ctx context.Context) (result model.StockAction)

GetSignal generates a trading signal based on the Fibonacci retracement levels.

func (*FibonacciAdapter) Name

func (fa *FibonacciAdapter) Name() string

Name returns the adapterName of the Fibonacci adapter.

type FibonacciMetrics

type FibonacciMetrics struct {
	SignalCounter monitor.CounterMetric
	LevelCounter  monitor.CounterMetric
	// contains filtered or unexported fields
}

type IndicatorAdaptor

type IndicatorAdaptor interface {
	Name() string
	Clone(ctx context.Context) IndicatorAdaptor
	AddDataPoint(ctx context.Context, data model.DataPoint) error
	GetSignal(ctx context.Context) model.StockAction
}

type IndicatorAdaptorCache

type IndicatorAdaptorCache interface {
	Name() string
	Clone(ctx context.Context) IndicatorAdaptorCache
	Evaluate(ctx context.Context, data *model.DataPoint) model.StockAction
	CleanUp()
}

func NewDayCacheIndicatorAdaptorCacheImpl

func NewDayCacheIndicatorAdaptorCacheImpl(adaptor IndicatorAdaptor) IndicatorAdaptorCache

NewDayCacheIndicatorAdaptorCacheImpl creates a new instance of IndicatorAdaptorCacheImpl

func NewDaySingleBigCacheIndicatorAdaptorCacheImpl

func NewDaySingleBigCacheIndicatorAdaptorCacheImpl(adaptor IndicatorAdaptor) IndicatorAdaptorCache

NewDaySingleBigCacheIndicatorAdaptorCacheImpl creates a new instance of IndicatorAdaptorCacheImpl

func NewDaySingleBigDirectCacheIndicatorAdaptorCacheImpl

func NewDaySingleBigDirectCacheIndicatorAdaptorCacheImpl(adaptor IndicatorAdaptor) IndicatorAdaptorCache

NewDaySingleBigDirectCacheIndicatorAdaptorCacheImpl creates a new instance of IndicatorAdaptorCacheImpl

func NewIndicatorAdaptorCacheImpl

func NewIndicatorAdaptorCacheImpl(adaptor IndicatorAdaptor) IndicatorAdaptorCache

func NewMapIndicatorAdaptorCacheImpl

func NewMapIndicatorAdaptorCacheImpl(adaptor IndicatorAdaptor) IndicatorAdaptorCache

type InitializeStatus

type InitializeStatus int
const (
	NOT_INITIALIZED InitializeStatus = iota
	INITIALIZED
	START_SIGNALING
)

type MACDAdapter

type MACDAdapter struct {
	MACD                   *indicator.MACD
	CurrentData            model.DataPoint
	MaxTotalHistoricalData int
	HistoricalValues       []indicator.MACDResult
	// contains filtered or unexported fields
}

MACDAdapter handles a single MACD indicator and maintains historical values.

func NewMACDAdapter

func NewMACDAdapter(ctx context.Context, shortPeriod, longPeriod, signalPeriod, maxTotalHistoricalData int, monitor monitor.Monitoring) *MACDAdapter

NewMACDAdapter initializes a new MACDAdapter instance.

func NewMACDAdapterFromName

func NewMACDAdapterFromName(ctx context.Context, name string, monitor monitor.Monitoring) *MACDAdapter

func (*MACDAdapter) AddDataPoint

func (ma *MACDAdapter) AddDataPoint(ctx context.Context, data model.DataPoint) error

AddDataPoint adds a new data point and updates the MACD.

func (*MACDAdapter) Clone

func (*MACDAdapter) GetSignal

func (ma *MACDAdapter) GetSignal(ctx context.Context) (result model.StockAction)

GetSignal returns a trading signal based on the MACD logic.

func (*MACDAdapter) Name

func (ma *MACDAdapter) Name() string

Name returns the adapterName of the MACD adapter.

type MACDMetrics

type MACDMetrics struct {
	DataPointsCounter monitor.CounterMetric
	SignalCounter     monitor.CounterMetric
	MACDLine          monitor.GaugeMetric
	SignalLine        monitor.GaugeMetric
	// contains filtered or unexported fields
}

type MapIndicatorAdaptorCacheImpl

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

func (*MapIndicatorAdaptorCacheImpl) CleanUp

func (i *MapIndicatorAdaptorCacheImpl) CleanUp()

func (*MapIndicatorAdaptorCacheImpl) Clone

func (*MapIndicatorAdaptorCacheImpl) Evaluate

func (*MapIndicatorAdaptorCacheImpl) Name

type PivotPointAdapter

type PivotPointAdapter struct {
	PivotPoint             *indicator.PivotPoint
	MaxTotalHistoricalData int
	HistoricalValues       []model.DataPoint
	CurrentData            model.DataPoint
	Threshold              int
	// contains filtered or unexported fields
}

func NewPivotPointAdapter

func NewPivotPointAdapter(ctx context.Context, maxTotalHistoricalData, threshold int, monitor monitor.Monitoring) *PivotPointAdapter

func NewPivotPointAdapterFromName

func NewPivotPointAdapterFromName(ctx context.Context, name string, monitor monitor.Monitoring) *PivotPointAdapter

func (*PivotPointAdapter) AddDataPoint

func (ppa *PivotPointAdapter) AddDataPoint(ctx context.Context, data model.DataPoint) error

func (*PivotPointAdapter) Clone

func (*PivotPointAdapter) GetSignal

func (ppa *PivotPointAdapter) GetSignal(ctx context.Context) (result model.StockAction)

func (*PivotPointAdapter) Name

func (ppa *PivotPointAdapter) Name() string

type PivotPointMetrics

type PivotPointMetrics struct {
	SignalCounter monitor.CounterMetric
	LevelGauge    monitor.GaugeMetric
	// contains filtered or unexported fields
}

type RSIAdapter

type RSIAdapter struct {
	RSI                    *indicator.RSI
	MaxTotalHistoricalData int
	HistoricalValues       *utils.CyclicSlice[float64]
	OverboughtThreshold    float64
	OversoldThreshold      float64
	// contains filtered or unexported fields
}

func NewRSIAdapter

func NewRSIAdapter(ctx context.Context, period, maxTotalHistoricalData int, overboughtThreshold, oversoldThreshold float64, monitor monitor.Monitoring) *RSIAdapter

func NewRSIAdapterFromName

func NewRSIAdapterFromName(ctx context.Context, name string, monitor monitor.Monitoring) *RSIAdapter

func (*RSIAdapter) AddDataPoint

func (ra *RSIAdapter) AddDataPoint(ctx context.Context, data model.DataPoint) error

func (*RSIAdapter) Clone

func (ra *RSIAdapter) Clone(ctx context.Context) IndicatorAdaptor

func (*RSIAdapter) GetSignal

func (ra *RSIAdapter) GetSignal(ctx context.Context) (result model.StockAction)

func (*RSIAdapter) Name

func (ra *RSIAdapter) Name() string

type RSIMetrics

type RSIMetrics struct {
	SignalCounter   monitor.CounterMetric
	RsiValueCounter monitor.CounterMetric
	LevelGauge      monitor.GaugeMetric
	// contains filtered or unexported fields
}

type SuperTrendAdapter

type SuperTrendAdapter struct {
	SuperTrend    *indicator.SuperTrend
	PreviousTrend bool
	CurrentTrend  bool
	// contains filtered or unexported fields
}

SuperTrendAdapter handles a single SuperTrend indicator and maintains historical values.

func NewSuperTrendAdapter

func NewSuperTrendAdapter(ctx context.Context, period int, multiplier float64, monitor monitor.Monitoring) *SuperTrendAdapter

NewSuperTrendAdapter initializes a new SuperTrendAdapter instance.

func NewSuperTrendAdapterFromName

func NewSuperTrendAdapterFromName(ctx context.Context, name string, monitor monitor.Monitoring) *SuperTrendAdapter

func (*SuperTrendAdapter) AddDataPoint

func (sta *SuperTrendAdapter) AddDataPoint(ctx context.Context, data model.DataPoint) error

AddDataPoint adds a new data point and updates the SuperTrend.

func (*SuperTrendAdapter) Clone

Clone creates a new instance of SuperTrendAdapter with the same configuration.

func (*SuperTrendAdapter) GetSignal

func (sta *SuperTrendAdapter) GetSignal(ctx context.Context) (result model.StockAction)

GetSignal returns a trading signal based on the SuperTrend logic.

func (*SuperTrendAdapter) Name

func (sta *SuperTrendAdapter) Name() string

Name returns the adapterName of the SuperTrend adapter.

type SuperTrendMetrics

type SuperTrendMetrics struct {
	SignalCounter monitor.CounterMetric
	TrendCounter  monitor.CounterMetric
	TrendLine     monitor.CounterMetric
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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