bittrex

package
v0.0.0-...-4ab53fc Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2021 License: MIT Imports: 18 Imported by: 0

README

GoCryptoTrader package Bittrex

Build Status Software License GoDoc Coverage Status Go Report Card

This bittrex package is part of the GoCryptoTrader codebase.

This is still in active development

You can track ideas, planned features and what's in progresss on this Trello board: https://trello.com/b/ZAhMhpOy/gocryptotrader.

Join our slack to discuss all things related to GoCryptoTrader! GoCryptoTrader Slack

Bittrex Exchange

Current Features
  • REST Support
How to enable
  // Exchanges will be abstracted out in further updates and examples will be
  // supplied then
How to do REST public/private calls
  • If enabled via "configuration".json file the exchange will be added to the IBotExchange array in the go var bot Bot and you will only be able to use the wrapper interface functions for accessing exchange data. View routines.go for an example of integration usage with GoCryptoTrader. Rudimentary example below:

main.go

var b exchange.IBotExchange

for i := range bot.exchanges {
  if bot.exchanges[i].GetName() == "Bittrex" {
    b = bot.exchanges[i]
  }
}

// Public calls - wrapper functions

// Fetches current ticker information
tick, err := b.GetTickerPrice()
if err != nil {
  // Handle error
}

// Fetches current orderbook information
ob, err := b.GetOrderbookEx()
if err != nil {
  // Handle error
}

// Private calls - wrapper functions - make sure your APIKEY and APISECRET are
// set and AuthenticatedAPISupport is set to true

// Fetches current account information
accountInfo, err := b.GetAccountInfo()
if err != nil {
  // Handle error
}
  • If enabled via individually importing package, rudimentary example below:
// Public calls

// Fetches current ticker information
ticker, err := b.GetTicker()
if err != nil {
  // Handle error
}

// Fetches current orderbook information
ob, err := b.GetOrderBook()
if err != nil {
  // Handle error
}

// Private calls - make sure your APIKEY and APISECRET are set and
// AuthenticatedAPISupport is set to true

// GetUserInfo returns account info
accountInfo, err := b.GetUserInfo(...)
if err != nil {
  // Handle error
}

// Submits an order and the exchange and returns its tradeID
tradeID, err := b.Trade(...)
if err != nil {
  // Handle error
}
Please click GoDocs chevron above to view current GoDoc information for this package

Contribution

Please feel free to submit any pull requests or suggest any desired features to be added.

When submitting a PR, please abide by our coding guidelines:

  • Code must adhere to the official Go formatting guidelines (i.e. uses gofmt).
  • Code must be documented adhering to the official Go commentary guidelines.
  • Code must adhere to our coding style.
  • Pull requests need to be based on and opened against the master branch.

Donations

If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:

1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Balance

type Balance struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
	Result  struct {
		Currency      string  `json:"Currency"`
		Balance       float64 `json:"Balance"`
		Available     float64 `json:"Available"`
		Pending       float64 `json:"Pending"`
		CryptoAddress string  `json:"CryptoAddress"`
		Requested     bool    `json:"Requested"`
		UUID          string  `json:"Uuid"`
	} `json:"result"`
}

Balance holds the balance from your account for a specified currency

type Balances

type Balances struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
	Result  []struct {
		Currency      string  `json:"Currency"`
		Balance       float64 `json:"Balance"`
		Available     float64 `json:"Available"`
		Pending       float64 `json:"Pending"`
		CryptoAddress string  `json:"CryptoAddress"`
		Requested     bool    `json:"Requested"`
		UUID          string  `json:"Uuid"`
	} `json:"result"`
}

Balances holds the balance from your account for a specified currency

type Bittrex

type Bittrex struct {
	exchange.Base
}

Bittrex is the overaching type across the bittrex methods

func (*Bittrex) AuthenticateWebsocket

func (b *Bittrex) AuthenticateWebsocket() error

AuthenticateWebsocket sends an authentication message to the websocket

func (*Bittrex) CancelAllOrders

CancelAllOrders cancels all orders associated with a currency pair

func (*Bittrex) CancelExistingOrder

func (b *Bittrex) CancelExistingOrder(uuid string) (Balances, error)

