avr

package
v0.0.0-...-51300c0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2022 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OrderExpiration string = "order_expiration"
	Commission      string = "order_commission"
	RelDerivative   string = "relative_derivative"
	StopLoss        string = "stop_loss"
)
View Source
const (
	ShortDur string = "short_dur" //Short window length in sec
	LongDur  string = "long_dur"  //Long window length in sec
)

Average window parameters

Variables

This section is empty.

Functions

func NewHist

NewHist constructs new algorithm using history data processor

func NewParamSplitter

func NewParamSplitter(logger *zap.SugaredLogger) stmodel.ParamSplitter

func NewProd

func NewProd(algo *entity.Algorithm, infoSrv service.InfoSrv, logger *zap.SugaredLogger) (stmodel.Algorithm, error)

NewProd constructs new algorithm using production data processor

func NewSandbox

func NewSandbox(algo *entity.Algorithm, infoSrv service.InfoSrv, logger *zap.SugaredLogger) (stmodel.Algorithm, error)

NewSandbox constructs new algorithm using production data processor cause it the same for such algorithm

Types

type AlgoData

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

type AlgorithmImpl

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

AlgorithmImpl is base implementation of average trading algorithm. Data processor is aggregation part of algorithm and controlled by the algorithm. This implementation supports one subscription and communication with one trader Algorithm based on 2 moving average windows - short and long. Average window values calculated and provided by DataProc Average algorithm just check the difference between windows and compare sign with previous step if difference changes from negative to positive - then there is trend for rising and buy condition is met if difference changes from positive to negative - then there is trend to falling and sell condition is met

Important note! Currently, at start algorithm assumes that there is no available instruments to sell (it may be added in future as parameter or domain.Algorithm) So at start algorithm search for buy conditions and only after that it cat make sell operations

func (*AlgorithmImpl) Configure

func (a *AlgorithmImpl) Configure(ctx []*entity.CtxParam) error

func (*AlgorithmImpl) GetAlgorithm

func (a *AlgorithmImpl) GetAlgorithm() *entity.Algorithm

func (*AlgorithmImpl) GetParam

func (a *AlgorithmImpl) GetParam() map[string]string

func (*AlgorithmImpl) Go

func (a *AlgorithmImpl) Go(parCtx context.Context) error

func (AlgorithmImpl) IsActive

func (a AlgorithmImpl) IsActive() bool

func (*AlgorithmImpl) Stop

func (a *AlgorithmImpl) Stop() error

func (*AlgorithmImpl) Subscribe

func (a *AlgorithmImpl) Subscribe() (*stmodel.Subscription, error)

type DataProc

type DataProc interface {
	//GetDataStream provide channel with data stream from processor
	GetDataStream() (<-chan procData, error)
	//Go commands DataProc to start processing data in background
	Go(ctx context.Context) error
}

DataProc provides data with short and long AVR windows for the algorithm

type DataProcProd

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

func (*DataProcProd) GetDataStream

func (d *DataProcProd) GetDataStream() (<-chan procData, error)

func (*DataProcProd) Go

func (d *DataProcProd) Go(ctx context.Context) error

func (*DataProcProd) Stop

func (d *DataProcProd) Stop() error

type DbDataProc

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

func (*DbDataProc) GetDataStream

func (d *DbDataProc) GetDataStream() (<-chan procData, error)

func (*DbDataProc) Go

func (d *DbDataProc) Go(ctx context.Context) error

type ParamSplitterImpl

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

func (*ParamSplitterImpl) ParseAndSplit

func (p *ParamSplitterImpl) ParseAndSplit(param map[string]string) ([]map[string]string, error)

Jump to

Keyboard shortcuts

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