hitbtc

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: 9 Imported by: 0

Documentation

Overview

Package HitBTC is an implementation of the HitBTC API in Golang.

Index

Constants

View Source
const (
	ORDER_TYPE_LIMIT       = "limit"
	ORDER_TYPE_MARKET      = "market"
	ORDER_TYPE_STOP_LIMIT  = "stopLimit"
	ORDER_TYPE_STOP_MARKET = "stopMarket"
)
View Source
const (
	GTC = "GTC"
	IOC = "IOC"
	FOK = "FOK"
	GTD = "GTD"
)
View Source
const (
	API_BASE = "https://api.hitbtc.com/api/2" // HitBtc API endpoint
)

Variables

View Source
var (
	RequestsPerSecond float64                         = 10
	BeforeRequest     func(method, path string) error = nil
	AfterRequest      func()                          = nil
)

Functions

func NewClient

func NewClient(apiKey, apiSecret string) (c *client)

NewClient return a new HitBtc HTTP client

func NewClientWithCustomHttpConfig

func NewClientWithCustomHttpConfig(apiKey, apiSecret string, httpClient *http.Client) (c *client)

NewClientWithCustomHttpConfig returns a new HitBtc HTTP client using the predefined http client

func NewClientWithCustomTimeout

func NewClientWithCustomTimeout(apiKey, apiSecret string, timeout time.Duration) (c *client)

NewClient returns a new HitBtc HTTP client with custom timeout

Types

type Book

type Book struct {
	Ask []BookEntry `json:"ask"`
	Bid []BookEntry `json:"bid"`
}

type BookEntry

type BookEntry struct {
	Price float64 `json:"price,string"`
	Size  float64 `json:"size,string"`
}

type HitBtc

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

HitBtc represent a HitBTC client

func New

func New(apiKey, apiSecret string) *HitBtc

New returns an instantiated HitBTC struct

func NewWithCustomHttpClient

func NewWithCustomHttpClient(apiKey, apiSecret string, httpClient *http.Client) *HitBtc

NewWithCustomHttpClient returns an instantiated HitBTC struct with custom http client

func NewWithCustomTimeout

func NewWithCustomTimeout(apiKey, apiSecret string, timeout time.Duration) *HitBtc

NewWithCustomTimeout returns an instantiated HitBTC struct with custom timeout

func (*HitBtc) CancelClientOrderId

func (b *HitBtc) CancelClientOrderId(clientOrderId string) (order Order, err error)

func (*HitBtc) CancelOrder

func (b *HitBtc) CancelOrder(currencyPair string) (orders []Order, err error)

func (*HitBtc) GetOpenOrders

func (b *HitBtc) GetOpenOrders(currencyPair string) (orders []Order, err error)

func (*HitBtc) GetOrder

func (b *HitBtc) GetOrder(orderId string) (orders []Order, err error)

func (*HitBtc) GetOrderBook

func (b *HitBtc) GetOrderBook(currencyPair string, limit uint32) (book Book, err error)

func (*HitBtc) GetOrderHistory

func (b *HitBtc) GetOrderHistory() (orders []Order, err error)

func (*HitBtc) GetSymbols

func (b *HitBtc) GetSymbols() (symbols []Symbol, err error)

GetSymbols is used to get the open and available trading markets at HitBtc along with other meta data.

func (*HitBtc) GetTicker

func (b *HitBtc) GetTicker(market string) (ticker Ticker, err error)

GetTicker is used to get the current ticker values for a market.

func (*HitBtc) GetTrades

func (b *HitBtc) GetTrades(currencyPair string) (trades []Trade, err error)

GetTrades used to retrieve your trade history. market string literal for the market (ie. BTC/LTC). If set to "all", will return for all market

func (*HitBtc) PlaceOrder

func (b *HitBtc) PlaceOrder(
	clientOrderId string,
	symbol string,
	side string,
	orderType string,
	timeInForce string,
	quantity float64,
	price float64,
	stopPrice float64,
) (responseOrder Order, err error)

type Order

type Order struct {
	Id            uint64    `json:"id"`
	ClientOrderId string    `json:"clientOrderId"`
	Symbol        string    `json:"symbol"`
	Side          string    `json:"side"`
	Status        string    `json:"status"`
	Type          string    `json:"type"`
	TimeInForce   string    `json:"timeInForce"`
	Quantity      float64   `json:"quantity,string"`
	Price         string    `json:"price,omitempty"`
	CumQuantity   float64   `json:"cumQuantity,string,omitempty"`
	Created       time.Time `json:"createdAt,omitempty"`
	Updated       time.Time `json:"updatedAt,omitempty"`
	StopPrice     string    `json:"stopPrice,omitempty"`
	Expire        time.Time `json:"expireTime,omitempty"`
}

func (*Order) ParsePrice

func (o *Order) ParsePrice() float64

func (*Order) ParseStopPrice

func (o *Order) ParseStopPrice() float64

func (*Order) UnmarshalJSON

func (t *Order) UnmarshalJSON(data []byte) error

type Symbol

type Symbol struct {
	Id                   string  `json:"id"`
	BaseCurrency         string  `json:"baseCurrency"`
	QuoteCurrency        string  `json:"quoteCurrency"`
	QuantityIncrement    float64 `json:"quantityIncrement,string"`
	TickSize             float64 `json:"tickSize,string"`
	TakeLiquidityRate    float64 `json:"takeLiquidityRate,string"`
	ProvideLiquidityRate float64 `json:"provideLiquidityRate,string"`
	FeeCurrency          string  `json:"feeCurrency"`
}

type Ticker

type Ticker struct {
	Ask         float64   `json:"ask,string"`
	Bid         float64   `json:"bid,string"`
	Last        float64   `json:"last,string"`
	Open        float64   `json:"open,string"`
	Low         float64   `json:"low,string"`
	High        float64   `json:"high,string"`
	Volume      float64   `json:"volume,string"`
	VolumeQuote float64   `json:"volumeQuote,string"`
	Timestamp   time.Time `json:"timestamp"`
	Symbol      string    `json:"symbol"`
}

func (*Ticker) UnmarshalJSON

func (t *Ticker) UnmarshalJSON(data []byte) error

type Trade

type Trade struct {
	Id            uint64    `json:"id"`
	OrderId       uint64    `json:"orderId"`
	ClientOrderId string    `json:"clientOrderId"`
	Symbol        string    `json:"symbol"`
	Side          string    `json:"side"`
	Price         float64   `json:"price,string"`
	Quantity      float64   `json:"quantity,string"`
	Fee           float64   `json:"fee,string"`
	Timestamp     time.Time `json:"timestamp"`
}

func (*Trade) UnmarshalJSON

func (t *Trade) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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