mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-07 07:26:48 +00:00
exchanges: Initial context propagation (#744)
* gct: phase one context awareness pass * exchanges: context propagation pass * common/requester: force context requirement * gctcli/exchanges: linter fix * rpcserver: fix test using dummy rpc server * backtester: fix comments * grpc: add correct cancel and timeout for commands * rpcserver_test: add comment on dummy server * common: deprecated SendHTTPGetRequest * linter: fix * linter: turn on no context check * apichecker: fix context linter issue * binance: use param context * common: remove checks as this gets executed before main * common: change mutex to RW as clients can be used by multiple go routines. * common: remove init and JIT default client. Unexport global variables and add protection. * common: Add comments * bithumb: after dinner mints fix
This commit is contained in:
@@ -67,48 +67,48 @@ const (
|
||||
|
||||
// GetMarkets is used to get the open and available trading markets at Bittrex
|
||||
// along with other meta data.
|
||||
func (b *Bittrex) GetMarkets() ([]MarketData, error) {
|
||||
func (b *Bittrex) GetMarkets(ctx context.Context) ([]MarketData, error) {
|
||||
var resp []MarketData
|
||||
return resp, b.SendHTTPRequest(exchange.RestSpot, getMarkets, &resp, nil)
|
||||
return resp, b.SendHTTPRequest(ctx, exchange.RestSpot, getMarkets, &resp, nil)
|
||||
}
|
||||
|
||||
// GetCurrencies is used to get all supported currencies at Bittrex
|
||||
func (b *Bittrex) GetCurrencies() ([]CurrencyData, error) {
|
||||
func (b *Bittrex) GetCurrencies(ctx context.Context) ([]CurrencyData, error) {
|
||||
var resp []CurrencyData
|
||||
return resp, b.SendHTTPRequest(exchange.RestSpot, getCurrencies, &resp, nil)
|
||||
return resp, b.SendHTTPRequest(ctx, exchange.RestSpot, getCurrencies, &resp, nil)
|
||||
}
|
||||
|
||||
// GetTicker sends a public get request and returns current ticker information
|
||||
// on the supplied currency. Example currency input param "ltc-btc".
|
||||
func (b *Bittrex) GetTicker(marketName string) (TickerData, error) {
|
||||
func (b *Bittrex) GetTicker(ctx context.Context, marketName string) (TickerData, error) {
|
||||
var resp TickerData
|
||||
return resp, b.SendHTTPRequest(exchange.RestSpot, fmt.Sprintf(getTicker, marketName), &resp, nil)
|
||||
return resp, b.SendHTTPRequest(ctx, exchange.RestSpot, fmt.Sprintf(getTicker, marketName), &resp, nil)
|
||||
}
|
||||
|
||||
// GetMarketSummaries is used to get the last 24 hour summary of all active
|
||||
// exchanges
|
||||
func (b *Bittrex) GetMarketSummaries() ([]MarketSummaryData, error) {
|
||||
func (b *Bittrex) GetMarketSummaries(ctx context.Context) ([]MarketSummaryData, error) {
|
||||
var resp []MarketSummaryData
|
||||
return resp, b.SendHTTPRequest(exchange.RestSpot, getMarketSummaries, &resp, nil)
|
||||
return resp, b.SendHTTPRequest(ctx, exchange.RestSpot, getMarketSummaries, &resp, nil)
|
||||
}
|
||||
|
||||
// GetMarketSummary is used to get the last 24 hour summary of all active
|
||||
// exchanges by currency pair (ltc-btc).
|
||||
func (b *Bittrex) GetMarketSummary(marketName string) (MarketSummaryData, error) {
|
||||
func (b *Bittrex) GetMarketSummary(ctx context.Context, marketName string) (MarketSummaryData, error) {
|
||||
var resp MarketSummaryData
|
||||
return resp, b.SendHTTPRequest(exchange.RestSpot, fmt.Sprintf(getMarketSummary, marketName), &resp, nil)
|
||||
return resp, b.SendHTTPRequest(ctx, exchange.RestSpot, fmt.Sprintf(getMarketSummary, marketName), &resp, nil)
|
||||
}
|
||||
|
||||
// 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 (b *Bittrex) GetOrderbook(marketName string, depth int64) (OrderbookData, int64, error) {
|
||||
func (b *Bittrex) GetOrderbook(ctx context.Context, marketName string, depth int64) (OrderbookData, int64, error) {
|
||||
strDepth := strconv.FormatInt(depth, 10)
|
||||
|
||||
var resp OrderbookData
|
||||
var sequence int64
|
||||
resultHeader := http.Header{}
|
||||
err := b.SendHTTPRequest(exchange.RestSpot, fmt.Sprintf(getOrderbook, marketName, strDepth), &resp, &resultHeader)
|
||||
err := b.SendHTTPRequest(ctx, exchange.RestSpot, fmt.Sprintf(getOrderbook, marketName, strDepth), &resp, &resultHeader)
|
||||
if err != nil {
|
||||
return OrderbookData{}, 0, err
|
||||
}
|
||||
@@ -121,13 +121,13 @@ func (b *Bittrex) GetOrderbook(marketName string, depth int64) (OrderbookData, i
|
||||
}
|
||||
|
||||
// GetMarketHistory retrieves the latest trades that have occurred for a specific market
|
||||
func (b *Bittrex) GetMarketHistory(currency string) ([]TradeData, error) {
|
||||
func (b *Bittrex) GetMarketHistory(ctx context.Context, currency string) ([]TradeData, error) {
|
||||
var resp []TradeData
|
||||
return resp, b.SendHTTPRequest(exchange.RestSpot, fmt.Sprintf(getMarketTrades, currency), &resp, nil)
|
||||
return resp, b.SendHTTPRequest(ctx, exchange.RestSpot, fmt.Sprintf(getMarketTrades, currency), &resp, nil)
|
||||
}
|
||||
|
||||
// Order places an order
|
||||
func (b *Bittrex) Order(marketName, side, orderType string, timeInForce TimeInForce, price, amount, ceiling float64) (OrderData, error) {
|
||||
func (b *Bittrex) Order(ctx context.Context, marketName, side, orderType string, timeInForce TimeInForce, price, amount, ceiling float64) (OrderData, error) {
|
||||
req := make(map[string]interface{})
|
||||
req["marketSymbol"] = marketName
|
||||
req["direction"] = side
|
||||
@@ -145,12 +145,12 @@ func (b *Bittrex) Order(marketName, side, orderType string, timeInForce TimeInFo
|
||||
req["timeInForce"] = GoodTilCancelled
|
||||
}
|
||||
var resp OrderData
|
||||
return resp, b.SendAuthHTTPRequest(exchange.RestSpot, http.MethodPost, submitOrder, nil, req, &resp, nil)
|
||||
return resp, b.SendAuthHTTPRequest(ctx, exchange.RestSpot, http.MethodPost, submitOrder, nil, req, &resp, nil)
|
||||
}
|
||||
|
||||
// GetOpenOrders returns all orders that you currently have opened.
|
||||
// A specific market can be requested for example "ltc-btc"
|
||||
func (b *Bittrex) GetOpenOrders(marketName string) ([]OrderData, int64, error) {
|
||||
func (b *Bittrex) GetOpenOrders(ctx context.Context, marketName string) ([]OrderData, int64, error) {
|
||||
var path string
|
||||
if marketName == "" || marketName == " " {
|
||||
path = getAllOpenOrders
|
||||
@@ -160,7 +160,7 @@ func (b *Bittrex) GetOpenOrders(marketName string) ([]OrderData, int64, error) {
|
||||
var resp []OrderData
|
||||
var sequence int64
|
||||
resultHeader := http.Header{}
|
||||
err := b.SendAuthHTTPRequest(exchange.RestSpot, http.MethodGet, path, nil, nil, &resp, &resultHeader)
|
||||
err := b.SendAuthHTTPRequest(ctx, exchange.RestSpot, http.MethodGet, path, nil, nil, &resp, &resultHeader)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
@@ -172,14 +172,14 @@ func (b *Bittrex) GetOpenOrders(marketName string) ([]OrderData, int64, error) {
|
||||
}
|
||||
|
||||
// CancelExistingOrder is used to cancel a buy or sell order.
|
||||
func (b *Bittrex) CancelExistingOrder(uuid string) (OrderData, error) {
|
||||
func (b *Bittrex) CancelExistingOrder(ctx context.Context, uuid string) (OrderData, error) {
|
||||
var resp OrderData
|
||||
return resp, b.SendAuthHTTPRequest(exchange.RestSpot, http.MethodDelete, fmt.Sprintf(cancelOrder, uuid), nil, nil, &resp, nil)
|
||||
return resp, b.SendAuthHTTPRequest(ctx, exchange.RestSpot, http.MethodDelete, fmt.Sprintf(cancelOrder, uuid), nil, nil, &resp, nil)
|
||||
}
|
||||
|
||||
// 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 (b *Bittrex) CancelOpenOrders(market string) ([]BulkCancelResultData, error) {
|
||||
func (b *Bittrex) CancelOpenOrders(ctx context.Context, market string) ([]BulkCancelResultData, error) {
|
||||
var resp []BulkCancelResultData
|
||||
|
||||
params := url.Values{}
|
||||
@@ -187,21 +187,21 @@ func (b *Bittrex) CancelOpenOrders(market string) ([]BulkCancelResultData, error
|
||||
params.Set("marketSymbol", market)
|
||||
}
|
||||
|
||||
return resp, b.SendAuthHTTPRequest(exchange.RestSpot, http.MethodDelete, cancelOpenOrders, params, nil, &resp, nil)
|
||||
return resp, b.SendAuthHTTPRequest(ctx, exchange.RestSpot, http.MethodDelete, cancelOpenOrders, params, nil, &resp, nil)
|
||||
}
|
||||
|
||||
// GetRecentCandles retrieves recent candles;
|
||||
// Interval: MINUTE_1, MINUTE_5, HOUR_1, or DAY_1
|
||||
// Type: TRADE or MIDPOINT
|
||||
func (b *Bittrex) GetRecentCandles(marketName, candleInterval, candleType string) ([]CandleData, error) {
|
||||
func (b *Bittrex) GetRecentCandles(ctx context.Context, marketName, candleInterval, candleType string) ([]CandleData, error) {
|
||||
var resp []CandleData
|
||||
|
||||
return resp, b.SendHTTPRequest(exchange.RestSpot, fmt.Sprintf(getRecentCandles, marketName, candleType, candleInterval), &resp, nil)
|
||||
return resp, b.SendHTTPRequest(ctx, exchange.RestSpot, fmt.Sprintf(getRecentCandles, marketName, candleType, candleInterval), &resp, nil)
|
||||
}
|
||||
|
||||
// GetHistoricalCandles retrieves recent candles
|
||||
// Type: TRADE or MIDPOINT
|
||||
func (b *Bittrex) GetHistoricalCandles(marketName, candleInterval, candleType string, year, month, day int) ([]CandleData, error) {
|
||||
func (b *Bittrex) GetHistoricalCandles(ctx context.Context, marketName, candleInterval, candleType string, year, month, day int) ([]CandleData, error) {
|
||||
var resp []CandleData
|
||||
|
||||
var start string
|
||||
@@ -219,30 +219,30 @@ func (b *Bittrex) GetHistoricalCandles(marketName, candleInterval, candleType st
|
||||
return resp, fmt.Errorf("invalid interval %v, not supported", candleInterval)
|
||||
}
|
||||
|
||||
return resp, b.SendHTTPRequest(exchange.RestSpot, fmt.Sprintf(getHistoricalCandles, marketName, candleType, candleInterval, start), &resp, nil)
|
||||
return resp, b.SendHTTPRequest(ctx, exchange.RestSpot, fmt.Sprintf(getHistoricalCandles, marketName, candleType, candleInterval, start), &resp, nil)
|
||||
}
|
||||
|
||||
// GetBalances is used to retrieve all balances from your account
|
||||
func (b *Bittrex) GetBalances() ([]BalanceData, error) {
|
||||
func (b *Bittrex) GetBalances(ctx context.Context) ([]BalanceData, error) {
|
||||
var resp []BalanceData
|
||||
return resp, b.SendAuthHTTPRequest(exchange.RestSpot, http.MethodGet, getBalances, nil, nil, &resp, nil)
|
||||
return resp, b.SendAuthHTTPRequest(ctx, exchange.RestSpot, http.MethodGet, getBalances, nil, nil, &resp, nil)
|
||||
}
|
||||
|
||||
// GetAccountBalanceByCurrency is used to retrieve the balance from your account
|
||||
// for a specific currency. ie. "btc" or "ltc"
|
||||
func (b *Bittrex) GetAccountBalanceByCurrency(currency string) (BalanceData, error) {
|
||||
func (b *Bittrex) GetAccountBalanceByCurrency(ctx context.Context, currency string) (BalanceData, error) {
|
||||
var resp BalanceData
|
||||
return resp, b.SendAuthHTTPRequest(exchange.RestSpot, http.MethodGet, fmt.Sprintf(getBalance, currency), nil, nil, &resp, nil)
|
||||
return resp, b.SendAuthHTTPRequest(ctx, exchange.RestSpot, http.MethodGet, fmt.Sprintf(getBalance, currency), nil, nil, &resp, nil)
|
||||
}
|
||||
|
||||
// GetCryptoDepositAddress is used to retrieve an address for a specific currency
|
||||
func (b *Bittrex) GetCryptoDepositAddress(currency string) (AddressData, error) {
|
||||
func (b *Bittrex) GetCryptoDepositAddress(ctx context.Context, currency string) (AddressData, error) {
|
||||
var resp AddressData
|
||||
return resp, b.SendAuthHTTPRequest(exchange.RestSpot, http.MethodGet, fmt.Sprintf(getDepositAddress, currency), nil, nil, &resp, nil)
|
||||
return resp, b.SendAuthHTTPRequest(ctx, exchange.RestSpot, http.MethodGet, fmt.Sprintf(getDepositAddress, currency), nil, nil, &resp, nil)
|
||||
}
|
||||
|
||||
// Withdraw is used to withdraw funds from your account.
|
||||
func (b *Bittrex) Withdraw(currency, paymentID, address string, quantity float64) (WithdrawalData, error) {
|
||||
func (b *Bittrex) Withdraw(ctx context.Context, currency, paymentID, address string, quantity float64) (WithdrawalData, error) {
|
||||
req := make(map[string]interface{})
|
||||
req["currencySymbol"] = currency
|
||||
req["quantity"] = strconv.FormatFloat(quantity, 'f', -1, 64)
|
||||
@@ -251,60 +251,60 @@ func (b *Bittrex) Withdraw(currency, paymentID, address string, quantity float64
|
||||
req["cryptoAddressTag"] = paymentID
|
||||
}
|
||||
var resp WithdrawalData
|
||||
return resp, b.SendAuthHTTPRequest(exchange.RestSpot, http.MethodPost, submitWithdrawal, nil, req, &resp, nil)
|
||||
return resp, b.SendAuthHTTPRequest(ctx, exchange.RestSpot, http.MethodPost, submitWithdrawal, nil, req, &resp, nil)
|
||||
}
|
||||
|
||||
// GetOrder is used to retrieve a single order by UUID.
|
||||
func (b *Bittrex) GetOrder(uuid string) (OrderData, error) {
|
||||
func (b *Bittrex) GetOrder(ctx context.Context, uuid string) (OrderData, error) {
|
||||
var resp OrderData
|
||||
return resp, b.SendAuthHTTPRequest(exchange.RestSpot, http.MethodGet, fmt.Sprintf(getOrder, uuid), nil, nil, &resp, nil)
|
||||
return resp, b.SendAuthHTTPRequest(ctx, exchange.RestSpot, http.MethodGet, fmt.Sprintf(getOrder, uuid), nil, nil, &resp, nil)
|
||||
}
|
||||
|
||||
// GetOrderHistoryForCurrency is used to retrieve your order history. If marketName
|
||||
// is omitted it will return the entire order History.
|
||||
func (b *Bittrex) GetOrderHistoryForCurrency(currency string) ([]OrderData, error) {
|
||||
func (b *Bittrex) GetOrderHistoryForCurrency(ctx context.Context, currency string) ([]OrderData, error) {
|
||||
var resp []OrderData
|
||||
return resp, b.SendAuthHTTPRequest(exchange.RestSpot, http.MethodGet, fmt.Sprintf(getClosedOrders, currency), nil, nil, &resp, nil)
|
||||
return resp, b.SendAuthHTTPRequest(ctx, exchange.RestSpot, http.MethodGet, fmt.Sprintf(getClosedOrders, currency), nil, nil, &resp, nil)
|
||||
}
|
||||
|
||||
// GetClosedWithdrawals is used to retrieve your withdrawal history.
|
||||
func (b *Bittrex) GetClosedWithdrawals() ([]WithdrawalData, error) {
|
||||
func (b *Bittrex) GetClosedWithdrawals(ctx context.Context) ([]WithdrawalData, error) {
|
||||
var resp []WithdrawalData
|
||||
|
||||
return resp, b.SendAuthHTTPRequest(exchange.RestSpot, http.MethodGet, getClosedWithdrawals, nil, nil, &resp, nil)
|
||||
return resp, b.SendAuthHTTPRequest(ctx, exchange.RestSpot, http.MethodGet, getClosedWithdrawals, nil, nil, &resp, nil)
|
||||
}
|
||||
|
||||
// GetClosedWithdrawalsForCurrency is used to retrieve your withdrawal history for the specified currency.
|
||||
func (b *Bittrex) GetClosedWithdrawalsForCurrency(currency string) ([]WithdrawalData, error) {
|
||||
func (b *Bittrex) GetClosedWithdrawalsForCurrency(ctx context.Context, currency string) ([]WithdrawalData, error) {
|
||||
var resp []WithdrawalData
|
||||
|
||||
params := url.Values{}
|
||||
params.Set("currencySymbol", currency)
|
||||
|
||||
return resp, b.SendAuthHTTPRequest(exchange.RestSpot, http.MethodGet, getClosedWithdrawals, params, nil, &resp, nil)
|
||||
return resp, b.SendAuthHTTPRequest(ctx, exchange.RestSpot, http.MethodGet, getClosedWithdrawals, params, nil, &resp, nil)
|
||||
}
|
||||
|
||||
// GetOpenWithdrawals is used to retrieve your withdrawal history. If currency
|
||||
// omitted it will return the entire history
|
||||
func (b *Bittrex) GetOpenWithdrawals() ([]WithdrawalData, error) {
|
||||
func (b *Bittrex) GetOpenWithdrawals(ctx context.Context) ([]WithdrawalData, error) {
|
||||
var resp []WithdrawalData
|
||||
return resp, b.SendAuthHTTPRequest(exchange.RestSpot, http.MethodGet, getOpenWithdrawals, nil, nil, &resp, nil)
|
||||
return resp, b.SendAuthHTTPRequest(ctx, exchange.RestSpot, http.MethodGet, getOpenWithdrawals, nil, nil, &resp, nil)
|
||||
}
|
||||
|
||||
// GetClosedDeposits is used to retrieve your deposit history.
|
||||
func (b *Bittrex) GetClosedDeposits() ([]DepositData, error) {
|
||||
func (b *Bittrex) GetClosedDeposits(ctx context.Context) ([]DepositData, error) {
|
||||
var resp []DepositData
|
||||
return resp, b.SendAuthHTTPRequest(exchange.RestSpot, http.MethodGet, getClosedDeposits, nil, nil, &resp, nil)
|
||||
return resp, b.SendAuthHTTPRequest(ctx, exchange.RestSpot, http.MethodGet, getClosedDeposits, nil, nil, &resp, nil)
|
||||
}
|
||||
|
||||
// GetClosedDepositsForCurrency is used to retrieve your deposit history for the specified currency
|
||||
func (b *Bittrex) GetClosedDepositsForCurrency(currency string) ([]DepositData, error) {
|
||||
func (b *Bittrex) GetClosedDepositsForCurrency(ctx context.Context, currency string) ([]DepositData, error) {
|
||||
var resp []DepositData
|
||||
|
||||
params := url.Values{}
|
||||
params.Set("currencySymbol", currency)
|
||||
|
||||
return resp, b.SendAuthHTTPRequest(exchange.RestSpot, http.MethodGet, getClosedDeposits, params, nil, &resp, nil)
|
||||
return resp, b.SendAuthHTTPRequest(ctx, exchange.RestSpot, http.MethodGet, getClosedDeposits, params, nil, &resp, nil)
|
||||
}
|
||||
|
||||
// GetClosedDepositsPaginated is used to retrieve your deposit history.
|
||||
@@ -312,7 +312,7 @@ func (b *Bittrex) GetClosedDepositsForCurrency(currency string) ([]DepositData,
|
||||
// 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 (b *Bittrex) GetClosedDepositsPaginated(pageSize int, previousPageTokenOptional ...string) ([]DepositData, error) {
|
||||
func (b *Bittrex) GetClosedDepositsPaginated(ctx context.Context, pageSize int, previousPageTokenOptional ...string) ([]DepositData, error) {
|
||||
var resp []DepositData
|
||||
|
||||
params := url.Values{}
|
||||
@@ -322,27 +322,27 @@ func (b *Bittrex) GetClosedDepositsPaginated(pageSize int, previousPageTokenOpti
|
||||
params.Set("previousPageToken", previousPageTokenOptional[0])
|
||||
}
|
||||
|
||||
return resp, b.SendAuthHTTPRequest(exchange.RestSpot, http.MethodGet, getClosedDeposits, params, nil, &resp, nil)
|
||||
return resp, b.SendAuthHTTPRequest(ctx, exchange.RestSpot, http.MethodGet, getClosedDeposits, params, nil, &resp, nil)
|
||||
}
|
||||
|
||||
// GetOpenDeposits is used to retrieve your open deposits.
|
||||
func (b *Bittrex) GetOpenDeposits() ([]DepositData, error) {
|
||||
func (b *Bittrex) GetOpenDeposits(ctx context.Context) ([]DepositData, error) {
|
||||
var resp []DepositData
|
||||
return resp, b.SendAuthHTTPRequest(exchange.RestSpot, http.MethodGet, getOpenDeposits, nil, nil, &resp, nil)
|
||||
return resp, b.SendAuthHTTPRequest(ctx, exchange.RestSpot, http.MethodGet, getOpenDeposits, nil, nil, &resp, nil)
|
||||
}
|
||||
|
||||
// GetOpenDepositsForCurrency is used to retrieve your open deposits for the specified currency
|
||||
func (b *Bittrex) GetOpenDepositsForCurrency(currency string) ([]DepositData, error) {
|
||||
func (b *Bittrex) GetOpenDepositsForCurrency(ctx context.Context, currency string) ([]DepositData, error) {
|
||||
var resp []DepositData
|
||||
|
||||
params := url.Values{}
|
||||
params.Set("currencySymbol", currency)
|
||||
|
||||
return resp, b.SendAuthHTTPRequest(exchange.RestSpot, http.MethodGet, getOpenDeposits, params, nil, &resp, nil)
|
||||
return resp, b.SendAuthHTTPRequest(ctx, exchange.RestSpot, http.MethodGet, getOpenDeposits, params, nil, &resp, nil)
|
||||
}
|
||||
|
||||
// SendHTTPRequest sends an unauthenticated HTTP request
|
||||
func (b *Bittrex) SendHTTPRequest(ep exchange.URL, path string, result interface{}, resultHeader *http.Header) error {
|
||||
func (b *Bittrex) SendHTTPRequest(ctx context.Context, ep exchange.URL, path string, result interface{}, resultHeader *http.Header) error {
|
||||
endpoint, err := b.API.Endpoints.GetURL(ep)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -356,11 +356,11 @@ func (b *Bittrex) SendHTTPRequest(ep exchange.URL, path string, result interface
|
||||
HTTPRecording: b.HTTPRecording,
|
||||
HeaderResponse: resultHeader,
|
||||
}
|
||||
return b.SendPayload(context.Background(), request.Unset, func() (*request.Item, error) { return item, nil })
|
||||
return b.SendPayload(ctx, request.Unset, func() (*request.Item, error) { return item, nil })
|
||||
}
|
||||
|
||||
// SendAuthHTTPRequest sends an authenticated request
|
||||
func (b *Bittrex) SendAuthHTTPRequest(ep exchange.URL, method, action string, params url.Values, data, result interface{}, resultHeader *http.Header) error {
|
||||
func (b *Bittrex) SendAuthHTTPRequest(ctx context.Context, ep exchange.URL, method, action string, params url.Values, data, result interface{}, resultHeader *http.Header) error {
|
||||
if !b.AllowAuthenticatedRequest() {
|
||||
return fmt.Errorf("%s %w", b.Name, exchange.ErrAuthenticatedRequestWithoutCredentialsSet)
|
||||
}
|
||||
@@ -421,11 +421,11 @@ func (b *Bittrex) SendAuthHTTPRequest(ep exchange.URL, method, action string, pa
|
||||
}, nil
|
||||
}
|
||||
|
||||
return b.SendPayload(context.Background(), request.Unset, newRequest)
|
||||
return b.SendPayload(ctx, request.Unset, newRequest)
|
||||
}
|
||||
|
||||
// GetFee returns an estimate of fee based on type of transaction
|
||||
func (b *Bittrex) GetFee(feeBuilder *exchange.FeeBuilder) (float64, error) {
|
||||
func (b *Bittrex) GetFee(ctx context.Context, feeBuilder *exchange.FeeBuilder) (float64, error) {
|
||||
var fee float64
|
||||
var err error
|
||||
|
||||
@@ -433,7 +433,7 @@ func (b *Bittrex) GetFee(feeBuilder *exchange.FeeBuilder) (float64, error) {
|
||||
case exchange.CryptocurrencyTradeFee:
|
||||
fee = calculateTradingFee(feeBuilder.PurchasePrice, feeBuilder.Amount)
|
||||
case exchange.CryptocurrencyWithdrawalFee:
|
||||
fee, err = b.GetWithdrawalFee(feeBuilder.Pair.Base)
|
||||
fee, err = b.GetWithdrawalFee(ctx, feeBuilder.Pair.Base)
|
||||
case exchange.OfflineTradeFee:
|
||||
fee = calculateTradingFee(feeBuilder.PurchasePrice, feeBuilder.Amount)
|
||||
}
|
||||
@@ -444,10 +444,10 @@ func (b *Bittrex) GetFee(feeBuilder *exchange.FeeBuilder) (float64, error) {
|
||||
}
|
||||
|
||||
// GetWithdrawalFee returns the fee for withdrawing from the exchange
|
||||
func (b *Bittrex) GetWithdrawalFee(c currency.Code) (float64, error) {
|
||||
func (b *Bittrex) GetWithdrawalFee(ctx context.Context, c currency.Code) (float64, error) {
|
||||
var fee float64
|
||||
|
||||
currencies, err := b.GetCurrencies()
|
||||
currencies, err := b.GetCurrencies(ctx)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user