order

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Controller

type Controller struct {
	Results map[string]*summary
	// contains filtered or unexported fields
}

func NewController

func NewController(ctx context.Context, exchange service.Exchange, storage storage.Storage,
	orderFeed *Feed) *Controller

func (*Controller) Account

func (c *Controller) Account() (model.Account, error)

func (*Controller) Cancel

func (c *Controller) Cancel(order model.Order) error

func (*Controller) CreateOrderLimit

func (c *Controller) CreateOrderLimit(side model.SideType, pair string, size, limit float64) (model.Order, error)

func (*Controller) CreateOrderMarket

func (c *Controller) CreateOrderMarket(side model.SideType, pair string, size float64) (model.Order, error)

func (*Controller) CreateOrderMarketQuote

func (c *Controller) CreateOrderMarketQuote(side model.SideType, pair string, amount float64) (model.Order, error)

func (*Controller) CreateOrderOCO

func (c *Controller) CreateOrderOCO(side model.SideType, pair string, size, price, stop,
	stopLimit float64) ([]model.Order, error)

func (*Controller) CreateOrderStop

func (c *Controller) CreateOrderStop(pair string, size float64, limit float64) (model.Order, error)

func (*Controller) LastQuote

func (c *Controller) LastQuote(pair string) (float64, error)

func (*Controller) OnCandle

func (c *Controller) OnCandle(candle model.Candle)

func (*Controller) Order

func (c *Controller) Order(pair string, id int64) (model.Order, error)

func (*Controller) Position

func (c *Controller) Position(pair string) (asset, quote float64, err error)

func (*Controller) PositionValue

func (c *Controller) PositionValue(pair string) (float64, error)

func (*Controller) SetNotifier

func (c *Controller) SetNotifier(notifier service.Notifier)

func (*Controller) Start

func (c *Controller) Start()

func (*Controller) Status

func (c *Controller) Status() Status

func (*Controller) Stop

func (c *Controller) Stop()

type DataFeed

type DataFeed struct {
	Data chan model.Order
	Err  chan error
}

type Feed

type Feed struct {
	OrderFeeds            map[string]*DataFeed
	SubscriptionsBySymbol map[string][]Subscription
}

func NewOrderFeed

func NewOrderFeed() *Feed

func (*Feed) Publish

func (d *Feed) Publish(order model.Order, _ bool)

func (*Feed) Start

func (d *Feed) Start()

func (*Feed) Subscribe

func (d *Feed) Subscribe(pair string, consumer FeedConsumer, onlyNewOrder bool)

type FeedConsumer

type FeedConsumer func(order model.Order)

type Position

type Position struct {
	Side      model.SideType
	AvgPrice  float64
	Quantity  float64
	CreatedAt time.Time
}

func (*Position) Update

func (p *Position) Update(order *model.Order) (result *Result, finished bool)

type Result

type Result struct {
	Pair          string
	ProfitPercent float64
	ProfitValue   float64
	Side          model.SideType
	Duration      time.Duration
	CreatedAt     time.Time
}

type Status

type Status string
const (
	StatusRunning Status = "running"
	StatusStopped Status = "stopped"
	StatusError   Status = "error"
)

type Subscription

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

Jump to

Keyboard shortcuts

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