Documentation ¶
Index ¶
- Constants
- func NewHist(algo *entity.Algorithm, hRep repository.HistoryRepository, ...) (stmodel.Algorithm, error)
- func NewParamSplitter(logger *zap.SugaredLogger) stmodel.ParamSplitter
- func NewProd(algo *entity.Algorithm, infoSrv service.InfoSrv, logger *zap.SugaredLogger) (stmodel.Algorithm, error)
- func NewSandbox(algo *entity.Algorithm, infoSrv service.InfoSrv, logger *zap.SugaredLogger) (stmodel.Algorithm, error)
- type AlgoData
- type AlgorithmImpl
- func (a *AlgorithmImpl) Configure(ctx []*entity.CtxParam) error
- func (a *AlgorithmImpl) GetAlgorithm() *entity.Algorithm
- func (a *AlgorithmImpl) GetParam() map[string]string
- func (a *AlgorithmImpl) Go(parCtx context.Context) error
- func (a AlgorithmImpl) IsActive() bool
- func (a *AlgorithmImpl) Stop() error
- func (a *AlgorithmImpl) Subscribe() (*stmodel.Subscription, error)
- type DataProc
- type DataProcProd
- type DbDataProc
- type ParamSplitterImpl
Constants ¶
const ( OrderExpiration string = "order_expiration" Commission string = "order_commission" RelDerivative string = "relative_derivative" StopLoss string = "stop_loss" )
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 ¶
func NewHist(algo *entity.Algorithm, hRep repository.HistoryRepository, rootLogger *zap.SugaredLogger) (stmodel.Algorithm, error)
NewHist constructs new algorithm using history data processor
func NewParamSplitter ¶
func NewParamSplitter(logger *zap.SugaredLogger) stmodel.ParamSplitter
Types ¶
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) GetAlgorithm ¶
func (a *AlgorithmImpl) GetAlgorithm() *entity.Algorithm
func (*AlgorithmImpl) GetParam ¶
func (a *AlgorithmImpl) GetParam() map[string]string
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) 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)
type ParamSplitterImpl ¶
type ParamSplitterImpl struct {
// contains filtered or unexported fields
}