CoinbasePro: Fix funds parameter for market orders (#1079)

* Fix funds parameter in coinbasepro wrapper for market orders

* Update tests

* Reorganize tests
This commit is contained in:
dsinuela-taurus
2022-11-11 03:25:50 +01:00
committed by GitHub
parent 453c3118f6
commit 37b946b0b9
2 changed files with 45 additions and 2 deletions

View File

@@ -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) {

View File

@@ -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(),
"")