CancelExistingOrder is used to cancel a buy or sell order.

func (*Bittrex) CancelOrder

func (b *Bittrex) CancelOrder(order *exchange.OrderCancellation) error

CancelOrder cancels an order by its corresponding ID number

func (*Bittrex) GetAccountBalanceByCurrency

func (b *Bittrex) GetAccountBalanceByCurrency(currency string) (Balance, error)

GetAccountBalanceByCurrency is used to retrieve the balance from your account for a specific currency. ie. "btc" or "ltc"

func (*Bittrex) GetAccountBalances

func (b *Bittrex) GetAccountBalances() (Balances, error)

GetAccountBalances is used to retrieve all balances from your account

func (*Bittrex) GetAccountInfo

func (b *Bittrex) GetAccountInfo() (exchange.AccountInfo, error)

GetAccountInfo Retrieves balances for all enabled currencies for the Bittrex exchange

func (*Bittrex) GetActiveOrders

func (b *Bittrex) GetActiveOrders(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error)

GetActiveOrders retrieves any orders that are active/open

func (*Bittrex) GetCryptoDepositAddress

func (b *Bittrex) GetCryptoDepositAddress(currency string) (DepositAddress, error)

GetCryptoDepositAddress is used to retrieve or generate an address for a specific currency. If one does not exist, the call will fail and return ADDRESS_GENERATING until one is available.

func (*Bittrex) GetCurrencies

func (b *Bittrex) GetCurrencies() (Currency, error)

GetCurrencies is used to get all supported currencies at Bittrex

func (*Bittrex) GetDepositAddress

func (b *Bittrex) GetDepositAddress(cryptocurrency currency.Code, _ string) (string, error)

GetDepositAddress returns a deposit address for a specified currency

func (*Bittrex) GetDepositHistory

func (b *Bittrex) GetDepositHistory(currency string) (WithdrawalHistory, error)

GetDepositHistory is used to retrieve your deposit history. If currency is is omitted it will return the entire deposit history

func (*Bittrex) GetExchangeHistory

func (b *Bittrex) GetExchangeHistory(p currency.Pair, assetType string) ([]exchange.TradeHistory, error)

GetExchangeHistory returns historic trade data since exchange opening.

func (*Bittrex) GetFee

func (b *Bittrex) GetFee(feeBuilder *exchange.FeeBuilder) (float64, error)

GetFee returns an estimate of fee based on type of transaction

func (*Bittrex) GetFeeByType

func (b *Bittrex) GetFeeByType(feeBuilder *exchange.FeeBuilder) (float64, error)

GetFeeByType returns an estimate of fee based on type of transaction

func (*Bittrex) GetFundingHistory

func (b *Bittrex) GetFundingHistory() ([]exchange.FundHistory, error)

GetFundingHistory returns funding history, deposits and withdrawals

func (*Bittrex) GetMarketHistory

func (b *Bittrex) GetMarketHistory(currencyPair string) (MarketHistory, error)

GetMarketHistory retrieves the latest trades that have occurred for a specific market

func (*Bittrex) GetMarketSummaries

func (b *Bittrex) GetMarketSummaries() (MarketSummary, error)

GetMarketSummaries is used to get the last 24 hour summary of all active exchanges

func (*Bittrex) GetMarketSummary

func (b *Bittrex) GetMarketSummary(currencyPair string) (MarketSummary, error)

GetMarketSummary is used to get the last 24 hour summary of all active exchanges by currency pair (btc-ltc).

func (*Bittrex) GetMarkets

