cexio

package module
v0.0.0-...-c1cb090 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2021 License: MIT Imports: 17 Imported by: 0

README

Documentation

cexio

Simple unofficial cex.io api client: lib + command.

See usage examples in ./cmd/cexio/main.go

Documentation

Index

Constants

View Source
const (
	Buy  = "buy"
	Sell = "sell"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Balance

type Balance struct {
	Balances      map[string]decimal.Decimal `json:"balance"`
	OrderBalances map[string]decimal.Decimal `json:"obalance"`
	Timestamp     int64                      `json:"time,omitempty"`
}

type CEX

type CEX struct {
	// contains filtered or unexported fields
}

func New

func New(key string, secret []byte) (c *CEX, err error)

func (*CEX) Websocket

func (c *CEX) Websocket(ctx context.Context) (ws *Websocket, err error)

type Error

type Error struct {
	Err string `json:"error"`
}

func (*Error) Error

func (e *Error) Error() string

type Event

type Event struct {
	Event string      `json:"e"`
	OK    string      `json:"ok,omitempty"`
	ReqID string      `json:"oid,omitempty"`
	Data  interface{} `json:"data,omitempty"`
	// contains filtered or unexported fields
}

func (*Event) Raw

func (ev *Event) Raw() []byte

type History

type History struct {
	Trades []Trade
}

type MarketData

type MarketData struct {
	ID        int64           `json:"id"`
	Timestamp int64           `json:"timestamp"`
	Pair      string          `json:"pair"`
	BuyTotal  decimal.Decimal `json:"buy_total"`
	SellTotal decimal.Decimal `json:"sell_total"`
	Buy       []PriceLevel    `json:"buy"`
	Sell      []PriceLevel    `json:"sell"`

	Symbol1 string `json:"symbol1"`
	Symbol2 string `json:"symbol2"`

	Full bool `json:"-"`
}

type MarketDataUpdate

type MarketDataUpdate struct {
	ID        int64           `json:"id"`
	Timestamp int64           `json:"timestamp"`
	Pair      string          `json:"pair"`
	BuyTotal  decimal.Decimal `json:"buy_total"`
	SellTotal decimal.Decimal `json:"sell_total"`
	Bids      []PriceLevel    `json:"bids"`
	Asks      []PriceLevel    `json:"asks"`

	Symbol1 string `json:"symbol1"`
	Symbol2 string `json:"symbol2"`

	Full bool `json:"-"`
}

type OHLCV24

type OHLCV24 struct {
	Open   decimal.Decimal `json:"open"`
	High   decimal.Decimal `json:"high"`
	Low    decimal.Decimal `json:"low"`
	Close  decimal.Decimal `json:"close"`
	Volume decimal.Decimal `json:"volume"`
}

type Order

type Order struct {
	Action string          `json:"action"`
	Pair   string          `json:"pair"`
	Price  decimal.Decimal `json:"price"`
	Amount decimal.Decimal `json:"amount"`
}

type OrderCancelled

type OrderCancelled struct {
	ID      string          `json:"id"`
	Time    int64           `json:"time"`
	Remains decimal.Decimal `json:"remains"`
}

type OrderStatus

type OrderStatus struct {
	ID        string          `json:"id"`
	Action    string          `json:"action"`
	Time      int64           `json:"time"`
	Price     decimal.Decimal `json:"price"`
	Amount    decimal.Decimal `json:"amount"`
	Pending   decimal.Decimal `json:"pending"`
	Remains   decimal.Decimal `json:"remains"`
	Symbol1   string          `json:"symbol1"`
	Symbol2   string          `json:"symbol2"`
	Completed bool            `json:"complete"`
	Cancel    bool            `json:"cancel"`
}

type PriceLevel

type PriceLevel struct {
	Price  decimal.Decimal `json:"price"`
	Volume decimal.Decimal `json:"volume"`
}

type SymbolBalance

type SymbolBalance struct {
	Symbol  string          `json:"symbol"`
	Balance decimal.Decimal `json:"balance"`
}

type TickEvent

type TickEvent struct {
	Symbol1 string          `json:"symbol1"`
	Symbol2 string          `json:"symbol2"`
	Price   decimal.Decimal `json:"price"`

	Open24 decimal.Decimal `json:"open24"`
	Volume decimal.Decimal `json:"volume"`
}

type Ticker

type Ticker struct {
	Timestamp          int64           `json:"timestamp,omitempty,string"`
	Low                decimal.Decimal `json:"low,omitempty"`
	High               decimal.Decimal `json:"high,omitempty"`
	Last               decimal.Decimal `json:"last,omitempty"`
	Volume             decimal.Decimal `json:"volume,omitempty"`
	Volume30d          decimal.Decimal `json:"volume30d,omitempty"`
	Bid                decimal.Decimal `json:"bid,omitempty"`
	Ask                decimal.Decimal `json:"ask,omitempty"`
	PriceChange        decimal.Decimal `json:"priceChange,omitempty"`
	PriceChangePercent decimal.Decimal `json:"priceChangePercentage,omitempty"`

	Pair []string `json:"pair,omitempty"`

	Symbol1 string `json:"-"`
	Symbol2 string `json:"-"`
}

type Trade

type Trade struct {
	Action string          `json:"action"`
	Time   int64           `json:"ts"`
	Amount decimal.Decimal `json:"amount"`
	Price  decimal.Decimal `json:"price"`
	TxID   int64           `json:"tx_id"`
}

type Tx

type Tx struct {
	ID        string          `json:"id"`
	Action    string          `json:"action"`
	Order     string          `json:"order"`
	BuyOrder  string          `json:"buy_order"`
	SellOrder string          `json:"sell_order"`
	Time      int64           `json:"time"`
	User      string          `json:"user"`
	Price     decimal.Decimal `json:"price"`
	Amount    decimal.Decimal `json:"amount"`
	Balance   decimal.Decimal `json:"balance"`
	Fee       decimal.Decimal `json:"fee"`
	Symbol1   string          `json:"symbol1"`
	Symbol2   string          `json:"symbol2"`
}

type Websocket

type Websocket struct {
	// contains filtered or unexported fields
}

func (*Websocket) CancelOrder

func (ws *Websocket) CancelOrder(id string) (ev Event, err error)

func (*Websocket) Events

func (ws *Websocket) Events() <-chan Event

func (*Websocket) GetBalance

func (ws *Websocket) GetBalance() (ev Event, err error)

func (*Websocket) Orders

func (ws *Websocket) Orders(sym1, sym2 string) (ev Event, err error)

func (*Websocket) PlaceOrder

func (ws *Websocket) PlaceOrder(o Order) (ev Event, err error)

func (*Websocket) SubscribeOrderbook

func (ws *Websocket) SubscribeOrderbook(sym1, sym2 string) (err error)

func (*Websocket) SubscribePublic

func (ws *Websocket) SubscribePublic(tickers []string) (err error)

Subscribe subscribes to "tickers" (trades) or "pair-A-B" where A and B are BTC, ETH, USD and so on.

func (*Websocket) Ticker

func (ws *Websocket) Ticker(s1, s2 string) (ev Event, err error)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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