bittrex

package
v0.0.0-...-f14c41b Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2018 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

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

Index

Constants

View Source
const (
	API_BASE    = "https://bittrex.com/api/" // Bittrex API endpoint
	API_VERSION = "v1.1"
	WS_BASE     = "socket.bittrex.com" // Bittrex WS API endpoint
	WS_HUB      = "CoreHub"            // SignalR main hub
)
View Source
const (
	BittrexWebURL               = "https://Bittrex.com"
	BittrexWebTradingEndpoint   = "tradingApi"
	BittrexWebVersion           = "1"
	BittrexTradeHistory         = "returnTradeHistory"
	BittrexBalances             = "returnBalances"
	BittrexBalancesComplete     = "returnCompleteBalances"
	BittrexDepositAddresses     = "returnDepositAddresses"
	BittrexGenerateNewAddress   = "generateNewAddress"
	BittrexDepositsWithdrawals  = "returnDepositsWithdrawals"
	BittrexOrders               = "returnOpenOrders"
	BittrexOrderBuy             = "buy"
	BittrexOrderSell            = "sell"
	BittrexOrderCancel          = "cancelOrder"
	BittrexOrderMove            = "moveOrder"
	BittrexWithdraw             = "withdraw"
	BittrexFeeInfo              = "returnFeeInfo"
	BittrexAvailableBalances    = "returnAvailableAccountBalances"
	BittrexTradableBalances     = "returnTradableBalances"
	BittrexTransferBalance      = "transferBalance"
	BittrexMarginAccountSummary = "returnMarginAccountSummary"
	BittrexMarginBuy            = "marginBuy"
	BittrexMarginSell           = "marginSell"
	BittrexMarginPosition       = "getMarginPosition"
	BittrexMarginPositionClose  = "closeMarginPosition"
	BittrexCreateLoanOffer      = "createLoanOffer"
	BittrexCancelLoanOffer      = "cancelLoanOffer"
	BittrexOpenLoanOffers       = "returnOpenLoanOffers"
	BittrexActiveLoans          = "returnActiveLoans"
	BittrexLendingHistory       = "returnLendingHistory"
	BittrexAutoRenew            = "toggleAutoRenew"

	BittrexAuthRate   = 6
	BittrexUnauthRate = 6
)
View Source
const TIME_FORMAT = "2006-01-02T15:04:05"

Variables

View Source
var (
	API_KEY    = ""
	API_SECRET = ""
)
View Source
var CANDLE_INTERVALS = map[string]bool{
	"oneMin":    true,
	"fiveMin":   true,
	"thirtyMin": true,
	"hour":      true,
	"day":       true,
}

Functions

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)

NewClient returns a new Bittrex HTTP client with custom timeout

Types

type BalanceD

type BalanceD struct {
	BalanceD decimal.Decimal `json:"Balance"`
}

type Bittrex

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

Bittrex struct

func NewBittrex

func NewBittrex() *Bittrex

func (*Bittrex) BuyLimit

func (b *Bittrex) BuyLimit(market string, quantity, rate decimal.Decimal) (uuid string, err error)

BuyLimit is used to place a limited buy order in a specific market.

func (*Bittrex) CancelOrder

func (b *Bittrex) CancelOrder(orderID string) (err error)

CancelOrder is used to cancel a buy or sell order.

func (*Bittrex) Done

func (b *Bittrex) Done()

Done ...

func (*Bittrex) GetBalance

func (b *Bittrex) GetBalance(currency string) (balance btBalance, err error)

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

func (b *Bittrex) GetBalances() (balances []btBalance, err error)

GetBalances is used to retrieve all balances from your account

func (*Bittrex) GetCurrencies

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

GetCurrencies is used to get all supported currencies at Bittrex along with other meta data.

func (*Bittrex) GetCurrencyByName

func (b *Bittrex) GetCurrencyByName(name string) *common.Currency

func (*Bittrex) GetDepositAddress

func (b *Bittrex) GetDepositAddress(currency string) (address btAddress, err error)

GetDepositAddress is sed to generate or retrieve an address for a specific currency. currency a string literal for the currency (ie. BTC)

func (*Bittrex) GetDepositHistory

func (b *Bittrex) GetDepositHistory(currency string) (deposits []btDeposit, err error)

GetDepositHistory is used to retrieve your deposit history currency string a string literal for the currency (ie. BTC). If set to "all", will return for all currencies

func (*Bittrex) GetDistribution