func (b *Bittrex) GetMarkets() (Market, 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(currencyPair string) (Order, error)

GetOpenOrders returns all orders that you currently have opened. A specific market can be requested for example "btc-ltc"

func (*Bittrex) GetOrder

func (b *Bittrex) GetOrder(uuid string) (Order, error)

GetOrder is used to retrieve a single order by UUID.

func (*Bittrex) GetOrderHistory

func (b *Bittrex) GetOrderHistory(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error)

GetOrderHistory retrieves account order information Can Limit response to specific order status

func (*Bittrex) GetOrderHistoryForCurrency

func (b *Bittrex) GetOrderHistoryForCurrency(currencyPair string) (Order, error)

GetOrderHistoryForCurrency is used to retrieve your order history. If currencyPair omitted it will return the entire order History.

func (*Bittrex) GetOrderInfo

func (b *Bittrex) GetOrderInfo(orderID string) (exchange.OrderDetail, error)

GetOrderInfo returns information on a current open order

func (*Bittrex) GetOrderbook

func (b *Bittrex) GetOrderbook(currencyPair string) (OrderBooks, error)

GetOrderbook method returns current order book information by currency, type & depth. "Currency Pair" ie btc-ltc "Category" either "buy", "sell" or "both"; for ease of use and reduced complexity this function is set to "both" "Depth" max depth is 50 but you can literally set it any integer you want and it returns full depth. So depth default is 50.

func (*Bittrex) GetOrderbookEx

func (b *Bittrex) GetOrderbookEx(p currency.Pair, assetType string) (orderbook.Base, error)

GetOrderbookEx returns the orderbook for a currency pair

func (*Bittrex) GetSubscriptions

func (b *Bittrex) GetSubscriptions() ([]wshandler.WebsocketChannelSubscription, error)

GetSubscriptions returns a copied list of subscriptions

func (*Bittrex) GetTicker

func (b *Bittrex) GetTicker(currencyPair string) (Ticker, error)

GetTicker sends a public get request and returns current ticker information on the supplied currency. Example currency input param "btc-ltc".

func (*Bittrex) GetTickerPrice

func (b *Bittrex) GetTickerPrice(p currency.Pair, assetType string) (ticker.Price, error)

GetTickerPrice returns the ticker for a currency pair

func (*Bittrex) GetWebsocket

func (b *Bittrex) GetWebsocket() (*wshandler.Websocket, error)

GetWebsocket returns a pointer to the exchange websocket

func (*Bittrex) GetWithdrawalFee

func (b *Bittrex) GetWithdrawalFee(c currency.Code) (float64, error)

GetWithdrawalFee returns the fee for withdrawing from the exchange

func (*Bittrex) GetWithdrawalHistory

func (b *Bittrex) GetWithdrawalHistory(currency string) (WithdrawalHistory, error)

GetWithdrawalHistory is used to retrieve your withdrawal history. If currency omitted it will return the entire history

func (*Bittrex) ModifyOrder

func (b *Bittrex) ModifyOrder(action *exchange.ModifyOrder) (string, error)

ModifyOrder will allow of changing orderbook placement and limit to market conversion

func (*Bittrex) PlaceBuyLimit

func (b *Bittrex) PlaceBuyLimit(currencyPair string, quantity, rate float64) (UUID, error)

PlaceBuyLimit is used to place a buy order in a specific market. Use buylimit to place limit orders. Make sure you have the proper permissions set on your API keys for this call to work. "Currency" ie "btc-ltc" "Quantity" is the amount to purchase "Rate" is the rate at which to purchase

func (*Bittrex) PlaceSellLimit

func (b *Bittrex) PlaceSellLimit(currencyPair string, quantity, rate float64) (UUID, error)

PlaceSellLimit is used to place a sell order in a specific market. Use selllimit to place limit orders. Make sure you have the proper permissions set on your API keys for this call to work. "Currency" ie "btc-ltc" "Quantity" is the amount to purchase "Rate" is the rate at which to purchase

func (*Bittrex) Run

func (b *Bittrex) Run()

Run implements the Bittrex wrapper

func (*Bittrex) SendAuthenticatedHTTPRequest

func (b *Bittrex) SendAuthenticatedHTTPRequest(path string, values url.Values, result interface{}) (err error)

SendAuthenticatedHTTPRequest sends an authenticated http request to a desired path

func (*Bittrex) SendHTTPRequest

func (b *Bittrex) SendHTTPRequest(path string, result interface{}) error

SendHTTPRequest sends an unauthenticated HTTP request

func (*Bittrex) SetDefaults

func (b *Bittrex) SetDefaults()

SetDefaults method assignes the default values for Bittrex

func (*Bittrex) Setup

func (b *Bittrex) Setup(exch *config.ExchangeConfig)

Setup method sets current configuration details if enabled

func (*Bittrex) Start

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

Start starts the Bittrex go routine

func (*Bittrex) SubmitOrder

func (b *Bittrex) SubmitOrder(p currency.Pair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, _ string) (exchange.SubmitOrderResponse, error)

SubmitOrder submits a new order

func (*Bittrex) SubscribeToWebsocketChannels

func (b *Bittrex) SubscribeToWebsocketChannels(channels []wshandler.WebsocketChannelSubscription) error

SubscribeToWebsocketChannels appends to ChannelsToSubscribe which lets websocket.manageSubscriptions handle subscribing

func (*Bittrex) UnsubscribeToWebsocketChannels

func (b *Bittrex) UnsubscribeToWebsocketChannels(channels []wshandler.WebsocketChannelSubscription) error

UnsubscribeToWebsocketChannels removes from ChannelsToSubscribe which lets websocket.manageSubscriptions handle unsubscribing

func (*Bittrex) UpdateOrderbook

func (b *Bittrex) UpdateOrderbook(p currency.Pair, assetType string) (orderbook.Base, error)

UpdateOrderbook updates and returns the orderbook for a currency pair

func (*Bittrex) UpdateTicker

func (b *Bittrex) UpdateTicker(p currency.Pair, assetType string) (ticker.Price, error)

UpdateTicker updates and returns the ticker for a currency pair

func (*Bittrex) Withdraw

func (b *Bittrex) Withdraw(currency, paymentID, address string, quantity float64) (UUID, error)

Withdraw is used to withdraw funds from your account. note: Please account for transaction fee.

func (*Bittrex) WithdrawCryptocurrencyFunds

func (b *Bittrex) WithdrawCryptocurrencyFunds(withdrawRequest *exchange.WithdrawRequest) (string, error)

WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is submitted

func (*Bittrex) WithdrawFiatFunds

func (b *Bittrex) WithdrawFiatFunds(withdrawRequest *exchange.WithdrawRequest) (string, error)

WithdrawFiatFunds returns a withdrawal ID when a withdrawal is submitted

func (*Bittrex) WithdrawFiatFundsToInternationalBank

func (b *Bittrex) WithdrawFiatFundsToInternationalBank(withdrawRequest *exchange.WithdrawRequest) (string, error)

WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a withdrawal is submitted

type Currency

type Currency struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
	Result  []struct {
		Currency        string  `json:"Currency"`
		CurrencyLong    string  `json:"CurrencyLong"`
		MinConfirmation int     `json:"MinConfirmation"`
		TxFee           float64 `json:"TxFee"`
		IsActive        bool    `json:"IsActive"`
		CoinType        string  `json:"CoinType"`
		BaseAddress     string  `json:"BaseAddress"`
	} `json:"result"`
}

