bittrex

package
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2022 License: MIT Imports: 36 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
Notes
  • Bittrex used to have reversed market names: btc-ltc. The v3 API changed this to the more widely accepted format with first the base pair and then the quote pair: ltc-btc.
  • Asset names and market names are not case sensitive.
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 AddressData

type AddressData struct {
	Status           string `json:"status"`
	CurrencySymbol   string `json:"currencySymbol"`
	CryptoAddress    string `json:"cryptoAddress"`
	CryptoAddressTag string `json:"cryptoAddressTag"`
}

AddressData holds address data Status is REQUESTED or PROVISIONED

type BalanceData

type BalanceData struct {
	CurrencySymbol string    `json:"currencySymbol"`
	Total          float64   `json:"total,string"`
	Available      float64   `json:"available,string"`
	UpdatedAt      time.Time `json:"updatedAt"`
}

BalanceData holds balance data

type Bittrex

type Bittrex struct {
	exchange.Base
	WsSequenceOrders int64
	// contains filtered or unexported fields
}

Bittrex is the overaching type across the bittrex methods

func (*Bittrex) CancelAllOrders

func (b *Bittrex) CancelAllOrders(ctx context.Context, orderCancellation *order.Cancel) (order.CancelAllResponse, error)

CancelAllOrders cancels all orders associated with a currency pair, or cancels all orders for all pairs if no pair was specified

func (*Bittrex) CancelBatchOrders

func (b *Bittrex) CancelBatchOrders(_ context.Context, _ []order.Cancel) (order.CancelBatchResponse, error)

CancelBatchOrders cancels an orders by their corresponding ID numbers

func (*Bittrex) CancelExistingOrder

func (b *Bittrex) CancelExistingOrder(ctx context.Context, uuid string) (OrderData, error)

CancelExistingOrder is used to cancel a buy or sell order.

func (*Bittrex) CancelOpenOrders

func (b *Bittrex) CancelOpenOrders(ctx context.Context, market string) ([]BulkCancelResultData, error)

CancelOpenOrders is used to cancel all open orders for a specific market Or cancel all orders for all markets if the parameter `markets` is set to ""

func (*Bittrex) CancelOrder

func (b *Bittrex) CancelOrder(ctx context.Context, ord *order.Cancel) error

CancelOrder cancels an order by its corresponding ID number

func (*Bittrex) ConstructOrderDetail

func (b *Bittrex) ConstructOrderDetail(orderData *OrderData) (order.Detail, error)

ConstructOrderDetail constructs an order detail item from the underlying data

func (*Bittrex) FetchAccountInfo

func (b *Bittrex) FetchAccountInfo(ctx context.Context, assetType asset.Item) (account.Holdings, error)

FetchAccountInfo retrieves balances for all enabled currencies

func (*Bittrex) FetchOrderbook

func (b *Bittrex) FetchOrderbook(ctx context.Context, c currency.Pair, assetType asset.Item) (*orderbook.Base, error)

FetchOrderbook returns orderbook base on the currency pair

func (*Bittrex) FetchTicker

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

FetchTicker returns the ticker for a currency pair

func (*Bittrex) FetchTradablePairs

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

FetchTradablePairs returns a list of the exchanges tradable pairs

func (*Bittrex) FormatExchangeKlineInterval

func (b *Bittrex) FormatExchangeKlineInterval(in kline.Interval) string

FormatExchangeKlineInterval returns Interval to string Overrides Base function

func (*Bittrex) GenerateDefaultSubscriptions

func (b *Bittrex) GenerateDefaultSubscriptions() ([]stream.ChannelSubscription, error)

GenerateDefaultSubscriptions Adds default subscriptions to websocket to be handled by ManageSubscriptions()

func (*Bittrex) GetAccountBalanceByCurrency

func (b *Bittrex) GetAccountBalanceByCurrency(ctx context.Context, currency string) (BalanceData, error)

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

func (*Bittrex) GetActiveOrders

func (b *Bittrex) GetActiveOrders(ctx context.Context, req *order.GetOrdersRequest) ([]order.Detail, error)

GetActiveOrders retrieves any orders that are active/open

