services

package
v0.0.0-...-2ee53ed Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnomalyDetector

type AnomalyDetector interface {
	// IsAnomaly checks whether price is anomaly or not
	IsAnomaly(price decimal.Decimal) bool
}

type Detector

type Detector interface {
	// NeedAction checks need to buy, sell assets or do nothing.
	NeedAction(price decimal.Decimal) (entity.Action, error)
	// LastAction returns last decision made by detector.
	LastAction() entity.Action
}

Detector checks need to buy, sell assets or do nothing. This service must be instantiated for every trade pair separately.

type Pricer

type Pricer interface {
	GetPrice(pair entity.Pair) (decimal.Decimal, error)
}

Pricer provides current price of asset in trade pair.

type TradeService

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

TradeService makes trades for specific trade pair.

func NewTradeService

func NewTradeService(l *zap.Logger, pair entity.Pair, amount decimal.Decimal, pricer Pricer, detector Detector,
	trader Trader, anomalyDetector AnomalyDetector) *TradeService

NewTradeService creates new TradeService instance.

func (*TradeService) Trade

func (t *TradeService) Trade() (*entity.TradeEvent, error)

Trade checks current price of asset and decides whether to buy, sell or do anything.

type Trader

type Trader interface {
	// Buy buys amount of asset in trade pair.
	Buy(amount decimal.Decimal) error
	// Sell sells amount of asset in trade pair.
	Sell(amount decimal.Decimal) error
}

Trader makes buy and sell actions for trade pair.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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