cexio

package
v0.0.184 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Endpoint          = "https://cex.io/api/"
	RequestsPerSecond = 1 // limited to 600 requests per 10 minutes
)

Variables

View Source
var (
	BeforeRequest func(path string) error = nil
	AfterRequest  func()                  = nil
)
View Source
var SideString = map[Side]string{
	SIDE_UNKNOWN: "",
	BUY:          "buy",
	SELL:         "sell",
}

Functions

This section is empty.

Types

type BookEntry

type BookEntry []float64

func (*BookEntry) Price

func (be *BookEntry) Price() float64

func (*BookEntry) Size

func (be *BookEntry) Size() float64

type Client

type Client struct {
	URL      string
	Key      string
	Secret   string
	UserName string
	// contains filtered or unexported fields
}

func New

func New(apiKey, apiSecret, userName string) *Client

func (*Client) ArchivedOrders

func (client *Client) ArchivedOrders(symbol1, symbol2 string) ([]Order, error)

func (*Client) ArchivedOrdersAll

func (client *Client) ArchivedOrdersAll() ([]Order, error)

func (*Client) CancelOrder

func (client *Client) CancelOrder(id string) error

func (*Client) CurrencyLimits

func (client *Client) CurrencyLimits() ([]Pair, error)

func (*Client) OpenOrders

func (client *Client) OpenOrders(symbol1, symbol2 string) ([]Order, error)

func (*Client) OpenOrdersAll

func (client *Client) OpenOrdersAll() ([]Order, error)

func (*Client) OrderBook

func (client *Client) OrderBook(symbol1, symbol2 string) (*OrderBook, error)

func (*Client) PlaceMarketOrder

func (client *Client) PlaceMarketOrder(symbol1, symbol2 string, side Side, amount float64) (*Order, error)

func (*Client) PlaceOrder

func (client *Client) PlaceOrder(symbol1, symbol2 string, side Side, amount, price float64) (*Order, error)

func (*Client) Ticker

func (client *Client) Ticker(symbol1, symbol2 string) (*Ticker, error)

type Order

type Order struct {
	Id      string      `json:"id"`
	Time    interface{} `json:"time"`
	Type    string      `json:"type"`
	Price   float64     `json:"price,string"`
	Amount  float64     `json:"amount,string"`
	Pending float64     `json:"pending,string"`
	Symbol1 string      `json:"symbol1"`
	Symbol2 string      `json:"symbol2"`
}

func (*Order) GetTime

func (order *Order) GetTime() (time.Time, error)

func (*Order) Side

func (order *Order) Side() Side

type OrderBook

type OrderBook struct {
	Timestamp int64       `json:"timestamp"`
	Bids      []BookEntry `json:"bids"`
	Asks      []BookEntry `json:"asks"`
	Pair      string      `json:"pair"` // warning: NOT equal to market name
	Id        int64       `json:"id"`
	SellTotal float64     `json:"sell_total,string"`
	BuyTotal  float64     `json:"buy_total,string"`
}

type Orders

type Orders []Order

func (Orders) IndexById

func (orders Orders) IndexById(id string) int

func (Orders) OrderById

func (orders Orders) OrderById(id string) *Order

type Pair

type Pair struct {
	MaxLotSize float64 `json:"maxLotSize"`
	MinLotSize float64 `json:"minLotSize"`
	MaxPrice   float64 `json:"maxPrice,string"`
	MinPrice   float64 `json:"minPrice,string"`
	Symbol1    string  `json:"symbol1"` // 1st listed currency of this market pair
	Symbol2    string  `json:"symbol2"` // 2nd listed currency of this market pair
}

type Side

type Side int
const (
	SIDE_UNKNOWN Side = iota
	BUY
	SELL
)

func NewSide

func NewSide(data string) Side

func (*Side) String

func (side *Side) String() string

type Ticker

type Ticker struct {
	Timestamp int64   `json:"timestamp,string"`
	Low       float64 `json:"low,string"`
	High      float64 `json:"high,string"`
	Last      float64 `json:"last,string"`
	Volume    float64 `json:"volume,string"`
	Volume30d float64 `json:"volume30d,string"`
	Bid       float64 `json:"bid"`
	Ask       float64 `json:"ask"`
}

Jump to

Keyboard shortcuts

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