orderbook

package
Version: v0.0.0-...-eb07c7e Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2019 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.

  • Attaches methods to an orderbook

    • To Return total Bids
    • To Return total Asks
    • Update orderbooks
  • Gets a loaded orderbook by exchange, asset type and currency pair.

  • This package is primarily used in conjunction with but not limited to the exchange interface system set by exchange wrapper orderbook functions in "exchange"_wrapper.go.

Examples below:

ob, err := yobitExchange.GetOrderbookEx()
if err != nil {
  // Handle error
}

// Find total asks which also returns total orderbook value
totalAsks, totalOrderbookVal := ob.CalculateTotalAsks()
  • or if you have a routine setting an exchange orderbook you can access it via the package itself.
ob, err := orderbook.Get(...)
if err != nil {
  // Handle error
}
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 (
	Spot = "SPOT"
)

const values for orderbook package

Variables

View Source
var (
	Orderbooks []Orderbook
)

Vars for the orderbook package

Functions

func BaseCurrencyExists

func BaseCurrencyExists(exchange string, currency currency.Code) bool

BaseCurrencyExists checks to see if the base currency of the orderbook map exists

func QuoteCurrencyExists

func QuoteCurrencyExists(exchange string, p currency.Pair) bool

QuoteCurrencyExists checks to see if the quote currency of the orderbook map exists

Types

type Base

type Base struct {
	Pair         currency.Pair `json:"pair"`
	Bids         []Item        `json:"bids"`
	Asks         []Item        `json:"asks"`
	LastUpdated  time.Time     `json:"lastUpdated"`
	AssetType    string        `json:"assetType"`
	ExchangeName string        `json:"exchangeName"`
}

Base holds the fields for the orderbook base

func Get

func Get(exchange string, p currency.Pair, orderbookType string) (Base, error)

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

func (*Base) Process

func (o *Base) Process() error

Process processes incoming orderbooks, creating or updating the orderbook list

func (*Base) TotalAsksAmount

func (o *Base) TotalAsksAmount() (amountCollated, total float64)

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

func (*Base) TotalBidsAmount

func (o *Base) TotalBidsAmount() (amountCollated, total float64)

TotalBidsAmount 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
	ID     int64
}

Item stores the amount and price values

type Orderbook

type Orderbook struct {
	Orderbook    map[*currency.Item]map[*currency.Item]map[string]Base
	ExchangeName string
}

Orderbook holds the orderbook information for a currency pair and type

func CreateNewOrderbook

func CreateNewOrderbook(exchangeName string, orderbookNew *Base, orderbookType string) *Orderbook

CreateNewOrderbook creates a new orderbook

func GetByExchange

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

GetByExchange returns an exchange orderbook

Source Files

Jump to

Keyboard shortcuts

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