bittrex

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2022 License: MIT Imports: 21 Imported by: 1

Documentation

Overview

Package bittrex is an implementation of the Biitrex API in Golang.

Index

Constants

View Source
const (
	API_BASE    = "https://api.bittrex.com/" // HTTP API endpoint
	API_VERSION = "v3"                       // API version
)
View Source
const (
	CANDLETYPE_TRADE    = "TRADE"
	CANDLETYPE_MIDPOINT = "MIDPOINT"

	INTERVAL_DAY1    = "DAY_1"
	INTERVAL_HOUR1   = "HOUR_1"
	INTERVAL_MINUTE5 = "MINUTE_5"
	INTERVAL_MINUTE1 = "MINUTE_1"
)
View Source
const (
	WS_BASE = "socket-v3.bittrex.com" // WS API endpoint
	WS_HUB  = "C3"                    // SignalR main hub

	STREAM_CANDLE          = "candle"
	STREAM_ORDERBOOK       = "orderBook"
	STREAM_TICKER          = "ticker"
	STREAM_TICKERS         = "tickers"
	STREAM_MARKETSUMMARIES = "marketSummaries"
	STREAM_MARKETSUMMARY   = "marketSummary"
	STREAM_ORDER           = "order"
	STREAM_TRADE           = "trade"
	STREAM_HEARTBEAT       = "heartbeat"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Bittrex

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

func New

func New(apiKey, apiSecret string) *Bittrex

New returns an instantiated bittrex struct

func NewWithCustomHTTPClient

func NewWithCustomHTTPClient(apiKey, apiSecret string, httpClient *http.Client) *Bittrex

NewWithCustomHTTPClient returns an instantiated bittrex struct with custom http client

func NewWithCustomTimeout

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

NewWithCustomTimeout returns an instantiated bittrex struct with custom timeout

func (*Bittrex) Authentication

func (b *Bittrex) Authentication(c *signalr.Client) error

Some streams contain private data and require that you be authenticated prior to subscribing.

func (*Bittrex) GetCandles added in v0.1.4

func (b *Bittrex) GetCandles(marketSymbol string, candleInterval string) (candles []Candle, err error)

Retrieve recent candles for a specific market and candle interval.

The maximum age of the returned candles depends on the interval as follows:
(MINUTE_1: 1 day, MINUTE_5: 1 day, HOUR_1: 31 days, DAY_1: 366 days).
Candles for intervals without any trading activity will match the previous close and volume will be zero.

func (*Bittrex) GetCandlesHistory added in v0.1.4

func (b *Bittrex) GetCandlesHistory(marketSymbol string, candleInterval string, year int) (candles []Candle, err error)

Retrieve recent candles for a specific market and candle interval.

The date range of returned candles depends on the interval as follows:
(MINUTE_1: 1 day, MINUTE_5: 1 day, HOUR_1: 31 days, DAY_1: 366 days).
Candles for intervals without any trading activity will match the previous close and volume will be zero.

func (*Bittrex) GetCandlesHistoryWithOpts added in v0.1.4

func (b *Bittrex) GetCandlesHistoryWithOpts(marketSymbol string, candleInterval string, year int, opts *GetCandlesHistoryOpts) (candles []Candle, err error)

Retrieve recent candles for a specific market and candle interval.

The date range of returned candles depends on the interval as follows:
(MINUTE_1: 1 day, MINUTE_5: 1 day, HOUR_1: 31 days, DAY_1: 366 days).
Candles for intervals without any trading activity will match the previous close and volume will be zero.

func (*Bittrex) GetCandlesWithOpts added in v0.1.4

func (b *Bittrex) GetCandlesWithOpts(marketSymbol string, candleInterval string, opts *GetCandlesOpts) (candles []Candle, err error)

Retrieve recent candles for a specific market and candle interval.

The maximum age of the returned candles depends on the interval as follows:
(MINUTE_1: 1 day, MINUTE_5: 1 day, HOUR_1: 31 days, DAY_1: 366 days).
Candles for intervals without any trading activity will match the previous close and volume will be zero.

func (*Bittrex) GetCurrencies added in v0.1.4

func (b *Bittrex) GetCurrencies() (currencies []Currency, err error)

List currencies.

func (*Bittrex) GetCurrency

func (b *Bittrex) GetCurrency(symbol string) (currency Currency, err error)

Retrieve info on a specified currency.

func (*Bittrex) GetMarket added in v0.1.4

func (b *Bittrex) GetMarket(marketSymbol string) (market Market, err error)

Retrieve the ticker for a specific market.

func (*Bittrex) GetMarkets

func (b *Bittrex) GetMarkets() (markets []Market, err error)

List markets.

func (*Bittrex) GetMarketsSummaries added in v0.1.4

func (b *Bittrex) GetMarketsSummaries() (marketSummaries []MarketSummary, err error)

List summaries of the last 24 hours of activity for all markets.

func (*Bittrex) GetMarketsTickers added in v0.1.4

func (b *Bittrex) GetMarketsTickers() (marketTickers []Ticker, err error)

List tickers for all markets.

func (*Bittrex) GetOrderBook added in v0.1.4

func (b *Bittrex) GetOrderBook(marketSymbol string) (orderBook OrderBook, err error)

Retrieve the order book for a specific market.

func (*Bittrex) GetOrderBookWithOpts added in v0.1.4

func (b *Bittrex) GetOrderBookWithOpts(marketSymbol string, opts *GetOrderBookOpts) (orderBook OrderBook, err error)

Retrieve the order book for a specific market.

func (*Bittrex) GetSummary added in v0.1.4

func (b *Bittrex) GetSummary(marketSymbol string) (marketSummary MarketSummary, err error)

Retrieve summary of the last 24 hours of activity for a specific market.

func (*Bittrex) GetTicker added in v0.1.4

func (b *Bittrex) GetTicker(marketSymbol string) (ticker Ticker, err error)

Retrieve the ticker for a specific market.

func (*Bittrex) GetTrades added in v0.1.4

func (b *Bittrex) GetTrades(marketSymbol string) (trades []Trade, err error)

Retrieve the recent trades for a specific market.

func (*Bittrex) Ping added in v0.1.4

func (b *Bittrex) Ping() (serverTime int64, err error)

Pings the service

func (*Bittrex) SetDebug

func (b *Bittrex) SetDebug(enable bool)

SetDebug set enable/disable http request/response dump

func (*Bittrex) SubscribeCandleUpdates added in v0.1.5

func (b *Bittrex) SubscribeCandleUpdates(market string, candles chan<- Candle, stop <-chan bool) error

Sends a message at the start of each candle (based on the subscribed interval) and when trades have occurred on the market.

Note that this means on an active market you will receive many updates over the course of each candle interval as trades occur.
You will always receive an update at the start of each interval.
If no trades occurred yet, this update will be a 0-volume placeholder that carries forward the Close of the previous interval as the current interval's OHLC values.

func (*Bittrex) SubscribeCandleUpdatesWithOpts added in v0.1.5

func (b *Bittrex) SubscribeCandleUpdatesWithOpts(market string, candleInterval string, candles chan<- Candle, stop <-chan bool) error

Sends a message at the start of each candle (based on the subscribed interval) and when trades have occurred on the market.

Note that this means on an active market you will receive many updates over the course of each candle interval as trades occur.
You will always receive an update at the start of each interval.
If no trades occurred yet, this update will be a 0-volume placeholder that carries forward the Close of the previous interval as the current interval's OHLC values.

func (*Bittrex) SubscribeMarketSummariesUpdates added in v0.1.5

func (b *Bittrex) SubscribeMarketSummariesUpdates(marketSummaries chan<- MarketSummary, stop <-chan bool) error

Provides regular updates of the current market summary data for all markets.

Market summary data is different from candles in that it is a rolling 24-hour number as opposed to data for a fixed interval like candles.

func (*Bittrex) SubscribeMarketSummaryUpdates added in v0.1.5

func (b *Bittrex) SubscribeMarketSummaryUpdates(market string, marketSummaries chan<- MarketSummary, stop <-chan bool) error

Provides regular updates of the current market summary data for a given market.

Market summary data is different from candles in that it is a rolling 24-hour number as opposed to data for a fixed interval like candles.

func (*Bittrex) SubscribeOrderbookUpdates added in v0.1.4

func (b *Bittrex) SubscribeOrderbookUpdates(marketSymbol string, orderbooks chan<- OrderBook, stop <-chan bool) error

Sends a message when there are changes to the order book within the subscribed depth.

func (*Bittrex) SubscribeOrderbookUpdatesWithOpts added in v0.1.5

func (b *Bittrex) SubscribeOrderbookUpdatesWithOpts(marketSymbol string, depth int, orderbooks chan<- OrderBook, stop <-chan bool) error

Sends a message when there are changes to the order book within the subscribed depth.

func (*Bittrex) SubscribeTickerUpdates added in v0.1.4

func (b *Bittrex) SubscribeTickerUpdates(marketSymbol string, tickers chan<- Ticker, stop <-chan bool) error

Sends a message with the best bid and ask price for the given market as well as the last trade price whenever there is a relevant change to the order book or a trade.

func (*Bittrex) SubscribeTickersUpdates added in v0.1.5

func (b *Bittrex) SubscribeTickersUpdates(tickers chan<- Ticker, stop <-chan bool) error

Sends a message with the best bid price, best ask price, and last trade price for all markets as there are changes to the order book or trades.

func (*Bittrex) SubscribeTradeUpdates

func (b *Bittrex) SubscribeTradeUpdates(marketSymbol string, trades chan<- Trade, stop <-chan bool) error

Sends a message with the quantity and rate of trades on a market as they occur.

type Candle added in v0.1.4

type Candle struct {
	MarketSymbol string
	Interval     string
	StartsAt     time.Time       `json:"startsAt"`
	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"`
	QuoteVolume  decimal.Decimal `json:"quoteVolume"`
}

type CandleSlice added in v0.1.5

type CandleSlice struct {
	Sequence     int    `json:"sequence"`
	MarketSymbol string `json:"marketSymbol"`
	Interval     string `json:"interval"`
	Delta        struct {
		StartsAt    time.Time       `json:"startsAt"`
		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"`
		QuoteVolume decimal.Decimal `json:"quoteVolume"`
	}
}

type Client

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

func NewClient

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

NewClient return a new Bittrex HTTP client

func NewClientWithCustomHTTPConfig

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

NewClientWithCustomHTTPConfig returns a new Bittrex HTTP client using the predefined http client

func NewClientWithCustomTimeout

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

NewClientWithCustomTimeout returns a new Bittrex HTTP client with custom timeout

type Currency

type Currency struct {
	Symbol                   string        `json:"symbol"`
	Name                     string        `json:"name"`
	CoinType                 string        `json:"coinType"`
	Status                   string        `json:"status"`
	MinConfirmations         int           `json:"minConfirmations"`
	Notice                   string        `json:"notice"`
	TxFee                    string        `json:"txFee"`
	LogoURL                  string        `json:"logoUrl"`
	ProhibitedIn             []interface{} `json:"prohibitedIn"`
	BaseAddress              string        `json:"baseAddress"`
	AssociatedTermsOfService []interface{} `json:"associatedTermsOfService"`
	Tags                     []interface{} `json:"tags"`
}

type GetCandlesHistoryOpts added in v0.1.4

type GetCandlesHistoryOpts struct {
	CandleType   string
	HistoryMonth int
	HistoryDay   int
}

type GetCandlesOpts added in v0.1.4

type GetCandlesOpts struct {
	CandleType string
}

type GetOrderBookOpts added in v0.1.4

type GetOrderBookOpts struct {
	Depth int
}

type Market

type Market struct {
	Symbol                   string          `json:"symbol"`
	BaseCurrencySymbol       string          `json:"baseCurrencySymbol"`
	QuoteCurrencySymbol      string          `json:"quoteCurrencySymbol"`
	MinTradeSize             decimal.Decimal `json:"minTradeSize"`
	Precision                int             `json:"precision"`
	Status                   string          `json:"status"`
	CreatedAt                time.Time       `json:"createdAt"`
	ProhibitedIn             []string        `json:"prohibitedIn"`
	AssociatedTermsOfService []string        `json:"associatedTermsOfService"`
	Tags                     []string        `json:"tags"`
}

type MarketSummary added in v0.1.4

type MarketSummary struct {
	Symbol        string          `json:"symbol"`
	High          decimal.Decimal `json:"high"`
	Low           decimal.Decimal `json:"low"`
	Volume        decimal.Decimal `json:"volume"`
	QuoteVolume   decimal.Decimal `json:"quoteVolume"`
	PercentChange decimal.Decimal `json:"percentChange"`
	UpdatedAt     time.Time       `json:"updatedAt"`
}

type MarketSummarySlice added in v0.1.5

type MarketSummarySlice struct {
	Sequence int `json:"sequence"`
	Deltas   []struct {
		Symbol        string          `json:"symbol"`
		High          decimal.Decimal `json:"high"`
		Low           decimal.Decimal `json:"low"`
		Volume        decimal.Decimal `json:"volume"`
		QuoteVolume   decimal.Decimal `json:"quoteVolume"`
		PercentChange decimal.Decimal `json:"percentChange"`
		UpdatedAt     time.Time       `json:"updatedAt"`
	}
}

type Order added in v0.1.4

type Order struct {
	Quantity decimal.Decimal `json:"quantity"`
	Rate     decimal.Decimal `json:"rate"`
}

type OrderBook added in v0.1.4

type OrderBook struct {
	Symbol string
	Depth  int
	Bid    []Order `json:"bid"`
	Ask    []Order `json:"ask"`
}

type OrderBookSlice added in v0.1.4

type OrderBookSlice struct {
	MarketSymbol string  `json:"marketSymbol"`
	Depth        int     `json:"depth"`
	Sequence     int     `json:"sequence"`
	BidDeltas    []Order `json:"bidDeltas"`
	AskDeltas    []Order `json:"askDeltas"`
}

type Ping added in v0.1.4

type Ping struct {
	ServerTime int64 `json:"serverTime"`
}

type Response added in v0.1.4

type Response struct {
	Success   bool        `json:"Success"`
	ErrorCode interface{} `json:"ErrorCode"`
}

type Ticker added in v0.1.4

type Ticker struct {
	Symbol        string          `json:"symbol"`
	LastTradeRate decimal.Decimal `json:"lastTradeRate"`
	BidRate       decimal.Decimal `json:"bidRate"`
	AskRate       decimal.Decimal `json:"askRate"`
}

type TickerSlice added in v0.1.5

type TickerSlice struct {
	Sequence int `json:"sequence"`
	Deltas   []struct {
		Symbol        string          `json:"symbol"`
		LastTradeRate decimal.Decimal `json:"lastTradeRate"`
		BidRate       decimal.Decimal `json:"bidRate"`
		AskRate       decimal.Decimal `json:"askRate"`
	}
}

type Trade

type Trade struct {
	Symbol     string
	ID         string          `json:"id"`
	ExecutedAt time.Time       `json:"executedAt"`
	Quantity   decimal.Decimal `json:"quantity"`
	Rate       decimal.Decimal `json:"rate"`
	TakerSide  string          `json:"takerSide"`
}

type TradeSlice

type TradeSlice struct {
	Deltas []struct {
		ID         string          `json:"id"`
		ExecutedAt time.Time       `json:"executedAt"`
		Quantity   decimal.Decimal `json:"quantity"`
		Rate       decimal.Decimal `json:"rate"`
		TakerSide  string          `json:"takerSide"`
	} `json:"deltas"`
	Sequence     int    `json:"sequence"`
	MarketSymbol string `json:"marketSymbol"`
}

Jump to

Keyboard shortcuts

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