diff --git a/pom.xml b/pom.xml index d48044e..84f9fb4 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ io.github.binance binance-connector-java - 3.4.0 + 3.4.1-wwcdfork jar ${project.groupId}:${project.artifactId} lightweight connector to API @@ -145,6 +145,14 @@ + + org.apache.maven.plugins + maven-compiler-plugin + + 16 + 16 + + @@ -174,6 +182,11 @@ json 20231013 + + com.fasterxml.jackson.core + jackson-databind + 2.18.1 + org.slf4j slf4j-api diff --git a/src/main/java/com/binance/connector/client/enums/OrderType.java b/src/main/java/com/binance/connector/client/enums/OrderType.java new file mode 100644 index 0000000..5a9fa08 --- /dev/null +++ b/src/main/java/com/binance/connector/client/enums/OrderType.java @@ -0,0 +1,7 @@ +package com.binance.connector.client.enums; + +public enum OrderType { + + LIMIT, LIMIT_MAKER, MARKET, STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, TAKE_PROFIT_LIMIT + +} diff --git a/src/main/java/com/binance/connector/client/enums/TradingStatus.java b/src/main/java/com/binance/connector/client/enums/TradingStatus.java new file mode 100644 index 0000000..ab2e953 --- /dev/null +++ b/src/main/java/com/binance/connector/client/enums/TradingStatus.java @@ -0,0 +1,7 @@ +package com.binance.connector.client.enums; + +public enum TradingStatus { + + TRADING, HALT, BREAK + +} diff --git a/src/main/java/com/binance/connector/client/impl/spot/Market.java b/src/main/java/com/binance/connector/client/impl/spot/Market.java index f81b881..7b4a822 100644 --- a/src/main/java/com/binance/connector/client/impl/spot/Market.java +++ b/src/main/java/com/binance/connector/client/impl/spot/Market.java @@ -2,13 +2,17 @@ import java.util.ArrayList; import java.util.Map; +import java.util.Set; import com.binance.connector.client.enums.HttpMethod; import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.spot.data.SymbolResponse; import com.binance.connector.client.utils.JSONParser; import com.binance.connector.client.utils.ParameterChecker; import com.binance.connector.client.utils.ProxyAuth; import com.binance.connector.client.utils.RequestHandler; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.type.TypeFactory; /** *

Market Endpoints

@@ -94,6 +98,37 @@ public String exchangeInfo(Map parameters) { return requestHandler.sendPublicRequest(baseUrl, EXCHANGE_INFO, parameters, HttpMethod.GET, showLimitUsage); } + /** + * Symbol information as a set of POJOs + *

+ * GET /api/v3/exchangeinfo + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * symbol -- optional/string
+ * symbols -- optional/ArrayList
+ * permissions -- optional/ArrayList -- support single or multiple values (e.g. "SPOT", ["MARGIN","LEVERAGED"])
+ * @return A {@link Set} of {@link SymbolResponse} objects representing the parsed symbols data. + * @see + * https://developers.binance.com/docs/binance-spot-api-docs/rest-api#exchange-information + */ + public Set getSymbols(Map parameters) { + String exchangeInfoResponse = exchangeInfo(parameters); + ObjectMapper mapper = new ObjectMapper(); + try { + Map map = mapper.readValue(exchangeInfoResponse, Map.class); + Set symbols = mapper.convertValue( + map.get("symbols"), + TypeFactory.defaultInstance().constructCollectionType(Set.class, SymbolResponse.class) + ); + return symbols; + } catch (Exception e) { + throw new RuntimeException("Error parsing JSON", e); + } + } + private final String DEPTH = "/api/v3/depth"; /** * GET /api/v3/depth diff --git a/src/main/java/com/binance/connector/client/impl/spot/data/SymbolResponse.java b/src/main/java/com/binance/connector/client/impl/spot/data/SymbolResponse.java new file mode 100644 index 0000000..7679c66 --- /dev/null +++ b/src/main/java/com/binance/connector/client/impl/spot/data/SymbolResponse.java @@ -0,0 +1,30 @@ +package com.binance.connector.client.impl.spot.data; + +import com.binance.connector.client.enums.OrderType; +import com.binance.connector.client.enums.TradingStatus; + +import java.math.BigDecimal; +import java.util.Set; + +public record SymbolResponse( + + String symbol, + TradingStatus status, + String baseAsset, + BigDecimal baseAssetPrecision, + String quoteAsset, + BigDecimal quoteAssetPrecision, + + Set orderTypes, + + Boolean icebergAllowed, + Boolean ocoAllowed, + Boolean otoAllowed, + Boolean quoteOrderQtyMarketAllowed, + Boolean allowTrailingStop, + Boolean cancelReplaceAllowed, + Boolean isSpotTradingAllowed, + Boolean isMarginTradingAllowed +) { + +}