bittrex

package
v0.0.0-...-069e140 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2021 License: MIT Imports: 25 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 progress 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.FetchTicker()
if err != nil {
  // Handle error
}

// Fetches current orderbook information
ob, err := b.FetchOrderbook()
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:

bc1qk0jareu4jytc0cfrhr5wgshsq8282awpavfahc

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

func (b *Bittrex) CancelAllOrders(_ *order.Cancel) (order.CancelAllResponse, error)

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 *order.Cancel) error

CancelOrder cancels an order by its corresponding ID number

func (*Bittrex) FetchAccountInfo

func (b *Bittrex) FetchAccountInfo() (account.Holdings, error)

FetchAccountInfo retrieves balances for all enabled currencies

func (*Bittrex) FetchOrderbook

func (b *Bittrex) FetchOrderbook(p currency.Pair, assetType asset.Item) (*orderbook.Base, error)

FetchOrderbook returns the orderbook for a currency pair

func (*Bittrex) FetchTicker

func (b *Bittrex) FetchTicker(p currency.Pair, assetType asset.Item) (*ticker.Price, error)

FetchTicker returns the ticker for a currency pair

func (*Bittrex) FetchTradablePairs

func (b *Bittrex) FetchTradablePairs(asset asset.Item) ([]string, error)

FetchTradablePairs returns a list of the exchanges tradable pairs

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

func (b *Bittrex) GetActiveOrders(req *order.GetOrdersRequest) ([]order.Detail, 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) GetDefaultConfig

func (b *Bittrex) GetDefaultConfig() (*config.ExchangeConfig, error)

GetDefaultConfig returns a default exchange config

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) (DepositHistory, 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 asset.Item, timestampStart, timestampEnd time.Time) ([]exchange.TradeHistory, error)

GetExchangeHistory returns historic trade data within the timeframe provided.

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

func (b *Bittrex) GetHistoricCandles(pair currency.Pair, a asset.Item, start, end time.Time, interval kline.Interval) (kline.Item, error)

GetHistoricCandles returns candles between a time period for a set time interval

func (*Bittrex) GetHistoricCandlesExtended

func (b *Bittrex) GetHistoricCandlesExtended(pair currency.Pair, a asset.Item, start, end time.Time, interval kline.Interval) (kline.Item, error)

GetHistoricCandlesExtended returns candles between a time period for a set time interval

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(req *order.GetOrdersRequest) ([]order.Detail, 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) (order.Detail, 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) 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) 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 *order.Modify) (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) error

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(s *order.Submit) (order.SubmitResponse, error)

SubmitOrder submits a new order

func (*Bittrex) UpdateAccountInfo

func (b *Bittrex) UpdateAccountInfo() (account.Holdings, error)

UpdateAccountInfo Retrieves balances for all enabled currencies for the Bittrex exchange

func (*Bittrex) UpdateOrderbook

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

UpdateOrderbook updates and returns the orderbook for a currency pair

func (*Bittrex) UpdateTicker

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

UpdateTicker updates and returns the ticker for a currency pair

func (*Bittrex) UpdateTradablePairs

func (b *Bittrex) UpdateTradablePairs(forceUpdate bool) error

UpdateTradablePairs updates the exchanges available pairs and stores them in the exchanges config

func (*Bittrex) ValidateCredentials

func (b *Bittrex) ValidateCredentials() error

ValidateCredentials validates current credentials used for wrapper functionality

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 *withdraw.Request) (*withdraw.ExchangeResponse, error)

WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is submitted

func (*Bittrex) WithdrawFiatFunds

func (b *Bittrex) WithdrawFiatFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error)

WithdrawFiatFunds returns a withdrawal ID when a withdrawal is submitted

func (*Bittrex) WithdrawFiatFundsToInternationalBank

func (b *Bittrex) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, 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 int64   `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 DepositHistory

type DepositHistory struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
	Result  []struct {
		ID            int64   `json:"Id"`
		Amount        float64 `json:"Amount"`
		Currency      string  `json:"Currency"`
		Confirmations int64   `json:"Confirmations"`
		LastUpdated   string  `json:"LastUpdated"`
		TxID          string  `json:"TxId"`
		CryptoAddress string  `json:"CryptoAddress"`
	} `json:"result"`
}

DepositHistory holds the Deposit history data

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        int64   `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     int64   `json:"OpenBuyOrders"`
		OpenSellOrders    int64   `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