Documentation ¶
Overview ¶
Package Bittrex is an implementation of the Biitrex API in Golang.
Index ¶
- Constants
- Variables
- func NewClient(apiKey, apiSecret string) (c *client)
- func NewClientWithCustomHttpConfig(apiKey, apiSecret string, httpClient *http.Client) (c *client)
- func NewClientWithCustomTimeout(apiKey, apiSecret string, timeout time.Duration) (c *client)
- type Address
- type AddressParams
- type AddressV3
- type Balance
- type BalanceD
- type BalanceUpdate
- type BalanceV3
- type Bittrex
- func (b *Bittrex) Authentication(c *signalr.Client) error
- func (b *Bittrex) BuyLimit(market string, quantity, rate decimal.Decimal) (uuid string, err error)
- func (b *Bittrex) CancelOrder(orderID string) (order OrderV3, err error)
- func (b *Bittrex) CreateOrder(params CreateOrderParams) (order OrderV3, err error)
- func (b *Bittrex) GetBalance(currency string) (balance Balance, err error)
- func (b *Bittrex) GetBalances() (balances []BalanceV3, err error)
- func (b *Bittrex) GetClosedDepositHistory(currency string, status DepositStatus) (deposits []DepositV3, err error)
- func (b *Bittrex) GetClosedOrders(market string) (closedOrders []OrderV3, err error)
- func (b *Bittrex) GetClosedWithdrawals(currency string, status WithdrawalStatus) (withdrawals []WithdrawalV3, err error)
- func (b *Bittrex) GetCurrencies() (currencies []CurrencyV3, err error)
- func (b *Bittrex) GetCurrency(symbol string) (currencies CurrencyV3, err error)
- func (b *Bittrex) GetDepositAddress(currency string) (address AddressV3, err error)
- func (b *Bittrex) GetDistribution(market string) (distribution Distribution, err error)
- func (b *Bittrex) GetLatestTick(market string, interval string) ([]Candle, error)
- func (b *Bittrex) GetMarketHistory(market string) (trades []TradeV3, err error)
- func (b *Bittrex) GetMarketSummaries() (marketSummaries []MarketSummaryV3, err error)
- func (b *Bittrex) GetMarketSummary(market string) (marketSummary MarketSummaryV3, err error)
- func (b *Bittrex) GetMarkets() (markets []MarketV3, err error)
- func (b *Bittrex) GetOpenDepositHistory(currency string, status DepositStatus) (deposits []DepositV3, err error)
- func (b *Bittrex) GetOpenOrders(market string) (openOrders []OrderV3, err error)
- func (b *Bittrex) GetOpenWithdrawals(currency string, status WithdrawalStatus) (withdrawals []WithdrawalV3, err error)
- func (b *Bittrex) GetOrder(order_uuid string) (order Order2, err error)
- func (b *Bittrex) GetOrderBook(market string, depth int32, cat string) (orderBook OrderBookV3, err error)
- func (b *Bittrex) GetOrderBookBuySell(market string, depth int32, cat string) (orderb []OrderbV3, err error)
- func (b *Bittrex) GetTicker(market string) (ticker []TickerV3, err error)
- func (b *Bittrex) GetTicks(market string, interval string) ([]Candle, error)
- func (b *Bittrex) GetWithdrawalByTxId(txid string) (withdrawal WithdrawalV3, err error)
- func (c *Bittrex) SetDebug(enable bool)
- func (b *Bittrex) SubscribeBalanceUpdates(dataCh chan<- BalanceUpdate) error
- func (b *Bittrex) SubscribeOrderUpdates(dataCh chan<- OrderUpdate) error
- func (b *Bittrex) SubscribeOrderbookUpdates(market string, orderbook chan<- OrderBook, stop chan bool) error
- func (b *Bittrex) SubscribeTickerUpdates(market string, ticker chan<- Ticker) error
- func (b *Bittrex) Withdraw(address, currency string, quantity decimal.Decimal, tag string) (withdraw WithdrawalV3, err error)
- type Candle
- type CandleTime
- type CreateOrderParams
- type Currency
- type CurrencyV3
- type Deposit
- type DepositHistoryParams
- type DepositStatus
- type DepositV3
- type Distribution
- type Market
- type MarketSummary
- type MarketSummaryV3
- type MarketV3
- type NewCandles
- type NewOrder
- type Order
- type Order2
- type OrderBook
- type OrderBookV3
- type OrderData
- type OrderDirection
- type OrderType
- type OrderUpdate
- type OrderV3
- type Orderb
- type OrderbV3
- type OrderbookUpdate
- type Responce
- type Ticker
- type TickerV3
- type TimeInForce
- type Trade
- type TradeV3
- type Uuid
- type Withdrawal
- type WithdrawalHistoryParams
- type WithdrawalParams
- type WithdrawalStatus
- type WithdrawalV3
Constants ¶
const ( API_BASE = "https://api.bittrex.com/" // Bittrex API endpoint API_VERSION = "v3" WS_BASE = "socket-v3.bittrex.com" // Bittrex WS API endpoint WS_HUB = "c3" // SignalR main hub //ORDERBOOK const BALANCE = "balance" //ORDERBOOK const ORDERBOOK = "orderBook" //TICKER const TICKER = "ticker" //ORDER const ORDER = "order" //TRADE const TRADE = "trade" //HEARTBEAT const HEARTBEAT = "heartbeat" //AUTHEXPIRED const AUTHEXPIRED = "authenticationExpiring" )
const TIME_FORMAT = "2006-01-02T15:04:05"
Variables ¶
var ( ERR_ORDER_MISSING_PARAMETERS = errors.New("missing parameters. make sure (type, market_symbol, direction, time_in_force) are set") ERR_WITHDRAWAL_MISSING_PARAMETERS = errors.New("missing parameters. make sure (address, currency, quantity) are set") )
Functions ¶
func NewClient ¶
func NewClient(apiKey, apiSecret string) (c *client)
NewClient return a new Bittrex HTTP client
func NewClientWithCustomHttpConfig ¶
NewClientWithCustomHttpConfig returns a new Bittrex HTTP client using the predefined http client
func NewClientWithCustomTimeout ¶
NewClientWithCustomTimeout returns a new Bittrex HTTP client with custom timeout
Types ¶
type AddressParams ¶
type AddressParams struct {
CurrencySymbol string `json:"currencySymbol"`
}
type BalanceUpdate ¶
type BalanceUpdate struct { AccountID string `json:"accountId"` Sequence int `json:"sequence"` Delta struct { CurrencySymbol string `json:"currencySymbol"` Total decimal.Decimal `json:"total"` Available decimal.Decimal `json:"available"` UpdatedAt *jTime `json:"updatedAt"` } `json:"delta"` }
BalanceUpdate struct
type Bittrex ¶
type Bittrex struct {
// contains filtered or unexported fields
}
bittrex represent a bittrex client
func NewWithCustomHttpClient ¶
NewWithCustomHttpClient returns an instantiated bittrex struct with custom http client
func NewWithCustomTimeout ¶
NewWithCustomTimeout returns an instantiated bittrex struct with custom timeout
func (*Bittrex) Authentication ¶
Authentication func
func (*Bittrex) CancelOrder ¶
CancelOrder is used to cancel a buy or sell order.
func (*Bittrex) CreateOrder ¶
func (b *Bittrex) CreateOrder(params CreateOrderParams) (order OrderV3, err error)
CreateOrder is used to create any type of supported order.
func (*Bittrex) GetBalance ¶
Getbalance is used to retrieve the balance from your account for a specific currency. currency: a string literal for the currency (ex: LTC)
func (*Bittrex) GetBalances ¶
GetBalances is used to retrieve all balances from your account
func (*Bittrex) GetClosedDepositHistory ¶
func (b *Bittrex) GetClosedDepositHistory(currency string, status DepositStatus) (deposits []DepositV3, err error)
GetClosedDepositHistory is used to retrieve your closed deposit history currency string a string literal for the currency (ie. BTC). If set to "all", will return for all currencies
func (*Bittrex) GetClosedOrders ¶
GetClosedOrders returns orders that you currently have opened. If market is set to "all", GetClosedOrders return all orders If market is set to a specific order, GetClosedOrders return orders for this market
func (*Bittrex) GetClosedWithdrawals ¶
func (b *Bittrex) GetClosedWithdrawals(currency string, status WithdrawalStatus) (withdrawals []WithdrawalV3, err error)
GetClosedWithdrawals is used to retrieve your closed withdrawal history currency string a string literal for the currency (ie. BTC). If set to "all", will return for all currencies TODO Add more parameters according to https://bittrex.github.io/api/v3#operation--withdrawals-closed-get
func (*Bittrex) GetCurrencies ¶
func (b *Bittrex) GetCurrencies() (currencies []CurrencyV3, err error)
GetCurrencies is used to get all supported currencies at Bittrex along with other meta data.
func (*Bittrex) GetCurrency ¶
func (b *Bittrex) GetCurrency(symbol string) (currencies CurrencyV3, err error)
GetCurrency is used to get information of a single currency at Bittrex along with other meta data.
func (*Bittrex) GetDepositAddress ¶
GetDepositAddress is sed to generate or retrieve an address for a specific currency. currency a string literal for the currency (ie. BTC)
func (*Bittrex) GetDistribution ¶
func (b *Bittrex) GetDistribution(market string) (distribution Distribution, err error)
GetDistribution is used to get the distribution.
func (*Bittrex) GetLatestTick ¶
GetLatestTick returns array with a single element latest candle object
func (*Bittrex) GetMarketHistory ¶
GetMarketHistory is used to retrieve the latest trades that have occured for a specific market. market a string literal for the market (ex: BTC-LTC)
func (*Bittrex) GetMarketSummaries ¶
func (b *Bittrex) GetMarketSummaries() (marketSummaries []MarketSummaryV3, err error)
GetMarketSummaries is used to get the last 24 hour summary of all active exchanges
func (*Bittrex) GetMarketSummary ¶
func (b *Bittrex) GetMarketSummary(market string) (marketSummary MarketSummaryV3, err error)
GetMarketSummary is used to get the last 24 hour summary for a given market
func (*Bittrex) GetMarkets ¶
GetMarkets is used to get the open and available trading markets at Bittrex along with other meta data.
func (*Bittrex) GetOpenDepositHistory ¶
func (b *Bittrex) GetOpenDepositHistory(currency string, status DepositStatus) (deposits []DepositV3, err error)
GetOpenDepositHistory is used to retrieve your open deposit history currency string a string literal for the currency (ie. BTC). If set to "all", will return for all currencies
func (*Bittrex) GetOpenOrders ¶
GetOpenOrders returns orders that you currently have opened. If market is set to "all", GetOpenOrders return all orders If market is set to a specific order, GetOpenOrders return orders for this market
func (*Bittrex) GetOpenWithdrawals ¶
func (b *Bittrex) GetOpenWithdrawals(currency string, status WithdrawalStatus) (withdrawals []WithdrawalV3, err error)
GetOpenWithdrawals is used to retrieve your open withdrawal history currency string a string literal for the currency (ie. BTC). If set to "", will return for all currencies
func (*Bittrex) GetOrderBook ¶
func (b *Bittrex) GetOrderBook(market string, depth int32, cat string) (orderBook OrderBookV3, err error)
GetOrderBook is used to get retrieve the orderbook for a given market market: a string literal for the market (ex: BTC-LTC) cat: buy, sell or both to identify the type of orderbook to return.
func (*Bittrex) GetOrderBookBuySell ¶
func (b *Bittrex) GetOrderBookBuySell(market string, depth int32, cat string) (orderb []OrderbV3, err error)
GetOrderBookBuySell is used to get retrieve the buy or sell side of an orderbook for a given market market: a string literal for the market (ex: BTC-LTC) cat: buy or sell to identify the type of orderbook to return.
func (*Bittrex) GetTicker ¶
GetTicker is used to get the current ticker values for a market, if none is specified, returns info for all.
func (*Bittrex) GetTicks ¶
GetTicks is used to get ticks history values for a market. Interval can be -> ["oneMin", "fiveMin", "thirtyMin", "hour", "day"]
func (*Bittrex) GetWithdrawalByTxId ¶
func (b *Bittrex) GetWithdrawalByTxId(txid string) (withdrawal WithdrawalV3, err error)
GetWithdrawalByTxId is used to retrieve information of a withdrawal by txid. txid string a string literal for the on chain transaction id.
func (*Bittrex) SubscribeBalanceUpdates ¶
func (b *Bittrex) SubscribeBalanceUpdates(dataCh chan<- BalanceUpdate) error
SubscribeBalanceUpdates func
func (*Bittrex) SubscribeOrderUpdates ¶
func (b *Bittrex) SubscribeOrderUpdates(dataCh chan<- OrderUpdate) error
SubscribeOrderUpdates func
func (*Bittrex) SubscribeOrderbookUpdates ¶
func (b *Bittrex) SubscribeOrderbookUpdates(market string, orderbook chan<- OrderBook, stop chan bool) error
SubscribeOrderbookUpdates subscribes for updates of the market. Updates will be sent to dataCh. To stop subscription, send to, or close 'stop'.
func (*Bittrex) SubscribeTickerUpdates ¶
SubscribeTickerUpdates subscribes for updates of the market.
func (*Bittrex) Withdraw ¶
func (b *Bittrex) Withdraw(address, currency string, quantity decimal.Decimal, tag string) (withdraw WithdrawalV3, err error)
Withdraw is used to withdraw funds from your account. address string the address where to send the funds. currency string literal for the currency (ie. BTC) quantity decimal.Decimal the quantity of coins to withdraw tag string an optional name for the withdrawal address
type CandleTime ¶
func (*CandleTime) UnmarshalJSON ¶
func (t *CandleTime) UnmarshalJSON(b []byte) error
type CreateOrderParams ¶
type CreateOrderParams struct { MarketSymbol string `json:"marketSymbol"` Direction OrderDirection `json:"direction"` Type OrderType `json:"type"` Quantity decimal.Decimal `json:"quantity"` TimeInForce TimeInForce `json:"timeInForce"` Ceiling float64 `json:"ceiling,omitempty"` Limit float64 `json:"limit,omitempty"` ClientOrderID string `json:"clientOrderId,omitempty"` UseAwards string `json:"useAwards,omitempty"` }
type Currency ¶
type Currency struct { Currency string `json:"Currency"` CurrencyLong string `json:"CurrencyLong"` MinConfirmation int `json:"MinConfirmation"` TxFee decimal.Decimal `json:"TxFee"` IsActive bool `json:"IsActive"` CoinType string `json:"CoinType"` BaseAddress string `json:"BaseAddress"` Notice string `json:"Notice"` }
type CurrencyV3 ¶
type CurrencyV3 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 decimal.Decimal `json:"txFee"` LogoURL string `json:"logoUrl,omitempty"` ProhibitedIn []interface{} `json:"prohibitedIn"` BaseAddress string `json:"baseAddress,omitempty"` AssociatedTermsOfService []interface{} `json:"associatedTermsOfService"` }
type DepositHistoryParams ¶
type DepositStatus ¶
type DepositStatus string
const ( DEPOSIT_PENDING DepositStatus = "PENDING" DEPOSIT_COMPLETED DepositStatus = "COMPLETED" DEPOSIT_ORPHANED DepositStatus = "ORPHANED" DEPOSIT_INVALIDATED DepositStatus = "INVALIDATED" DEPOSIT_ALL DepositStatus = "" )
type DepositV3 ¶
type DepositV3 struct { ID string `json:"id"` CurrencySymbol string `json:"currencySymbol"` Quantity decimal.Decimal `json:"quantity"` CryptoAddress string `json:"cryptoAddress"` CryptoAddressTag string `json:"cryptoAddressTag"` TxID string `json:"txId"` Confirmations int32 `json:"confirmations"` UpdatedAt string `json:"updatedAt"` CompletedAt string `json:"completedAt"` Status string `json:"status"` Source string `json:"source"` }
type Distribution ¶
type Market ¶
type Market struct { MarketCurrency string `json:"MarketCurrency"` BaseCurrency string `json:"BaseCurrency"` MarketCurrencyLong string `json:"MarketCurrencyLong"` BaseCurrencyLong string `json:"BaseCurrencyLong"` MinTradeSize decimal.Decimal `json:"MinTradeSize"` MarketName string `json:"MarketName"` IsActive bool `json:"IsActive"` IsRestricted bool `json:"IsRestricted"` Notice string `json:"Notice"` IsSponsored bool `json:"IsSponsored"` LogoUrl string `json:"LogoUrl"` Created string `json:"Created"` }
type MarketSummary ¶
type MarketSummary struct { MarketName string `json:"MarketName"` High decimal.Decimal `json:"High"` Low decimal.Decimal `json:"Low"` Ask decimal.Decimal `json:"Ask"` Bid decimal.Decimal `json:"Bid"` OpenBuyOrders int `json:"OpenBuyOrders"` OpenSellOrders int `json:"OpenSellOrders"` Volume decimal.Decimal `json:"Volume"` Last decimal.Decimal `json:"Last"` BaseVolume decimal.Decimal `json:"BaseVolume"` PrevDay decimal.Decimal `json:"PrevDay"` TimeStamp string `json:"TimeStamp"` }
type MarketSummaryV3 ¶
type MarketSummaryV3 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 MarketV3 ¶
type MarketV3 struct { Symbol string `json:"symbol"` BaseCurrencySymbol string `json:"baseCurrencySymbol"` QuoteCurrencySymbol string `json:"quoteCurrencySymbol"` MinTradeSize decimal.Decimal `json:"minTradeSize"` Precision int32 `json:"precision"` Status string `json:"status"` CreatedAt time.Time `json:"createdAt"` Notice string `json:"notice"` ProhibitedIn []string `json:"prohibitedIn"` }
type NewCandles ¶
type NewCandles struct {
Ticks []Candle `json:"ticks"`
}
type NewOrder ¶
type NewOrder struct { MarketSymbol string `json:"marketSymbol"` Direction string `json:"direction"` Type string `json:"type"` Quantity string `json:"quantity"` Ceiling string `json:"ceiling,omitempty"` Limit string `json:"limit"` TimeInForce string `json:"timeInForce"` ClientOrderID string `json:"clientOrderId,omitempty"` UseAwards bool `json:"useAwards"` }
NewOrder struct
type Order ¶
type Order struct { Uuid *string OrderUuid string `json:"OrderUuid"` Exchange string `json:"Exchange"` OrderType string `json:"OrderType"` Limit decimal.Decimal `json:"Limit"` Quantity decimal.Decimal `json:"Quantity"` QuantityRemaining decimal.Decimal `json:"QuantityRemaining"` Price decimal.Decimal `json:"Price"` PricePerUnit decimal.Decimal `json:"PricePerUnit"` CommissionPaid decimal.Decimal Opened jTime Closed *jTime CancelInitiated bool ImmediateOrCancel bool IsConditional bool Condition string ConditionTarget decimal.Decimal }
type Order2 ¶
type Order2 struct { AccountId string OrderUuid string `json:"OrderUuid"` Exchange string `json:"Exchange"` Type string Quantity decimal.Decimal `json:"Quantity"` QuantityRemaining decimal.Decimal `json:"QuantityRemaining"` Limit decimal.Decimal `json:"Limit"` Reserved decimal.Decimal ReserveRemaining decimal.Decimal CommissionReserved decimal.Decimal CommissionReserveRemaining decimal.Decimal CommissionPaid decimal.Decimal Price decimal.Decimal `json:"Price"` PricePerUnit decimal.Decimal `json:"PricePerUnit"` Opened jTime Closed *jTime IsOpen bool Sentinel string CancelInitiated bool ImmediateOrCancel bool IsConditional bool Condition string ConditionTarget decimal.Decimal }
For getorder
type OrderBookV3 ¶
type OrderDirection ¶
type OrderDirection string
const ( BUY OrderDirection = "BUY" SELL OrderDirection = "SELL" )
type OrderUpdate ¶
type OrderUpdate struct { AccountID string `json:"accountId"` Sequence int `json:"sequence"` Delta struct { ID string `json:"id"` MarketSymbol string `json:"marketSymbol"` Direction string `json:"direction"` Type string `json:"type"` Quantity string `json:"quantity"` Limit string `json:"limit"` TimeInForce string `json:"timeInForce"` FillQuantity string `json:"fillQuantity"` Commission string `json:"commission"` Proceeds string `json:"proceeds"` Status string `json:"status"` CreatedAt jTime `json:"createdAt"` UpdatedAt *jTime `json:"updatedAt"` ClosedAt *jTime `json:"closedAt"` } `json:"delta"` }
OrderUpdate struct
type OrderV3 ¶
type OrderV3 struct { ID string `json:"id"` MarketSymbol string `json:"marketSymbol"` Direction string `json:"direction"` Type string `json:"type"` Quantity decimal.Decimal `json:"quantity"` Limit decimal.Decimal `json:"limit"` Ceiling decimal.Decimal `json:"ceiling"` TimeInForce string `json:"timeInForce"` ClientOrderID string `json:"clientOrderId"` FillQuantity decimal.Decimal `json:"fillQuantity"` Commission decimal.Decimal `json:"commission"` Proceeds decimal.Decimal `json:"proceeds"` Status string `json:"status"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` ClosedAt time.Time `json:"closedAt"` OrderToCancel OrderData `json:"orderToCancel"` }
type OrderbookUpdate ¶
type OrderbookUpdate struct { AccountID string `json:"accountId"` Sequence int `json:"sequence"` BidDeltas []OrderbV3 `json:"bidDeltas"` AskDeltas []OrderbV3 `json:"askDeltas"` }
OrderbookUpdate struct
type Responce ¶
type Responce struct { Success bool `json:"Success"` ErrorCode interface{} `json:"ErrorCode"` }
Responce struct
type TimeInForce ¶
type TimeInForce string
const ( GOOD_TIL_CANCELLED TimeInForce = "GOOD_TIL_CANCELLED" IMMEDIATE_OR_CANCEL TimeInForce = "IMMEDIATE_OR_CANCEL" FILL_OR_KILL TimeInForce = "FILL_OR_KILL" POST_ONLY_GOOD_TIL_CANCELLED TimeInForce = "POST_ONLY_GOOD_TIL_CANCELLED" BUY_NOW TimeInForce = "BUY_NOW" )
type Trade ¶
type Trade struct { OrderUuid int64 `json:"Id"` Timestamp jTime `json:"TimeStamp"` Quantity decimal.Decimal `json:"Quantity"` Price decimal.Decimal `json:"Price"` Total decimal.Decimal `json:"Total"` FillType string `json:"FillType"` OrderType string `json:"OrderType"` }
Used in getmarkethistory
type Withdrawal ¶
type Withdrawal struct { PaymentUuid string `json:"PaymentUuid"` Currency string `json:"Currency"` Amount decimal.Decimal `json:"Amount"` Address string `json:"Address"` Opened jTime `json:"Opened"` Authorized bool `json:"Authorized"` PendingPayment bool `json:"PendingPayment"` TxCost decimal.Decimal `json:"TxCost"` TxId string `json:"TxId"` Canceled bool `json:"Canceled"` }
type WithdrawalHistoryParams ¶
type WithdrawalParams ¶
type WithdrawalStatus ¶
type WithdrawalStatus string
const ( REQUESTED WithdrawalStatus = "REQUESTED" AUTHORIZED WithdrawalStatus = "AUTHORIZED" PENDING WithdrawalStatus = "PENDING" COMPLETED WithdrawalStatus = "COMPLETED" CANCELLED WithdrawalStatus = "CANCELLED" ERROR_INVALID_ADDRESS WithdrawalStatus = "ERROR_INVALID_ADDRESS" ALL WithdrawalStatus = "" )
type WithdrawalV3 ¶
type WithdrawalV3 struct { ID string `json:"id"` CurrencySymbol string `json:"currencySymbol"` Quantity decimal.Decimal `json:"quantity"` CryptoAddress string `json:"cryptoAddress"` CryptoAddressTag string `json:"cryptoAddressTag"` TxCost decimal.Decimal `json:"txCost"` TxID string `json:"txId"` Status WithdrawalStatus `json:"status"` CreatedAt time.Time `json:"createdAt"` CompletedAt time.Time `json:"completedAt"` }