mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-31 15:10:42 +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:
@@ -53,12 +53,17 @@ type Alphapoint struct {
|
||||
|
||||
// GetTicker returns current ticker information from Alphapoint for a selected
|
||||
// currency pair ie "BTCUSD"
|
||||
func (a *Alphapoint) GetTicker(currencyPair string) (Ticker, error) {
|
||||
func (a *Alphapoint) GetTicker(ctx context.Context, currencyPair string) (Ticker, error) {
|
||||
req := make(map[string]interface{})
|
||||
req["productPair"] = currencyPair
|
||||
response := Ticker{}
|
||||
|
||||
err := a.SendHTTPRequest(exchange.RestSpot, http.MethodPost, alphapointTicker, req, &response)
|
||||
err := a.SendHTTPRequest(ctx,
|
||||
exchange.RestSpot,
|
||||
http.MethodPost,
|
||||
alphapointTicker,
|
||||
req,
|
||||
&response)
|
||||
if err != nil {
|
||||
return response, err
|
||||
}
|
||||
@@ -74,14 +79,15 @@ func (a *Alphapoint) GetTicker(currencyPair string) (Ticker, error) {
|
||||
// AlphaPoint Exchange. To begin from the most recent trade, set startIndex to
|
||||
// 0 (default: 0)
|
||||
// Count: specifies the number of trades to return (default: 10)
|
||||
func (a *Alphapoint) GetTrades(currencyPair string, startIndex, count int) (Trades, error) {
|
||||
func (a *Alphapoint) GetTrades(ctx context.Context, currencyPair string, startIndex, count int) (Trades, error) {
|
||||
req := make(map[string]interface{})
|
||||
req["ins"] = currencyPair
|
||||
req["startIndex"] = startIndex
|
||||
req["Count"] = count
|
||||
response := Trades{}
|
||||
|
||||
err := a.SendHTTPRequest(exchange.RestSpot, http.MethodPost, alphapointTrades, req, &response)
|
||||
err := a.SendHTTPRequest(ctx,
|
||||
exchange.RestSpot, http.MethodPost, alphapointTrades, req, &response)
|
||||
if err != nil {
|
||||
return response, err
|
||||
}
|
||||
@@ -95,14 +101,19 @@ func (a *Alphapoint) GetTrades(currencyPair string, startIndex, count int) (Trad
|
||||
// CurrencyPair - instrument code (ex: “BTCUSD”)
|
||||
// StartDate - specifies the starting time in epoch time, type is long
|
||||
// EndDate - specifies the end time in epoch time, type is long
|
||||
func (a *Alphapoint) GetTradesByDate(currencyPair string, startDate, endDate int64) (Trades, error) {
|
||||
func (a *Alphapoint) GetTradesByDate(ctx context.Context, currencyPair string, startDate, endDate int64) (Trades, error) {
|
||||
req := make(map[string]interface{})
|
||||
req["ins"] = currencyPair
|
||||
req["startDate"] = startDate
|
||||
req["endDate"] = endDate
|
||||
response := Trades{}
|
||||
|
||||
err := a.SendHTTPRequest(exchange.RestSpot, http.MethodPost, alphapointTradesByDate, req, &response)
|
||||
err := a.SendHTTPRequest(ctx,
|
||||
exchange.RestSpot,
|
||||
http.MethodPost,
|
||||
alphapointTradesByDate,
|
||||
req,
|
||||
&response)
|
||||
if err != nil {
|
||||
return response, err
|
||||
}
|
||||
@@ -114,12 +125,13 @@ func (a *Alphapoint) GetTradesByDate(currencyPair string, startDate, endDate int
|
||||
|
||||
// GetOrderbook fetches the current orderbook for a given currency pair
|
||||
// CurrencyPair - trade pair (ex: “BTCUSD”)
|
||||
func (a *Alphapoint) GetOrderbook(currencyPair string) (Orderbook, error) {
|
||||
func (a *Alphapoint) GetOrderbook(ctx context.Context, currencyPair string) (Orderbook, error) {
|
||||
req := make(map[string]interface{})
|
||||
req["productPair"] = currencyPair
|
||||
response := Orderbook{}
|
||||
|
||||
err := a.SendHTTPRequest(exchange.RestSpot, http.MethodPost, alphapointOrderbook, req, &response)
|
||||
err := a.SendHTTPRequest(ctx,
|
||||
exchange.RestSpot, http.MethodPost, alphapointOrderbook, req, &response)
|
||||
if err != nil {
|
||||
return response, err
|
||||
}
|
||||
@@ -130,10 +142,11 @@ func (a *Alphapoint) GetOrderbook(currencyPair string) (Orderbook, error) {
|
||||
}
|
||||
|
||||
// GetProductPairs gets the currency pairs currently traded on alphapoint
|
||||
func (a *Alphapoint) GetProductPairs() (ProductPairs, error) {
|
||||
func (a *Alphapoint) GetProductPairs(ctx context.Context) (ProductPairs, error) {
|
||||
response := ProductPairs{}
|
||||
|
||||
err := a.SendHTTPRequest(exchange.RestSpot, http.MethodPost, alphapointProductPairs, nil, &response)
|
||||
err := a.SendHTTPRequest(ctx,
|
||||
exchange.RestSpot, http.MethodPost, alphapointProductPairs, nil, &response)
|
||||
if err != nil {
|
||||
return response, err
|
||||
}
|
||||
@@ -144,10 +157,11 @@ func (a *Alphapoint) GetProductPairs() (ProductPairs, error) {
|
||||
}
|
||||
|
||||
// GetProducts gets the currency products currently supported on alphapoint
|
||||
func (a *Alphapoint) GetProducts() (Products, error) {
|
||||
func (a *Alphapoint) GetProducts(ctx context.Context) (Products, error) {
|
||||
response := Products{}
|
||||
|
||||
err := a.SendHTTPRequest(exchange.RestSpot, http.MethodPost, alphapointProducts, nil, &response)
|
||||
err := a.SendHTTPRequest(ctx,
|
||||
exchange.RestSpot, http.MethodPost, alphapointProducts, nil, &response)
|
||||
if err != nil {
|
||||
return response, err
|
||||
}
|
||||
@@ -163,7 +177,7 @@ func (a *Alphapoint) GetProducts() (Products, error) {
|
||||
// Email - Email address
|
||||
// Phone - Phone number (ex: “+12223334444”)
|
||||
// Password - Minimum 8 characters
|
||||
func (a *Alphapoint) CreateAccount(firstName, lastName, email, phone, password string) error {
|
||||
func (a *Alphapoint) CreateAccount(ctx context.Context, firstName, lastName, email, phone, password string) error {
|
||||
if len(password) < 8 {
|
||||
return errors.New(
|
||||
"alphapoint Error - Create account - Password must be 8 characters or more",
|
||||
@@ -178,7 +192,8 @@ func (a *Alphapoint) CreateAccount(firstName, lastName, email, phone, password s
|
||||
req["password"] = password
|
||||
response := Response{}
|
||||
|
||||
err := a.SendAuthenticatedHTTPRequest(exchange.RestSpot, http.MethodPost, alphapointCreateAccount, req, &response)
|
||||
err := a.SendAuthenticatedHTTPRequest(ctx,
|
||||
exchange.RestSpot, http.MethodPost, alphapointCreateAccount, req, &response)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to create account. Reason: %s", err)
|
||||
}
|
||||
@@ -189,10 +204,15 @@ func (a *Alphapoint) CreateAccount(firstName, lastName, email, phone, password s
|
||||
}
|
||||
|
||||
// GetUserInfo returns current account user information
|
||||
func (a *Alphapoint) GetUserInfo() (UserInfo, error) {
|
||||
func (a *Alphapoint) GetUserInfo(ctx context.Context) (UserInfo, error) {
|
||||
response := UserInfo{}
|
||||
|
||||
err := a.SendAuthenticatedHTTPRequest(exchange.RestSpot, http.MethodPost, alphapointUserInfo, map[string]interface{}{}, &response)
|
||||
err := a.SendAuthenticatedHTTPRequest(ctx,
|
||||
exchange.RestSpot,
|
||||
http.MethodPost,
|
||||
alphapointUserInfo,
|
||||
map[string]interface{}{},
|
||||
&response)
|
||||
if err != nil {
|
||||
return UserInfo{}, err
|
||||
}
|
||||
@@ -211,7 +231,7 @@ func (a *Alphapoint) GetUserInfo() (UserInfo, error) {
|
||||
// Cell2FAValue - Cell phone number, required for Authentication
|
||||
// Use2FAForWithdraw - “true” or “false” set to true for using 2FA for
|
||||
// withdrawals
|
||||
func (a *Alphapoint) SetUserInfo(firstName, lastName, cell2FACountryCode, cell2FAValue string, useAuthy2FA, use2FAForWithdraw bool) (UserInfoSet, error) {
|
||||
func (a *Alphapoint) SetUserInfo(ctx context.Context, firstName, lastName, cell2FACountryCode, cell2FAValue string, useAuthy2FA, use2FAForWithdraw bool) (UserInfoSet, error) {
|
||||
response := UserInfoSet{}
|
||||
|
||||
var userInfoKVPs = []UserInfoKVP{
|
||||
@@ -244,7 +264,7 @@ func (a *Alphapoint) SetUserInfo(firstName, lastName, cell2FACountryCode, cell2F
|
||||
req := make(map[string]interface{})
|
||||
req["userInfoKVP"] = userInfoKVPs
|
||||
|
||||
err := a.SendAuthenticatedHTTPRequest(
|
||||
err := a.SendAuthenticatedHTTPRequest(ctx,
|
||||
exchange.RestSpot,
|
||||
http.MethodPost,
|
||||
alphapointUserInfo,
|
||||
@@ -261,10 +281,10 @@ func (a *Alphapoint) SetUserInfo(firstName, lastName, cell2FACountryCode, cell2F
|
||||
}
|
||||
|
||||
// GetAccountInformation returns account info
|
||||
func (a *Alphapoint) GetAccountInformation() (AccountInfo, error) {
|
||||
func (a *Alphapoint) GetAccountInformation(ctx context.Context) (AccountInfo, error) {
|
||||
response := AccountInfo{}
|
||||
|
||||
err := a.SendAuthenticatedHTTPRequest(
|
||||
err := a.SendAuthenticatedHTTPRequest(ctx,
|
||||
exchange.RestSpot,
|
||||
http.MethodPost,
|
||||
alphapointAccountInfo,
|
||||
@@ -284,14 +304,14 @@ func (a *Alphapoint) GetAccountInformation() (AccountInfo, error) {
|
||||
// CurrencyPair - Instrument code (ex: “BTCUSD”)
|
||||
// StartIndex - Starting index, if less than 0 then start from the beginning
|
||||
// Count - Returns last trade, (Default: 30)
|
||||
func (a *Alphapoint) GetAccountTrades(currencyPair string, startIndex, count int) (Trades, error) {
|
||||
func (a *Alphapoint) GetAccountTrades(ctx context.Context, currencyPair string, startIndex, count int) (Trades, error) {
|
||||
req := make(map[string]interface{})
|
||||
req["ins"] = currencyPair
|
||||
req["startIndex"] = startIndex
|
||||
req["count"] = count
|
||||
response := Trades{}
|
||||
|
||||
err := a.SendAuthenticatedHTTPRequest(
|
||||
err := a.SendAuthenticatedHTTPRequest(ctx,
|
||||
exchange.RestSpot,
|
||||
http.MethodPost,
|
||||
alphapointAccountTrades,
|
||||
@@ -308,11 +328,15 @@ func (a *Alphapoint) GetAccountTrades(currencyPair string, startIndex, count int
|
||||
}
|
||||
|
||||
// GetDepositAddresses generates a deposit address
|
||||
func (a *Alphapoint) GetDepositAddresses() ([]DepositAddresses, error) {
|
||||
func (a *Alphapoint) GetDepositAddresses(ctx context.Context) ([]DepositAddresses, error) {
|
||||
response := Response{}
|
||||
|
||||
err := a.SendAuthenticatedHTTPRequest(exchange.RestSpot, http.MethodPost, alphapointDepositAddresses,
|
||||
map[string]interface{}{}, &response,
|
||||
err := a.SendAuthenticatedHTTPRequest(ctx,
|
||||
exchange.RestSpot,
|
||||
http.MethodPost,
|
||||
alphapointDepositAddresses,
|
||||
map[string]interface{}{},
|
||||
&response,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -328,7 +352,7 @@ func (a *Alphapoint) GetDepositAddresses() ([]DepositAddresses, error) {
|
||||
// product - Currency name (ex: “BTC”)
|
||||
// amount - Amount (ex: “.011”)
|
||||
// address - Withdraw address
|
||||
func (a *Alphapoint) WithdrawCoins(symbol, product, address string, amount float64) error {
|
||||
func (a *Alphapoint) WithdrawCoins(ctx context.Context, symbol, product, address string, amount float64) error {
|
||||
req := make(map[string]interface{})
|
||||
req["ins"] = symbol
|
||||
req["product"] = product
|
||||
@@ -336,7 +360,7 @@ func (a *Alphapoint) WithdrawCoins(symbol, product, address string, amount float
|
||||
req["sendToAddress"] = address
|
||||
|
||||
response := Response{}
|
||||
err := a.SendAuthenticatedHTTPRequest(
|
||||
err := a.SendAuthenticatedHTTPRequest(ctx,
|
||||
exchange.RestSpot,
|
||||
http.MethodPost,
|
||||
alphapointWithdraw,
|
||||
@@ -366,7 +390,7 @@ func (a *Alphapoint) convertOrderTypeToOrderTypeNumber(orderType string) (orderT
|
||||
// orderType - “1” for market orders, “0” for limit orders
|
||||
// quantity - Quantity
|
||||
// price - Price in USD
|
||||
func (a *Alphapoint) CreateOrder(symbol, side, orderType string, quantity, price float64) (int64, error) {
|
||||
func (a *Alphapoint) CreateOrder(ctx context.Context, symbol, side, orderType string, quantity, price float64) (int64, error) {
|
||||
orderTypeNumber := a.convertOrderTypeToOrderTypeNumber(orderType)
|
||||
req := make(map[string]interface{})
|
||||
req["ins"] = symbol
|
||||
@@ -376,7 +400,7 @@ func (a *Alphapoint) CreateOrder(symbol, side, orderType string, quantity, price
|
||||
req["px"] = strconv.FormatFloat(price, 'f', -1, 64)
|
||||
response := Response{}
|
||||
|
||||
err := a.SendAuthenticatedHTTPRequest(
|
||||
err := a.SendAuthenticatedHTTPRequest(ctx,
|
||||
exchange.RestSpot,
|
||||
http.MethodPost,
|
||||
alphapointCreateOrder,
|
||||
@@ -400,14 +424,14 @@ func (a *Alphapoint) CreateOrder(symbol, side, orderType string, quantity, price
|
||||
// book. A buy order will be modified to the highest bid and a sell order will
|
||||
// be modified to the lowest ask price. “1” means "Execute now", which will
|
||||
// convert a limit order into a market order.
|
||||
func (a *Alphapoint) ModifyExistingOrder(symbol string, orderID, action int64) (int64, error) {
|
||||
func (a *Alphapoint) ModifyExistingOrder(ctx context.Context, symbol string, orderID, action int64) (int64, error) {
|
||||
req := make(map[string]interface{})
|
||||
req["ins"] = symbol
|
||||
req["serverOrderId"] = orderID
|
||||
req["modifyAction"] = action
|
||||
response := Response{}
|
||||
|
||||
err := a.SendAuthenticatedHTTPRequest(
|
||||
err := a.SendAuthenticatedHTTPRequest(ctx,
|
||||
exchange.RestSpot,
|
||||
http.MethodPost,
|
||||
alphapointModifyOrder,
|
||||
@@ -426,13 +450,13 @@ func (a *Alphapoint) ModifyExistingOrder(symbol string, orderID, action int64) (
|
||||
// CancelExistingOrder cancels an order that has not been executed.
|
||||
// symbol - Instrument code (ex: “BTCUSD”)
|
||||
// OrderId - Order id (ex: 1000)
|
||||
func (a *Alphapoint) CancelExistingOrder(orderID int64, omsid string) (int64, error) {
|
||||
func (a *Alphapoint) CancelExistingOrder(ctx context.Context, orderID int64, omsid string) (int64, error) {
|
||||
req := make(map[string]interface{})
|
||||
req["OrderId"] = orderID
|
||||
req["OMSId"] = omsid
|
||||
response := Response{}
|
||||
|
||||
err := a.SendAuthenticatedHTTPRequest(
|
||||
err := a.SendAuthenticatedHTTPRequest(ctx,
|
||||
exchange.RestSpot,
|
||||
http.MethodPost,
|
||||
alphapointCancelOrder,
|
||||
@@ -450,12 +474,12 @@ func (a *Alphapoint) CancelExistingOrder(orderID int64, omsid string) (int64, er
|
||||
|
||||
// CancelAllExistingOrders cancels all open orders by symbol
|
||||
// symbol - Instrument code (ex: “BTCUSD”)
|
||||
func (a *Alphapoint) CancelAllExistingOrders(omsid string) error {
|
||||
func (a *Alphapoint) CancelAllExistingOrders(ctx context.Context, omsid string) error {
|
||||
req := make(map[string]interface{})
|
||||
req["OMSId"] = omsid
|
||||
response := Response{}
|
||||
|
||||
err := a.SendAuthenticatedHTTPRequest(
|
||||
err := a.SendAuthenticatedHTTPRequest(ctx,
|
||||
exchange.RestSpot,
|
||||
http.MethodPost,
|
||||
alphapointCancelAllOrders,
|
||||
@@ -472,10 +496,10 @@ func (a *Alphapoint) CancelAllExistingOrders(omsid string) error {
|
||||
}
|
||||
|
||||
// GetOrders returns all current open orders
|
||||
func (a *Alphapoint) GetOrders() ([]OpenOrders, error) {
|
||||
func (a *Alphapoint) GetOrders(ctx context.Context) ([]OpenOrders, error) {
|
||||
response := OrderInfo{}
|
||||
|
||||
err := a.SendAuthenticatedHTTPRequest(
|
||||
err := a.SendAuthenticatedHTTPRequest(ctx,
|
||||
exchange.RestSpot,
|
||||
http.MethodPost,
|
||||
alphapointOpenOrders,
|
||||
@@ -496,7 +520,7 @@ func (a *Alphapoint) GetOrders() ([]OpenOrders, error) {
|
||||
// side - “buy” or “sell”
|
||||
// quantity - Quantity
|
||||
// price - Price in USD
|
||||
func (a *Alphapoint) GetOrderFee(symbol, side string, quantity, price float64) (float64, error) {
|
||||
func (a *Alphapoint) GetOrderFee(ctx context.Context, symbol, side string, quantity, price float64) (float64, error) {
|
||||
req := make(map[string]interface{})
|
||||
req["ins"] = symbol
|
||||
req["side"] = side
|
||||
@@ -504,7 +528,7 @@ func (a *Alphapoint) GetOrderFee(symbol, side string, quantity, price float64) (
|
||||
req["px"] = strconv.FormatFloat(price, 'f', -1, 64)
|
||||
response := Response{}
|
||||
|
||||
err := a.SendAuthenticatedHTTPRequest(
|
||||
err := a.SendAuthenticatedHTTPRequest(ctx,
|
||||
exchange.RestSpot,
|
||||
http.MethodPost,
|
||||
alphapointOrderFee,
|
||||
@@ -521,7 +545,7 @@ func (a *Alphapoint) GetOrderFee(symbol, side string, quantity, price float64) (
|
||||
}
|
||||
|
||||
// SendHTTPRequest sends an unauthenticated HTTP request
|
||||
func (a *Alphapoint) SendHTTPRequest(ep exchange.URL, method, path string, data map[string]interface{}, result interface{}) error {
|
||||
func (a *Alphapoint) SendHTTPRequest(ctx context.Context, ep exchange.URL, method, path string, data map[string]interface{}, result interface{}) error {
|
||||
endpoint, err := a.API.Endpoints.GetURL(ep)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -551,7 +575,7 @@ func (a *Alphapoint) SendHTTPRequest(ep exchange.URL, method, path string, data
|
||||
}
|
||||
|
||||
// SendAuthenticatedHTTPRequest sends an authenticated request
|
||||
func (a *Alphapoint) SendAuthenticatedHTTPRequest(ep exchange.URL, method, path string, data map[string]interface{}, result interface{}) error {
|
||||
func (a *Alphapoint) SendAuthenticatedHTTPRequest(ctx context.Context, ep exchange.URL, method, path string, data map[string]interface{}, result interface{}) error {
|
||||
if !a.AllowAuthenticatedRequest() {
|
||||
return fmt.Errorf("%s %w", a.Name, exchange.ErrAuthenticatedRequestWithoutCredentialsSet)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package alphapoint
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"os"
|
||||
"testing"
|
||||
@@ -41,12 +42,12 @@ func TestGetTicker(t *testing.T) {
|
||||
var ticker Ticker
|
||||
var err error
|
||||
if onlineTest {
|
||||
ticker, err = a.GetTicker("BTCUSD")
|
||||
ticker, err = a.GetTicker(context.Background(), "BTCUSD")
|
||||
if err != nil {
|
||||
t.Fatal("Alphapoint GetTicker init error: ", err)
|
||||
}
|
||||
|
||||
_, err = a.GetTicker("wigwham")
|
||||
_, err = a.GetTicker(context.Background(), "wigwham")
|
||||
if err == nil {
|
||||
t.Error("Alphapoint GetTicker Expected error")
|
||||
}
|
||||
@@ -75,12 +76,12 @@ func TestGetTrades(t *testing.T) {
|
||||
var trades Trades
|
||||
var err error
|
||||
if onlineTest {
|
||||
trades, err = a.GetTrades("BTCUSD", 0, 10)
|
||||
trades, err = a.GetTrades(context.Background(), "BTCUSD", 0, 10)
|
||||
if err != nil {
|
||||
t.Fatalf("Init error: %s", err)
|
||||
}
|
||||
|
||||
_, err = a.GetTrades("wigwham", 0, 10)
|
||||
_, err = a.GetTrades(context.Background(), "wigwham", 0, 10)
|
||||
if err == nil {
|
||||
t.Fatal("GetTrades Expected error")
|
||||
}
|
||||
@@ -113,11 +114,13 @@ func TestGetTradesByDate(t *testing.T) {
|
||||
var trades Trades
|
||||
var err error
|
||||
if onlineTest {
|
||||
trades, err = a.GetTradesByDate("BTCUSD", 1414799400, 1414800000)
|
||||
trades, err = a.GetTradesByDate(context.Background(),
|
||||
"BTCUSD", 1414799400, 1414800000)
|
||||
if err != nil {
|
||||
t.Errorf("Init error: %s", err)
|
||||
}
|
||||
_, err = a.GetTradesByDate("wigwham", 1414799400, 1414800000)
|
||||
_, err = a.GetTradesByDate(context.Background(),
|
||||
"wigwham", 1414799400, 1414800000)
|
||||
if err == nil {
|
||||
t.Error("GetTradesByDate Expected error")
|
||||
}
|
||||
@@ -157,12 +160,12 @@ func TestGetOrderbook(t *testing.T) {
|
||||
var orderBook Orderbook
|
||||
var err error
|
||||
if onlineTest {
|
||||
orderBook, err = a.GetOrderbook("BTCUSD")
|
||||
orderBook, err = a.GetOrderbook(context.Background(), "BTCUSD")
|
||||
if err != nil {
|
||||
t.Errorf("Init error: %s", err)
|
||||
}
|
||||
|
||||
_, err = a.GetOrderbook("wigwham")
|
||||
_, err = a.GetOrderbook(context.Background(), "wigwham")
|
||||
if err == nil {
|
||||
t.Error("GetOrderbook() Expected error")
|
||||
}
|
||||
@@ -200,7 +203,7 @@ func TestGetProductPairs(t *testing.T) {
|
||||
var err error
|
||||
|
||||
if onlineTest {
|
||||
products, err = a.GetProductPairs()
|
||||
products, err = a.GetProductPairs(context.Background())
|
||||
if err != nil {
|
||||
t.Errorf("Init error: %s", err)
|
||||
}
|
||||
@@ -238,7 +241,7 @@ func TestGetProducts(t *testing.T) {
|
||||
var err error
|
||||
|
||||
if onlineTest {
|
||||
products, err = a.GetProducts()
|
||||
products, err = a.GetProducts(context.Background())
|
||||
if err != nil {
|
||||
t.Errorf("Init error: %s", err)
|
||||
}
|
||||
@@ -276,15 +279,17 @@ func TestCreateAccount(t *testing.T) {
|
||||
t.Skip("API keys not set, skipping")
|
||||
}
|
||||
|
||||
err := a.CreateAccount("test", "account", "something@something.com", "0292383745", "lolcat123")
|
||||
err := a.CreateAccount(context.Background(),
|
||||
"test", "account", "something@something.com", "0292383745", "lolcat123")
|
||||
if err != nil {
|
||||
t.Errorf("Init error: %s", err)
|
||||
}
|
||||
err = a.CreateAccount("test", "account", "something@something.com", "0292383745", "bla")
|
||||
err = a.CreateAccount(context.Background(),
|
||||
"test", "account", "something@something.com", "0292383745", "bla")
|
||||
if err == nil {
|
||||
t.Errorf("CreateAccount() Expected error")
|
||||
}
|
||||
err = a.CreateAccount("", "", "", "", "lolcat123")
|
||||
err = a.CreateAccount(context.Background(), "", "", "", "", "lolcat123")
|
||||
if err == nil {
|
||||
t.Errorf("CreateAccount() Expected error")
|
||||
}
|
||||
@@ -296,7 +301,7 @@ func TestGetUserInfo(t *testing.T) {
|
||||
t.Skip("API keys not set, skipping")
|
||||
}
|
||||
|
||||
_, err := a.GetUserInfo()
|
||||
_, err := a.GetUserInfo(context.Background())
|
||||
if err == nil {
|
||||
t.Error("GetUserInfo() Expected error")
|
||||
}
|
||||
@@ -308,7 +313,8 @@ func TestSetUserInfo(t *testing.T) {
|
||||
t.Skip("API keys not set, skipping")
|
||||
}
|
||||
|
||||
_, err := a.SetUserInfo("bla", "bla", "1", "meh", true, true)
|
||||
_, err := a.SetUserInfo(context.Background(),
|
||||
"bla", "bla", "1", "meh", true, true)
|
||||
if err == nil {
|
||||
t.Error("GetUserInfo() Expected error")
|
||||
}
|
||||
@@ -320,7 +326,7 @@ func TestGetAccountInfo(t *testing.T) {
|
||||
t.Skip("API keys not set, skipping")
|
||||
}
|
||||
|
||||
_, err := a.UpdateAccountInfo(asset.Spot)
|
||||
_, err := a.UpdateAccountInfo(context.Background(), asset.Spot)
|
||||
if err == nil {
|
||||
t.Error("GetUserInfo() Expected error")
|
||||
}
|
||||
@@ -332,7 +338,7 @@ func TestGetAccountTrades(t *testing.T) {
|
||||
t.Skip("API keys not set, skipping")
|
||||
}
|
||||
|
||||
_, err := a.GetAccountTrades("", 1, 2)
|
||||
_, err := a.GetAccountTrades(context.Background(), "", 1, 2)
|
||||
if err == nil {
|
||||
t.Error("GetUserInfo() Expected error")
|
||||
}
|
||||
@@ -344,7 +350,7 @@ func TestGetDepositAddresses(t *testing.T) {
|
||||
t.Skip("API keys not set, skipping")
|
||||
}
|
||||
|
||||
_, err := a.GetDepositAddresses()
|
||||
_, err := a.GetDepositAddresses(context.Background())
|
||||
if err == nil {
|
||||
t.Error("GetUserInfo() Expected error")
|
||||
}
|
||||
@@ -356,7 +362,7 @@ func TestWithdrawCoins(t *testing.T) {
|
||||
t.Skip("API keys not set, skipping")
|
||||
}
|
||||
|
||||
err := a.WithdrawCoins("", "", "", 0.01)
|
||||
err := a.WithdrawCoins(context.Background(), "", "", "", 0.01)
|
||||
if err == nil {
|
||||
t.Error("GetUserInfo() Expected error")
|
||||
}
|
||||
@@ -368,7 +374,8 @@ func TestCreateOrder(t *testing.T) {
|
||||
t.Skip("API keys not set, skipping")
|
||||
}
|
||||
|
||||
_, err := a.CreateOrder("", "", order.Limit.String(), 0.01, 0)
|
||||
_, err := a.CreateOrder(context.Background(),
|
||||
"", "", order.Limit.String(), 0.01, 0)
|
||||
if err == nil {
|
||||
t.Error("GetUserInfo() Expected error")
|
||||
}
|
||||
@@ -380,7 +387,7 @@ func TestModifyExistingOrder(t *testing.T) {
|
||||
t.Skip("API keys not set, skipping")
|
||||
}
|
||||
|
||||
_, err := a.ModifyExistingOrder("", 1, 1)
|
||||
_, err := a.ModifyExistingOrder(context.Background(), "", 1, 1)
|
||||
if err == nil {
|
||||
t.Error("GetUserInfo() Expected error")
|
||||
}
|
||||
@@ -392,7 +399,7 @@ func TestCancelAllExistingOrders(t *testing.T) {
|
||||
t.Skip("API keys not set, skipping")
|
||||
}
|
||||
|
||||
err := a.CancelAllExistingOrders("")
|
||||
err := a.CancelAllExistingOrders(context.Background(), "")
|
||||
if err == nil {
|
||||
t.Error("GetUserInfo() Expected error")
|
||||
}
|
||||
@@ -404,7 +411,7 @@ func TestGetOrders(t *testing.T) {
|
||||
t.Skip("API keys not set, skipping")
|
||||
}
|
||||
|
||||
_, err := a.GetOrders()
|
||||
_, err := a.GetOrders(context.Background())
|
||||
if err == nil {
|
||||
t.Error("GetUserInfo() Expected error")
|
||||
}
|
||||
@@ -416,7 +423,7 @@ func TestGetOrderFee(t *testing.T) {
|
||||
t.Skip("API keys not set, skipping")
|
||||
}
|
||||
|
||||
_, err := a.GetOrderFee("", "", 1, 1)
|
||||
_, err := a.GetOrderFee(context.Background(), "", "", 1, 1)
|
||||
if err == nil {
|
||||
t.Error("GetUserInfo() Expected error")
|
||||
}
|
||||
@@ -438,7 +445,7 @@ func TestGetActiveOrders(t *testing.T) {
|
||||
AssetType: asset.Spot,
|
||||
}
|
||||
|
||||
_, err := a.GetActiveOrders(&getOrdersRequest)
|
||||
_, err := a.GetActiveOrders(context.Background(), &getOrdersRequest)
|
||||
if areTestAPIKeysSet() && err != nil {
|
||||
t.Errorf("Could not get open orders: %s", err)
|
||||
} else if !areTestAPIKeysSet() && err == nil {
|
||||
@@ -453,7 +460,7 @@ func TestGetOrderHistory(t *testing.T) {
|
||||
AssetType: asset.Spot,
|
||||
}
|
||||
|
||||
_, err := a.GetOrderHistory(&getOrdersRequest)
|
||||
_, err := a.GetOrderHistory(context.Background(), &getOrdersRequest)
|
||||
if areTestAPIKeysSet() && err != nil {
|
||||
t.Errorf("Could not get order history: %s", err)
|
||||
} else if !areTestAPIKeysSet() && err == nil {
|
||||
@@ -484,7 +491,7 @@ func TestSubmitOrder(t *testing.T) {
|
||||
AssetType: asset.Spot,
|
||||
}
|
||||
|
||||
response, err := a.SubmitOrder(orderSubmission)
|
||||
response, err := a.SubmitOrder(context.Background(), orderSubmission)
|
||||
if !areTestAPIKeysSet() && err == nil {
|
||||
t.Error("Expecting an error when no keys are set")
|
||||
}
|
||||
@@ -512,7 +519,7 @@ func TestCancelExchangeOrder(t *testing.T) {
|
||||
AssetType: asset.Spot,
|
||||
}
|
||||
|
||||
err := a.CancelOrder(orderCancellation)
|
||||
err := a.CancelOrder(context.Background(), orderCancellation)
|
||||
if !areTestAPIKeysSet() && err == nil {
|
||||
t.Error("Expecting an error when no keys are set")
|
||||
}
|
||||
@@ -536,7 +543,7 @@ func TestCancelAllExchangeOrders(t *testing.T) {
|
||||
AssetType: asset.Spot,
|
||||
}
|
||||
|
||||
resp, err := a.CancelAllOrders(orderCancellation)
|
||||
resp, err := a.CancelAllOrders(context.Background(), orderCancellation)
|
||||
if !areTestAPIKeysSet() && err == nil {
|
||||
t.Error("Expecting an error when no keys are set")
|
||||
}
|
||||
@@ -562,7 +569,8 @@ func TestModifyOrder(t *testing.T) {
|
||||
|
||||
func TestWithdraw(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := a.WithdrawCryptocurrencyFunds(&withdraw.Request{})
|
||||
_, err := a.WithdrawCryptocurrencyFunds(context.Background(),
|
||||
&withdraw.Request{})
|
||||
if err != common.ErrNotYetImplemented {
|
||||
t.Errorf("Expected 'Not implemented', received %v", err)
|
||||
}
|
||||
@@ -574,7 +582,8 @@ func TestWithdrawFiat(t *testing.T) {
|
||||
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
|
||||
}
|
||||
|
||||
_, err := a.WithdrawFiatFunds(&withdraw.Request{})
|
||||
_, err := a.WithdrawFiatFunds(context.Background(),
|
||||
&withdraw.Request{})
|
||||
if err != common.ErrNotYetImplemented {
|
||||
t.Errorf("Expected '%v', received: '%v'", common.ErrNotYetImplemented, err)
|
||||
}
|
||||
@@ -610,7 +619,8 @@ func TestGetHistoricTrades(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_, err = a.GetHistoricTrades(currencyPair, asset.Spot, time.Now().Add(-time.Minute*15), time.Now())
|
||||
_, err = a.GetHistoricTrades(context.Background(),
|
||||
currencyPair, asset.Spot, time.Now().Add(-time.Minute*15), time.Now())
|
||||
if err != nil && err != common.ErrNotYetImplemented {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package alphapoint
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strconv"
|
||||
"time"
|
||||
@@ -77,22 +78,22 @@ func (a *Alphapoint) SetDefaults() {
|
||||
}
|
||||
|
||||
// FetchTradablePairs returns a list of the exchanges tradable pairs
|
||||
func (a *Alphapoint) FetchTradablePairs(asset asset.Item) ([]string, error) {
|
||||
func (a *Alphapoint) FetchTradablePairs(ctx context.Context, asset asset.Item) ([]string, error) {
|
||||
return nil, common.ErrFunctionNotSupported
|
||||
}
|
||||
|
||||
// UpdateTradablePairs updates the exchanges available pairs and stores
|
||||
// them in the exchanges config
|
||||
func (a *Alphapoint) UpdateTradablePairs(forceUpdate bool) error {
|
||||
func (a *Alphapoint) UpdateTradablePairs(ctx context.Context, forceUpdate bool) error {
|
||||
return common.ErrFunctionNotSupported
|
||||
}
|
||||
|
||||
// UpdateAccountInfo retrieves balances for all enabled currencies on the
|
||||
// Alphapoint exchange
|
||||
func (a *Alphapoint) UpdateAccountInfo(assetType asset.Item) (account.Holdings, error) {
|
||||
func (a *Alphapoint) UpdateAccountInfo(ctx context.Context, assetType asset.Item) (account.Holdings, error) {
|
||||
var response account.Holdings
|
||||
response.Exchange = a.Name
|
||||
acc, err := a.GetAccountInformation()
|
||||
acc, err := a.GetAccountInformation(ctx)
|
||||
if err != nil {
|
||||
return response, err
|
||||
}
|
||||
@@ -121,10 +122,10 @@ func (a *Alphapoint) UpdateAccountInfo(assetType asset.Item) (account.Holdings,
|
||||
|
||||
// FetchAccountInfo retrieves balances for all enabled currencies on the
|
||||
// Alphapoint exchange
|
||||
func (a *Alphapoint) FetchAccountInfo(assetType asset.Item) (account.Holdings, error) {
|
||||
func (a *Alphapoint) FetchAccountInfo(ctx context.Context, assetType asset.Item) (account.Holdings, error) {
|
||||
acc, err := account.GetHoldings(a.Name, assetType)
|
||||
if err != nil {
|
||||
return a.UpdateAccountInfo(assetType)
|
||||
return a.UpdateAccountInfo(ctx, assetType)
|
||||
}
|
||||
|
||||
return acc, nil
|
||||
@@ -136,8 +137,8 @@ func (a *Alphapoint) UpdateTickers(assetType asset.Item) error {
|
||||
}
|
||||
|
||||
// UpdateTicker updates and returns the ticker for a currency pair
|
||||
func (a *Alphapoint) UpdateTicker(p currency.Pair, assetType asset.Item) (*ticker.Price, error) {
|
||||
tick, err := a.GetTicker(p.String())
|
||||
func (a *Alphapoint) UpdateTicker(ctx context.Context, p currency.Pair, assetType asset.Item) (*ticker.Price, error) {
|
||||
tick, err := a.GetTicker(ctx, p.String())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -161,18 +162,18 @@ func (a *Alphapoint) UpdateTicker(p currency.Pair, assetType asset.Item) (*ticke
|
||||
}
|
||||
|
||||
// FetchTicker returns the ticker for a currency pair
|
||||
func (a *Alphapoint) FetchTicker(p currency.Pair, assetType asset.Item) (*ticker.Price, error) {
|
||||
func (a *Alphapoint) FetchTicker(ctx context.Context, p currency.Pair, assetType asset.Item) (*ticker.Price, error) {
|
||||
tick, err := ticker.GetTicker(a.Name, p, assetType)
|
||||
if err != nil {
|
||||
return a.UpdateTicker(p, assetType)
|
||||
return a.UpdateTicker(ctx, p, assetType)
|
||||
}
|
||||
return tick, nil
|
||||
}
|
||||
|
||||
// UpdateOrderbook updates and returns the orderbook for a currency pair
|
||||
func (a *Alphapoint) UpdateOrderbook(p currency.Pair, assetType asset.Item) (*orderbook.Base, error) {
|
||||
func (a *Alphapoint) UpdateOrderbook(ctx context.Context, p currency.Pair, assetType asset.Item) (*orderbook.Base, error) {
|
||||
orderBook := new(orderbook.Base)
|
||||
orderbookNew, err := a.GetOrderbook(p.String())
|
||||
orderbookNew, err := a.GetOrderbook(ctx, p.String())
|
||||
if err != nil {
|
||||
return orderBook, err
|
||||
}
|
||||
@@ -204,23 +205,23 @@ func (a *Alphapoint) UpdateOrderbook(p currency.Pair, assetType asset.Item) (*or
|
||||
}
|
||||
|
||||
// FetchOrderbook returns the orderbook for a currency pair
|
||||
func (a *Alphapoint) FetchOrderbook(p currency.Pair, assetType asset.Item) (*orderbook.Base, error) {
|
||||
func (a *Alphapoint) FetchOrderbook(ctx context.Context, p currency.Pair, assetType asset.Item) (*orderbook.Base, error) {
|
||||
ob, err := orderbook.Get(a.Name, p, assetType)
|
||||
if err != nil {
|
||||
return a.UpdateOrderbook(p, assetType)
|
||||
return a.UpdateOrderbook(ctx, p, assetType)
|
||||
}
|
||||
return ob, nil
|
||||
}
|
||||
|
||||
// GetFundingHistory returns funding history, deposits and
|
||||
// withdrawals
|
||||
func (a *Alphapoint) GetFundingHistory() ([]exchange.FundHistory, error) {
|
||||
func (a *Alphapoint) GetFundingHistory(ctx context.Context) ([]exchange.FundHistory, error) {
|
||||
// https://alphapoint.github.io/slate/#generatetreasuryactivityreport
|
||||
return nil, common.ErrNotYetImplemented
|
||||
}
|
||||
|
||||
// GetWithdrawalsHistory returns previous withdrawals data
|
||||
func (a *Alphapoint) GetWithdrawalsHistory(c currency.Code) (resp []exchange.WithdrawalHistory, err error) {
|
||||
func (a *Alphapoint) GetWithdrawalsHistory(ctx context.Context, c currency.Code) (resp []exchange.WithdrawalHistory, err error) {
|
||||
return nil, common.ErrNotYetImplemented
|
||||
}
|
||||
|
||||
@@ -230,13 +231,13 @@ func (a *Alphapoint) GetRecentTrades(_ currency.Pair, _ asset.Item) ([]trade.Dat
|
||||
}
|
||||
|
||||
// GetHistoricTrades returns historic trade data within the timeframe provided
|
||||
func (a *Alphapoint) GetHistoricTrades(_ currency.Pair, _ asset.Item, _, _ time.Time) ([]trade.Data, error) {
|
||||
func (a *Alphapoint) GetHistoricTrades(_ context.Context, _ currency.Pair, _ asset.Item, _, _ time.Time) ([]trade.Data, error) {
|
||||
return nil, common.ErrNotYetImplemented
|
||||
}
|
||||
|
||||
// SubmitOrder submits a new order and returns a true value when
|
||||
// successfully submitted
|
||||
func (a *Alphapoint) SubmitOrder(s *order.Submit) (order.SubmitResponse, error) {
|
||||
func (a *Alphapoint) SubmitOrder(ctx context.Context, s *order.Submit) (order.SubmitResponse, error) {
|
||||
var submitOrderResponse order.SubmitResponse
|
||||
if err := s.Validate(); err != nil {
|
||||
return submitOrderResponse, err
|
||||
@@ -247,7 +248,8 @@ func (a *Alphapoint) SubmitOrder(s *order.Submit) (order.SubmitResponse, error)
|
||||
return submitOrderResponse, err
|
||||
}
|
||||
|
||||
response, err := a.CreateOrder(fPair.String(),
|
||||
response, err := a.CreateOrder(ctx,
|
||||
fPair.String(),
|
||||
s.Side.String(),
|
||||
s.Type.String(),
|
||||
s.Amount,
|
||||
@@ -273,7 +275,7 @@ func (a *Alphapoint) ModifyOrder(_ *order.Modify) (order.Modify, error) {
|
||||
}
|
||||
|
||||
// CancelOrder cancels an order by its corresponding ID number
|
||||
func (a *Alphapoint) CancelOrder(o *order.Cancel) error {
|
||||
func (a *Alphapoint) CancelOrder(ctx context.Context, o *order.Cancel) error {
|
||||
if err := o.Validate(o.StandardCancel()); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -281,27 +283,27 @@ func (a *Alphapoint) CancelOrder(o *order.Cancel) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = a.CancelExistingOrder(orderIDInt, o.AccountID)
|
||||
_, err = a.CancelExistingOrder(ctx, orderIDInt, o.AccountID)
|
||||
return err
|
||||
}
|
||||
|
||||
// CancelBatchOrders cancels an orders by their corresponding ID numbers
|
||||
func (a *Alphapoint) CancelBatchOrders(o []order.Cancel) (order.CancelBatchResponse, error) {
|
||||
func (a *Alphapoint) CancelBatchOrders(ctx context.Context, o []order.Cancel) (order.CancelBatchResponse, error) {
|
||||
return order.CancelBatchResponse{}, common.ErrNotYetImplemented
|
||||
}
|
||||
|
||||
// CancelAllOrders cancels all orders for a given account
|
||||
func (a *Alphapoint) CancelAllOrders(orderCancellation *order.Cancel) (order.CancelAllResponse, error) {
|
||||
func (a *Alphapoint) CancelAllOrders(ctx context.Context, orderCancellation *order.Cancel) (order.CancelAllResponse, error) {
|
||||
if err := orderCancellation.Validate(); err != nil {
|
||||
return order.CancelAllResponse{}, err
|
||||
}
|
||||
return order.CancelAllResponse{},
|
||||
a.CancelAllExistingOrders(orderCancellation.AccountID)
|
||||
a.CancelAllExistingOrders(ctx, orderCancellation.AccountID)
|
||||
}
|
||||
|
||||
// GetOrderInfo returns order information based on order ID
|
||||
func (a *Alphapoint) GetOrderInfo(orderID string, pair currency.Pair, assetType asset.Item) (float64, error) {
|
||||
orders, err := a.GetOrders()
|
||||
func (a *Alphapoint) GetOrderInfo(ctx context.Context, orderID string, pair currency.Pair, assetType asset.Item) (float64, error) {
|
||||
orders, err := a.GetOrders(ctx)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@@ -317,8 +319,8 @@ func (a *Alphapoint) GetOrderInfo(orderID string, pair currency.Pair, assetType
|
||||
}
|
||||
|
||||
// GetDepositAddress returns a deposit address for a specified currency
|
||||
func (a *Alphapoint) GetDepositAddress(cryptocurrency currency.Code, _ string) (string, error) {
|
||||
addreses, err := a.GetDepositAddresses()
|
||||
func (a *Alphapoint) GetDepositAddress(ctx context.Context, cryptocurrency currency.Code, _ string) (string, error) {
|
||||
addreses, err := a.GetDepositAddresses(ctx)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -333,12 +335,12 @@ func (a *Alphapoint) GetDepositAddress(cryptocurrency currency.Code, _ string) (
|
||||
|
||||
// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is
|
||||
// submitted
|
||||
func (a *Alphapoint) WithdrawCryptocurrencyFunds(_ *withdraw.Request) (*withdraw.ExchangeResponse, error) {
|
||||
func (a *Alphapoint) WithdrawCryptocurrencyFunds(_ context.Context, _ *withdraw.Request) (*withdraw.ExchangeResponse, error) {
|
||||
return nil, common.ErrNotYetImplemented
|
||||
}
|
||||
|
||||
// WithdrawFiatFunds returns a withdrawal ID when a withdrawal is submitted
|
||||
func (a *Alphapoint) WithdrawFiatFunds(_ *withdraw.Request) (*withdraw.ExchangeResponse, error) {
|
||||
func (a *Alphapoint) WithdrawFiatFunds(_ context.Context, _ *withdraw.Request) (*withdraw.ExchangeResponse, error) {
|
||||
return nil, common.ErrNotYetImplemented
|
||||
}
|
||||
|
||||
@@ -355,11 +357,11 @@ func (a *Alphapoint) GetFeeByType(_ *exchange.FeeBuilder) (float64, error) {
|
||||
|
||||
// GetActiveOrders retrieves any orders that are active/open
|
||||
// This function is not concurrency safe due to orderSide/orderType maps
|
||||
func (a *Alphapoint) GetActiveOrders(req *order.GetOrdersRequest) ([]order.Detail, error) {
|
||||
func (a *Alphapoint) GetActiveOrders(ctx context.Context, req *order.GetOrdersRequest) ([]order.Detail, error) {
|
||||
if err := req.Validate(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := a.GetOrders()
|
||||
resp, err := a.GetOrders(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -400,12 +402,12 @@ func (a *Alphapoint) GetActiveOrders(req *order.GetOrdersRequest) ([]order.Detai
|
||||
// GetOrderHistory retrieves account order information
|
||||
// Can Limit response to specific order status
|
||||
// This function is not concurrency safe due to orderSide/orderType maps
|
||||
func (a *Alphapoint) GetOrderHistory(req *order.GetOrdersRequest) ([]order.Detail, error) {
|
||||
func (a *Alphapoint) GetOrderHistory(ctx context.Context, req *order.GetOrdersRequest) ([]order.Detail, error) {
|
||||
if err := req.Validate(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp, err := a.GetOrders()
|
||||
resp, err := a.GetOrders(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -445,7 +447,7 @@ func (a *Alphapoint) GetOrderHistory(req *order.GetOrdersRequest) ([]order.Detai
|
||||
|
||||
// ValidateCredentials validates current credentials used for wrapper
|
||||
// functionality
|
||||
func (a *Alphapoint) ValidateCredentials(assetType asset.Item) error {
|
||||
_, err := a.UpdateAccountInfo(assetType)
|
||||
func (a *Alphapoint) ValidateCredentials(ctx context.Context, assetType asset.Item) error {
|
||||
_, err := a.UpdateAccountInfo(ctx, assetType)
|
||||
return a.CheckTransientError(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user