func (b *Bittrex) GetDistribution(market string) (distribution btDistribution, err error)

GetDistribution is used to get the distribution.

func (*Bittrex) GetLatestTick

func (b *Bittrex) GetLatestTick(market string, interval string) ([]btCandle, error)

GetLatestTick returns array with a single element latest candle object

func (*Bittrex) GetMarketHistory

func (b *Bittrex) GetMarketHistory(market string) (trades []btTrade, err error)

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 []btMarketSummary, 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 []btMarketSummary, err error)

GetMarketSummary is used to get the last 24 hour summary for a given market

func (*Bittrex) GetMarkets

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

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

func (*Bittrex) GetOpenOrders

func (b *Bittrex) GetOpenOrders(market string) (openOrders []btOrder, err error)

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) GetOrder

func (b *Bittrex) GetOrder(order_uuid string) (order btOrder2, err error)

func (*Bittrex) GetOrderBook

func (b *Bittrex) GetOrderBook(market, cat string) (orderBook btOrderBook, 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, cat string) (orderb []Orderb, 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) GetOrderHistory

func (b *Bittrex) GetOrderHistory(market string) (orders []btOrder, err error)

GetOrderHistory used to retrieve your order history. market string literal for the market (ie. BTC-LTC). If set to "all", will return for all market

func (*Bittrex) GetTicker

func (b *Bittrex) GetTicker(market string) (ticker btTicker, err error)

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

func (*Bittrex) GetTicks

func (b *Bittrex) GetTicks(market string, interval string) ([]btCandle, error)

GetTicks is used to get ticks history values for a market. Interval can be -> ["oneMin", "fiveMin", "thirtyMin", "hour", "day"]

func (*Bittrex) GetWithdrawalHistory

func (b *Bittrex) GetWithdrawalHistory(currency string) (withdrawals []btWithdrawal, err error)

GetWithdrawalHistory is used to retrieve your withdrawal history currency string a string literal for the currency (ie. BTC). If set to "all", will return for all currencies

func (*Bittrex) Logf

func (b *Bittrex) Logf(format string, v ...interface{})

func (*Bittrex) Logln

func (b *Bittrex) Logln(v ...interface{})

func (*Bittrex) NewLogger

func (b *Bittrex) NewLogger()

func (*Bittrex) Panic

func (b *Bittrex) Panic(v ...interface{})

func (*Bittrex) Panicf

func (b *Bittrex) Panicf(format string, v ...interface{})

func (*Bittrex) SellLimit

func (b *Bittrex) SellLimit(market string, quantity, rate decimal.Decimal) (uuid string, err error)

SellLimit is used to place a limited sell order in a specific market.

func (*Bittrex) SetDebug

func (b *Bittrex) SetDebug(enable bool)

set enable/disable http request/response dump

func (*Bittrex) Setup

func (b *Bittrex) Setup() error

Setup prepares the basic data for startup and main duty loop

func (*Bittrex) Start

func (b *Bittrex) Start(wg *sync.WaitGroup)

Start ...

func (*Bittrex) Stop

func (b *Bittrex) Stop()

Stop ...

func (*Bittrex) SubscribeExchangeUpdate

func (b *Bittrex) SubscribeExchangeUpdate(market string, dataCh chan<- ExchangeState, stop <-chan bool) error

SubscribeExchangeUpdate subscribes for updates of the market. Updates will be sent to dataCh. To stop subscription, send to, or close 'stop'.

func (*Bittrex) Withdraw

func (b *Bittrex) Withdraw(address, currency string, quantity decimal.Decimal) (withdrawUuid string, 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

type CandleTime

type CandleTime struct {
	time.Time
}

func (*CandleTime) UnmarshalJSON

func (t *CandleTime) UnmarshalJSON(b []byte) error

type ExchangeState

type ExchangeState struct {
	MarketName string
	Nounce     int
	Buys       []OrderUpdate
	Sells      []OrderUpdate
	Fills      []Fill
	Initial    bool
}

ExchangeState contains fills and order book updates for a market.

type Fill

type Fill struct {
	Orderb
	OrderType string
	Timestamp jTime
}

type OrderUpdate

type OrderUpdate struct {
	Orderb
	Type int
}

type Orderb

type Orderb struct {
	Quantity decimal.Decimal `json:"Quantity"`
	Rate     decimal.Decimal `json:"Rate"`
}

type Uuid

type Uuid struct {
	Id string `json:"uuid"`
}

Jump to

Keyboard shortcuts

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