orderbook

package module
v0.0.0-...-16093ed Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2020 License: Apache-2.0 Imports: 2 Imported by: 0

README

go-orderbook

Documentation

Overview

Copyright 2019 Lane A. Shetron

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Copy

func Copy(src, dst *OrderBook)

Types

type AskBook

type AskBook struct {
	Orders AskOrders
	OrdersMap
	// contains filtered or unexported fields
}

func (*AskBook) Fix

func (ab *AskBook) Fix(key string)

func (*AskBook) Get

func (ab *AskBook) Get(key string) (*Node, bool)

func (*AskBook) Len

func (ab *AskBook) Len() int

func (*AskBook) Peek

func (ab *AskBook) Peek() *Order

func (*AskBook) Pop

func (ab *AskBook) Pop() *Node

func (*AskBook) Push

func (ab *AskBook) Push(n *Node)

func (*AskBook) Remove

func (ab *AskBook) Remove(key string)

type AskOrders

type AskOrders struct {
	BaseHeap
}

func (AskOrders) Less

func (ob AskOrders) Less(i, j int) bool

type BaseHeap

type BaseHeap []*Node

func (BaseHeap) Len

func (h BaseHeap) Len() int

func (*BaseHeap) Pop

func (h *BaseHeap) Pop() interface{}

func (*BaseHeap) Push

func (h *BaseHeap) Push(x interface{})

func (BaseHeap) Swap

func (h BaseHeap) Swap(i, j int)

type BidBook

type BidBook struct {
	Orders BidOrders
	OrdersMap
	// contains filtered or unexported fields
}

func (*BidBook) Fix

func (bb *BidBook) Fix(key string)

func (*BidBook) Get

func (bb *BidBook) Get(key string) (*Node, bool)

func (*BidBook) Len

func (bb *BidBook) Len() int

func (*BidBook) Peek

func (bb *BidBook) Peek() *Order

func (*BidBook) Pop

func (bb *BidBook) Pop() *Node

func (*BidBook) Push

func (bb *BidBook) Push(n *Node)

func (*BidBook) Remove

func (bb *BidBook) Remove(key string)

type BidOrders

type BidOrders struct {
	BaseHeap
}

func (BidOrders) Less

func (ob BidOrders) Less(i, j int) bool

type Book

type Book interface {
	Item
	Push(*Node)
	Pop() *Node
	Get(string) (*Node, bool)
	Remove(string)
	Fix(string)
	Len() int
}

type Item

type Item interface {
	Peek() *Order
}

type Node

type Node struct {
	Item
	Key    string
	Weight float64
	// contains filtered or unexported fields
}

func NewNode

func NewNode(key string, i Item, weight float64) Node

type Order

type Order struct {
	Price    float64 `json:"price"`
	Quantity float64 `json:"quantity"`
	OrderId  string  `json:"orderId"`
	Country  string  `json:"country"`
}

func NewOrder

func NewOrder(price float64, quantity float64, orderId string) Order

func (*Order) Peek

func (o *Order) Peek() *Order

type OrderBook

type OrderBook struct {
	AskBook
	BidBook
	// contains filtered or unexported fields
}

func NewOrderBook

func NewOrderBook() *OrderBook

func (OrderBook) HasBoth

func (ob OrderBook) HasBoth() bool

func (*OrderBook) Init

func (ob *OrderBook) Init()

func (OrderBook) Midpoint

func (ob OrderBook) Midpoint() float64

func (OrderBook) Spread

func (ob OrderBook) Spread() float64

func (OrderBook) Volume

func (ob OrderBook) Volume() float64

type OrdersMap

type OrdersMap map[string]*Node

type Quote

type Quote struct {
	Ask *Order `json:"ask,omitempty"`
	Bid *Order `json:"bid,omitempty"`
}

type TradeEvent

type TradeEvent struct {
	Price    float64
	Quantity float64
}

Jump to

Keyboard shortcuts

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