Currency holds supported currency metadata

type DepositAddress

type DepositAddress struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
	Result  struct {
		Currency string `json:"Currency"`
		Address  string `json:"Address"`
	} `json:"result"`
}

DepositAddress holds a generated address to send specific coins to the exchange

type Market

type Market struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
	Result  []struct {
		MarketCurrency     string  `json:"MarketCurrency"`
		BaseCurrency       string  `json:"BaseCurrency"`
		MarketCurrencyLong string  `json:"MarketCurrencyLong"`
		BaseCurrencyLong   string  `json:"BaseCurrencyLong"`
		MinTradeSize       float64 `json:"MinTradeSize"`
		MarketName         string  `json:"MarketName"`
		IsActive           bool    `json:"IsActive"`
		Created            string  `json:"Created"`
	} `json:"result"`
}

Market holds current market metadata

type MarketHistory

type MarketHistory struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
	Result  []struct {
		ID        int     `json:"Id"`
		Timestamp string  `json:"TimeStamp"`
		Quantity  float64 `json:"Quantity"`
		Price     float64 `json:"Price"`
		Total     float64 `json:"Total"`
		FillType  string  `json:"FillType"`
		OrderType string  `json:"OrderType"`
	} `json:"result"`
}

MarketHistory holds an executed trade's data for a market ie "BTC-LTC"

type MarketSummary

