stmodel

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionReq

type ActionReq struct {
	Action *entity.Action
	Limits []*entity.MoneyLimit
}

ActionReq represents common algorithm request model

func (ActionReq) GetCurrLimit

func (req ActionReq) GetCurrLimit(currency string) decimal.Decimal

GetCurrLimit simplifies retrieving limit by required currency from limit slice

type ActionResp

type ActionResp struct {
	Action *entity.Action
}

ActionResp represents common trader response model

type Algorithm

type Algorithm interface {
	//Configure is to configure Algorithm after restoring it state and data from db etc. (Currently not implemented)
	Configure(ctx []*entity.CtxParam) error
	//Subscribe to algorithm and retrieve subscription to interact with algorithm
	Subscribe() (*Subscription, error)
	//IsActive return true if algorithm running and false if it was stopped
	IsActive() bool
	//GetParam returns algorithm parameters as map
	GetParam() map[string]string
	//GetAlgorithm returns algorithm data which used as base
	GetAlgorithm() *entity.Algorithm
	//Go starts algorithm running in background
	Go(ctx context.Context) error
	//Stop running algorithm
	Stop() error
}

Algorithm is a general interface of any trading logic It supposed to run in the background and processing data, retrieved from data processor through channel Exchange with Trader made through channels from Subscription object. Algorithm keeps communication with Trader through channels using Action domain model Action domain model keeps all required information about single order request Action for sending from algorithm must be populated only partially some parameters populated and persisted by Trader (see domain.Action documentation)

type ParamSplitter

type ParamSplitter interface {
	ParseAndSplit(param map[string]string) ([]map[string]string, error)
}

ParamSplitter is a common interface for splitting algorithm params into range of param set for analysis purposes Each algorithm must have itself parameter set, delimiter and splitting logic This interface must be implemented for the algorithm and added to factory to provide possibility to use /analyze/range request on algorithm

type Subscription

type Subscription struct {
	AlgoID uint               //Subscribing algorithm identity
	AChan  <-chan *ActionReq  //Algorithm -> trade.Trader channel - to create order requests
	RChan  chan<- *ActionResp //trade.Trader -> Algorithm channel - to retrieve order result responses
}

Subscription represents common subscription object representing Algorithm/trade.Trader interaction mechanisms

Jump to

Keyboard shortcuts

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