storage

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bunt

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

func (*Bunt) CreateDiscard

func (b *Bunt) CreateDiscard(discard model.Discard) error

CreateDiscard keeps discard, once for its pair and its AfterID, under a key of its own, apart from the orders (see Orders).

func (*Bunt) CreateOrder

func (b *Bunt) CreateOrder(order *model.Order) error

func (*Bunt) Discards

func (b *Bunt) Discards() ([]model.Discard, error)

Discards returns the discards kept, see CreateDiscard.

func (*Bunt) Orders

func (b *Bunt) Orders(filters ...OrderFilter) ([]*model.Order, error)

func (*Bunt) UpdateOrder

func (b *Bunt) UpdateOrder(order *model.Order) error

UpdateOrder writes order under its id, unless the order stored ended (see model.OrderStatusType.Final) and order is open: an end is never undone, eg: by a move the exchange answered as the order filled, logged and not written. Unlike the database of the agents, the times aren't compared: the order controller writes the states of an order in their order.

type DiscardStorage

type DiscardStorage interface {
	CreateDiscard(discard model.Discard) error
	Discards() ([]model.Discard, error)
}

DiscardStorage is a Storage keeping the positions the order controller discarded, see model.Discard: CreateDiscard keeps one, once for its pair and its AfterID; Discards returns them all.

type OrderFilter

type OrderFilter func(model.Order) bool

func WithPair

func WithPair(pair string) OrderFilter

func WithStatus

func WithStatus(status model.OrderStatusType) OrderFilter

func WithStatusIn

func WithStatusIn(status ...model.OrderStatusType) OrderFilter

func WithUpdateAtBeforeOrEqual

func WithUpdateAtBeforeOrEqual(time time.Time) OrderFilter

type Storage

type Storage interface {
	CreateOrder(order *model.Order) error
	UpdateOrder(order *model.Order) error
	Orders(filters ...OrderFilter) ([]*model.Order, error)
}

func FromFile

func FromFile(file string) (Storage, error)

func FromMemory

func FromMemory() (Storage, error)

Jump to

Keyboard shortcuts

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