exchanges

package
v0.0.0-...-54de7ac Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2017 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrProviderNotFound = errors.New("provider not found")
	ErrManagerNotInit   = errors.New("manager is not init")
)

Functions

This section is empty.

Types

type ExchangeProvider

type ExchangeProvider interface {
	Name() string

	Ticker() TickerProvider
}

ExchangeProvider interface

type Manager

type Manager map[string]ExchangeProvider

Manager of ExchangeProvider

func NewManager

func NewManager() Manager

NewManager func

func (Manager) Add

func (m Manager) Add(exchange ExchangeProvider)

Add sets the key to value. It replaces any existing values.

func (Manager) Get

func (m Manager) Get(key string) (ExchangeProvider, error)

Get exchange by name

type OrderEvent

type OrderEvent struct {
	Side  SideType
	Price float64
}

OrderEvent struct

type Product

type Product struct {
	From string
	To   string
}

Product struct

func NewProduct

func NewProduct(from string, to string) Product

NewProduct create product object

func NewProductFromString

func NewProductFromString(product string) Product

NewProductFromString create product object

func (Product) MarshalJSON

func (p Product) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler. It will encode null if this time is null.

func (Product) String

func (p Product) String() string

func (*Product) UnmarshalJSON

func (p *Product) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler. It support string and null input.

type SideType

type SideType string
const (
	SideTypeSell SideType = "sell"
	SideTypeBuy  SideType = "buy"
)

type TickerEvent

type TickerEvent struct {
	Product Product   `json:"product"`
	Price   float64   `json:"price"`
	Side    SideType  `json:"side"`
	Time    time.Time `json:"time"`
	Size    float64   `json:"size"`
}

TickerEvent struct

type TickerProvider

type TickerProvider interface {
	Subscribe(products ...Product) error
	Unsubscribe(products ...Product) error
	Channel() <-chan *TickerEvent
}

TickerProvider interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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