diff --git a/exchanges/coinbasepro/coinbasepro_test.go b/exchanges/coinbasepro/coinbasepro_test.go index 57bd726a..ecb6c9eb 100644 --- a/exchanges/coinbasepro/coinbasepro_test.go +++ b/exchanges/coinbasepro/coinbasepro_test.go @@ -495,6 +495,7 @@ func TestSubmitOrder(t *testing.T) { t.Skip("API keys set, canManipulateRealOrders false, skipping test") } + // limit order var orderSubmission = &order.Submit{ Exchange: c.Name, Pair: currency.Pair{ @@ -505,7 +506,7 @@ func TestSubmitOrder(t *testing.T) { Side: order.Buy, Type: order.Limit, Price: 1, - Amount: 1, + Amount: 0.001, ClientID: "meowOrder", AssetType: asset.Spot, } @@ -515,6 +516,48 @@ func TestSubmitOrder(t *testing.T) { } else if !areTestAPIKeysSet() && err == nil { t.Error("Expecting an error when no keys are set") } + + // market order from amount + orderSubmission = &order.Submit{ + Exchange: c.Name, + Pair: currency.Pair{ + Delimiter: "-", + Base: currency.BTC, + Quote: currency.USD, + }, + Side: order.Buy, + Type: order.Market, + Amount: 0.001, + ClientID: "meowOrder", + AssetType: asset.Spot, + } + response, err = c.SubmitOrder(context.Background(), orderSubmission) + if areTestAPIKeysSet() && (err != nil || response.Status != order.New) { + t.Errorf("Order failed to be placed: %v", err) + } else if !areTestAPIKeysSet() && err == nil { + t.Error("Expecting an error when no keys are set") + } + + // market order from quote amount + orderSubmission = &order.Submit{ + Exchange: c.Name, + Pair: currency.Pair{ + Delimiter: "-", + Base: currency.BTC, + Quote: currency.USD, + }, + Side: order.Buy, + Type: order.Market, + QuoteAmount: 1, + ClientID: "meowOrder", + AssetType: asset.Spot, + } + response, err = c.SubmitOrder(context.Background(), orderSubmission) + if areTestAPIKeysSet() && (err != nil || response.Status != order.New) { + t.Errorf("Order failed to be placed: %v", err) + } else if !areTestAPIKeysSet() && err == nil { + t.Error("Expecting an error when no keys are set") + } } func TestCancelExchangeOrder(t *testing.T) { diff --git a/exchanges/coinbasepro/coinbasepro_wrapper.go b/exchanges/coinbasepro/coinbasepro_wrapper.go index 5951d4d6..b0f2616c 100644 --- a/exchanges/coinbasepro/coinbasepro_wrapper.go +++ b/exchanges/coinbasepro/coinbasepro_wrapper.go @@ -549,7 +549,7 @@ func (c *CoinbasePro) SubmitOrder(ctx context.Context, s *order.Submit) (*order. orderID, err = c.PlaceMarketOrder(ctx, "", s.Amount, - s.Amount, + s.QuoteAmount, s.Side.Lower(), fpair.String(), "")