From 0bc6135a1b286ca3465676dab8f9aa3dbcc2dde3 Mon Sep 17 00:00:00 2001 From: theo-s68 <194042188+theo-s68@users.noreply.github.com> Date: Thu, 24 Jul 2025 16:15:02 +0700 Subject: [PATCH] release spot 5.0.0 --- .github/workflows/java.yml | 10 +- clients/spot/CHANGELOG.md | 25 +- clients/spot/docs/rest-api/migration-guide.md | 4 +- clients/spot/example_rest.md | 4 +- clients/spot/example_websocket_api.md | 4 +- clients/spot/pom.xml | 2 +- .../client/spot/rest/api/AccountApi.java | 2 +- .../client/spot/rest/api/GeneralApi.java | 2 +- .../client/spot/rest/api/MarketApi.java | 2 +- .../client/spot/rest/api/TradeApi.java | 135 +++- .../spot/rest/api/UserDataStreamApi.java | 2 +- .../spot/rest/model/OrderTestRequest.java | 604 ++++++++++++++- .../spot/rest/model/SorOrderTestRequest.java | 506 ++++++++++++- .../websocket/api/api/SpotWebSocketApi.java | 2 +- .../websocket/api/model/AllOrdersRequest.java | 10 +- .../websocket/api/model/MyTradesRequest.java | 10 +- .../api/model/OrderCancelReplaceRequest.java | 10 +- .../api/model/OrderCancelRequest.java | 10 +- .../api/model/OrderStatusRequest.java | 10 +- .../websocket/api/model/OrderTestRequest.java | 685 +++++++++++++++++- .../api/model/SorOrderTestRequest.java | 571 ++++++++++++++- .../stream/api/SpotWebSocketStreams.java | 2 +- .../client/spot/rest/api/TradeApiTest.java | 17 +- .../spot/websocket/api/api/TradeApiTest.java | 2 + .../api/TradeApi/order.test-test.json | 18 +- .../api/TradeApi/sor.order.test-test.json | 18 +- examples/spot/pom.xml | 2 +- .../spot/rest/trade/OrderTestExample.java | 5 + .../spot/rest/trade/SorOrderTestExample.java | 6 + .../websocket/api/trade/OrderTestExample.java | 8 + .../api/trade/SorOrderTestExample.java | 10 + 31 files changed, 2626 insertions(+), 72 deletions(-) diff --git a/.github/workflows/java.yml b/.github/workflows/java.yml index 04e3706c..2c93169c 100644 --- a/.github/workflows/java.yml +++ b/.github/workflows/java.yml @@ -13,7 +13,7 @@ jobs: modified_targets: ${{ steps.filter.outputs.modified_targets }} steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 2 @@ -49,16 +49,16 @@ jobs: needs: detect-targets if: ${{ needs.detect-targets.outputs.modified_targets != '[]' }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: 17 distribution: 'adopt' cache: 'maven' cache-dependency-path: | - 'clients/pom.xml' - 'examples/pom.xml' + clients/pom.xml + examples/pom.xml - name: Validate modules run: | mvn -f clients/pom.xml -pl common install -Dgpg.skip diff --git a/clients/spot/CHANGELOG.md b/clients/spot/CHANGELOG.md index c50f7cc4..5ce05700 100644 --- a/clients/spot/CHANGELOG.md +++ b/clients/spot/CHANGELOG.md @@ -1,5 +1,29 @@ # Changelog +## 5.0.0 - 2025-07-24 + +### Changed (4) + +#### REST API + +- Added missing parameters to `orderTest()` (`POST /api/v3/order/test`) + +#### WebSocket API + +- Added missing parameters to `orderTest()` + +- Modified parameter `cancelOrderId`: + - format `Integer` → `Long` + - affected methods: + - `orderCancelReplace()` (`order.cancelReplace` method) +- Modified parameter `orderId`: + - format `Integer` → `Long` + - affected methods: + - `allOrders()` (`allOrders` method) + - `myTrades()` (`myTrades` method) + - `orderCancel()` (`order.cancel` method) + - `orderStatus()` (`order.status` method) + ## 4.0.0 - 2025-07-16 ### Added (1) @@ -28,7 +52,6 @@ - `symbols`: item property `amendAllowed` added - `symbols`: item property `allowAmend` deleted - #### WebSocket API - Modified response for `exchangeInfo()` method (`POST /exchangeInfo`): diff --git a/clients/spot/docs/rest-api/migration-guide.md b/clients/spot/docs/rest-api/migration-guide.md index f644bc9c..04a4311d 100644 --- a/clients/spot/docs/rest-api/migration-guide.md +++ b/clients/spot/docs/rest-api/migration-guide.md @@ -22,7 +22,7 @@ With the transition to a modularized structure, the Binance Connector has been s io.github.binance binance-spot - 3.1.0 + 5.0.0 ``` @@ -91,7 +91,7 @@ by: io.github.binance binance-spot - 3.1.0 + 5.0.0 ``` diff --git a/clients/spot/example_rest.md b/clients/spot/example_rest.md index dd6737b0..70054a63 100644 --- a/clients/spot/example_rest.md +++ b/clients/spot/example_rest.md @@ -82,11 +82,11 @@ [POST /api/v3/order/oco](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#new-oco---deprecated-trade) - orderOco - [OrderOcoExample.java:53](/examples/spot/src/main/java/com/binance/connector/client/spot/rest/trade/OrderOcoExample.java#L53) -[POST /api/v3/order/test](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#test-new-order-trade) - orderTest - [OrderTestExample.java:50](/examples/spot/src/main/java/com/binance/connector/client/spot/rest/trade/OrderTestExample.java#L50) +[POST /api/v3/order/test](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#test-new-order-trade) - orderTest - [OrderTestExample.java:52](/examples/spot/src/main/java/com/binance/connector/client/spot/rest/trade/OrderTestExample.java#L52) [POST /api/v3/sor/order](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#new-order-using-sor-trade) - sorOrder - [SorOrderExample.java:51](/examples/spot/src/main/java/com/binance/connector/client/spot/rest/trade/SorOrderExample.java#L51) -[POST /api/v3/sor/order/test](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#test-new-order-using-sor-trade) - sorOrderTest - [SorOrderTestExample.java:50](/examples/spot/src/main/java/com/binance/connector/client/spot/rest/trade/SorOrderTestExample.java#L50) +[POST /api/v3/sor/order/test](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#test-new-order-using-sor-trade) - sorOrderTest - [SorOrderTestExample.java:52](/examples/spot/src/main/java/com/binance/connector/client/spot/rest/trade/SorOrderTestExample.java#L52) ## UserDataStream diff --git a/clients/spot/example_websocket_api.md b/clients/spot/example_websocket_api.md index 1d4a75ce..1088c653 100644 --- a/clients/spot/example_websocket_api.md +++ b/clients/spot/example_websocket_api.md @@ -90,11 +90,11 @@ [order.place](https://developers.binance.com/docs/binance-spot-api-docs/websocket-api/trading-requests#place-new-order-trade) - orderPlace - [OrderPlaceExample.java:51](/examples/spot/src/main/java/com/binance/connector/client/spot/websocket/api/trade/OrderPlaceExample.java#L51) -[order.test](https://developers.binance.com/docs/binance-spot-api-docs/websocket-api/trading-requests#test-new-order-trade) - orderTest - [OrderTestExample.java:51](/examples/spot/src/main/java/com/binance/connector/client/spot/websocket/api/trade/OrderTestExample.java#L51) +[order.test](https://developers.binance.com/docs/binance-spot-api-docs/websocket-api/trading-requests#test-new-order-trade) - orderTest - [OrderTestExample.java:53](/examples/spot/src/main/java/com/binance/connector/client/spot/websocket/api/trade/OrderTestExample.java#L53) [sor.order.place](https://developers.binance.com/docs/binance-spot-api-docs/websocket-api/trading-requests#place-new-order-using-sor-trade) - sorOrderPlace - [SorOrderPlaceExample.java:52](/examples/spot/src/main/java/com/binance/connector/client/spot/websocket/api/trade/SorOrderPlaceExample.java#L52) -[sor.order.test](https://developers.binance.com/docs/binance-spot-api-docs/websocket-api/trading-requests#test-new-order-using-sor-trade) - sorOrderTest - [SorOrderTestExample.java:51](/examples/spot/src/main/java/com/binance/connector/client/spot/websocket/api/trade/SorOrderTestExample.java#L51) +[sor.order.test](https://developers.binance.com/docs/binance-spot-api-docs/websocket-api/trading-requests#test-new-order-using-sor-trade) - sorOrderTest - [SorOrderTestExample.java:53](/examples/spot/src/main/java/com/binance/connector/client/spot/websocket/api/trade/SorOrderTestExample.java#L53) ## UserDataStream diff --git a/clients/spot/pom.xml b/clients/spot/pom.xml index dac1d91e..1df1a4c2 100644 --- a/clients/spot/pom.xml +++ b/clients/spot/pom.xml @@ -5,7 +5,7 @@ 4.0.0 binance-spot spot - 4.0.0 + 5.0.0 jar diff --git a/clients/spot/src/main/java/com/binance/connector/client/spot/rest/api/AccountApi.java b/clients/spot/src/main/java/com/binance/connector/client/spot/rest/api/AccountApi.java index 25f8a92d..978ebf3f 100644 --- a/clients/spot/src/main/java/com/binance/connector/client/spot/rest/api/AccountApi.java +++ b/clients/spot/src/main/java/com/binance/connector/client/spot/rest/api/AccountApi.java @@ -54,7 +54,7 @@ public class AccountApi { private static final String USER_AGENT = String.format( - "binance-spot/4.0.0 (Java/%s; %s; %s)", + "binance-spot/5.0.0 (Java/%s; %s; %s)", SystemUtil.getJavaVersion(), SystemUtil.getOs(), SystemUtil.getArch()); private static final boolean HAS_TIME_UNIT = true; diff --git a/clients/spot/src/main/java/com/binance/connector/client/spot/rest/api/GeneralApi.java b/clients/spot/src/main/java/com/binance/connector/client/spot/rest/api/GeneralApi.java index 4070d909..19c06ac5 100644 --- a/clients/spot/src/main/java/com/binance/connector/client/spot/rest/api/GeneralApi.java +++ b/clients/spot/src/main/java/com/binance/connector/client/spot/rest/api/GeneralApi.java @@ -47,7 +47,7 @@ public class GeneralApi { private static final String USER_AGENT = String.format( - "binance-spot/4.0.0 (Java/%s; %s; %s)", + "binance-spot/5.0.0 (Java/%s; %s; %s)", SystemUtil.getJavaVersion(), SystemUtil.getOs(), SystemUtil.getArch()); private static final boolean HAS_TIME_UNIT = true; diff --git a/clients/spot/src/main/java/com/binance/connector/client/spot/rest/api/MarketApi.java b/clients/spot/src/main/java/com/binance/connector/client/spot/rest/api/MarketApi.java index a62add63..da5ae667 100644 --- a/clients/spot/src/main/java/com/binance/connector/client/spot/rest/api/MarketApi.java +++ b/clients/spot/src/main/java/com/binance/connector/client/spot/rest/api/MarketApi.java @@ -58,7 +58,7 @@ public class MarketApi { private static final String USER_AGENT = String.format( - "binance-spot/4.0.0 (Java/%s; %s; %s)", + "binance-spot/5.0.0 (Java/%s; %s; %s)", SystemUtil.getJavaVersion(), SystemUtil.getOs(), SystemUtil.getArch()); private static final boolean HAS_TIME_UNIT = true; diff --git a/clients/spot/src/main/java/com/binance/connector/client/spot/rest/api/TradeApi.java b/clients/spot/src/main/java/com/binance/connector/client/spot/rest/api/TradeApi.java index 28b315d1..779daf14 100644 --- a/clients/spot/src/main/java/com/binance/connector/client/spot/rest/api/TradeApi.java +++ b/clients/spot/src/main/java/com/binance/connector/client/spot/rest/api/TradeApi.java @@ -67,7 +67,7 @@ public class TradeApi { private static final String USER_AGENT = String.format( - "binance-spot/4.0.0 (Java/%s; %s; %s)", + "binance-spot/5.0.0 (Java/%s; %s; %s)", SystemUtil.getJavaVersion(), SystemUtil.getOs(), SystemUtil.getArch()); private static final boolean HAS_TIME_UNIT = true; @@ -2449,6 +2449,80 @@ private okhttp3.Call orderTestCall(OrderTestRequest orderTestRequest) throws Api "computeCommissionRates", orderTestRequest.getComputeCommissionRates()); } + if (orderTestRequest.getSymbol() != null) { + localVarFormParams.put("symbol", orderTestRequest.getSymbol()); + } + + if (orderTestRequest.getSide() != null) { + localVarFormParams.put("side", orderTestRequest.getSide()); + } + + if (orderTestRequest.getType() != null) { + localVarFormParams.put("type", orderTestRequest.getType()); + } + + if (orderTestRequest.getTimeInForce() != null) { + localVarFormParams.put("timeInForce", orderTestRequest.getTimeInForce()); + } + + if (orderTestRequest.getQuantity() != null) { + localVarFormParams.put( + "quantity", + DecimalFormatter.getFormatter().format(orderTestRequest.getQuantity())); + } + + if (orderTestRequest.getQuoteOrderQty() != null) { + localVarFormParams.put( + "quoteOrderQty", + DecimalFormatter.getFormatter().format(orderTestRequest.getQuoteOrderQty())); + } + + if (orderTestRequest.getPrice() != null) { + localVarFormParams.put( + "price", DecimalFormatter.getFormatter().format(orderTestRequest.getPrice())); + } + + if (orderTestRequest.getNewClientOrderId() != null) { + localVarFormParams.put("newClientOrderId", orderTestRequest.getNewClientOrderId()); + } + + if (orderTestRequest.getStrategyId() != null) { + localVarFormParams.put("strategyId", orderTestRequest.getStrategyId()); + } + + if (orderTestRequest.getStrategyType() != null) { + localVarFormParams.put("strategyType", orderTestRequest.getStrategyType()); + } + + if (orderTestRequest.getStopPrice() != null) { + localVarFormParams.put( + "stopPrice", + DecimalFormatter.getFormatter().format(orderTestRequest.getStopPrice())); + } + + if (orderTestRequest.getTrailingDelta() != null) { + localVarFormParams.put("trailingDelta", orderTestRequest.getTrailingDelta()); + } + + if (orderTestRequest.getIcebergQty() != null) { + localVarFormParams.put( + "icebergQty", + DecimalFormatter.getFormatter().format(orderTestRequest.getIcebergQty())); + } + + if (orderTestRequest.getNewOrderRespType() != null) { + localVarFormParams.put("newOrderRespType", orderTestRequest.getNewOrderRespType()); + } + + if (orderTestRequest.getSelfTradePreventionMode() != null) { + localVarFormParams.put( + "selfTradePreventionMode", orderTestRequest.getSelfTradePreventionMode()); + } + + if (orderTestRequest.getRecvWindow() != null) { + localVarFormParams.put("recvWindow", orderTestRequest.getRecvWindow()); + } + final String[] localVarAccepts = {"application/json"}; final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) { @@ -2782,6 +2856,65 @@ private okhttp3.Call sorOrderTestCall(SorOrderTestRequest sorOrderTestRequest) "computeCommissionRates", sorOrderTestRequest.getComputeCommissionRates()); } + if (sorOrderTestRequest.getSymbol() != null) { + localVarFormParams.put("symbol", sorOrderTestRequest.getSymbol()); + } + + if (sorOrderTestRequest.getSide() != null) { + localVarFormParams.put("side", sorOrderTestRequest.getSide()); + } + + if (sorOrderTestRequest.getType() != null) { + localVarFormParams.put("type", sorOrderTestRequest.getType()); + } + + if (sorOrderTestRequest.getTimeInForce() != null) { + localVarFormParams.put("timeInForce", sorOrderTestRequest.getTimeInForce()); + } + + if (sorOrderTestRequest.getQuantity() != null) { + localVarFormParams.put( + "quantity", + DecimalFormatter.getFormatter().format(sorOrderTestRequest.getQuantity())); + } + + if (sorOrderTestRequest.getPrice() != null) { + localVarFormParams.put( + "price", + DecimalFormatter.getFormatter().format(sorOrderTestRequest.getPrice())); + } + + if (sorOrderTestRequest.getNewClientOrderId() != null) { + localVarFormParams.put("newClientOrderId", sorOrderTestRequest.getNewClientOrderId()); + } + + if (sorOrderTestRequest.getStrategyId() != null) { + localVarFormParams.put("strategyId", sorOrderTestRequest.getStrategyId()); + } + + if (sorOrderTestRequest.getStrategyType() != null) { + localVarFormParams.put("strategyType", sorOrderTestRequest.getStrategyType()); + } + + if (sorOrderTestRequest.getIcebergQty() != null) { + localVarFormParams.put( + "icebergQty", + DecimalFormatter.getFormatter().format(sorOrderTestRequest.getIcebergQty())); + } + + if (sorOrderTestRequest.getNewOrderRespType() != null) { + localVarFormParams.put("newOrderRespType", sorOrderTestRequest.getNewOrderRespType()); + } + + if (sorOrderTestRequest.getSelfTradePreventionMode() != null) { + localVarFormParams.put( + "selfTradePreventionMode", sorOrderTestRequest.getSelfTradePreventionMode()); + } + + if (sorOrderTestRequest.getRecvWindow() != null) { + localVarFormParams.put("recvWindow", sorOrderTestRequest.getRecvWindow()); + } + final String[] localVarAccepts = {"application/json"}; final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) { diff --git a/clients/spot/src/main/java/com/binance/connector/client/spot/rest/api/UserDataStreamApi.java b/clients/spot/src/main/java/com/binance/connector/client/spot/rest/api/UserDataStreamApi.java index 75bfa3bf..e29efab0 100644 --- a/clients/spot/src/main/java/com/binance/connector/client/spot/rest/api/UserDataStreamApi.java +++ b/clients/spot/src/main/java/com/binance/connector/client/spot/rest/api/UserDataStreamApi.java @@ -44,7 +44,7 @@ public class UserDataStreamApi { private static final String USER_AGENT = String.format( - "binance-spot/4.0.0 (Java/%s; %s; %s)", + "binance-spot/5.0.0 (Java/%s; %s; %s)", SystemUtil.getJavaVersion(), SystemUtil.getOs(), SystemUtil.getArch()); private static final boolean HAS_TIME_UNIT = true; diff --git a/clients/spot/src/main/java/com/binance/connector/client/spot/rest/model/OrderTestRequest.java b/clients/spot/src/main/java/com/binance/connector/client/spot/rest/model/OrderTestRequest.java index 3b7392f3..475c16f6 100644 --- a/clients/spot/src/main/java/com/binance/connector/client/spot/rest/model/OrderTestRequest.java +++ b/clients/spot/src/main/java/com/binance/connector/client/spot/rest/model/OrderTestRequest.java @@ -22,6 +22,7 @@ import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import jakarta.validation.Valid; import jakarta.validation.constraints.*; import java.io.IOException; import java.io.UnsupportedEncodingException; @@ -42,6 +43,103 @@ public class OrderTestRequest { @jakarta.annotation.Nullable private Boolean computeCommissionRates; + public static final String SERIALIZED_NAME_SYMBOL = "symbol"; + + @SerializedName(SERIALIZED_NAME_SYMBOL) + @jakarta.annotation.Nonnull + private String symbol; + + public static final String SERIALIZED_NAME_SIDE = "side"; + + @SerializedName(SERIALIZED_NAME_SIDE) + @jakarta.annotation.Nonnull + private Side side; + + public static final String SERIALIZED_NAME_TYPE = "type"; + + @SerializedName(SERIALIZED_NAME_TYPE) + @jakarta.annotation.Nonnull + private OrderType type; + + public static final String SERIALIZED_NAME_TIME_IN_FORCE = "timeInForce"; + + @SerializedName(SERIALIZED_NAME_TIME_IN_FORCE) + @jakarta.annotation.Nullable + private TimeInForce timeInForce; + + public static final String SERIALIZED_NAME_QUANTITY = "quantity"; + + @SerializedName(SERIALIZED_NAME_QUANTITY) + @jakarta.annotation.Nullable + private Double quantity; + + public static final String SERIALIZED_NAME_QUOTE_ORDER_QTY = "quoteOrderQty"; + + @SerializedName(SERIALIZED_NAME_QUOTE_ORDER_QTY) + @jakarta.annotation.Nullable + private Double quoteOrderQty; + + public static final String SERIALIZED_NAME_PRICE = "price"; + + @SerializedName(SERIALIZED_NAME_PRICE) + @jakarta.annotation.Nullable + private Double price; + + public static final String SERIALIZED_NAME_NEW_CLIENT_ORDER_ID = "newClientOrderId"; + + @SerializedName(SERIALIZED_NAME_NEW_CLIENT_ORDER_ID) + @jakarta.annotation.Nullable + private String newClientOrderId; + + public static final String SERIALIZED_NAME_STRATEGY_ID = "strategyId"; + + @SerializedName(SERIALIZED_NAME_STRATEGY_ID) + @jakarta.annotation.Nullable + private Long strategyId; + + public static final String SERIALIZED_NAME_STRATEGY_TYPE = "strategyType"; + + @SerializedName(SERIALIZED_NAME_STRATEGY_TYPE) + @jakarta.annotation.Nullable + private Integer strategyType; + + public static final String SERIALIZED_NAME_STOP_PRICE = "stopPrice"; + + @SerializedName(SERIALIZED_NAME_STOP_PRICE) + @jakarta.annotation.Nullable + private Double stopPrice; + + public static final String SERIALIZED_NAME_TRAILING_DELTA = "trailingDelta"; + + @SerializedName(SERIALIZED_NAME_TRAILING_DELTA) + @jakarta.annotation.Nullable + private Long trailingDelta; + + public static final String SERIALIZED_NAME_ICEBERG_QTY = "icebergQty"; + + @SerializedName(SERIALIZED_NAME_ICEBERG_QTY) + @jakarta.annotation.Nullable + private Double icebergQty; + + public static final String SERIALIZED_NAME_NEW_ORDER_RESP_TYPE = "newOrderRespType"; + + @SerializedName(SERIALIZED_NAME_NEW_ORDER_RESP_TYPE) + @jakarta.annotation.Nullable + private NewOrderRespType newOrderRespType; + + public static final String SERIALIZED_NAME_SELF_TRADE_PREVENTION_MODE = + "selfTradePreventionMode"; + + @SerializedName(SERIALIZED_NAME_SELF_TRADE_PREVENTION_MODE) + @jakarta.annotation.Nullable + private SelfTradePreventionMode selfTradePreventionMode; + + public static final String SERIALIZED_NAME_RECV_WINDOW = "recvWindow"; + + @SerializedName(SERIALIZED_NAME_RECV_WINDOW) + @jakarta.annotation.Nullable + private Long recvWindow; + public OrderTestRequest() {} public OrderTestRequest computeCommissionRates( @@ -65,6 +163,327 @@ public void setComputeCommissionRates( this.computeCommissionRates = computeCommissionRates; } + public OrderTestRequest symbol(@jakarta.annotation.Nonnull String symbol) { + this.symbol = symbol; + return this; + } + + /** + * Get symbol + * + * @return symbol + */ + @jakarta.annotation.Nonnull + @NotNull + public String getSymbol() { + return symbol; + } + + public void setSymbol(@jakarta.annotation.Nonnull String symbol) { + this.symbol = symbol; + } + + public OrderTestRequest side(@jakarta.annotation.Nonnull Side side) { + this.side = side; + return this; + } + + /** + * Get side + * + * @return side + */ + @jakarta.annotation.Nonnull + @NotNull + @Valid + public Side getSide() { + return side; + } + + public void setSide(@jakarta.annotation.Nonnull Side side) { + this.side = side; + } + + public OrderTestRequest type(@jakarta.annotation.Nonnull OrderType type) { + this.type = type; + return this; + } + + /** + * Get type + * + * @return type + */ + @jakarta.annotation.Nonnull + @NotNull + @Valid + public OrderType getType() { + return type; + } + + public void setType(@jakarta.annotation.Nonnull OrderType type) { + this.type = type; + } + + public OrderTestRequest timeInForce(@jakarta.annotation.Nullable TimeInForce timeInForce) { + this.timeInForce = timeInForce; + return this; + } + + /** + * Get timeInForce + * + * @return timeInForce + */ + @jakarta.annotation.Nullable + @Valid + public TimeInForce getTimeInForce() { + return timeInForce; + } + + public void setTimeInForce(@jakarta.annotation.Nullable TimeInForce timeInForce) { + this.timeInForce = timeInForce; + } + + public OrderTestRequest quantity(@jakarta.annotation.Nullable Double quantity) { + this.quantity = quantity; + return this; + } + + /** + * Get quantity + * + * @return quantity + */ + @jakarta.annotation.Nullable + @Valid + public Double getQuantity() { + return quantity; + } + + public void setQuantity(@jakarta.annotation.Nullable Double quantity) { + this.quantity = quantity; + } + + public OrderTestRequest quoteOrderQty(@jakarta.annotation.Nullable Double quoteOrderQty) { + this.quoteOrderQty = quoteOrderQty; + return this; + } + + /** + * Get quoteOrderQty + * + * @return quoteOrderQty + */ + @jakarta.annotation.Nullable + @Valid + public Double getQuoteOrderQty() { + return quoteOrderQty; + } + + public void setQuoteOrderQty(@jakarta.annotation.Nullable Double quoteOrderQty) { + this.quoteOrderQty = quoteOrderQty; + } + + public OrderTestRequest price(@jakarta.annotation.Nullable Double price) { + this.price = price; + return this; + } + + /** + * Get price + * + * @return price + */ + @jakarta.annotation.Nullable + @Valid + public Double getPrice() { + return price; + } + + public void setPrice(@jakarta.annotation.Nullable Double price) { + this.price = price; + } + + public OrderTestRequest newClientOrderId(@jakarta.annotation.Nullable String newClientOrderId) { + this.newClientOrderId = newClientOrderId; + return this; + } + + /** + * Get newClientOrderId + * + * @return newClientOrderId + */ + @jakarta.annotation.Nullable + public String getNewClientOrderId() { + return newClientOrderId; + } + + public void setNewClientOrderId(@jakarta.annotation.Nullable String newClientOrderId) { + this.newClientOrderId = newClientOrderId; + } + + public OrderTestRequest strategyId(@jakarta.annotation.Nullable Long strategyId) { + this.strategyId = strategyId; + return this; + } + + /** + * Get strategyId + * + * @return strategyId + */ + @jakarta.annotation.Nullable + public Long getStrategyId() { + return strategyId; + } + + public void setStrategyId(@jakarta.annotation.Nullable Long strategyId) { + this.strategyId = strategyId; + } + + public OrderTestRequest strategyType(@jakarta.annotation.Nullable Integer strategyType) { + this.strategyType = strategyType; + return this; + } + + /** + * Get strategyType + * + * @return strategyType + */ + @jakarta.annotation.Nullable + public Integer getStrategyType() { + return strategyType; + } + + public void setStrategyType(@jakarta.annotation.Nullable Integer strategyType) { + this.strategyType = strategyType; + } + + public OrderTestRequest stopPrice(@jakarta.annotation.Nullable Double stopPrice) { + this.stopPrice = stopPrice; + return this; + } + + /** + * Get stopPrice + * + * @return stopPrice + */ + @jakarta.annotation.Nullable + @Valid + public Double getStopPrice() { + return stopPrice; + } + + public void setStopPrice(@jakarta.annotation.Nullable Double stopPrice) { + this.stopPrice = stopPrice; + } + + public OrderTestRequest trailingDelta(@jakarta.annotation.Nullable Long trailingDelta) { + this.trailingDelta = trailingDelta; + return this; + } + + /** + * Get trailingDelta + * + * @return trailingDelta + */ + @jakarta.annotation.Nullable + public Long getTrailingDelta() { + return trailingDelta; + } + + public void setTrailingDelta(@jakarta.annotation.Nullable Long trailingDelta) { + this.trailingDelta = trailingDelta; + } + + public OrderTestRequest icebergQty(@jakarta.annotation.Nullable Double icebergQty) { + this.icebergQty = icebergQty; + return this; + } + + /** + * Get icebergQty + * + * @return icebergQty + */ + @jakarta.annotation.Nullable + @Valid + public Double getIcebergQty() { + return icebergQty; + } + + public void setIcebergQty(@jakarta.annotation.Nullable Double icebergQty) { + this.icebergQty = icebergQty; + } + + public OrderTestRequest newOrderRespType( + @jakarta.annotation.Nullable NewOrderRespType newOrderRespType) { + this.newOrderRespType = newOrderRespType; + return this; + } + + /** + * Get newOrderRespType + * + * @return newOrderRespType + */ + @jakarta.annotation.Nullable + @Valid + public NewOrderRespType getNewOrderRespType() { + return newOrderRespType; + } + + public void setNewOrderRespType( + @jakarta.annotation.Nullable NewOrderRespType newOrderRespType) { + this.newOrderRespType = newOrderRespType; + } + + public OrderTestRequest selfTradePreventionMode( + @jakarta.annotation.Nullable SelfTradePreventionMode selfTradePreventionMode) { + this.selfTradePreventionMode = selfTradePreventionMode; + return this; + } + + /** + * Get selfTradePreventionMode + * + * @return selfTradePreventionMode + */ + @jakarta.annotation.Nullable + @Valid + public SelfTradePreventionMode getSelfTradePreventionMode() { + return selfTradePreventionMode; + } + + public void setSelfTradePreventionMode( + @jakarta.annotation.Nullable SelfTradePreventionMode selfTradePreventionMode) { + this.selfTradePreventionMode = selfTradePreventionMode; + } + + public OrderTestRequest recvWindow(@jakarta.annotation.Nullable Long recvWindow) { + this.recvWindow = recvWindow; + return this; + } + + /** + * Get recvWindow + * + * @return recvWindow + */ + @jakarta.annotation.Nullable + public Long getRecvWindow() { + return recvWindow; + } + + public void setRecvWindow(@jakarta.annotation.Nullable Long recvWindow) { + this.recvWindow = recvWindow; + } + @Override public boolean equals(Object o) { if (this == o) { @@ -74,12 +493,46 @@ public boolean equals(Object o) { return false; } OrderTestRequest orderTestRequest = (OrderTestRequest) o; - return Objects.equals(this.computeCommissionRates, orderTestRequest.computeCommissionRates); + return Objects.equals(this.computeCommissionRates, orderTestRequest.computeCommissionRates) + && Objects.equals(this.symbol, orderTestRequest.symbol) + && Objects.equals(this.side, orderTestRequest.side) + && Objects.equals(this.type, orderTestRequest.type) + && Objects.equals(this.timeInForce, orderTestRequest.timeInForce) + && Objects.equals(this.quantity, orderTestRequest.quantity) + && Objects.equals(this.quoteOrderQty, orderTestRequest.quoteOrderQty) + && Objects.equals(this.price, orderTestRequest.price) + && Objects.equals(this.newClientOrderId, orderTestRequest.newClientOrderId) + && Objects.equals(this.strategyId, orderTestRequest.strategyId) + && Objects.equals(this.strategyType, orderTestRequest.strategyType) + && Objects.equals(this.stopPrice, orderTestRequest.stopPrice) + && Objects.equals(this.trailingDelta, orderTestRequest.trailingDelta) + && Objects.equals(this.icebergQty, orderTestRequest.icebergQty) + && Objects.equals(this.newOrderRespType, orderTestRequest.newOrderRespType) + && Objects.equals( + this.selfTradePreventionMode, orderTestRequest.selfTradePreventionMode) + && Objects.equals(this.recvWindow, orderTestRequest.recvWindow); } @Override public int hashCode() { - return Objects.hash(computeCommissionRates); + return Objects.hash( + computeCommissionRates, + symbol, + side, + type, + timeInForce, + quantity, + quoteOrderQty, + price, + newClientOrderId, + strategyId, + strategyType, + stopPrice, + trailingDelta, + icebergQty, + newOrderRespType, + selfTradePreventionMode, + recvWindow); } @Override @@ -89,6 +542,24 @@ public String toString() { sb.append(" computeCommissionRates: ") .append(toIndentedString(computeCommissionRates)) .append("\n"); + sb.append(" symbol: ").append(toIndentedString(symbol)).append("\n"); + sb.append(" side: ").append(toIndentedString(side)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" timeInForce: ").append(toIndentedString(timeInForce)).append("\n"); + sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); + sb.append(" quoteOrderQty: ").append(toIndentedString(quoteOrderQty)).append("\n"); + sb.append(" price: ").append(toIndentedString(price)).append("\n"); + sb.append(" newClientOrderId: ").append(toIndentedString(newClientOrderId)).append("\n"); + sb.append(" strategyId: ").append(toIndentedString(strategyId)).append("\n"); + sb.append(" strategyType: ").append(toIndentedString(strategyType)).append("\n"); + sb.append(" stopPrice: ").append(toIndentedString(stopPrice)).append("\n"); + sb.append(" trailingDelta: ").append(toIndentedString(trailingDelta)).append("\n"); + sb.append(" icebergQty: ").append(toIndentedString(icebergQty)).append("\n"); + sb.append(" newOrderRespType: ").append(toIndentedString(newOrderRespType)).append("\n"); + sb.append(" selfTradePreventionMode: ") + .append(toIndentedString(selfTradePreventionMode)) + .append("\n"); + sb.append(" recvWindow: ").append(toIndentedString(recvWindow)).append("\n"); sb.append("}"); return sb.toString(); } @@ -102,6 +573,72 @@ public String toUrlQueryString() { sb.append("computeCommissionRates=") .append(urlEncode(computeCommissionRatesValueAsString)) .append(""); + Object symbolValue = getSymbol(); + String symbolValueAsString = ""; + symbolValueAsString = symbolValue.toString(); + sb.append("symbol=").append(urlEncode(symbolValueAsString)).append(""); + Object sideValue = getSide(); + String sideValueAsString = ""; + sideValueAsString = sideValue.toString(); + sb.append("side=").append(urlEncode(sideValueAsString)).append(""); + Object typeValue = getType(); + String typeValueAsString = ""; + typeValueAsString = typeValue.toString(); + sb.append("type=").append(urlEncode(typeValueAsString)).append(""); + Object timeInForceValue = getTimeInForce(); + String timeInForceValueAsString = ""; + timeInForceValueAsString = timeInForceValue.toString(); + sb.append("timeInForce=").append(urlEncode(timeInForceValueAsString)).append(""); + Object quantityValue = getQuantity(); + String quantityValueAsString = ""; + quantityValueAsString = quantityValue.toString(); + sb.append("quantity=").append(urlEncode(quantityValueAsString)).append(""); + Object quoteOrderQtyValue = getQuoteOrderQty(); + String quoteOrderQtyValueAsString = ""; + quoteOrderQtyValueAsString = quoteOrderQtyValue.toString(); + sb.append("quoteOrderQty=").append(urlEncode(quoteOrderQtyValueAsString)).append(""); + Object priceValue = getPrice(); + String priceValueAsString = ""; + priceValueAsString = priceValue.toString(); + sb.append("price=").append(urlEncode(priceValueAsString)).append(""); + Object newClientOrderIdValue = getNewClientOrderId(); + String newClientOrderIdValueAsString = ""; + newClientOrderIdValueAsString = newClientOrderIdValue.toString(); + sb.append("newClientOrderId=").append(urlEncode(newClientOrderIdValueAsString)).append(""); + Object strategyIdValue = getStrategyId(); + String strategyIdValueAsString = ""; + strategyIdValueAsString = strategyIdValue.toString(); + sb.append("strategyId=").append(urlEncode(strategyIdValueAsString)).append(""); + Object strategyTypeValue = getStrategyType(); + String strategyTypeValueAsString = ""; + strategyTypeValueAsString = strategyTypeValue.toString(); + sb.append("strategyType=").append(urlEncode(strategyTypeValueAsString)).append(""); + Object stopPriceValue = getStopPrice(); + String stopPriceValueAsString = ""; + stopPriceValueAsString = stopPriceValue.toString(); + sb.append("stopPrice=").append(urlEncode(stopPriceValueAsString)).append(""); + Object trailingDeltaValue = getTrailingDelta(); + String trailingDeltaValueAsString = ""; + trailingDeltaValueAsString = trailingDeltaValue.toString(); + sb.append("trailingDelta=").append(urlEncode(trailingDeltaValueAsString)).append(""); + Object icebergQtyValue = getIcebergQty(); + String icebergQtyValueAsString = ""; + icebergQtyValueAsString = icebergQtyValue.toString(); + sb.append("icebergQty=").append(urlEncode(icebergQtyValueAsString)).append(""); + Object newOrderRespTypeValue = getNewOrderRespType(); + String newOrderRespTypeValueAsString = ""; + newOrderRespTypeValueAsString = newOrderRespTypeValue.toString(); + sb.append("newOrderRespType=").append(urlEncode(newOrderRespTypeValueAsString)).append(""); + Object selfTradePreventionModeValue = getSelfTradePreventionMode(); + String selfTradePreventionModeValueAsString = ""; + selfTradePreventionModeValueAsString = selfTradePreventionModeValue.toString(); + sb.append("selfTradePreventionMode=") + .append(urlEncode(selfTradePreventionModeValueAsString)) + .append(""); + Object recvWindowValue = getRecvWindow(); + String recvWindowValueAsString = ""; + recvWindowValueAsString = recvWindowValue.toString(); + sb.append("recvWindow=").append(urlEncode(recvWindowValueAsString)).append(""); return sb.toString(); } @@ -131,9 +668,28 @@ private String toIndentedString(Object o) { // a set of all properties/fields (JSON key names) openapiFields = new HashSet(); openapiFields.add("computeCommissionRates"); + openapiFields.add("symbol"); + openapiFields.add("side"); + openapiFields.add("type"); + openapiFields.add("timeInForce"); + openapiFields.add("quantity"); + openapiFields.add("quoteOrderQty"); + openapiFields.add("price"); + openapiFields.add("newClientOrderId"); + openapiFields.add("strategyId"); + openapiFields.add("strategyType"); + openapiFields.add("stopPrice"); + openapiFields.add("trailingDelta"); + openapiFields.add("icebergQty"); + openapiFields.add("newOrderRespType"); + openapiFields.add("selfTradePreventionMode"); + openapiFields.add("recvWindow"); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("symbol"); + openapiRequiredFields.add("side"); + openapiRequiredFields.add("type"); } /** @@ -153,7 +709,51 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti OrderTestRequest.openapiRequiredFields.toString())); } } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : OrderTestRequest.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException( + String.format( + "The required field `%s` is not found in the JSON string: %s", + requiredField, jsonElement.toString())); + } + } JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("symbol").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `symbol` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("symbol").toString())); + } + // validate the required field `side` + Side.validateJsonElement(jsonObj.get("side")); + // validate the required field `type` + OrderType.validateJsonElement(jsonObj.get("type")); + // validate the optional field `timeInForce` + if (jsonObj.get("timeInForce") != null && !jsonObj.get("timeInForce").isJsonNull()) { + TimeInForce.validateJsonElement(jsonObj.get("timeInForce")); + } + if ((jsonObj.get("newClientOrderId") != null + && !jsonObj.get("newClientOrderId").isJsonNull()) + && !jsonObj.get("newClientOrderId").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `newClientOrderId` to be a primitive type in the" + + " JSON string but got `%s`", + jsonObj.get("newClientOrderId").toString())); + } + // validate the optional field `newOrderRespType` + if (jsonObj.get("newOrderRespType") != null + && !jsonObj.get("newOrderRespType").isJsonNull()) { + NewOrderRespType.validateJsonElement(jsonObj.get("newOrderRespType")); + } + // validate the optional field `selfTradePreventionMode` + if (jsonObj.get("selfTradePreventionMode") != null + && !jsonObj.get("selfTradePreventionMode").isJsonNull()) { + SelfTradePreventionMode.validateJsonElement(jsonObj.get("selfTradePreventionMode")); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/clients/spot/src/main/java/com/binance/connector/client/spot/rest/model/SorOrderTestRequest.java b/clients/spot/src/main/java/com/binance/connector/client/spot/rest/model/SorOrderTestRequest.java index 76b01e02..1496eae3 100644 --- a/clients/spot/src/main/java/com/binance/connector/client/spot/rest/model/SorOrderTestRequest.java +++ b/clients/spot/src/main/java/com/binance/connector/client/spot/rest/model/SorOrderTestRequest.java @@ -22,6 +22,7 @@ import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import jakarta.validation.Valid; import jakarta.validation.constraints.*; import java.io.IOException; import java.io.UnsupportedEncodingException; @@ -42,6 +43,85 @@ public class SorOrderTestRequest { @jakarta.annotation.Nullable private Boolean computeCommissionRates; + public static final String SERIALIZED_NAME_SYMBOL = "symbol"; + + @SerializedName(SERIALIZED_NAME_SYMBOL) + @jakarta.annotation.Nonnull + private String symbol; + + public static final String SERIALIZED_NAME_SIDE = "side"; + + @SerializedName(SERIALIZED_NAME_SIDE) + @jakarta.annotation.Nonnull + private Side side; + + public static final String SERIALIZED_NAME_TYPE = "type"; + + @SerializedName(SERIALIZED_NAME_TYPE) + @jakarta.annotation.Nonnull + private OrderType type; + + public static final String SERIALIZED_NAME_TIME_IN_FORCE = "timeInForce"; + + @SerializedName(SERIALIZED_NAME_TIME_IN_FORCE) + @jakarta.annotation.Nullable + private TimeInForce timeInForce; + + public static final String SERIALIZED_NAME_QUANTITY = "quantity"; + + @SerializedName(SERIALIZED_NAME_QUANTITY) + @jakarta.annotation.Nonnull + private Double quantity; + + public static final String SERIALIZED_NAME_PRICE = "price"; + + @SerializedName(SERIALIZED_NAME_PRICE) + @jakarta.annotation.Nullable + private Double price; + + public static final String SERIALIZED_NAME_NEW_CLIENT_ORDER_ID = "newClientOrderId"; + + @SerializedName(SERIALIZED_NAME_NEW_CLIENT_ORDER_ID) + @jakarta.annotation.Nullable + private String newClientOrderId; + + public static final String SERIALIZED_NAME_STRATEGY_ID = "strategyId"; + + @SerializedName(SERIALIZED_NAME_STRATEGY_ID) + @jakarta.annotation.Nullable + private Long strategyId; + + public static final String SERIALIZED_NAME_STRATEGY_TYPE = "strategyType"; + + @SerializedName(SERIALIZED_NAME_STRATEGY_TYPE) + @jakarta.annotation.Nullable + private Integer strategyType; + + public static final String SERIALIZED_NAME_ICEBERG_QTY = "icebergQty"; + + @SerializedName(SERIALIZED_NAME_ICEBERG_QTY) + @jakarta.annotation.Nullable + private Double icebergQty; + + public static final String SERIALIZED_NAME_NEW_ORDER_RESP_TYPE = "newOrderRespType"; + + @SerializedName(SERIALIZED_NAME_NEW_ORDER_RESP_TYPE) + @jakarta.annotation.Nullable + private NewOrderRespType newOrderRespType; + + public static final String SERIALIZED_NAME_SELF_TRADE_PREVENTION_MODE = + "selfTradePreventionMode"; + + @SerializedName(SERIALIZED_NAME_SELF_TRADE_PREVENTION_MODE) + @jakarta.annotation.Nullable + private SelfTradePreventionMode selfTradePreventionMode; + + public static final String SERIALIZED_NAME_RECV_WINDOW = "recvWindow"; + + @SerializedName(SERIALIZED_NAME_RECV_WINDOW) + @jakarta.annotation.Nullable + private Long recvWindow; + public SorOrderTestRequest() {} public SorOrderTestRequest computeCommissionRates( @@ -65,6 +145,270 @@ public void setComputeCommissionRates( this.computeCommissionRates = computeCommissionRates; } + public SorOrderTestRequest symbol(@jakarta.annotation.Nonnull String symbol) { + this.symbol = symbol; + return this; + } + + /** + * Get symbol + * + * @return symbol + */ + @jakarta.annotation.Nonnull + @NotNull + public String getSymbol() { + return symbol; + } + + public void setSymbol(@jakarta.annotation.Nonnull String symbol) { + this.symbol = symbol; + } + + public SorOrderTestRequest side(@jakarta.annotation.Nonnull Side side) { + this.side = side; + return this; + } + + /** + * Get side + * + * @return side + */ + @jakarta.annotation.Nonnull + @NotNull + @Valid + public Side getSide() { + return side; + } + + public void setSide(@jakarta.annotation.Nonnull Side side) { + this.side = side; + } + + public SorOrderTestRequest type(@jakarta.annotation.Nonnull OrderType type) { + this.type = type; + return this; + } + + /** + * Get type + * + * @return type + */ + @jakarta.annotation.Nonnull + @NotNull + @Valid + public OrderType getType() { + return type; + } + + public void setType(@jakarta.annotation.Nonnull OrderType type) { + this.type = type; + } + + public SorOrderTestRequest timeInForce(@jakarta.annotation.Nullable TimeInForce timeInForce) { + this.timeInForce = timeInForce; + return this; + } + + /** + * Get timeInForce + * + * @return timeInForce + */ + @jakarta.annotation.Nullable + @Valid + public TimeInForce getTimeInForce() { + return timeInForce; + } + + public void setTimeInForce(@jakarta.annotation.Nullable TimeInForce timeInForce) { + this.timeInForce = timeInForce; + } + + public SorOrderTestRequest quantity(@jakarta.annotation.Nonnull Double quantity) { + this.quantity = quantity; + return this; + } + + /** + * Get quantity + * + * @return quantity + */ + @jakarta.annotation.Nonnull + @NotNull + @Valid + public Double getQuantity() { + return quantity; + } + + public void setQuantity(@jakarta.annotation.Nonnull Double quantity) { + this.quantity = quantity; + } + + public SorOrderTestRequest price(@jakarta.annotation.Nullable Double price) { + this.price = price; + return this; + } + + /** + * Get price + * + * @return price + */ + @jakarta.annotation.Nullable + @Valid + public Double getPrice() { + return price; + } + + public void setPrice(@jakarta.annotation.Nullable Double price) { + this.price = price; + } + + public SorOrderTestRequest newClientOrderId( + @jakarta.annotation.Nullable String newClientOrderId) { + this.newClientOrderId = newClientOrderId; + return this; + } + + /** + * Get newClientOrderId + * + * @return newClientOrderId + */ + @jakarta.annotation.Nullable + public String getNewClientOrderId() { + return newClientOrderId; + } + + public void setNewClientOrderId(@jakarta.annotation.Nullable String newClientOrderId) { + this.newClientOrderId = newClientOrderId; + } + + public SorOrderTestRequest strategyId(@jakarta.annotation.Nullable Long strategyId) { + this.strategyId = strategyId; + return this; + } + + /** + * Get strategyId + * + * @return strategyId + */ + @jakarta.annotation.Nullable + public Long getStrategyId() { + return strategyId; + } + + public void setStrategyId(@jakarta.annotation.Nullable Long strategyId) { + this.strategyId = strategyId; + } + + public SorOrderTestRequest strategyType(@jakarta.annotation.Nullable Integer strategyType) { + this.strategyType = strategyType; + return this; + } + + /** + * Get strategyType + * + * @return strategyType + */ + @jakarta.annotation.Nullable + public Integer getStrategyType() { + return strategyType; + } + + public void setStrategyType(@jakarta.annotation.Nullable Integer strategyType) { + this.strategyType = strategyType; + } + + public SorOrderTestRequest icebergQty(@jakarta.annotation.Nullable Double icebergQty) { + this.icebergQty = icebergQty; + return this; + } + + /** + * Get icebergQty + * + * @return icebergQty + */ + @jakarta.annotation.Nullable + @Valid + public Double getIcebergQty() { + return icebergQty; + } + + public void setIcebergQty(@jakarta.annotation.Nullable Double icebergQty) { + this.icebergQty = icebergQty; + } + + public SorOrderTestRequest newOrderRespType( + @jakarta.annotation.Nullable NewOrderRespType newOrderRespType) { + this.newOrderRespType = newOrderRespType; + return this; + } + + /** + * Get newOrderRespType + * + * @return newOrderRespType + */ + @jakarta.annotation.Nullable + @Valid + public NewOrderRespType getNewOrderRespType() { + return newOrderRespType; + } + + public void setNewOrderRespType( + @jakarta.annotation.Nullable NewOrderRespType newOrderRespType) { + this.newOrderRespType = newOrderRespType; + } + + public SorOrderTestRequest selfTradePreventionMode( + @jakarta.annotation.Nullable SelfTradePreventionMode selfTradePreventionMode) { + this.selfTradePreventionMode = selfTradePreventionMode; + return this; + } + + /** + * Get selfTradePreventionMode + * + * @return selfTradePreventionMode + */ + @jakarta.annotation.Nullable + @Valid + public SelfTradePreventionMode getSelfTradePreventionMode() { + return selfTradePreventionMode; + } + + public void setSelfTradePreventionMode( + @jakarta.annotation.Nullable SelfTradePreventionMode selfTradePreventionMode) { + this.selfTradePreventionMode = selfTradePreventionMode; + } + + public SorOrderTestRequest recvWindow(@jakarta.annotation.Nullable Long recvWindow) { + this.recvWindow = recvWindow; + return this; + } + + /** + * Get recvWindow + * + * @return recvWindow + */ + @jakarta.annotation.Nullable + public Long getRecvWindow() { + return recvWindow; + } + + public void setRecvWindow(@jakarta.annotation.Nullable Long recvWindow) { + this.recvWindow = recvWindow; + } + @Override public boolean equals(Object o) { if (this == o) { @@ -75,12 +419,40 @@ public boolean equals(Object o) { } SorOrderTestRequest sorOrderTestRequest = (SorOrderTestRequest) o; return Objects.equals( - this.computeCommissionRates, sorOrderTestRequest.computeCommissionRates); + this.computeCommissionRates, sorOrderTestRequest.computeCommissionRates) + && Objects.equals(this.symbol, sorOrderTestRequest.symbol) + && Objects.equals(this.side, sorOrderTestRequest.side) + && Objects.equals(this.type, sorOrderTestRequest.type) + && Objects.equals(this.timeInForce, sorOrderTestRequest.timeInForce) + && Objects.equals(this.quantity, sorOrderTestRequest.quantity) + && Objects.equals(this.price, sorOrderTestRequest.price) + && Objects.equals(this.newClientOrderId, sorOrderTestRequest.newClientOrderId) + && Objects.equals(this.strategyId, sorOrderTestRequest.strategyId) + && Objects.equals(this.strategyType, sorOrderTestRequest.strategyType) + && Objects.equals(this.icebergQty, sorOrderTestRequest.icebergQty) + && Objects.equals(this.newOrderRespType, sorOrderTestRequest.newOrderRespType) + && Objects.equals( + this.selfTradePreventionMode, sorOrderTestRequest.selfTradePreventionMode) + && Objects.equals(this.recvWindow, sorOrderTestRequest.recvWindow); } @Override public int hashCode() { - return Objects.hash(computeCommissionRates); + return Objects.hash( + computeCommissionRates, + symbol, + side, + type, + timeInForce, + quantity, + price, + newClientOrderId, + strategyId, + strategyType, + icebergQty, + newOrderRespType, + selfTradePreventionMode, + recvWindow); } @Override @@ -90,6 +462,21 @@ public String toString() { sb.append(" computeCommissionRates: ") .append(toIndentedString(computeCommissionRates)) .append("\n"); + sb.append(" symbol: ").append(toIndentedString(symbol)).append("\n"); + sb.append(" side: ").append(toIndentedString(side)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" timeInForce: ").append(toIndentedString(timeInForce)).append("\n"); + sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); + sb.append(" price: ").append(toIndentedString(price)).append("\n"); + sb.append(" newClientOrderId: ").append(toIndentedString(newClientOrderId)).append("\n"); + sb.append(" strategyId: ").append(toIndentedString(strategyId)).append("\n"); + sb.append(" strategyType: ").append(toIndentedString(strategyType)).append("\n"); + sb.append(" icebergQty: ").append(toIndentedString(icebergQty)).append("\n"); + sb.append(" newOrderRespType: ").append(toIndentedString(newOrderRespType)).append("\n"); + sb.append(" selfTradePreventionMode: ") + .append(toIndentedString(selfTradePreventionMode)) + .append("\n"); + sb.append(" recvWindow: ").append(toIndentedString(recvWindow)).append("\n"); sb.append("}"); return sb.toString(); } @@ -103,6 +490,60 @@ public String toUrlQueryString() { sb.append("computeCommissionRates=") .append(urlEncode(computeCommissionRatesValueAsString)) .append(""); + Object symbolValue = getSymbol(); + String symbolValueAsString = ""; + symbolValueAsString = symbolValue.toString(); + sb.append("symbol=").append(urlEncode(symbolValueAsString)).append(""); + Object sideValue = getSide(); + String sideValueAsString = ""; + sideValueAsString = sideValue.toString(); + sb.append("side=").append(urlEncode(sideValueAsString)).append(""); + Object typeValue = getType(); + String typeValueAsString = ""; + typeValueAsString = typeValue.toString(); + sb.append("type=").append(urlEncode(typeValueAsString)).append(""); + Object timeInForceValue = getTimeInForce(); + String timeInForceValueAsString = ""; + timeInForceValueAsString = timeInForceValue.toString(); + sb.append("timeInForce=").append(urlEncode(timeInForceValueAsString)).append(""); + Object quantityValue = getQuantity(); + String quantityValueAsString = ""; + quantityValueAsString = quantityValue.toString(); + sb.append("quantity=").append(urlEncode(quantityValueAsString)).append(""); + Object priceValue = getPrice(); + String priceValueAsString = ""; + priceValueAsString = priceValue.toString(); + sb.append("price=").append(urlEncode(priceValueAsString)).append(""); + Object newClientOrderIdValue = getNewClientOrderId(); + String newClientOrderIdValueAsString = ""; + newClientOrderIdValueAsString = newClientOrderIdValue.toString(); + sb.append("newClientOrderId=").append(urlEncode(newClientOrderIdValueAsString)).append(""); + Object strategyIdValue = getStrategyId(); + String strategyIdValueAsString = ""; + strategyIdValueAsString = strategyIdValue.toString(); + sb.append("strategyId=").append(urlEncode(strategyIdValueAsString)).append(""); + Object strategyTypeValue = getStrategyType(); + String strategyTypeValueAsString = ""; + strategyTypeValueAsString = strategyTypeValue.toString(); + sb.append("strategyType=").append(urlEncode(strategyTypeValueAsString)).append(""); + Object icebergQtyValue = getIcebergQty(); + String icebergQtyValueAsString = ""; + icebergQtyValueAsString = icebergQtyValue.toString(); + sb.append("icebergQty=").append(urlEncode(icebergQtyValueAsString)).append(""); + Object newOrderRespTypeValue = getNewOrderRespType(); + String newOrderRespTypeValueAsString = ""; + newOrderRespTypeValueAsString = newOrderRespTypeValue.toString(); + sb.append("newOrderRespType=").append(urlEncode(newOrderRespTypeValueAsString)).append(""); + Object selfTradePreventionModeValue = getSelfTradePreventionMode(); + String selfTradePreventionModeValueAsString = ""; + selfTradePreventionModeValueAsString = selfTradePreventionModeValue.toString(); + sb.append("selfTradePreventionMode=") + .append(urlEncode(selfTradePreventionModeValueAsString)) + .append(""); + Object recvWindowValue = getRecvWindow(); + String recvWindowValueAsString = ""; + recvWindowValueAsString = recvWindowValue.toString(); + sb.append("recvWindow=").append(urlEncode(recvWindowValueAsString)).append(""); return sb.toString(); } @@ -132,9 +573,26 @@ private String toIndentedString(Object o) { // a set of all properties/fields (JSON key names) openapiFields = new HashSet(); openapiFields.add("computeCommissionRates"); + openapiFields.add("symbol"); + openapiFields.add("side"); + openapiFields.add("type"); + openapiFields.add("timeInForce"); + openapiFields.add("quantity"); + openapiFields.add("price"); + openapiFields.add("newClientOrderId"); + openapiFields.add("strategyId"); + openapiFields.add("strategyType"); + openapiFields.add("icebergQty"); + openapiFields.add("newOrderRespType"); + openapiFields.add("selfTradePreventionMode"); + openapiFields.add("recvWindow"); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("symbol"); + openapiRequiredFields.add("side"); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("quantity"); } /** @@ -154,7 +612,51 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti SorOrderTestRequest.openapiRequiredFields.toString())); } } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SorOrderTestRequest.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException( + String.format( + "The required field `%s` is not found in the JSON string: %s", + requiredField, jsonElement.toString())); + } + } JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("symbol").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `symbol` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("symbol").toString())); + } + // validate the required field `side` + Side.validateJsonElement(jsonObj.get("side")); + // validate the required field `type` + OrderType.validateJsonElement(jsonObj.get("type")); + // validate the optional field `timeInForce` + if (jsonObj.get("timeInForce") != null && !jsonObj.get("timeInForce").isJsonNull()) { + TimeInForce.validateJsonElement(jsonObj.get("timeInForce")); + } + if ((jsonObj.get("newClientOrderId") != null + && !jsonObj.get("newClientOrderId").isJsonNull()) + && !jsonObj.get("newClientOrderId").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `newClientOrderId` to be a primitive type in the" + + " JSON string but got `%s`", + jsonObj.get("newClientOrderId").toString())); + } + // validate the optional field `newOrderRespType` + if (jsonObj.get("newOrderRespType") != null + && !jsonObj.get("newOrderRespType").isJsonNull()) { + NewOrderRespType.validateJsonElement(jsonObj.get("newOrderRespType")); + } + // validate the optional field `selfTradePreventionMode` + if (jsonObj.get("selfTradePreventionMode") != null + && !jsonObj.get("selfTradePreventionMode").isJsonNull()) { + SelfTradePreventionMode.validateJsonElement(jsonObj.get("selfTradePreventionMode")); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/clients/spot/src/main/java/com/binance/connector/client/spot/websocket/api/api/SpotWebSocketApi.java b/clients/spot/src/main/java/com/binance/connector/client/spot/websocket/api/api/SpotWebSocketApi.java index dd02705e..e8907c68 100644 --- a/clients/spot/src/main/java/com/binance/connector/client/spot/websocket/api/api/SpotWebSocketApi.java +++ b/clients/spot/src/main/java/com/binance/connector/client/spot/websocket/api/api/SpotWebSocketApi.java @@ -105,7 +105,7 @@ public class SpotWebSocketApi { private static final String USER_AGENT = String.format( - "binance-spot/4.0.0 (Java/%s; %s; %s)", + "binance-spot/5.0.0 (Java/%s; %s; %s)", SystemUtil.getJavaVersion(), SystemUtil.getOs(), SystemUtil.getArch()); private AccountApi accountApi; diff --git a/clients/spot/src/main/java/com/binance/connector/client/spot/websocket/api/model/AllOrdersRequest.java b/clients/spot/src/main/java/com/binance/connector/client/spot/websocket/api/model/AllOrdersRequest.java index 120a9ec4..92a6c758 100644 --- a/clients/spot/src/main/java/com/binance/connector/client/spot/websocket/api/model/AllOrdersRequest.java +++ b/clients/spot/src/main/java/com/binance/connector/client/spot/websocket/api/model/AllOrdersRequest.java @@ -49,7 +49,7 @@ public class AllOrdersRequest extends BaseDTO { @SerializedName(SERIALIZED_NAME_ORDER_ID) @jakarta.annotation.Nullable - private Integer orderId; + private Long orderId; public static final String SERIALIZED_NAME_START_TIME = "startTime"; @@ -97,7 +97,7 @@ public void setSymbol(@jakarta.annotation.Nonnull String symbol) { this.symbol = symbol; } - public AllOrdersRequest orderId(@jakarta.annotation.Nullable Integer orderId) { + public AllOrdersRequest orderId(@jakarta.annotation.Nullable Long orderId) { this.orderId = orderId; return this; } @@ -108,11 +108,11 @@ public AllOrdersRequest orderId(@jakarta.annotation.Nullable Integer orderId) { * @return orderId */ @jakarta.annotation.Nullable - public Integer getOrderId() { + public Long getOrderId() { return orderId; } - public void setOrderId(@jakarta.annotation.Nullable Integer orderId) { + public void setOrderId(@jakarta.annotation.Nullable Long orderId) { this.orderId = orderId; } @@ -237,7 +237,7 @@ public String toUrlQueryString() { String symbolValueAsString = symbolValue.toString(); valMap.put("symbol", symbolValueAsString); } - Integer orderIdValue = getOrderId(); + Long orderIdValue = getOrderId(); if (orderIdValue != null) { String orderIdValueAsString = orderIdValue.toString(); valMap.put("orderId", orderIdValueAsString); diff --git a/clients/spot/src/main/java/com/binance/connector/client/spot/websocket/api/model/MyTradesRequest.java b/clients/spot/src/main/java/com/binance/connector/client/spot/websocket/api/model/MyTradesRequest.java index f21a55eb..f7886a08 100644 --- a/clients/spot/src/main/java/com/binance/connector/client/spot/websocket/api/model/MyTradesRequest.java +++ b/clients/spot/src/main/java/com/binance/connector/client/spot/websocket/api/model/MyTradesRequest.java @@ -49,7 +49,7 @@ public class MyTradesRequest extends BaseDTO { @SerializedName(SERIALIZED_NAME_ORDER_ID) @jakarta.annotation.Nullable - private Integer orderId; + private Long orderId; public static final String SERIALIZED_NAME_START_TIME = "startTime"; @@ -103,7 +103,7 @@ public void setSymbol(@jakarta.annotation.Nonnull String symbol) { this.symbol = symbol; } - public MyTradesRequest orderId(@jakarta.annotation.Nullable Integer orderId) { + public MyTradesRequest orderId(@jakarta.annotation.Nullable Long orderId) { this.orderId = orderId; return this; } @@ -114,11 +114,11 @@ public MyTradesRequest orderId(@jakarta.annotation.Nullable Integer orderId) { * @return orderId */ @jakarta.annotation.Nullable - public Integer getOrderId() { + public Long getOrderId() { return orderId; } - public void setOrderId(@jakarta.annotation.Nullable Integer orderId) { + public void setOrderId(@jakarta.annotation.Nullable Long orderId) { this.orderId = orderId; } @@ -264,7 +264,7 @@ public String toUrlQueryString() { String symbolValueAsString = symbolValue.toString(); valMap.put("symbol", symbolValueAsString); } - Integer orderIdValue = getOrderId(); + Long orderIdValue = getOrderId(); if (orderIdValue != null) { String orderIdValueAsString = orderIdValue.toString(); valMap.put("orderId", orderIdValueAsString); diff --git a/clients/spot/src/main/java/com/binance/connector/client/spot/websocket/api/model/OrderCancelReplaceRequest.java b/clients/spot/src/main/java/com/binance/connector/client/spot/websocket/api/model/OrderCancelReplaceRequest.java index 994b413c..e6d7ab15 100644 --- a/clients/spot/src/main/java/com/binance/connector/client/spot/websocket/api/model/OrderCancelReplaceRequest.java +++ b/clients/spot/src/main/java/com/binance/connector/client/spot/websocket/api/model/OrderCancelReplaceRequest.java @@ -57,7 +57,7 @@ public class OrderCancelReplaceRequest extends BaseDTO { @SerializedName(SERIALIZED_NAME_CANCEL_ORDER_ID) @jakarta.annotation.Nullable - private Integer cancelOrderId; + private Long cancelOrderId; public static final String SERIALIZED_NAME_CANCEL_ORIG_CLIENT_ORDER_ID = "cancelOrigClientOrderId"; @@ -223,7 +223,7 @@ public void setCancelReplaceMode( } public OrderCancelReplaceRequest cancelOrderId( - @jakarta.annotation.Nullable Integer cancelOrderId) { + @jakarta.annotation.Nullable Long cancelOrderId) { this.cancelOrderId = cancelOrderId; return this; } @@ -234,11 +234,11 @@ public OrderCancelReplaceRequest cancelOrderId( * @return cancelOrderId */ @jakarta.annotation.Nullable - public Integer getCancelOrderId() { + public Long getCancelOrderId() { return cancelOrderId; } - public void setCancelOrderId(@jakarta.annotation.Nullable Integer cancelOrderId) { + public void setCancelOrderId(@jakarta.annotation.Nullable Long cancelOrderId) { this.cancelOrderId = cancelOrderId; } @@ -759,7 +759,7 @@ public String toUrlQueryString() { String cancelReplaceModeValueAsString = cancelReplaceModeValue.toString(); valMap.put("cancelReplaceMode", cancelReplaceModeValueAsString); } - Integer cancelOrderIdValue = getCancelOrderId(); + Long cancelOrderIdValue = getCancelOrderId(); if (cancelOrderIdValue != null) { String cancelOrderIdValueAsString = cancelOrderIdValue.toString(); valMap.put("cancelOrderId", cancelOrderIdValueAsString); diff --git a/clients/spot/src/main/java/com/binance/connector/client/spot/websocket/api/model/OrderCancelRequest.java b/clients/spot/src/main/java/com/binance/connector/client/spot/websocket/api/model/OrderCancelRequest.java index 0dadaba2..098fcb2d 100644 --- a/clients/spot/src/main/java/com/binance/connector/client/spot/websocket/api/model/OrderCancelRequest.java +++ b/clients/spot/src/main/java/com/binance/connector/client/spot/websocket/api/model/OrderCancelRequest.java @@ -50,7 +50,7 @@ public class OrderCancelRequest extends BaseDTO { @SerializedName(SERIALIZED_NAME_ORDER_ID) @jakarta.annotation.Nullable - private Integer orderId; + private Long orderId; public static final String SERIALIZED_NAME_ORIG_CLIENT_ORDER_ID = "origClientOrderId"; @@ -98,7 +98,7 @@ public void setSymbol(@jakarta.annotation.Nonnull String symbol) { this.symbol = symbol; } - public OrderCancelRequest orderId(@jakarta.annotation.Nullable Integer orderId) { + public OrderCancelRequest orderId(@jakarta.annotation.Nullable Long orderId) { this.orderId = orderId; return this; } @@ -109,11 +109,11 @@ public OrderCancelRequest orderId(@jakarta.annotation.Nullable Integer orderId) * @return orderId */ @jakarta.annotation.Nullable - public Integer getOrderId() { + public Long getOrderId() { return orderId; } - public void setOrderId(@jakarta.annotation.Nullable Integer orderId) { + public void setOrderId(@jakarta.annotation.Nullable Long orderId) { this.orderId = orderId; } @@ -251,7 +251,7 @@ public String toUrlQueryString() { String symbolValueAsString = symbolValue.toString(); valMap.put("symbol", symbolValueAsString); } - Integer orderIdValue = getOrderId(); + Long orderIdValue = getOrderId(); if (orderIdValue != null) { String orderIdValueAsString = orderIdValue.toString(); valMap.put("orderId", orderIdValueAsString); diff --git a/clients/spot/src/main/java/com/binance/connector/client/spot/websocket/api/model/OrderStatusRequest.java b/clients/spot/src/main/java/com/binance/connector/client/spot/websocket/api/model/OrderStatusRequest.java index 1a205be5..2cd9ef11 100644 --- a/clients/spot/src/main/java/com/binance/connector/client/spot/websocket/api/model/OrderStatusRequest.java +++ b/clients/spot/src/main/java/com/binance/connector/client/spot/websocket/api/model/OrderStatusRequest.java @@ -49,7 +49,7 @@ public class OrderStatusRequest extends BaseDTO { @SerializedName(SERIALIZED_NAME_ORDER_ID) @jakarta.annotation.Nullable - private Integer orderId; + private Long orderId; public static final String SERIALIZED_NAME_ORIG_CLIENT_ORDER_ID = "origClientOrderId"; @@ -85,7 +85,7 @@ public void setSymbol(@jakarta.annotation.Nonnull String symbol) { this.symbol = symbol; } - public OrderStatusRequest orderId(@jakarta.annotation.Nullable Integer orderId) { + public OrderStatusRequest orderId(@jakarta.annotation.Nullable Long orderId) { this.orderId = orderId; return this; } @@ -96,11 +96,11 @@ public OrderStatusRequest orderId(@jakarta.annotation.Nullable Integer orderId) * @return orderId */ @jakarta.annotation.Nullable - public Integer getOrderId() { + public Long getOrderId() { return orderId; } - public void setOrderId(@jakarta.annotation.Nullable Integer orderId) { + public void setOrderId(@jakarta.annotation.Nullable Long orderId) { this.orderId = orderId; } @@ -184,7 +184,7 @@ public String toUrlQueryString() { String symbolValueAsString = symbolValue.toString(); valMap.put("symbol", symbolValueAsString); } - Integer orderIdValue = getOrderId(); + Long orderIdValue = getOrderId(); if (orderIdValue != null) { String orderIdValueAsString = orderIdValue.toString(); valMap.put("orderId", orderIdValueAsString); diff --git a/clients/spot/src/main/java/com/binance/connector/client/spot/websocket/api/model/OrderTestRequest.java b/clients/spot/src/main/java/com/binance/connector/client/spot/websocket/api/model/OrderTestRequest.java index f1331e37..015f5a26 100644 --- a/clients/spot/src/main/java/com/binance/connector/client/spot/websocket/api/model/OrderTestRequest.java +++ b/clients/spot/src/main/java/com/binance/connector/client/spot/websocket/api/model/OrderTestRequest.java @@ -12,6 +12,7 @@ package com.binance.connector.client.spot.websocket.api.model; +import com.binance.connector.client.common.DecimalFormatter; import com.binance.connector.client.common.websocket.dtos.BaseDTO; import com.binance.connector.client.spot.websocket.api.JSON; import com.google.gson.Gson; @@ -23,6 +24,7 @@ import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import jakarta.validation.Valid; import jakarta.validation.constraints.*; import java.io.IOException; import java.nio.charset.StandardCharsets; @@ -45,6 +47,103 @@ public class OrderTestRequest extends BaseDTO { @jakarta.annotation.Nullable private Boolean computeCommissionRates; + public static final String SERIALIZED_NAME_SYMBOL = "symbol"; + + @SerializedName(SERIALIZED_NAME_SYMBOL) + @jakarta.annotation.Nonnull + private String symbol; + + public static final String SERIALIZED_NAME_SIDE = "side"; + + @SerializedName(SERIALIZED_NAME_SIDE) + @jakarta.annotation.Nonnull + private Side side; + + public static final String SERIALIZED_NAME_TYPE = "type"; + + @SerializedName(SERIALIZED_NAME_TYPE) + @jakarta.annotation.Nonnull + private OrderType type; + + public static final String SERIALIZED_NAME_TIME_IN_FORCE = "timeInForce"; + + @SerializedName(SERIALIZED_NAME_TIME_IN_FORCE) + @jakarta.annotation.Nullable + private TimeInForce timeInForce; + + public static final String SERIALIZED_NAME_PRICE = "price"; + + @SerializedName(SERIALIZED_NAME_PRICE) + @jakarta.annotation.Nullable + private Double price; + + public static final String SERIALIZED_NAME_QUANTITY = "quantity"; + + @SerializedName(SERIALIZED_NAME_QUANTITY) + @jakarta.annotation.Nullable + private Double quantity; + + public static final String SERIALIZED_NAME_QUOTE_ORDER_QTY = "quoteOrderQty"; + + @SerializedName(SERIALIZED_NAME_QUOTE_ORDER_QTY) + @jakarta.annotation.Nullable + private Double quoteOrderQty; + + public static final String SERIALIZED_NAME_NEW_CLIENT_ORDER_ID = "newClientOrderId"; + + @SerializedName(SERIALIZED_NAME_NEW_CLIENT_ORDER_ID) + @jakarta.annotation.Nullable + private String newClientOrderId; + + public static final String SERIALIZED_NAME_NEW_ORDER_RESP_TYPE = "newOrderRespType"; + + @SerializedName(SERIALIZED_NAME_NEW_ORDER_RESP_TYPE) + @jakarta.annotation.Nullable + private NewOrderRespType newOrderRespType; + + public static final String SERIALIZED_NAME_STOP_PRICE = "stopPrice"; + + @SerializedName(SERIALIZED_NAME_STOP_PRICE) + @jakarta.annotation.Nullable + private Double stopPrice; + + public static final String SERIALIZED_NAME_TRAILING_DELTA = "trailingDelta"; + + @SerializedName(SERIALIZED_NAME_TRAILING_DELTA) + @jakarta.annotation.Nullable + private Integer trailingDelta; + + public static final String SERIALIZED_NAME_ICEBERG_QTY = "icebergQty"; + + @SerializedName(SERIALIZED_NAME_ICEBERG_QTY) + @jakarta.annotation.Nullable + private Double icebergQty; + + public static final String SERIALIZED_NAME_STRATEGY_ID = "strategyId"; + + @SerializedName(SERIALIZED_NAME_STRATEGY_ID) + @jakarta.annotation.Nullable + private Long strategyId; + + public static final String SERIALIZED_NAME_STRATEGY_TYPE = "strategyType"; + + @SerializedName(SERIALIZED_NAME_STRATEGY_TYPE) + @jakarta.annotation.Nullable + private Integer strategyType; + + public static final String SERIALIZED_NAME_SELF_TRADE_PREVENTION_MODE = + "selfTradePreventionMode"; + + @SerializedName(SERIALIZED_NAME_SELF_TRADE_PREVENTION_MODE) + @jakarta.annotation.Nullable + private SelfTradePreventionMode selfTradePreventionMode; + + public static final String SERIALIZED_NAME_RECV_WINDOW = "recvWindow"; + + @SerializedName(SERIALIZED_NAME_RECV_WINDOW) + @jakarta.annotation.Nullable + private Long recvWindow; + public OrderTestRequest() {} public OrderTestRequest computeCommissionRates( @@ -68,6 +167,327 @@ public void setComputeCommissionRates( this.computeCommissionRates = computeCommissionRates; } + public OrderTestRequest symbol(@jakarta.annotation.Nonnull String symbol) { + this.symbol = symbol; + return this; + } + + /** + * Get symbol + * + * @return symbol + */ + @jakarta.annotation.Nonnull + @NotNull + public String getSymbol() { + return symbol; + } + + public void setSymbol(@jakarta.annotation.Nonnull String symbol) { + this.symbol = symbol; + } + + public OrderTestRequest side(@jakarta.annotation.Nonnull Side side) { + this.side = side; + return this; + } + + /** + * Get side + * + * @return side + */ + @jakarta.annotation.Nonnull + @NotNull + @Valid + public Side getSide() { + return side; + } + + public void setSide(@jakarta.annotation.Nonnull Side side) { + this.side = side; + } + + public OrderTestRequest type(@jakarta.annotation.Nonnull OrderType type) { + this.type = type; + return this; + } + + /** + * Get type + * + * @return type + */ + @jakarta.annotation.Nonnull + @NotNull + @Valid + public OrderType getType() { + return type; + } + + public void setType(@jakarta.annotation.Nonnull OrderType type) { + this.type = type; + } + + public OrderTestRequest timeInForce(@jakarta.annotation.Nullable TimeInForce timeInForce) { + this.timeInForce = timeInForce; + return this; + } + + /** + * Get timeInForce + * + * @return timeInForce + */ + @jakarta.annotation.Nullable + @Valid + public TimeInForce getTimeInForce() { + return timeInForce; + } + + public void setTimeInForce(@jakarta.annotation.Nullable TimeInForce timeInForce) { + this.timeInForce = timeInForce; + } + + public OrderTestRequest price(@jakarta.annotation.Nullable Double price) { + this.price = price; + return this; + } + + /** + * Get price + * + * @return price + */ + @jakarta.annotation.Nullable + @Valid + public Double getPrice() { + return price; + } + + public void setPrice(@jakarta.annotation.Nullable Double price) { + this.price = price; + } + + public OrderTestRequest quantity(@jakarta.annotation.Nullable Double quantity) { + this.quantity = quantity; + return this; + } + + /** + * Get quantity + * + * @return quantity + */ + @jakarta.annotation.Nullable + @Valid + public Double getQuantity() { + return quantity; + } + + public void setQuantity(@jakarta.annotation.Nullable Double quantity) { + this.quantity = quantity; + } + + public OrderTestRequest quoteOrderQty(@jakarta.annotation.Nullable Double quoteOrderQty) { + this.quoteOrderQty = quoteOrderQty; + return this; + } + + /** + * Get quoteOrderQty + * + * @return quoteOrderQty + */ + @jakarta.annotation.Nullable + @Valid + public Double getQuoteOrderQty() { + return quoteOrderQty; + } + + public void setQuoteOrderQty(@jakarta.annotation.Nullable Double quoteOrderQty) { + this.quoteOrderQty = quoteOrderQty; + } + + public OrderTestRequest newClientOrderId(@jakarta.annotation.Nullable String newClientOrderId) { + this.newClientOrderId = newClientOrderId; + return this; + } + + /** + * Get newClientOrderId + * + * @return newClientOrderId + */ + @jakarta.annotation.Nullable + public String getNewClientOrderId() { + return newClientOrderId; + } + + public void setNewClientOrderId(@jakarta.annotation.Nullable String newClientOrderId) { + this.newClientOrderId = newClientOrderId; + } + + public OrderTestRequest newOrderRespType( + @jakarta.annotation.Nullable NewOrderRespType newOrderRespType) { + this.newOrderRespType = newOrderRespType; + return this; + } + + /** + * Get newOrderRespType + * + * @return newOrderRespType + */ + @jakarta.annotation.Nullable + @Valid + public NewOrderRespType getNewOrderRespType() { + return newOrderRespType; + } + + public void setNewOrderRespType( + @jakarta.annotation.Nullable NewOrderRespType newOrderRespType) { + this.newOrderRespType = newOrderRespType; + } + + public OrderTestRequest stopPrice(@jakarta.annotation.Nullable Double stopPrice) { + this.stopPrice = stopPrice; + return this; + } + + /** + * Get stopPrice + * + * @return stopPrice + */ + @jakarta.annotation.Nullable + @Valid + public Double getStopPrice() { + return stopPrice; + } + + public void setStopPrice(@jakarta.annotation.Nullable Double stopPrice) { + this.stopPrice = stopPrice; + } + + public OrderTestRequest trailingDelta(@jakarta.annotation.Nullable Integer trailingDelta) { + this.trailingDelta = trailingDelta; + return this; + } + + /** + * Get trailingDelta + * + * @return trailingDelta + */ + @jakarta.annotation.Nullable + public Integer getTrailingDelta() { + return trailingDelta; + } + + public void setTrailingDelta(@jakarta.annotation.Nullable Integer trailingDelta) { + this.trailingDelta = trailingDelta; + } + + public OrderTestRequest icebergQty(@jakarta.annotation.Nullable Double icebergQty) { + this.icebergQty = icebergQty; + return this; + } + + /** + * Get icebergQty + * + * @return icebergQty + */ + @jakarta.annotation.Nullable + @Valid + public Double getIcebergQty() { + return icebergQty; + } + + public void setIcebergQty(@jakarta.annotation.Nullable Double icebergQty) { + this.icebergQty = icebergQty; + } + + public OrderTestRequest strategyId(@jakarta.annotation.Nullable Long strategyId) { + this.strategyId = strategyId; + return this; + } + + /** + * Get strategyId + * + * @return strategyId + */ + @jakarta.annotation.Nullable + public Long getStrategyId() { + return strategyId; + } + + public void setStrategyId(@jakarta.annotation.Nullable Long strategyId) { + this.strategyId = strategyId; + } + + public OrderTestRequest strategyType(@jakarta.annotation.Nullable Integer strategyType) { + this.strategyType = strategyType; + return this; + } + + /** + * Get strategyType + * + * @return strategyType + */ + @jakarta.annotation.Nullable + public Integer getStrategyType() { + return strategyType; + } + + public void setStrategyType(@jakarta.annotation.Nullable Integer strategyType) { + this.strategyType = strategyType; + } + + public OrderTestRequest selfTradePreventionMode( + @jakarta.annotation.Nullable SelfTradePreventionMode selfTradePreventionMode) { + this.selfTradePreventionMode = selfTradePreventionMode; + return this; + } + + /** + * Get selfTradePreventionMode + * + * @return selfTradePreventionMode + */ + @jakarta.annotation.Nullable + @Valid + public SelfTradePreventionMode getSelfTradePreventionMode() { + return selfTradePreventionMode; + } + + public void setSelfTradePreventionMode( + @jakarta.annotation.Nullable SelfTradePreventionMode selfTradePreventionMode) { + this.selfTradePreventionMode = selfTradePreventionMode; + } + + public OrderTestRequest recvWindow(@jakarta.annotation.Nullable Long recvWindow) { + this.recvWindow = recvWindow; + return this; + } + + /** + * Get recvWindow + * + * @return recvWindow + */ + @jakarta.annotation.Nullable + public Long getRecvWindow() { + return recvWindow; + } + + public void setRecvWindow(@jakarta.annotation.Nullable Long recvWindow) { + this.recvWindow = recvWindow; + } + @Override public boolean equals(Object o) { if (this == o) { @@ -77,12 +497,46 @@ public boolean equals(Object o) { return false; } OrderTestRequest orderTestRequest = (OrderTestRequest) o; - return Objects.equals(this.computeCommissionRates, orderTestRequest.computeCommissionRates); + return Objects.equals(this.computeCommissionRates, orderTestRequest.computeCommissionRates) + && Objects.equals(this.symbol, orderTestRequest.symbol) + && Objects.equals(this.side, orderTestRequest.side) + && Objects.equals(this.type, orderTestRequest.type) + && Objects.equals(this.timeInForce, orderTestRequest.timeInForce) + && Objects.equals(this.price, orderTestRequest.price) + && Objects.equals(this.quantity, orderTestRequest.quantity) + && Objects.equals(this.quoteOrderQty, orderTestRequest.quoteOrderQty) + && Objects.equals(this.newClientOrderId, orderTestRequest.newClientOrderId) + && Objects.equals(this.newOrderRespType, orderTestRequest.newOrderRespType) + && Objects.equals(this.stopPrice, orderTestRequest.stopPrice) + && Objects.equals(this.trailingDelta, orderTestRequest.trailingDelta) + && Objects.equals(this.icebergQty, orderTestRequest.icebergQty) + && Objects.equals(this.strategyId, orderTestRequest.strategyId) + && Objects.equals(this.strategyType, orderTestRequest.strategyType) + && Objects.equals( + this.selfTradePreventionMode, orderTestRequest.selfTradePreventionMode) + && Objects.equals(this.recvWindow, orderTestRequest.recvWindow); } @Override public int hashCode() { - return Objects.hash(computeCommissionRates); + return Objects.hash( + computeCommissionRates, + symbol, + side, + type, + timeInForce, + price, + quantity, + quoteOrderQty, + newClientOrderId, + newOrderRespType, + stopPrice, + trailingDelta, + icebergQty, + strategyId, + strategyType, + selfTradePreventionMode, + recvWindow); } @Override @@ -92,6 +546,24 @@ public String toString() { sb.append(" computeCommissionRates: ") .append(toIndentedString(computeCommissionRates)) .append("\n"); + sb.append(" symbol: ").append(toIndentedString(symbol)).append("\n"); + sb.append(" side: ").append(toIndentedString(side)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" timeInForce: ").append(toIndentedString(timeInForce)).append("\n"); + sb.append(" price: ").append(toIndentedString(price)).append("\n"); + sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); + sb.append(" quoteOrderQty: ").append(toIndentedString(quoteOrderQty)).append("\n"); + sb.append(" newClientOrderId: ").append(toIndentedString(newClientOrderId)).append("\n"); + sb.append(" newOrderRespType: ").append(toIndentedString(newOrderRespType)).append("\n"); + sb.append(" stopPrice: ").append(toIndentedString(stopPrice)).append("\n"); + sb.append(" trailingDelta: ").append(toIndentedString(trailingDelta)).append("\n"); + sb.append(" icebergQty: ").append(toIndentedString(icebergQty)).append("\n"); + sb.append(" strategyId: ").append(toIndentedString(strategyId)).append("\n"); + sb.append(" strategyType: ").append(toIndentedString(strategyType)).append("\n"); + sb.append(" selfTradePreventionMode: ") + .append(toIndentedString(selfTradePreventionMode)) + .append("\n"); + sb.append(" recvWindow: ").append(toIndentedString(recvWindow)).append("\n"); sb.append("}"); return sb.toString(); } @@ -105,6 +577,88 @@ public String toUrlQueryString() { String computeCommissionRatesValueAsString = computeCommissionRatesValue.toString(); valMap.put("computeCommissionRates", computeCommissionRatesValueAsString); } + String symbolValue = getSymbol(); + if (symbolValue != null) { + String symbolValueAsString = symbolValue.toString(); + valMap.put("symbol", symbolValueAsString); + } + Side sideValue = getSide(); + if (sideValue != null) { + String sideValueAsString = sideValue.toString(); + valMap.put("side", sideValueAsString); + } + OrderType typeValue = getType(); + if (typeValue != null) { + String typeValueAsString = typeValue.toString(); + valMap.put("type", typeValueAsString); + } + TimeInForce timeInForceValue = getTimeInForce(); + if (timeInForceValue != null) { + String timeInForceValueAsString = timeInForceValue.toString(); + valMap.put("timeInForce", timeInForceValueAsString); + } + Double priceValue = getPrice(); + if (priceValue != null) { + String priceValueAsString = DecimalFormatter.getFormatter().format(priceValue); + valMap.put("price", priceValueAsString); + } + Double quantityValue = getQuantity(); + if (quantityValue != null) { + String quantityValueAsString = DecimalFormatter.getFormatter().format(quantityValue); + valMap.put("quantity", quantityValueAsString); + } + Double quoteOrderQtyValue = getQuoteOrderQty(); + if (quoteOrderQtyValue != null) { + String quoteOrderQtyValueAsString = + DecimalFormatter.getFormatter().format(quoteOrderQtyValue); + valMap.put("quoteOrderQty", quoteOrderQtyValueAsString); + } + String newClientOrderIdValue = getNewClientOrderId(); + if (newClientOrderIdValue != null) { + String newClientOrderIdValueAsString = newClientOrderIdValue.toString(); + valMap.put("newClientOrderId", newClientOrderIdValueAsString); + } + NewOrderRespType newOrderRespTypeValue = getNewOrderRespType(); + if (newOrderRespTypeValue != null) { + String newOrderRespTypeValueAsString = newOrderRespTypeValue.toString(); + valMap.put("newOrderRespType", newOrderRespTypeValueAsString); + } + Double stopPriceValue = getStopPrice(); + if (stopPriceValue != null) { + String stopPriceValueAsString = DecimalFormatter.getFormatter().format(stopPriceValue); + valMap.put("stopPrice", stopPriceValueAsString); + } + Integer trailingDeltaValue = getTrailingDelta(); + if (trailingDeltaValue != null) { + String trailingDeltaValueAsString = trailingDeltaValue.toString(); + valMap.put("trailingDelta", trailingDeltaValueAsString); + } + Double icebergQtyValue = getIcebergQty(); + if (icebergQtyValue != null) { + String icebergQtyValueAsString = + DecimalFormatter.getFormatter().format(icebergQtyValue); + valMap.put("icebergQty", icebergQtyValueAsString); + } + Long strategyIdValue = getStrategyId(); + if (strategyIdValue != null) { + String strategyIdValueAsString = strategyIdValue.toString(); + valMap.put("strategyId", strategyIdValueAsString); + } + Integer strategyTypeValue = getStrategyType(); + if (strategyTypeValue != null) { + String strategyTypeValueAsString = strategyTypeValue.toString(); + valMap.put("strategyType", strategyTypeValueAsString); + } + SelfTradePreventionMode selfTradePreventionModeValue = getSelfTradePreventionMode(); + if (selfTradePreventionModeValue != null) { + String selfTradePreventionModeValueAsString = selfTradePreventionModeValue.toString(); + valMap.put("selfTradePreventionMode", selfTradePreventionModeValueAsString); + } + Long recvWindowValue = getRecvWindow(); + if (recvWindowValue != null) { + String recvWindowValueAsString = recvWindowValue.toString(); + valMap.put("recvWindow", recvWindowValueAsString); + } valMap.put("timestamp", getTimestamp()); return asciiEncode( @@ -120,6 +674,70 @@ public Map toMap() { if (computeCommissionRatesValue != null) { valMap.put("computeCommissionRates", computeCommissionRatesValue); } + Object symbolValue = getSymbol(); + if (symbolValue != null) { + valMap.put("symbol", symbolValue); + } + Object sideValue = getSide(); + if (sideValue != null) { + valMap.put("side", sideValue); + } + Object typeValue = getType(); + if (typeValue != null) { + valMap.put("type", typeValue); + } + Object timeInForceValue = getTimeInForce(); + if (timeInForceValue != null) { + valMap.put("timeInForce", timeInForceValue); + } + Object priceValue = getPrice(); + if (priceValue != null) { + valMap.put("price", priceValue); + } + Object quantityValue = getQuantity(); + if (quantityValue != null) { + valMap.put("quantity", quantityValue); + } + Object quoteOrderQtyValue = getQuoteOrderQty(); + if (quoteOrderQtyValue != null) { + valMap.put("quoteOrderQty", quoteOrderQtyValue); + } + Object newClientOrderIdValue = getNewClientOrderId(); + if (newClientOrderIdValue != null) { + valMap.put("newClientOrderId", newClientOrderIdValue); + } + Object newOrderRespTypeValue = getNewOrderRespType(); + if (newOrderRespTypeValue != null) { + valMap.put("newOrderRespType", newOrderRespTypeValue); + } + Object stopPriceValue = getStopPrice(); + if (stopPriceValue != null) { + valMap.put("stopPrice", stopPriceValue); + } + Object trailingDeltaValue = getTrailingDelta(); + if (trailingDeltaValue != null) { + valMap.put("trailingDelta", trailingDeltaValue); + } + Object icebergQtyValue = getIcebergQty(); + if (icebergQtyValue != null) { + valMap.put("icebergQty", icebergQtyValue); + } + Object strategyIdValue = getStrategyId(); + if (strategyIdValue != null) { + valMap.put("strategyId", strategyIdValue); + } + Object strategyTypeValue = getStrategyType(); + if (strategyTypeValue != null) { + valMap.put("strategyType", strategyTypeValue); + } + Object selfTradePreventionModeValue = getSelfTradePreventionMode(); + if (selfTradePreventionModeValue != null) { + valMap.put("selfTradePreventionMode", selfTradePreventionModeValue); + } + Object recvWindowValue = getRecvWindow(); + if (recvWindowValue != null) { + valMap.put("recvWindow", recvWindowValue); + } valMap.put("timestamp", getTimestamp()); return valMap; @@ -147,9 +765,28 @@ private String toIndentedString(Object o) { // a set of all properties/fields (JSON key names) openapiFields = new HashSet(); openapiFields.add("computeCommissionRates"); + openapiFields.add("symbol"); + openapiFields.add("side"); + openapiFields.add("type"); + openapiFields.add("timeInForce"); + openapiFields.add("price"); + openapiFields.add("quantity"); + openapiFields.add("quoteOrderQty"); + openapiFields.add("newClientOrderId"); + openapiFields.add("newOrderRespType"); + openapiFields.add("stopPrice"); + openapiFields.add("trailingDelta"); + openapiFields.add("icebergQty"); + openapiFields.add("strategyId"); + openapiFields.add("strategyType"); + openapiFields.add("selfTradePreventionMode"); + openapiFields.add("recvWindow"); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("symbol"); + openapiRequiredFields.add("side"); + openapiRequiredFields.add("type"); } /** @@ -181,7 +818,51 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti entry.getKey(), jsonElement.toString())); } } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : OrderTestRequest.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException( + String.format( + "The required field `%s` is not found in the JSON string: %s", + requiredField, jsonElement.toString())); + } + } JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("symbol").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `symbol` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("symbol").toString())); + } + // validate the required field `side` + Side.validateJsonElement(jsonObj.get("side")); + // validate the required field `type` + OrderType.validateJsonElement(jsonObj.get("type")); + // validate the optional field `timeInForce` + if (jsonObj.get("timeInForce") != null && !jsonObj.get("timeInForce").isJsonNull()) { + TimeInForce.validateJsonElement(jsonObj.get("timeInForce")); + } + if ((jsonObj.get("newClientOrderId") != null + && !jsonObj.get("newClientOrderId").isJsonNull()) + && !jsonObj.get("newClientOrderId").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `newClientOrderId` to be a primitive type in the" + + " JSON string but got `%s`", + jsonObj.get("newClientOrderId").toString())); + } + // validate the optional field `newOrderRespType` + if (jsonObj.get("newOrderRespType") != null + && !jsonObj.get("newOrderRespType").isJsonNull()) { + NewOrderRespType.validateJsonElement(jsonObj.get("newOrderRespType")); + } + // validate the optional field `selfTradePreventionMode` + if (jsonObj.get("selfTradePreventionMode") != null + && !jsonObj.get("selfTradePreventionMode").isJsonNull()) { + SelfTradePreventionMode.validateJsonElement(jsonObj.get("selfTradePreventionMode")); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/clients/spot/src/main/java/com/binance/connector/client/spot/websocket/api/model/SorOrderTestRequest.java b/clients/spot/src/main/java/com/binance/connector/client/spot/websocket/api/model/SorOrderTestRequest.java index 0f2f22c2..03169ffe 100644 --- a/clients/spot/src/main/java/com/binance/connector/client/spot/websocket/api/model/SorOrderTestRequest.java +++ b/clients/spot/src/main/java/com/binance/connector/client/spot/websocket/api/model/SorOrderTestRequest.java @@ -12,6 +12,7 @@ package com.binance.connector.client.spot.websocket.api.model; +import com.binance.connector.client.common.DecimalFormatter; import com.binance.connector.client.common.websocket.dtos.BaseDTO; import com.binance.connector.client.spot.websocket.api.JSON; import com.google.gson.Gson; @@ -23,6 +24,7 @@ import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import jakarta.validation.Valid; import jakarta.validation.constraints.*; import java.io.IOException; import java.nio.charset.StandardCharsets; @@ -45,6 +47,85 @@ public class SorOrderTestRequest extends BaseDTO { @jakarta.annotation.Nullable private Boolean computeCommissionRates; + public static final String SERIALIZED_NAME_SYMBOL = "symbol"; + + @SerializedName(SERIALIZED_NAME_SYMBOL) + @jakarta.annotation.Nonnull + private String symbol; + + public static final String SERIALIZED_NAME_SIDE = "side"; + + @SerializedName(SERIALIZED_NAME_SIDE) + @jakarta.annotation.Nonnull + private Side side; + + public static final String SERIALIZED_NAME_TYPE = "type"; + + @SerializedName(SERIALIZED_NAME_TYPE) + @jakarta.annotation.Nonnull + private OrderType type; + + public static final String SERIALIZED_NAME_TIME_IN_FORCE = "timeInForce"; + + @SerializedName(SERIALIZED_NAME_TIME_IN_FORCE) + @jakarta.annotation.Nullable + private TimeInForce timeInForce; + + public static final String SERIALIZED_NAME_PRICE = "price"; + + @SerializedName(SERIALIZED_NAME_PRICE) + @jakarta.annotation.Nullable + private Double price; + + public static final String SERIALIZED_NAME_QUANTITY = "quantity"; + + @SerializedName(SERIALIZED_NAME_QUANTITY) + @jakarta.annotation.Nonnull + private Double quantity; + + public static final String SERIALIZED_NAME_NEW_CLIENT_ORDER_ID = "newClientOrderId"; + + @SerializedName(SERIALIZED_NAME_NEW_CLIENT_ORDER_ID) + @jakarta.annotation.Nullable + private String newClientOrderId; + + public static final String SERIALIZED_NAME_NEW_ORDER_RESP_TYPE = "newOrderRespType"; + + @SerializedName(SERIALIZED_NAME_NEW_ORDER_RESP_TYPE) + @jakarta.annotation.Nullable + private NewOrderRespType newOrderRespType; + + public static final String SERIALIZED_NAME_ICEBERG_QTY = "icebergQty"; + + @SerializedName(SERIALIZED_NAME_ICEBERG_QTY) + @jakarta.annotation.Nullable + private Double icebergQty; + + public static final String SERIALIZED_NAME_STRATEGY_ID = "strategyId"; + + @SerializedName(SERIALIZED_NAME_STRATEGY_ID) + @jakarta.annotation.Nullable + private Long strategyId; + + public static final String SERIALIZED_NAME_STRATEGY_TYPE = "strategyType"; + + @SerializedName(SERIALIZED_NAME_STRATEGY_TYPE) + @jakarta.annotation.Nullable + private Integer strategyType; + + public static final String SERIALIZED_NAME_SELF_TRADE_PREVENTION_MODE = + "selfTradePreventionMode"; + + @SerializedName(SERIALIZED_NAME_SELF_TRADE_PREVENTION_MODE) + @jakarta.annotation.Nullable + private SelfTradePreventionMode selfTradePreventionMode; + + public static final String SERIALIZED_NAME_RECV_WINDOW = "recvWindow"; + + @SerializedName(SERIALIZED_NAME_RECV_WINDOW) + @jakarta.annotation.Nullable + private Long recvWindow; + public SorOrderTestRequest() {} public SorOrderTestRequest computeCommissionRates( @@ -68,6 +149,270 @@ public void setComputeCommissionRates( this.computeCommissionRates = computeCommissionRates; } + public SorOrderTestRequest symbol(@jakarta.annotation.Nonnull String symbol) { + this.symbol = symbol; + return this; + } + + /** + * Get symbol + * + * @return symbol + */ + @jakarta.annotation.Nonnull + @NotNull + public String getSymbol() { + return symbol; + } + + public void setSymbol(@jakarta.annotation.Nonnull String symbol) { + this.symbol = symbol; + } + + public SorOrderTestRequest side(@jakarta.annotation.Nonnull Side side) { + this.side = side; + return this; + } + + /** + * Get side + * + * @return side + */ + @jakarta.annotation.Nonnull + @NotNull + @Valid + public Side getSide() { + return side; + } + + public void setSide(@jakarta.annotation.Nonnull Side side) { + this.side = side; + } + + public SorOrderTestRequest type(@jakarta.annotation.Nonnull OrderType type) { + this.type = type; + return this; + } + + /** + * Get type + * + * @return type + */ + @jakarta.annotation.Nonnull + @NotNull + @Valid + public OrderType getType() { + return type; + } + + public void setType(@jakarta.annotation.Nonnull OrderType type) { + this.type = type; + } + + public SorOrderTestRequest timeInForce(@jakarta.annotation.Nullable TimeInForce timeInForce) { + this.timeInForce = timeInForce; + return this; + } + + /** + * Get timeInForce + * + * @return timeInForce + */ + @jakarta.annotation.Nullable + @Valid + public TimeInForce getTimeInForce() { + return timeInForce; + } + + public void setTimeInForce(@jakarta.annotation.Nullable TimeInForce timeInForce) { + this.timeInForce = timeInForce; + } + + public SorOrderTestRequest price(@jakarta.annotation.Nullable Double price) { + this.price = price; + return this; + } + + /** + * Get price + * + * @return price + */ + @jakarta.annotation.Nullable + @Valid + public Double getPrice() { + return price; + } + + public void setPrice(@jakarta.annotation.Nullable Double price) { + this.price = price; + } + + public SorOrderTestRequest quantity(@jakarta.annotation.Nonnull Double quantity) { + this.quantity = quantity; + return this; + } + + /** + * Get quantity + * + * @return quantity + */ + @jakarta.annotation.Nonnull + @NotNull + @Valid + public Double getQuantity() { + return quantity; + } + + public void setQuantity(@jakarta.annotation.Nonnull Double quantity) { + this.quantity = quantity; + } + + public SorOrderTestRequest newClientOrderId( + @jakarta.annotation.Nullable String newClientOrderId) { + this.newClientOrderId = newClientOrderId; + return this; + } + + /** + * Get newClientOrderId + * + * @return newClientOrderId + */ + @jakarta.annotation.Nullable + public String getNewClientOrderId() { + return newClientOrderId; + } + + public void setNewClientOrderId(@jakarta.annotation.Nullable String newClientOrderId) { + this.newClientOrderId = newClientOrderId; + } + + public SorOrderTestRequest newOrderRespType( + @jakarta.annotation.Nullable NewOrderRespType newOrderRespType) { + this.newOrderRespType = newOrderRespType; + return this; + } + + /** + * Get newOrderRespType + * + * @return newOrderRespType + */ + @jakarta.annotation.Nullable + @Valid + public NewOrderRespType getNewOrderRespType() { + return newOrderRespType; + } + + public void setNewOrderRespType( + @jakarta.annotation.Nullable NewOrderRespType newOrderRespType) { + this.newOrderRespType = newOrderRespType; + } + + public SorOrderTestRequest icebergQty(@jakarta.annotation.Nullable Double icebergQty) { + this.icebergQty = icebergQty; + return this; + } + + /** + * Get icebergQty + * + * @return icebergQty + */ + @jakarta.annotation.Nullable + @Valid + public Double getIcebergQty() { + return icebergQty; + } + + public void setIcebergQty(@jakarta.annotation.Nullable Double icebergQty) { + this.icebergQty = icebergQty; + } + + public SorOrderTestRequest strategyId(@jakarta.annotation.Nullable Long strategyId) { + this.strategyId = strategyId; + return this; + } + + /** + * Get strategyId + * + * @return strategyId + */ + @jakarta.annotation.Nullable + public Long getStrategyId() { + return strategyId; + } + + public void setStrategyId(@jakarta.annotation.Nullable Long strategyId) { + this.strategyId = strategyId; + } + + public SorOrderTestRequest strategyType(@jakarta.annotation.Nullable Integer strategyType) { + this.strategyType = strategyType; + return this; + } + + /** + * Get strategyType + * + * @return strategyType + */ + @jakarta.annotation.Nullable + public Integer getStrategyType() { + return strategyType; + } + + public void setStrategyType(@jakarta.annotation.Nullable Integer strategyType) { + this.strategyType = strategyType; + } + + public SorOrderTestRequest selfTradePreventionMode( + @jakarta.annotation.Nullable SelfTradePreventionMode selfTradePreventionMode) { + this.selfTradePreventionMode = selfTradePreventionMode; + return this; + } + + /** + * Get selfTradePreventionMode + * + * @return selfTradePreventionMode + */ + @jakarta.annotation.Nullable + @Valid + public SelfTradePreventionMode getSelfTradePreventionMode() { + return selfTradePreventionMode; + } + + public void setSelfTradePreventionMode( + @jakarta.annotation.Nullable SelfTradePreventionMode selfTradePreventionMode) { + this.selfTradePreventionMode = selfTradePreventionMode; + } + + public SorOrderTestRequest recvWindow(@jakarta.annotation.Nullable Long recvWindow) { + this.recvWindow = recvWindow; + return this; + } + + /** + * Get recvWindow + * + * @return recvWindow + */ + @jakarta.annotation.Nullable + public Long getRecvWindow() { + return recvWindow; + } + + public void setRecvWindow(@jakarta.annotation.Nullable Long recvWindow) { + this.recvWindow = recvWindow; + } + @Override public boolean equals(Object o) { if (this == o) { @@ -78,12 +423,40 @@ public boolean equals(Object o) { } SorOrderTestRequest sorOrderTestRequest = (SorOrderTestRequest) o; return Objects.equals( - this.computeCommissionRates, sorOrderTestRequest.computeCommissionRates); + this.computeCommissionRates, sorOrderTestRequest.computeCommissionRates) + && Objects.equals(this.symbol, sorOrderTestRequest.symbol) + && Objects.equals(this.side, sorOrderTestRequest.side) + && Objects.equals(this.type, sorOrderTestRequest.type) + && Objects.equals(this.timeInForce, sorOrderTestRequest.timeInForce) + && Objects.equals(this.price, sorOrderTestRequest.price) + && Objects.equals(this.quantity, sorOrderTestRequest.quantity) + && Objects.equals(this.newClientOrderId, sorOrderTestRequest.newClientOrderId) + && Objects.equals(this.newOrderRespType, sorOrderTestRequest.newOrderRespType) + && Objects.equals(this.icebergQty, sorOrderTestRequest.icebergQty) + && Objects.equals(this.strategyId, sorOrderTestRequest.strategyId) + && Objects.equals(this.strategyType, sorOrderTestRequest.strategyType) + && Objects.equals( + this.selfTradePreventionMode, sorOrderTestRequest.selfTradePreventionMode) + && Objects.equals(this.recvWindow, sorOrderTestRequest.recvWindow); } @Override public int hashCode() { - return Objects.hash(computeCommissionRates); + return Objects.hash( + computeCommissionRates, + symbol, + side, + type, + timeInForce, + price, + quantity, + newClientOrderId, + newOrderRespType, + icebergQty, + strategyId, + strategyType, + selfTradePreventionMode, + recvWindow); } @Override @@ -93,6 +466,21 @@ public String toString() { sb.append(" computeCommissionRates: ") .append(toIndentedString(computeCommissionRates)) .append("\n"); + sb.append(" symbol: ").append(toIndentedString(symbol)).append("\n"); + sb.append(" side: ").append(toIndentedString(side)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" timeInForce: ").append(toIndentedString(timeInForce)).append("\n"); + sb.append(" price: ").append(toIndentedString(price)).append("\n"); + sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); + sb.append(" newClientOrderId: ").append(toIndentedString(newClientOrderId)).append("\n"); + sb.append(" newOrderRespType: ").append(toIndentedString(newOrderRespType)).append("\n"); + sb.append(" icebergQty: ").append(toIndentedString(icebergQty)).append("\n"); + sb.append(" strategyId: ").append(toIndentedString(strategyId)).append("\n"); + sb.append(" strategyType: ").append(toIndentedString(strategyType)).append("\n"); + sb.append(" selfTradePreventionMode: ") + .append(toIndentedString(selfTradePreventionMode)) + .append("\n"); + sb.append(" recvWindow: ").append(toIndentedString(recvWindow)).append("\n"); sb.append("}"); return sb.toString(); } @@ -106,6 +494,72 @@ public String toUrlQueryString() { String computeCommissionRatesValueAsString = computeCommissionRatesValue.toString(); valMap.put("computeCommissionRates", computeCommissionRatesValueAsString); } + String symbolValue = getSymbol(); + if (symbolValue != null) { + String symbolValueAsString = symbolValue.toString(); + valMap.put("symbol", symbolValueAsString); + } + Side sideValue = getSide(); + if (sideValue != null) { + String sideValueAsString = sideValue.toString(); + valMap.put("side", sideValueAsString); + } + OrderType typeValue = getType(); + if (typeValue != null) { + String typeValueAsString = typeValue.toString(); + valMap.put("type", typeValueAsString); + } + TimeInForce timeInForceValue = getTimeInForce(); + if (timeInForceValue != null) { + String timeInForceValueAsString = timeInForceValue.toString(); + valMap.put("timeInForce", timeInForceValueAsString); + } + Double priceValue = getPrice(); + if (priceValue != null) { + String priceValueAsString = DecimalFormatter.getFormatter().format(priceValue); + valMap.put("price", priceValueAsString); + } + Double quantityValue = getQuantity(); + if (quantityValue != null) { + String quantityValueAsString = DecimalFormatter.getFormatter().format(quantityValue); + valMap.put("quantity", quantityValueAsString); + } + String newClientOrderIdValue = getNewClientOrderId(); + if (newClientOrderIdValue != null) { + String newClientOrderIdValueAsString = newClientOrderIdValue.toString(); + valMap.put("newClientOrderId", newClientOrderIdValueAsString); + } + NewOrderRespType newOrderRespTypeValue = getNewOrderRespType(); + if (newOrderRespTypeValue != null) { + String newOrderRespTypeValueAsString = newOrderRespTypeValue.toString(); + valMap.put("newOrderRespType", newOrderRespTypeValueAsString); + } + Double icebergQtyValue = getIcebergQty(); + if (icebergQtyValue != null) { + String icebergQtyValueAsString = + DecimalFormatter.getFormatter().format(icebergQtyValue); + valMap.put("icebergQty", icebergQtyValueAsString); + } + Long strategyIdValue = getStrategyId(); + if (strategyIdValue != null) { + String strategyIdValueAsString = strategyIdValue.toString(); + valMap.put("strategyId", strategyIdValueAsString); + } + Integer strategyTypeValue = getStrategyType(); + if (strategyTypeValue != null) { + String strategyTypeValueAsString = strategyTypeValue.toString(); + valMap.put("strategyType", strategyTypeValueAsString); + } + SelfTradePreventionMode selfTradePreventionModeValue = getSelfTradePreventionMode(); + if (selfTradePreventionModeValue != null) { + String selfTradePreventionModeValueAsString = selfTradePreventionModeValue.toString(); + valMap.put("selfTradePreventionMode", selfTradePreventionModeValueAsString); + } + Long recvWindowValue = getRecvWindow(); + if (recvWindowValue != null) { + String recvWindowValueAsString = recvWindowValue.toString(); + valMap.put("recvWindow", recvWindowValueAsString); + } valMap.put("timestamp", getTimestamp()); return asciiEncode( @@ -121,6 +575,58 @@ public Map toMap() { if (computeCommissionRatesValue != null) { valMap.put("computeCommissionRates", computeCommissionRatesValue); } + Object symbolValue = getSymbol(); + if (symbolValue != null) { + valMap.put("symbol", symbolValue); + } + Object sideValue = getSide(); + if (sideValue != null) { + valMap.put("side", sideValue); + } + Object typeValue = getType(); + if (typeValue != null) { + valMap.put("type", typeValue); + } + Object timeInForceValue = getTimeInForce(); + if (timeInForceValue != null) { + valMap.put("timeInForce", timeInForceValue); + } + Object priceValue = getPrice(); + if (priceValue != null) { + valMap.put("price", priceValue); + } + Object quantityValue = getQuantity(); + if (quantityValue != null) { + valMap.put("quantity", quantityValue); + } + Object newClientOrderIdValue = getNewClientOrderId(); + if (newClientOrderIdValue != null) { + valMap.put("newClientOrderId", newClientOrderIdValue); + } + Object newOrderRespTypeValue = getNewOrderRespType(); + if (newOrderRespTypeValue != null) { + valMap.put("newOrderRespType", newOrderRespTypeValue); + } + Object icebergQtyValue = getIcebergQty(); + if (icebergQtyValue != null) { + valMap.put("icebergQty", icebergQtyValue); + } + Object strategyIdValue = getStrategyId(); + if (strategyIdValue != null) { + valMap.put("strategyId", strategyIdValue); + } + Object strategyTypeValue = getStrategyType(); + if (strategyTypeValue != null) { + valMap.put("strategyType", strategyTypeValue); + } + Object selfTradePreventionModeValue = getSelfTradePreventionMode(); + if (selfTradePreventionModeValue != null) { + valMap.put("selfTradePreventionMode", selfTradePreventionModeValue); + } + Object recvWindowValue = getRecvWindow(); + if (recvWindowValue != null) { + valMap.put("recvWindow", recvWindowValue); + } valMap.put("timestamp", getTimestamp()); return valMap; @@ -148,9 +654,26 @@ private String toIndentedString(Object o) { // a set of all properties/fields (JSON key names) openapiFields = new HashSet(); openapiFields.add("computeCommissionRates"); + openapiFields.add("symbol"); + openapiFields.add("side"); + openapiFields.add("type"); + openapiFields.add("timeInForce"); + openapiFields.add("price"); + openapiFields.add("quantity"); + openapiFields.add("newClientOrderId"); + openapiFields.add("newOrderRespType"); + openapiFields.add("icebergQty"); + openapiFields.add("strategyId"); + openapiFields.add("strategyType"); + openapiFields.add("selfTradePreventionMode"); + openapiFields.add("recvWindow"); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("symbol"); + openapiRequiredFields.add("side"); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("quantity"); } /** @@ -182,7 +705,51 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti entry.getKey(), jsonElement.toString())); } } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SorOrderTestRequest.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException( + String.format( + "The required field `%s` is not found in the JSON string: %s", + requiredField, jsonElement.toString())); + } + } JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("symbol").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `symbol` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("symbol").toString())); + } + // validate the required field `side` + Side.validateJsonElement(jsonObj.get("side")); + // validate the required field `type` + OrderType.validateJsonElement(jsonObj.get("type")); + // validate the optional field `timeInForce` + if (jsonObj.get("timeInForce") != null && !jsonObj.get("timeInForce").isJsonNull()) { + TimeInForce.validateJsonElement(jsonObj.get("timeInForce")); + } + if ((jsonObj.get("newClientOrderId") != null + && !jsonObj.get("newClientOrderId").isJsonNull()) + && !jsonObj.get("newClientOrderId").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `newClientOrderId` to be a primitive type in the" + + " JSON string but got `%s`", + jsonObj.get("newClientOrderId").toString())); + } + // validate the optional field `newOrderRespType` + if (jsonObj.get("newOrderRespType") != null + && !jsonObj.get("newOrderRespType").isJsonNull()) { + NewOrderRespType.validateJsonElement(jsonObj.get("newOrderRespType")); + } + // validate the optional field `selfTradePreventionMode` + if (jsonObj.get("selfTradePreventionMode") != null + && !jsonObj.get("selfTradePreventionMode").isJsonNull()) { + SelfTradePreventionMode.validateJsonElement(jsonObj.get("selfTradePreventionMode")); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/clients/spot/src/main/java/com/binance/connector/client/spot/websocket/stream/api/SpotWebSocketStreams.java b/clients/spot/src/main/java/com/binance/connector/client/spot/websocket/stream/api/SpotWebSocketStreams.java index de292a1c..d4558242 100644 --- a/clients/spot/src/main/java/com/binance/connector/client/spot/websocket/stream/api/SpotWebSocketStreams.java +++ b/clients/spot/src/main/java/com/binance/connector/client/spot/websocket/stream/api/SpotWebSocketStreams.java @@ -39,7 +39,7 @@ public class SpotWebSocketStreams { private static final String USER_AGENT = String.format( - "binance-spot/4.0.0 (Java/%s; %s; %s)", + "binance-spot/5.0.0 (Java/%s; %s; %s)", SystemUtil.getJavaVersion(), SystemUtil.getOs(), SystemUtil.getArch()); private final StreamConnectionInterface connection; diff --git a/clients/spot/src/test/java/com/binance/connector/client/spot/rest/api/TradeApiTest.java b/clients/spot/src/test/java/com/binance/connector/client/spot/rest/api/TradeApiTest.java index e0d059e4..ea3361c2 100644 --- a/clients/spot/src/test/java/com/binance/connector/client/spot/rest/api/TradeApiTest.java +++ b/clients/spot/src/test/java/com/binance/connector/client/spot/rest/api/TradeApiTest.java @@ -512,6 +512,10 @@ public void orderOcoTest() throws ApiException, CryptoException { public void orderTestTest() throws ApiException, CryptoException { OrderTestRequest orderTestRequest = new OrderTestRequest(); + orderTestRequest.symbol("BNBUSDT"); + orderTestRequest.side(Side.BUY); + orderTestRequest.type(OrderType.MARKET); + ApiResponse orderTestResponseApiResponse = api.orderTest(orderTestRequest); ArgumentCaptor callArgumentCaptor = ArgumentCaptor.forClass(Call.class); @@ -523,9 +527,9 @@ public void orderTestTest() throws ApiException, CryptoException { Call captorValue = callArgumentCaptor.getValue(); Request actualRequest = captorValue.request(); - assertEquals("timestamp=1736393892000", signInputCaptor.getValue()); + assertEquals("timestamp=1736393892000symbol=BNBUSDT&side=BUY&type=MARKET", signInputCaptor.getValue()); assertEquals( - "53668e00dc92eb93de0b253c301e9fc0c20042b13db384a0ad94b38688a5a84c", + "6486465768232440fc305256c99d50fa366fe8e7f0e7be813f78507f50e0cb4c", actualRequest.url().queryParameter("signature")); assertEquals("/api/v3/order/test", actualRequest.url().encodedPath()); } @@ -581,6 +585,11 @@ public void sorOrderTest() throws ApiException, CryptoException { public void sorOrderTestTest() throws ApiException, CryptoException { SorOrderTestRequest sorOrderTestRequest = new SorOrderTestRequest(); + sorOrderTestRequest.symbol("BNBUSDT"); + sorOrderTestRequest.side(Side.BUY); + sorOrderTestRequest.type(OrderType.MARKET); + sorOrderTestRequest.quantity(1d); + ApiResponse response = api.sorOrderTest(sorOrderTestRequest); ArgumentCaptor callArgumentCaptor = ArgumentCaptor.forClass(Call.class); @@ -593,9 +602,9 @@ public void sorOrderTestTest() throws ApiException, CryptoException { Call captorValue = callArgumentCaptor.getValue(); Request actualRequest = captorValue.request(); - assertEquals("timestamp=1736393892000", signInputCaptor.getValue()); + assertEquals("timestamp=1736393892000symbol=BNBUSDT&side=BUY&quantity=1&type=MARKET", signInputCaptor.getValue()); assertEquals( - "53668e00dc92eb93de0b253c301e9fc0c20042b13db384a0ad94b38688a5a84c", + "84bb7809eacf584b9d7dccae40864b17ca8fcf3de423b05e0a171b8a0c67ed62", actualRequest.url().queryParameter("signature")); assertEquals("/api/v3/sor/order/test", actualRequest.url().encodedPath()); } diff --git a/clients/spot/src/test/java/com/binance/connector/client/spot/websocket/api/api/TradeApiTest.java b/clients/spot/src/test/java/com/binance/connector/client/spot/websocket/api/api/TradeApiTest.java index fd2492ec..0741a149 100644 --- a/clients/spot/src/test/java/com/binance/connector/client/spot/websocket/api/api/TradeApiTest.java +++ b/clients/spot/src/test/java/com/binance/connector/client/spot/websocket/api/api/TradeApiTest.java @@ -470,6 +470,7 @@ public void orderPlaceTest() throws ApiException, URISyntaxException, IOExceptio @Test public void orderTestTest() throws ApiException, URISyntaxException, IOException { OrderTestRequest orderTestRequest = new OrderTestRequest(); + orderTestRequest.symbol("BTCUSDT").quantity(0.00).side(Side.BUY).type(OrderType.LIMIT); CompletableFuture response = api.orderTest(orderTestRequest); ArgumentCaptor> callArgumentCaptor = ArgumentCaptor.forClass(RequestWrapperDTO.class); @@ -532,6 +533,7 @@ public void sorOrderPlaceTest() throws ApiException, URISyntaxException, IOExcep @Test public void sorOrderTestTest() throws ApiException, URISyntaxException, IOException { SorOrderTestRequest sorOrderTestRequest = new SorOrderTestRequest(); + sorOrderTestRequest.symbol("BTCUSDT").quantity(0.00).side(Side.BUY).type(OrderType.LIMIT); CompletableFuture response = api.sorOrderTest(sorOrderTestRequest); ArgumentCaptor> callArgumentCaptor = ArgumentCaptor.forClass(RequestWrapperDTO.class); diff --git a/clients/spot/src/test/resources/expected/api/TradeApi/order.test-test.json b/clients/spot/src/test/resources/expected/api/TradeApi/order.test-test.json index a483e65d..24048ce7 100644 --- a/clients/spot/src/test/resources/expected/api/TradeApi/order.test-test.json +++ b/clients/spot/src/test/resources/expected/api/TradeApi/order.test-test.json @@ -1,9 +1,13 @@ { - "id": "eaf3292c-64b6-4c04-ad4f-4ca2608b42b4", - "params": { - "apiKey": "apiKey", - "timestamp": "1736393892000", - "signature": "w5VdScCUjVCBg8gmima0WOwDjnL0BaNQ0Boi0A4rSSa8oszi1Ul+MWr5JH3JJ2zEduiEV781IxQg61lz3c+9BA\u003d\u003d" + "id" : "eaf3292c-64b6-4c04-ad4f-4ca2608b42b4", + "params" : { + "symbol" : "BTCUSDT", + "side" : "BUY", + "type" : "LIMIT", + "quantity" : "0", + "apiKey" : "apiKey", + "timestamp" : "1736393892000", + "signature" : "B0jL2/g4n2IwvNqT4MyGBe1OShUFiWCnQM3HAsRR1ByWYQfmX2GoWIj30l9LW3XC178spy7hK7dLu3Mg+NA6Dg==" }, - "method": "order.test" -} + "method" : "order.test" +} \ No newline at end of file diff --git a/clients/spot/src/test/resources/expected/api/TradeApi/sor.order.test-test.json b/clients/spot/src/test/resources/expected/api/TradeApi/sor.order.test-test.json index f96fbffc..56d20fed 100644 --- a/clients/spot/src/test/resources/expected/api/TradeApi/sor.order.test-test.json +++ b/clients/spot/src/test/resources/expected/api/TradeApi/sor.order.test-test.json @@ -1,9 +1,13 @@ { - "id": "eaf3292c-64b6-4c04-ad4f-4ca2608b42b4", - "params": { - "apiKey": "apiKey", - "timestamp": "1736393892000", - "signature": "w5VdScCUjVCBg8gmima0WOwDjnL0BaNQ0Boi0A4rSSa8oszi1Ul+MWr5JH3JJ2zEduiEV781IxQg61lz3c+9BA\u003d\u003d" + "id" : "eaf3292c-64b6-4c04-ad4f-4ca2608b42b4", + "params" : { + "symbol" : "BTCUSDT", + "side" : "BUY", + "type" : "LIMIT", + "quantity" : "0", + "apiKey" : "apiKey", + "timestamp" : "1736393892000", + "signature" : "B0jL2/g4n2IwvNqT4MyGBe1OShUFiWCnQM3HAsRR1ByWYQfmX2GoWIj30l9LW3XC178spy7hK7dLu3Mg+NA6Dg==" }, - "method": "sor.order.test" -} + "method" : "sor.order.test" +} \ No newline at end of file diff --git a/examples/spot/pom.xml b/examples/spot/pom.xml index e4d656ca..6e095017 100644 --- a/examples/spot/pom.xml +++ b/examples/spot/pom.xml @@ -31,7 +31,7 @@ io.github.binance binance-spot - 4.0.0 + 5.0.0 \ No newline at end of file diff --git a/examples/spot/src/main/java/com/binance/connector/client/spot/rest/trade/OrderTestExample.java b/examples/spot/src/main/java/com/binance/connector/client/spot/rest/trade/OrderTestExample.java index 7de4444f..cbbd335b 100644 --- a/examples/spot/src/main/java/com/binance/connector/client/spot/rest/trade/OrderTestExample.java +++ b/examples/spot/src/main/java/com/binance/connector/client/spot/rest/trade/OrderTestExample.java @@ -20,6 +20,8 @@ import com.binance.connector.client.spot.rest.api.SpotRestApi; import com.binance.connector.client.spot.rest.model.OrderTestRequest; import com.binance.connector.client.spot.rest.model.OrderTestResponse; +import com.binance.connector.client.spot.rest.model.OrderType; +import com.binance.connector.client.spot.rest.model.Side; /** API examples for TradeApi */ public class OrderTestExample { @@ -49,6 +51,9 @@ public SpotRestApi getApi() { */ public void orderTestExample() throws ApiException { OrderTestRequest orderTestRequest = new OrderTestRequest(); + orderTestRequest.symbol("BNBUSDT"); + orderTestRequest.side(Side.BUY); + orderTestRequest.type(OrderType.MARKET); ApiResponse response = getApi().orderTest(orderTestRequest); System.out.println(response.getData()); } diff --git a/examples/spot/src/main/java/com/binance/connector/client/spot/rest/trade/SorOrderTestExample.java b/examples/spot/src/main/java/com/binance/connector/client/spot/rest/trade/SorOrderTestExample.java index abff4931..403b2dbe 100644 --- a/examples/spot/src/main/java/com/binance/connector/client/spot/rest/trade/SorOrderTestExample.java +++ b/examples/spot/src/main/java/com/binance/connector/client/spot/rest/trade/SorOrderTestExample.java @@ -18,6 +18,8 @@ import com.binance.connector.client.common.configuration.SignatureConfiguration; import com.binance.connector.client.spot.rest.SpotRestApiUtil; import com.binance.connector.client.spot.rest.api.SpotRestApi; +import com.binance.connector.client.spot.rest.model.OrderType; +import com.binance.connector.client.spot.rest.model.Side; import com.binance.connector.client.spot.rest.model.SorOrderTestRequest; import com.binance.connector.client.spot.rest.model.SorOrderTestResponse; @@ -49,6 +51,10 @@ public SpotRestApi getApi() { */ public void sorOrderTestExample() throws ApiException { SorOrderTestRequest sorOrderTestRequest = new SorOrderTestRequest(); + sorOrderTestRequest.symbol("BNBUSDT"); + sorOrderTestRequest.side(Side.BUY); + sorOrderTestRequest.type(OrderType.MARKET); + sorOrderTestRequest.quantity(1.0d); ApiResponse response = getApi().sorOrderTest(sorOrderTestRequest); System.out.println(response.getData()); } diff --git a/examples/spot/src/main/java/com/binance/connector/client/spot/websocket/api/trade/OrderTestExample.java b/examples/spot/src/main/java/com/binance/connector/client/spot/websocket/api/trade/OrderTestExample.java index 24d08ff1..826b668b 100644 --- a/examples/spot/src/main/java/com/binance/connector/client/spot/websocket/api/trade/OrderTestExample.java +++ b/examples/spot/src/main/java/com/binance/connector/client/spot/websocket/api/trade/OrderTestExample.java @@ -18,6 +18,8 @@ import com.binance.connector.client.spot.websocket.api.api.SpotWebSocketApi; import com.binance.connector.client.spot.websocket.api.model.OrderTestRequest; import com.binance.connector.client.spot.websocket.api.model.OrderTestResponse; +import com.binance.connector.client.spot.websocket.api.model.OrderType; +import com.binance.connector.client.spot.websocket.api.model.Side; import java.util.concurrent.CompletableFuture; /** API examples for TradeApi */ @@ -50,6 +52,9 @@ public SpotWebSocketApi getApi() { */ public void orderTestExampleAsync() { OrderTestRequest orderTestRequest = new OrderTestRequest(); + orderTestRequest.symbol("BNBUSDT"); + orderTestRequest.side(Side.BUY); + orderTestRequest.type(OrderType.MARKET); CompletableFuture future = getApi().orderTest(orderTestRequest); future.handle( (response, error) -> { @@ -71,6 +76,9 @@ public void orderTestExampleAsync() { */ public void orderTestExampleSync() { OrderTestRequest orderTestRequest = new OrderTestRequest(); + orderTestRequest.symbol("BNBUSDT"); + orderTestRequest.side(Side.BUY); + orderTestRequest.type(OrderType.MARKET); CompletableFuture future = getApi().orderTest(orderTestRequest); OrderTestResponse response = future.join(); System.out.println(response); diff --git a/examples/spot/src/main/java/com/binance/connector/client/spot/websocket/api/trade/SorOrderTestExample.java b/examples/spot/src/main/java/com/binance/connector/client/spot/websocket/api/trade/SorOrderTestExample.java index ea6c627a..9a66f080 100644 --- a/examples/spot/src/main/java/com/binance/connector/client/spot/websocket/api/trade/SorOrderTestExample.java +++ b/examples/spot/src/main/java/com/binance/connector/client/spot/websocket/api/trade/SorOrderTestExample.java @@ -16,6 +16,8 @@ import com.binance.connector.client.common.websocket.configuration.WebSocketClientConfiguration; import com.binance.connector.client.spot.websocket.api.SpotWebSocketApiUtil; import com.binance.connector.client.spot.websocket.api.api.SpotWebSocketApi; +import com.binance.connector.client.spot.websocket.api.model.OrderType; +import com.binance.connector.client.spot.websocket.api.model.Side; import com.binance.connector.client.spot.websocket.api.model.SorOrderTestRequest; import com.binance.connector.client.spot.websocket.api.model.SorOrderTestResponse; import java.util.concurrent.CompletableFuture; @@ -50,6 +52,10 @@ public SpotWebSocketApi getApi() { */ public void sorOrderTestExampleAsync() { SorOrderTestRequest sorOrderTestRequest = new SorOrderTestRequest(); + sorOrderTestRequest.symbol("BNBUSDT"); + sorOrderTestRequest.side(Side.BUY); + sorOrderTestRequest.type(OrderType.MARKET); + sorOrderTestRequest.quantity(1.0d); CompletableFuture future = getApi().sorOrderTest(sorOrderTestRequest); future.handle( (response, error) -> { @@ -71,6 +77,10 @@ public void sorOrderTestExampleAsync() { */ public void sorOrderTestExampleSync() { SorOrderTestRequest sorOrderTestRequest = new SorOrderTestRequest(); + sorOrderTestRequest.symbol("BNBUSDT"); + sorOrderTestRequest.side(Side.BUY); + sorOrderTestRequest.type(OrderType.MARKET); + sorOrderTestRequest.quantity(1.0d); CompletableFuture future = getApi().sorOrderTest(sorOrderTestRequest); SorOrderTestResponse response = future.join(); System.out.println(response);