indicator

package module
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2026 License: AGPL-3.0 Imports: 5 Imported by: 5

README

indicator

The trade indicator.

Indicator Support

indicator support
EMA Yes
SMA Yes
SMMA Yes
Stoch No Test
StochRSI Yes

Cheers to

Some indicator refer to Gekko

Some indicator refer to tradingview wiki StochRSI

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ExtraIndicators = map[string]NewCommonIndicatorFunc{}
)

Functions

func RegisterIndicator

func RegisterIndicator(name string, fn NewCommonIndicatorFunc)

Types

type Boll

type Boll struct {
	*SMA
	// contains filtered or unexported fields
}

func NewBoll

func NewBoll(winLen, k int) *Boll

func (*Boll) Bottom

func (b *Boll) Bottom() float64

func (*Boll) Cal

func (b *Boll) Cal()

func (*Boll) Indicator

func (b *Boll) Indicator() map[string]float64

func (*Boll) Result

func (b *Boll) Result() float64

func (*Boll) Top

func (b *Boll) Top() float64

func (*Boll) Update

func (b *Boll) Update(price float64)

type CommonIndicator

type CommonIndicator interface {
	Indicator
	Indicator() map[string]float64
}

CommonIndicator

func NewCommonIndicator

func NewCommonIndicator(name string, params ...int) (ind CommonIndicator, err error)

type CrossTool

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

func NewCrossTool

func NewCrossTool(crosser Crosser) *CrossTool

func (*CrossTool) IsCrossDown

func (ct *CrossTool) IsCrossDown() bool

func (*CrossTool) IsCrossUp

func (ct *CrossTool) IsCrossUp() bool

func (*CrossTool) Update

func (ct *CrossTool) Update(price float64)

type Crosser

type Crosser interface {
	Updater
	SlowResult() float64
	FastResult() float64
}

type EMA

type EMA struct {
	MABase
	// contains filtered or unexported fields
}

func NewEMA

func NewEMA(winLen int) *EMA

func (*EMA) Update

func (e *EMA) Update(price float64)

type Indicator

type Indicator interface {
	Updater
	Result() float64
}

type JsonIndicator

type JsonIndicator struct {
	CommonIndicator
}

func NewJsonIndicator

func NewJsonIndicator(m CommonIndicator) *JsonIndicator

func (*JsonIndicator) MarshalJSON

func (j *JsonIndicator) MarshalJSON() (buf []byte, err error)

type MABase

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

func (*MABase) Result

func (m *MABase) Result() float64

type MACD

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

func NewMACD

func NewMACD(short, long, signal int) *MACD

func NewMACDWithSMA

func NewMACDWithSMA(short, long, signal int) *MACD

NewMACDWithSMA macd signal line with simple ma

func (*MACD) DEA

func (ma *MACD) DEA() float64

func (*MACD) DIF

func (ma *MACD) DIF() float64

func (*MACD) FastResult

func (ma *MACD) FastResult() float64

func (*MACD) Result

func (ma *MACD) Result() float64

func (*MACD) SlowResult

func (ma *MACD) SlowResult() float64

func (*MACD) Update

func (ma *MACD) Update(price float64)

type MAGroup

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

func NewMAGroup

func NewMAGroup(fast, slow Indicator) *MAGroup

func (*MAGroup) FastResult

func (mg *MAGroup) FastResult() float64

func (*MAGroup) SlowResult

func (mg *MAGroup) SlowResult() float64

func (*MAGroup) Update

func (mg *MAGroup) Update(price float64)

type Mixed

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

func NewMixed

func NewMixed(indicator Indicator, crossIndicator Crosser) *Mixed

func (*Mixed) FastResult

func (m *Mixed) FastResult() float64

func (*Mixed) Indicator

func (m *Mixed) Indicator() map[string]float64

func (*Mixed) IsCrossDown

func (m *Mixed) IsCrossDown() bool

func (*Mixed) IsCrossUp

func (m *Mixed) IsCrossUp() bool

func (*Mixed) Result

func (m *Mixed) Result() float64

func (*Mixed) SlowResult

func (m *Mixed) SlowResult() float64

func (*Mixed) SupportResult

func (m *Mixed) SupportResult() bool

func (*Mixed) SupportSlowFast

func (m *Mixed) SupportSlowFast() bool

func (*Mixed) Update

func (m *Mixed) Update(price float64)

type NewCommonIndicatorFunc

type NewCommonIndicatorFunc func(params ...int) (CommonIndicator, error)

type RSI

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

func NewRSI

func NewRSI(winLen int) *RSI

func (*RSI) Result

func (r *RSI) Result() float64

func (*RSI) Update

func (r *RSI) Update(price float64)

type SMA

type SMA struct {
	MABase
	// contains filtered or unexported fields
}

func NewSMA

func NewSMA(winLen int) *SMA

func (*SMA) Update

func (s *SMA) Update(price float64)

type SMMA

type SMMA struct {
	MABase
	// contains filtered or unexported fields
}

SMMA Smoothed Moving Average (SMMA)

func NewSMMA

func NewSMMA(winLen int) *SMMA

func (*SMMA) Update

func (sm *SMMA) Update(price float64)

type Stoch

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

Stoch just test with StochRSI

func NewStoch

func NewStoch(winLen, periodK, periodD int) *Stoch

func (*Stoch) DResult

func (s *Stoch) DResult() float64

func (*Stoch) KResult

func (s *Stoch) KResult() float64

func (*Stoch) Result

func (s *Stoch) Result() float64

func (*Stoch) Update

func (s *Stoch) Update(price float64)

type StochRSI

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

StochRSI result test with aicoin's bitmex data maybe it's difference with different website

func NewStochRSI

func NewStochRSI(winLen, rsiWinLen, k, d int) *StochRSI

func (*StochRSI) DResult

func (sr *StochRSI) DResult() float64

func (*StochRSI) FastResult

func (sr *StochRSI) FastResult() float64

func (*StochRSI) KResult

func (sr *StochRSI) KResult() float64

func (*StochRSI) Result

func (sr *StochRSI) Result() float64

func (*StochRSI) SlowResult

func (sr *StochRSI) SlowResult() float64

func (*StochRSI) Update

func (sr *StochRSI) Update(price float64)

type Updater

type Updater interface {
	Update(price float64)
}

Jump to

Keyboard shortcuts

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