orderbook

package
v0.0.0-...-3240a16 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2017 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrOrderbookForExchangeNotFound = "Ticker for exchange does not exist."
	ErrPrimaryCurrencyNotFound      = "Error primary currency for orderbook not found."
	ErrSecondaryCurrencyNotFound    = "Error secondary currency for orderbook not found."

	Spot = "SPOT"
)

Const values for orderbook package

Variables

View Source
var (
	Orderbooks []Orderbook
)

Vars for the orderbook package

Functions

func FirstCurrencyExists

func FirstCurrencyExists(exchange string, currency pair.CurrencyItem) bool

FirstCurrencyExists checks to see if the first currency of the orderbook map exists

func ProcessOrderbook

func ProcessOrderbook(exchangeName string, p pair.CurrencyPair, orderbookNew Base, orderbookType string)

ProcessOrderbook processes incoming orderbooks, creating or updating the Orderbook list

func SecondCurrencyExists

func SecondCurrencyExists(exchange string, p pair.CurrencyPair) bool

SecondCurrencyExists checks to see if the second currency of the orderbook map exists

Types

type Base

type Base struct {
	Pair         pair.CurrencyPair `json:"pair"`
	CurrencyPair string            `json:"CurrencyPair"`
	Bids         []Item            `json:"bids"`
	Asks         []Item            `json:"asks"`
	LastUpdated  time.Time         `json:"last_updated"`
}

Base holds the fields for the orderbook base

func GetOrderbook

func GetOrderbook(exchange string, p pair.CurrencyPair, orderbookType string) (Base, error)

GetOrderbook checks and returns the orderbook given an exchange name and currency pair if it exists

func (*Base) CalculateTotalAsks

func (o *Base) CalculateTotalAsks() (float64, float64)

CalculateTotalAsks returns the total amount of asks and the total orderbook asks value

func (*Base) CalculateTotalBids

func (o *Base) CalculateTotalBids() (float64, float64)

CalculateTotalBids returns the total amount of bids and the total orderbook bids value

func (*Base) Update

func (o *Base) Update(Bids, Asks []Item)

Update updates the bids and asks

type Item

type Item struct {
	Amount float64
	Price  float64
}

Item stores the amount and price values

type Orderbook

type Orderbook struct {
	Orderbook    map[pair.CurrencyItem]map[pair.CurrencyItem]map[string]Base
	ExchangeName string
}

Orderbook holds the orderbook information for a currency pair and type

func CreateNewOrderbook

func CreateNewOrderbook(exchangeName string, p pair.CurrencyPair, orderbookNew Base, orderbookType string) Orderbook

CreateNewOrderbook creates a new orderbook

func GetOrderbookByExchange

func GetOrderbookByExchange(exchange string) (*Orderbook, error)

GetOrderbookByExchange returns an exchange orderbook

Jump to

Keyboard shortcuts

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