type MarketSummary struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
	Result  []struct {
		MarketName        string  `json:"MarketName"`
		High              float64 `json:"High"`
		Low               float64 `json:"Low"`
		Volume            float64 `json:"Volume"`
		Last              float64 `json:"Last"`
		BaseVolume        float64 `json:"BaseVolume"`
		TimeStamp         string  `json:"TimeStamp"`
		Bid               float64 `json:"Bid"`
		Ask               float64 `json:"Ask"`
		OpenBuyOrders     int     `json:"OpenBuyOrders"`
		OpenSellOrders    int     `json:"OpenSellOrders"`
		PrevDay           float64 `json:"PrevDay"`
		Created           string  `json:"Created"`
		DisplayMarketName string  `json:"DisplayMarketName"`
	} `json:"result"`
}

MarketSummary holds last 24 hour metadata of an active exchange

type Order

type Order struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
	Result  []struct {
		AccountID                  string  `json:"AccountId"`
		OrderUUID                  string  `json:"OrderUuid"`
		Exchange                   string  `json:"Exchange"`
		Type                       string  `json:"Type"`
		Quantity                   float64 `json:"Quantity"`
		QuantityRemaining          float64 `json:"QuantityRemaining"`
		Limit                      float64 `json:"Limit"`
		Reserved                   float64 `json:"Reserved"`
		ReserveRemaining           float64 `json:"ReserveRemaining"`
		CommissionReserved         float64 `json:"CommissionReserved"`
		CommissionReserveRemaining float64 `json:"CommissionReserveRemaining"`
		CommissionPaid             float64 `json:"CommissionPaid"`
		Price                      float64 `json:"Price"`
		PricePerUnit               float64 `json:"PricePerUnit"`
		Opened                     string  `json:"Opened"`
		Closed                     string  `json:"Closed"`
		IsOpen                     bool    `json:"IsOpen"`
		Sentinel                   string  `json:"Sentinel"`
		CancelInitiated            bool    `json:"CancelInitiated"`
		ImmediateOrCancel          bool    `json:"ImmediateOrCancel"`
		IsConditional              bool    `json:"IsConditional"`
		Condition                  string  `json:"Condition"`
		ConditionTarget            string  `json:"ConditionTarget"`
		// Below Used in OrderHistory
		TimeStamp  string  `json:"TimeStamp"`
		Commission float64 `json:"Commission"`
	} `json:"result"`
}

Order holds the full order information associated with the UUID supplied

type OrderBook

type OrderBook struct {
	Quantity float64 `json:"Quantity"`
	Rate     float64 `json:"Rate"`
}

OrderBook holds a singular order on an exchange

type OrderBooks

type OrderBooks struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
	Result  struct {
		Buy  []OrderBook `json:"buy"`
		Sell []OrderBook `json:"sell"`
	} `json:"result"`
}

OrderBooks holds an array of buy & sell orders held on the exchange

type Response

type Response struct {
	Success bool            `json:"success"`
	Message string          `json:"message"`
	Result  json.RawMessage `json:"result"`
}

Response is the generalised response type for Bittrex

type Ticker

type Ticker struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
	Result  struct {
		Bid  float64 `json:"Bid"`
		Ask  float64 `json:"Ask"`
		Last float64 `json:"Last"`
	} `json:"result"`
}

Ticker holds basic ticker information

type UUID

type UUID struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
	Result  struct {
		ID string `json:"uuid"`
	} `json:"result"`
}

UUID contains the universal unique identifier for one or multiple transactions on the exchange

type WithdrawalHistory

type WithdrawalHistory struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
	Result  []struct {
		PaymentUUID    string  `json:"PaymentUuid"`
		Currency       string  `json:"Currency"`
		Amount         float64 `json:"Amount"`
		Address        string  `json:"Address"`
		Opened         string  `json:"Opened"`
		Authorized     bool    `json:"Authorized"`
		PendingPayment bool    `json:"PendingPayment"`
		TxCost         float64 `json:"TxCost"`
		TxID           string  `json:"TxId"`
		Canceled       bool    `json:"Canceled"`
		InvalidAddress bool    `json:"InvalidAddress"`
	} `json:"result"`
}

WithdrawalHistory holds the Withdrawal history data

Jump to

Keyboard shortcuts

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