func (*Bittrex) GetBalances

func (b *Bittrex) GetBalances(ctx context.Context) ([]BalanceData, error)

GetBalances is used to retrieve all balances from your account

func (*Bittrex) GetClosedDeposits

func (b *Bittrex) GetClosedDeposits(ctx context.Context) ([]DepositData, error)

GetClosedDeposits is used to retrieve your deposit history.

func (*Bittrex) GetClosedDepositsForCurrency

func (b *Bittrex) GetClosedDepositsForCurrency(ctx context.Context, currency string) ([]DepositData, error)

GetClosedDepositsForCurrency is used to retrieve your deposit history for the specified currency

func (*Bittrex) GetClosedDepositsPaginated

func (b *Bittrex) GetClosedDepositsPaginated(ctx context.Context, pageSize int, previousPageTokenOptional ...string) ([]DepositData, error)

GetClosedDepositsPaginated is used to retrieve your deposit history. The maximum page size is 200 and it defaults to 100. PreviousPageToken is the unique identifier of the item that the resulting query result should end before, in the sort order of the given endpoint. Used for traversing a paginated set in the reverse direction.

func (*Bittrex) GetClosedWithdrawals

func (b *Bittrex) GetClosedWithdrawals(ctx context.Context) ([]WithdrawalData, error)

GetClosedWithdrawals is used to retrieve your withdrawal history.

func (*Bittrex) GetClosedWithdrawalsForCurrency

func (b *Bittrex) GetClosedWithdrawalsForCurrency(ctx context.Context, currency string) ([]WithdrawalData, error)

GetClosedWithdrawalsForCurrency is used to retrieve your withdrawal history for the specified currency.

func (*Bittrex) GetCryptoDepositAddress

func (b *Bittrex) GetCryptoDepositAddress(ctx context.Context, currency string) (AddressData, error)

GetCryptoDepositAddress is used to retrieve an address for a specific currency

func (*Bittrex) GetCryptoDepositAddresses

func (b *Bittrex) GetCryptoDepositAddresses(ctx context.Context) ([]AddressData, error)

GetCryptoDepositAddresses is used to retrieve all deposit addresses

func (*Bittrex) GetCurrencies

func (b *Bittrex) GetCurrencies(ctx context.Context) ([]CurrencyData, error)

GetCurrencies is used to get all supported currencies at Bittrex

func (*Bittrex) GetDefaultConfig

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

GetDefaultConfig returns a default exchange config

func (*Bittrex) GetDepositAddress

func (b *Bittrex) GetDepositAddress(ctx context.Context, cryptocurrency currency.Code, _, _ string) (*deposit.Address, error)

GetDepositAddress returns a deposit address for a specified currency

func (*Bittrex) GetFee

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

GetFee returns an estimate of fee based on type of transaction

func (*Bittrex) GetFeeByType

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

GetFeeByType returns an estimate of fee based on type of transaction

func (*Bittrex) GetFundingHistory

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

GetFundingHistory returns funding history, deposits and withdrawals

func (*Bittrex) GetHistoricCandles

