Skip to content

Commit

Permalink
Quick fixies
Browse files Browse the repository at this point in the history
  • Loading branch information
cranktakular committed Aug 7, 2024
1 parent c0aa9a4 commit ac98019
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 18 deletions.
6 changes: 2 additions & 4 deletions exchanges/coinbasepro/coinbasepro_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const (
errExpectedNonEmpty = "expected non-empty response"
errPortfolioNameDuplicate = `CoinbasePro unsuccessful HTTP status code: 409 raw response: {"error":"CONFLICT","error_details":"A portfolio with this name already exists.","message":"A portfolio with this name already exists."}, authenticated request failed`
errPortTransferInsufFunds = `CoinbasePro unsuccessful HTTP status code: 429 raw response: {"error":"unknown","error_details":"[PORTFOLIO_ERROR_CODE_INSUFFICIENT_FUNDS] insufficient funds in source account","message":"[PORTFOLIO_ERROR_CODE_INSUFFICIENT_FUNDS] insufficient funds in source account"}, authenticated request failed`
errInvalidProductID = `CoinbasePro unsuccessful HTTP status code: 400 raw response: {"error":"INVALID_ARGUMENT","error_details":"valid product_id is required","message":"valid product_id is required"}`
errInvalidProductID = `CoinbasePro unsuccessful HTTP status code: 404 raw response: {"error":"NOT_FOUND","error_details":"valid product_id is required","message":"valid product_id is required"}`
errExpectedFeeRange = "expected fee range of %v and %v, received %v"
errOptionInvalid = `CoinbasePro unsuccessful HTTP status code: 400 raw response: {"error":"unknown","error_details":"parsing field \"product_type\": \"OPTION\" is not a valid value","message":"parsing field \"product_type\": \"OPTION\" is not a valid value"}`

Expand Down Expand Up @@ -1382,7 +1382,6 @@ func TestGetLatestFundingRates(t *testing.T) {

func TestGetFuturesContractDetails(t *testing.T) {
t.Parallel()
c.Verbose = true
_, err := c.GetFuturesContractDetails(context.Background(), asset.Empty)
assert.ErrorIs(t, err, futures.ErrNotFuturesAsset)
_, err = c.GetFuturesContractDetails(context.Background(), asset.UpsideProfitContract)
Expand Down Expand Up @@ -1661,8 +1660,7 @@ func TestProcessSnapshotUpdate(t *testing.T) {

func TestGenerateDefaultSubscriptions(t *testing.T) {
comparison := subscription.List{{Channel: "heartbeats"}, {Channel: "status"}, {Channel: "ticker"},
{Channel: "ticker_batch"}, {Channel: "candles"}, {Channel: "market_trades"}, {Channel: "level2"},
{Channel: "user"}}
{Channel: "ticker_batch"}, {Channel: "candles"}, {Channel: "market_trades"}, {Channel: "level2"}}
for i := range comparison {
comparison[i].Pairs = currency.Pairs{
currency.NewPairWithDelimiter(testCrypto.String(), testFiat.String(), "-")}
Expand Down
19 changes: 5 additions & 14 deletions exchanges/coinbasepro/coinbasepro_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -655,10 +655,7 @@ func (c *CoinbasePro) GetOrderInfo(ctx context.Context, orderID string, pair cur
if err != nil {
return nil, err
}
response, err := c.getOrderRespToOrderDetail(genOrderDetail, pair, assetItem)
if err != nil {
return nil, err
}
response := c.getOrderRespToOrderDetail(genOrderDetail, pair, assetItem)
fillData, err := c.GetFills(ctx, orderID, "", "", time.Time{}, time.Now(), 2<<15-1)
if err != nil {
return nil, err
Expand Down Expand Up @@ -826,10 +823,7 @@ func (c *CoinbasePro) GetActiveOrders(ctx context.Context, req *order.MultiOrder
}
orders := make([]order.Detail, len(respOrders))
for i := range respOrders {
orderRec, err := c.getOrderRespToOrderDetail(&respOrders[i], req.Pairs[i], asset.Spot)
if err != nil {
return nil, err
}
orderRec := c.getOrderRespToOrderDetail(&respOrders[i], req.Pairs[i], asset.Spot)
orders[i] = *orderRec
}
return req.Filter(c.Name, orders), nil
Expand Down Expand Up @@ -874,10 +868,7 @@ func (c *CoinbasePro) GetOrderHistory(ctx context.Context, req *order.MultiOrder
}
orders := make([]order.Detail, len(ord))
for i := range ord {
singleOrder, err := c.getOrderRespToOrderDetail(&ord[i], req.Pairs[0], req.AssetType)
if err != nil {
return nil, err
}
singleOrder := c.getOrderRespToOrderDetail(&ord[i], req.Pairs[0], req.AssetType)
orders[i] = *singleOrder
}
return req.Filter(c.Name, orders), nil
Expand Down Expand Up @@ -1185,7 +1176,7 @@ func formatExchangeKlineIntervalV3(interval kline.Interval) string {

// getOrderRespToOrderDetail is a helper function used in GetOrderInfo, GetActiveOrders, and GetOrderHistory
// to convert data returned by the Coinbase API into a format suitable for the exchange package
func (c *CoinbasePro) getOrderRespToOrderDetail(genOrderDetail *GetOrderResponse, pair currency.Pair, assetItem asset.Item) (*order.Detail, error) {
func (c *CoinbasePro) getOrderRespToOrderDetail(genOrderDetail *GetOrderResponse, pair currency.Pair, assetItem asset.Item) *order.Detail {
var amount float64
var quoteAmount float64
var orderType order.Type
Expand Down Expand Up @@ -1280,7 +1271,7 @@ func (c *CoinbasePro) getOrderRespToOrderDetail(genOrderDetail *GetOrderResponse
LastUpdated: lastUpdateTime,
Pair: pair,
}
return &response, nil
return &response
}

// VerificationCheck returns whether authentication support is enabled or not
Expand Down

0 comments on commit ac98019

Please sign in to comment.