orders

package
v0.0.0-...-4e5e1bb Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Element

type Element struct {
	Index int
	Order *order.Order
	// contains filtered or unexported fields
}

Element this is the element as it will be used by the ring it wraps the OrderType with an index

func (Element) CheckTag

func (i Element) CheckTag(o Tag) bool

CheckTag check if a particular tag exists

func (Element) CheckTags

func (i Element) CheckTags(o ...Tag) bool

CheckTags check one or more tags exists

func (*Element) RemoveTag

func (i *Element) RemoveTag(t Tag) bool

RemoveTag remove a particular tag

func (*Element) SetTags

func (i *Element) SetTags(o ...Tag)

todo: transfer this logic into convenience functions - IsOldest IsNewest SetNewest SetOldest

ideally the type should answer a few questions about it self as
opposed us checking things in other packages, this is specially
useful in implementing logic that relates to orders, as you can
have the orders hold information about itself that is relevant
for a group of orders, i.e: is this the newest order?

SetTags set one or more tags

type Orders

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

Orders implements a type that holds multiple orders data... this could be the bids of an orders book or the X latest orders this structure implies that orders are sorted in a useful manner

func NewOrders

func NewOrders(asset string, maxSize int, orders ...*order.Order) (o Orders, err error)

NewOrders receives a list of orders and returns them in the Orders struct

func (Orders) Asset

func (o Orders) Asset() string

Asset returns the asset of these current orders

func (Orders) Cap

func (o Orders) Cap() (i int)

Cap returns the maximum capacity of this Orders struct

func (Orders) First

func (o Orders) First() (order.Order, error)

First returns a copy of the first order

func (*Orders) Insert

func (o *Orders) Insert(order *order.Order)

Insert adds order.Order into ring

func (Orders) Last

func (o Orders) Last() (order.Order, error)

Last returns a copy of the last order

func (Orders) Len

func (o Orders) Len() (i int)

Len returns the utilized capacity of this Orders struct

func (Orders) TimeEnd

func (o Orders) TimeEnd() time.Time

TimeEnd returns the time we received the last order

func (Orders) TimePeriod

func (o Orders) TimePeriod() time.Duration

TimePeriod returns the time period of orders inside

func (Orders) TimeStart

func (o Orders) TimeStart() time.Time

TimeStart returns the time we received the first order

func (Orders) VolumeWeightedAveragePrice

func (o Orders) VolumeWeightedAveragePrice() (vwap decimal.Decimal)

VolumeWeightedAveragePrice calculates the VWAP for a group of orders

type Tag

type Tag int

Tag describe non-trivial information about an Element which essentially means information about a particular element in relation to other elements

const (
	Empty Tag = iota
	Newest
	Matched
	Oldest
	Open
	Biggest
	Smallest
	Lowest
	Highest
	First
	Last
)

Jump to

Keyboard shortcuts

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