func (b *Bittrex) GetHistoricCandles(ctx context.Context, 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 Candles set size returned by Bittrex depends on interval length: - 1m interval: candles for 1 day (0:00 - 23:59) - 5m interval: candles for 1 day (0:00 - 23:55) - 1 hour interval: candles for 31 days - 1 day interval: candles for 366 days This implementation rounds returns candles up to the next interval or to the end time (whichever comes first)

func (*Bittrex) GetHistoricCandlesExtended

func (b *Bittrex) GetHistoricCandlesExtended(ctx context.Context, 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) GetHistoricTrades

func (b *Bittrex) GetHistoricTrades(_ context.Context, _ currency.Pair, _ asset.Item, _, _ time.Time) ([]trade.Data, error)

GetHistoricTrades returns historic trade data within the timeframe provided Bittrex only reports recent trades

func (*Bittrex) GetHistoricalCandles

func (b *Bittrex) GetHistoricalCandles(ctx context.Context, marketName, candleInterval, candleType string, year, month, day int) ([]CandleData, error)

GetHistoricalCandles retrieves recent candles Type: TRADE or MIDPOINT

func (*Bittrex) GetKlines

func (b *Bittrex) GetKlines(arg interface{}) ([]*kline.Kline, error)

GetKlines checks and returns a requested kline if it exists

func (*Bittrex) GetMarketHistory

func (b *Bittrex) GetMarketHistory(ctx context.Context, currency string) ([]TradeData, error)

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

func (*Bittrex) GetMarketSummaries

func (b *Bittrex) GetMarketSummaries(ctx context.Context) ([]MarketSummaryData, error)

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

func (*Bittrex) GetMarketSummary

func (b *Bittrex) GetMarketSummary(ctx context.Context, marketName string) (MarketSummaryData, error)

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

func (*Bittrex) GetMarkets

func (b *Bittrex) GetMarkets(ctx context.Context) ([]MarketData, error)

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

func (*Bittrex) GetOpenDeposits

func (b *Bittrex) GetOpenDeposits(ctx context.Context) ([]DepositData, error)

GetOpenDeposits is used to retrieve your open deposits.

func (*Bittrex) GetOpenDepositsForCurrency

func (b *Bittrex) GetOpenDepositsForCurrency(ctx context.Context, currency string) ([]DepositData, error)

GetOpenDepositsForCurrency is used to retrieve your open deposits for the specified currency

func (*Bittrex) GetOpenOrders

func (b *Bittrex) GetOpenOrders(ctx context.Context, marketName string) ([]OrderData, int64, error)

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

func (*Bittrex) GetOpenWithdrawals

func (b *Bittrex) GetOpenWithdrawals(ctx context.Context) ([]WithdrawalData, error)

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

func (*Bittrex) GetOrder

func (b *Bittrex) GetOrder(ctx context.Context, uuid string) (OrderData, error)

GetOrder is used to retrieve a single order by UUID.

func (*Bittrex) GetOrderHistory

func (b *Bittrex) GetOrderHistory(ctx context.Context, 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(ctx context.Context, currency string) ([]OrderData, error)

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

func (*Bittrex) GetOrderInfo

func (b *Bittrex) GetOrderInfo(ctx context.Context, orderID string, pair currency.Pair, assetType asset.Item) (order.Detail, error)

GetOrderInfo returns information on a current open order

func (*Bittrex) GetOrderbook

func (b *Bittrex) GetOrderbook(ctx context.Context, marketName string, depth int64) (OrderbookData, int64, error)

GetOrderbook method returns current order book information by currency and depth. "marketSymbol" ie ltc-btc "depth" is either 1, 25 or 500. Server side, the depth defaults to 25.

func (*Bittrex) GetRecentCandles

func (b *Bittrex) GetRecentCandles(ctx context.Context, marketName, candleInterval, candleType string) ([]CandleData, error)

GetRecentCandles retrieves recent candles; Interval: MINUTE_1, MINUTE_5, HOUR_1, or DAY_1 Type: TRADE or MIDPOINT

func (*Bittrex) GetRecentTrades

func (b *Bittrex) GetRecentTrades(ctx context.Context, p currency.Pair, assetType asset.Item) ([]trade.Data, error)

GetRecentTrades returns the most recent trades for a currency and asset

func (*Bittrex) GetTicker

func (b *Bittrex) GetTicker(ctx context.Context, marketName string) (TickerData, error)

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

func (*Bittrex) GetWithdrawalFee

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

GetWithdrawalFee returns the fee for withdrawing from the exchange

func (*Bittrex) GetWithdrawalsHistory

func (b *Bittrex) GetWithdrawalsHistory(ctx context.Context, c currency.Code) (resp []exchange.WithdrawalHistory, err error)

GetWithdrawalsHistory returns previous withdrawals data

func (*Bittrex) ModifyOrder

func (b *Bittrex) ModifyOrder(_ context.Context, _ *order.Modify) (order.Modify, error)

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

func (*Bittrex) Order

func (b *Bittrex) Order(ctx context.Context, marketName, side, orderType string, timeInForce TimeInForce, price, amount, ceiling float64) (OrderData, error)

Order places an order

func (*Bittrex) ProcessUpdateOB

func (b *Bittrex) ProcessUpdateOB(pair currency.Pair, message *OrderbookUpdateMessage) error

ProcessUpdateOB processes the websocket orderbook update

func (*Bittrex) ProvisionNewDepositAddress

func (b *Bittrex) ProvisionNewDepositAddress(ctx context.Context, currency string) (*ProvisionNewAddressData, error)

ProvisionNewDepositAddress provisions a new deposit address for a specific currency

func (*Bittrex) Run

func (b *Bittrex) Run()

Run implements the Bittrex wrapper

func (*Bittrex) SeedLocalCacheWithOrderBook

func (b *Bittrex) SeedLocalCacheWithOrderBook(p currency.Pair, sequence int64, orderbookNew *OrderbookData) error

SeedLocalCacheWithOrderBook seeds the local orderbook cache

func (*Bittrex) SeedLocalOBCache

func (b *Bittrex) SeedLocalOBCache(ctx context.Context, p currency.Pair) error

SeedLocalOBCache seeds depth data

func (*Bittrex) SendAuthHTTPRequest

func (b *Bittrex) SendAuthHTTPRequest(ctx context.Context, ep exchange.URL, method, action string, params url.Values, data, result interface{}, resultHeader *http.Header) error

SendAuthHTTPRequest sends an authenticated request

func (*Bittrex) SendHTTPRequest

func (b *Bittrex) SendHTTPRequest(ctx context.Context, ep exchange.URL, path string, result interface{}, resultHeader *http.Header) error

SendHTTPRequest sends an unauthenticated HTTP request

func (*Bittrex) SetDefaults

func (b *Bittrex) SetDefaults()

SetDefaults sets the basic defaults for Bittrex

func (*Bittrex) Setup

func (b *Bittrex) Setup(exch *config.Exchange) error

Setup takes in the supplied exchange configuration details and sets params

func (*Bittrex) Start

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

Start starts the Bittrex go routine

func (*Bittrex) SubmitOrder

func (b *Bittrex) SubmitOrder(ctx context.Context, s *order.Submit) (order.SubmitResponse, error)

SubmitOrder submits a new order

func (*Bittrex) Subscribe

func (b *Bittrex) Subscribe(channelsToSubscribe []stream.ChannelSubscription) error

Subscribe sends a websocket message to receive data from the channel

func (*Bittrex) SynchroniseWebsocketOrderbook

func (b *Bittrex) SynchroniseWebsocketOrderbook()

SynchroniseWebsocketOrderbook synchronises full orderbook for currency pair asset

func (*Bittrex) Unsubscribe

func (b *Bittrex) Unsubscribe(channelsToUnsubscribe []stream.ChannelSubscription) error

Unsubscribe sends a websocket message to receive data from the channel

func (*Bittrex) UpdateAccountInfo

func (b *Bittrex) UpdateAccountInfo(ctx context.Context, assetType asset.Item) (account.Holdings, error)

UpdateAccountInfo retrieves balances for all enabled currencies

func (*Bittrex) UpdateLocalOBBuffer

func (b *Bittrex) UpdateLocalOBBuffer(update *OrderbookUpdateMessage) (bool, error)

UpdateLocalOBBuffer updates and returns the most recent iteration of the orderbook

func (*Bittrex) UpdateOrderbook

func (b *Bittrex) UpdateOrderbook(ctx context.Context, 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(ctx context.Context, p currency.Pair, a asset.Item) (*ticker.Price, error)

UpdateTicker updates and returns the ticker for a currency pair

func (*Bittrex) UpdateTickers

func (b *Bittrex) UpdateTickers(ctx context.Context, a asset.Item) error

UpdateTickers updates the ticker for all currency pairs of a given asset type

func (*Bittrex) UpdateTradablePairs

func (b *Bittrex) UpdateTradablePairs(ctx context.Context, forceUpdate bool) error

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

func (*Bittrex) ValidateCredentials

func (b *Bittrex) ValidateCredentials(ctx context.Context, assetType asset.Item) error

ValidateCredentials validates current credentials used for wrapper functionality

func (*Bittrex) Withdraw

func (b *Bittrex) Withdraw(ctx context.Context, currency, paymentID, address string, quantity float64) (WithdrawalData, error)

Withdraw is used to withdraw funds from your account.

func (*Bittrex) WithdrawCryptocurrencyFunds

func (b *Bittrex) WithdrawCryptocurrencyFunds(ctx context.Context, withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error)

WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is submitted

func (*Bittrex) WithdrawFiatFunds

func (b *Bittrex) WithdrawFiatFunds(_ context.Context, _ *withdraw.Request) (*withdraw.ExchangeResponse, error)

WithdrawFiatFunds returns a withdrawal ID when a withdrawal is submitted

func (*Bittrex) WithdrawFiatFundsToInternationalBank

func (b *Bittrex) WithdrawFiatFundsToInternationalBank(_ context.Context, _ *withdraw.Request) (*withdraw.ExchangeResponse, error)

WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a withdrawal is submitted

func (*Bittrex) WsAuth

func (b *Bittrex) WsAuth() error

WsAuth sends an authentication message to receive auth data Authentications expire after 10 minutes

func (*Bittrex) WsConnect

func (b *Bittrex) WsConnect() error

WsConnect connects to a websocket feed

func (*Bittrex) WsProcessUpdateMarketSummary

func (b *Bittrex) WsProcessUpdateMarketSummary(marketSummaryData *MarketSummaryData) error

WsProcessUpdateMarketSummary processes an update on the ticker

func (*Bittrex) WsProcessUpdateOrder

func (b *Bittrex) WsProcessUpdateOrder(data *OrderUpdateMessage) error

WsProcessUpdateOrder processes an update on the open orders

func (*Bittrex) WsProcessUpdateTicker

func (b *Bittrex) WsProcessUpdateTicker(tickerData TickerData) error

WsProcessUpdateTicker processes an update on the ticker

func (*Bittrex) WsSignalRHandshake

func (b *Bittrex) WsSignalRHandshake(ctx context.Context, result interface{}) error

WsSignalRHandshake requests the SignalR connection token over https

type BulkCancelResultData

type BulkCancelResultData struct {
	ID         string    `json:"id"`
	StatusCode string    `json:"statusCode"`
	Result     OrderData `json:"result"`
}

BulkCancelResultData holds the result of a bulk cancel action

type CancelOrderRequest

type CancelOrderRequest struct {
	OrderID int64 `json:"orderId,string"`
}

CancelOrderRequest holds request data for CancelOrder

type CandleData

type CandleData struct {
	StartsAt    time.Time `json:"startsAt"`
	Open        float64   `json:"open,string"`
	High        float64   `json:"high,string"`
	Low         float64   `json:"low,string"`
	Close       float64   `json:"close,string"`
	Volume      float64   `json:"volume,string"`
	QuoteVolume float64   `json:"quoteVolume,string"`
}

CandleData holds candle data

type CurrencyData

type CurrencyData struct {
	Symbol           string   `json:"symbol"`
	Name             string   `json:"name"`
	CoinType         string   `json:"coinType"`
	Status           string   `json:"status"`
	MinConfirmations int32    `json:"minConfirmations"`
	Notice           string   `json:"notice"`
	TxFee            float64  `json:"txFee,string"`
	LogoURL          string   `json:"logoUrl"`
	ProhibitedIn     []string `json:"prohibitedIn"`
}

CurrencyData holds currency data Status is ONLINE or OFFLINE

type DepositData

type DepositData struct {
	ID               string    `json:"id"`
	CurrencySymbol   string    `json:"currencySymbol"`
	Quantity         float64   `json:"quantity,string"`
	CryptoAddress    string    `json:"cryptoAddress"`
	CryptoAddressTag string    `json:"cryptoAddressTag"`
	TxID             string    `json:"txId"`
	Confirmations    int32     `json:"confirmations"`
	UpdatedAt        time.Time `json:"updatedAt"`
	CompletedAt      time.Time `json:"completedAt"`
	Status           string    `json:"status"`
	Source           string    `json:"source"`
}

DepositData holds deposit data

type MarketData

type MarketData struct {
	Symbol              string    `json:"symbol"`
	BaseCurrencySymbol  string    `json:"baseCurrencySymbol"`
	QuoteCurrencySymbol string    `json:"quoteCurrencySymbol"`
	MinTradeSize        float64   `json:"minTradeSize,string"`
	Precision           int32     `json:"precision"`
	Status              string    `json:"status"`
	CreatedAt           time.Time `json:"createdAt"`
	Notice              string    `json:"notice"`
	ProhibitedIn        []string  `json:"prohibitedIn"`
}

MarketData stores market data

type MarketSummaryData

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

MarketSummaryData stores market summary data

type OrderData

type OrderData struct {
	ID            string    `json:"id"`
	MarketSymbol  string    `json:"marketSymbol"`
	Direction     string    `json:"direction"`
	Type          string    `json:"type"`
	Quantity      float64   `json:"quantity,string"`
	Limit         float64   `json:"limit,string"`
	Ceiling       float64   `json:"ceiling,string"`
	TimeInForce   string    `json:"timeInForce"`
	ClientOrderID string    `json:"clientOrderId"`
	FillQuantity  float64   `json:"fillQuantity,string"`
	Commission    float64   `json:"commission,string"`
	Proceeds      float64   `json:"proceeds,string"`
	Status        string    `json:"status"`
	CreatedAt     time.Time `json:"createdAt"`
	UpdatedAt     time.Time `json:"updatedAt"`
	ClosedAt      time.Time `json:"closedAt"`
	OrderToCancel struct {
		Type string `json:"type,string"`
		ID   string `json:"id,string"`
	} `json:"orderToCancel"`
}

OrderData holds order data

type OrderUpdateMessage

type OrderUpdateMessage struct {
	AccountID string    `json:"accountId"`
	Sequence  int       `json:"int,string"`
	Delta     OrderData `json:"delta"`
}

OrderUpdateMessage holds websocket order update messages

type OrderbookData

type OrderbookData struct {
	Bid []OrderbookEntryData `json:"bid"`
	Ask []OrderbookEntryData `json:"ask"`
}

OrderbookData holds the order book data

type OrderbookEntryData

type OrderbookEntryData struct {
	Quantity float64 `json:"quantity,string"`
	Rate     float64 `json:"rate,string"`
}

OrderbookEntryData holds an order book entry

type OrderbookUpdateMessage

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

OrderbookUpdateMessage holds websocket orderbook update messages

type ProvisionNewAddressData

type ProvisionNewAddressData struct {
	Status         string `json:"status"`
	CurrencySymbol string `json:"currencySymbol"`
}

ProvisionNewAddressData holds the provision deposit data Status is REQUESTED

type TickerCache

type TickerCache struct {
	MarketSummaries map[string]*MarketSummaryData
	Tickers         map[string]*TickerData
	sync.RWMutex
}

TickerCache holds ticker and market summary data in order to combine them when processing data

type TickerData

type TickerData struct {
	Symbol        string  `json:"symbol"`
	LastTradeRate float64 `json:"lastTradeRate,string"`
	BidRate       float64 `json:"bidRate,string"`
	AskRate       float64 `json:"askRate,string"`
}

TickerData stores ticker data

type TimeInForce

type TimeInForce string

TimeInForce defines timeInForce types

const (
	GoodTilCancelled         TimeInForce = "GOOD_TIL_CANCELLED"
	ImmediateOrCancel        TimeInForce = "IMMEDIATE_OR_CANCEL"
	FillOrKill               TimeInForce = "FILL_OR_KILL"
	PostOnlyGoodTilCancelled TimeInForce = "POST_ONLY_GOOD_TIL_CANCELLED"
	BuyNow                   TimeInForce = "BUY_NOW"
)

All order status types

type TradeData

type TradeData struct {
	ID         string    `json:"id"`
	ExecutedAt time.Time `json:"executedAt"`
	Quantity   float64   `json:"quantity,string"`
	Rate       float64   `json:"rate,string"`
	TakerSide  string    `json:"takerSide"`
}

TradeData stores trades data

type WithdrawalData

type WithdrawalData struct {
	ID                 string    `json:"id"`
	CurrencySymbol     string    `json:"currencySymbol"`
	Quantity           float64   `json:"quantity,string"`
	CryptoAddress      string    `json:"cryptoAddress"`
	CryptoAddressTag   string    `json:"cryptoAddressTag"`
	TxCost             float64   `json:"txCost,string"`
	TxID               string    `json:"txId"`
	Status             string    `json:"status"`
	CreatedAt          time.Time `json:"createdAt"`
	CompletedAt        time.Time `json:"completedAt"`
	ClientWithdrawalID string    `json:"clientWithdrawalId"`
}

WithdrawalData holds withdrawal data

type WsAuthResponse

type WsAuthResponse struct {
	C            string        `json:"C"`
	S            int           `json:"S"`
	G            string        `json:"G"`
	Response     WsEventStatus `json:"R"`
	InvocationID int64         `json:"I,string"`
	Message      []struct {
		Hub       string   `json:"H"`
		Method    string   `json:"M"`
		Arguments []string `json:"A"`
	} `json:"M"`
}

WsAuthResponse holds data on the websocket response

type WsEventRequest

type WsEventRequest struct {
	Hub          string      `json:"H"`
	Method       string      `json:"M"`
	Arguments    interface{} `json:"A"`
	InvocationID int64       `json:"I"`
}

WsEventRequest holds data on websocket requests

type WsEventResponse

type WsEventResponse struct {
	C            string      `json:"C"`
	S            int         `json:"S"`
	G            string      `json:"G"`
	Response     interface{} `json:"R"`
	InvocationID int64       `json:"I,string"`
	Message      []struct {
		Hub       string   `json:"H"`
		Method    string   `json:"M"`
		Arguments []string `json:"A"`
	} `json:"M"`
}

WsEventResponse holds data on the websocket response

type WsEventStatus

type WsEventStatus struct {
	Success   bool   `json:"Success"`
	ErrorCode string `json:"ErrorCode"`
}

WsEventStatus holds data on the websocket event status

type WsPendingRequest

type WsPendingRequest struct {
	WsEventRequest
	ChannelsToSubscribe *[]stream.ChannelSubscription
}

WsPendingRequest holds pending requests

type WsSignalRHandshakeData

type WsSignalRHandshakeData struct {
	URL                     string  `json:"Url"`                     // Path to the SignalR endpoint
	ConnectionToken         string  `json:"ConnectionToken"`         // Connection token assigned by the server
	ConnectionID            string  `json:"ConnectionId"`            // The ID of the connection
	KeepAliveTimeout        float64 `json:"KeepAliveTimeout"`        // Representing the amount of time to wait before sending a keep alive packet over an idle connection
	DisconnectTimeout       float64 `json:"DisconnectTimeout"`       // Represents the amount of time to wait after a connection goes away before raising the disconnect event
	ConnectionTimeout       float64 `json:"ConnectionTimeout"`       // Represents the amount of time to leave a connection open before timing out
	TryWebSockets           bool    `json:"TryWebSockets"`           // Whether the server supports websockets
	ProtocolVersion         string  `json:"ProtocolVersion"`         // The version of the protocol used for communication
	TransportConnectTimeout float64 `json:"TransportConnectTimeout"` // The maximum amount of time the client should try to connect to the server using a given transport
	LongPollDelay           float64 `json:"LongPollDelay"`           // The time to tell the browser to wait before reestablishing a long poll connection after data is sent from the server.
}

WsSignalRHandshakeData holds data for the SignalR websocket wrapper handshake

type WsSubscriptionResponse

type WsSubscriptionResponse struct {
	C            string          `json:"C"`
	S            int             `json:"S"`
	G            string          `json:"G"`
	Response     []WsEventStatus `json:"R"`
	InvocationID int64           `json:"I,string"`
	Message      []struct {
		Hub       string   `json:"H"`
		Method    string   `json:"M"`
		Arguments []string `json:"A"`
	} `json:"M"`
}

WsSubscriptionResponse holds data on the websocket response

Jump to

Keyboard shortcuts

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