orderbook

package
v0.0.0-...-b8e8dbd Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2018 License: MIT Imports: 4 Imported by: 0

README

GoCryptoTrader package Orderbook

Build Status Software License GoDoc Coverage Status Go Report Card

This orderbook package is part of the GoCryptoTrader codebase.

This is still in active development

You can track ideas, planned features and what's in progresss on this Trello board: https://trello.com/b/ZAhMhpOy/gocryptotrader.

Join our slack to discuss all things related to GoCryptoTrader! GoCryptoTrader Slack

Current Features for orderbook

  • This package facilitates orderbook generation.
Please click GoDocs chevron above to view current GoDoc information for this package

Contribution

Please feel free to submit any pull requests or suggest any desired features to be added.

When submitting a PR, please abide by our coding guidelines:

  • Code must adhere to the official Go formatting guidelines (i.e. uses gofmt).
  • Code must be documented adhering to the official Go commentary guidelines.
  • Code must adhere to our coding style.
  • Pull requests need to be based on and opened against the master branch.

Donations

If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:

1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB

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 string) 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[string]map[string]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