common

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2021 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OrderSideBid = 0
	OrderSideAsk = 1
)
View Source
const (
	ErrInvalidPair = "invalid pair"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CsvRow

type CsvRow interface {
	Row() []string
	Headers() []string
}

type CsvTable

type CsvTable interface {
	Rows() []CsvRow
	Headers() []string
}

type Event

type Event struct {
	Order
	Type EventType
}

func (*Event) Headers

func (e *Event) Headers() []string

func (*Event) Row

func (e *Event) Row() []string

type EventType

type EventType int
const (
	EventTypeInit EventType = iota
	EventTypeAdd
	EventTypeChange
	EventTypeRemove
)

type Exchange

type Exchange interface {
	Init(config interface{}) error
	Name() string
	AvailablePairs() []Pair
	PairAvailable(pair Pair) bool
	GetSnapshot(pair Pair) (Snapshot, error)
	SubscribeEvents(pair Pair) (context.Context, error)

	SubscribeUpdates(pair Pair, chanSize int) chan uint64
	UnsubscribeUpdates(pair Pair) bool
	SetMaxSnapshotSize(val int)

	Close() error
}

type Order

type Order struct {
	Timestamp time.Time
	Side      OrderSide
	Amount    float64
	Price     float64
}

func (Order) Equal

func (o Order) Equal(order Order) bool

func (*Order) Headers

func (o *Order) Headers() []string

func (*Order) Row

func (o *Order) Row() []string

type OrderSide

type OrderSide int

type Pair

type Pair struct {
	Base  string
	Quote string
}

func PairsFromString

func PairsFromString(pairStr string) (*Pair, error)

func PairsFromStrings

func PairsFromStrings(pairStrs ...string) ([]Pair, error)

func (Pair) String

func (p Pair) String() string

type Snapshot

type Snapshot struct {
	Timestamp time.Time
	Exchange  string
	Pair      Pair
	Orders    []Order
	Events    []Event
	SessionID int64
	Counter   int64
}

func (Snapshot) Equal

func (s Snapshot) Equal(snapshot Snapshot) bool

type SnapshotMode

type SnapshotMode int
const (
	SnapshotModeTime SnapshotMode = iota
	SnapshotModeTicks
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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