Skip to content

Commit

Permalink
Merge branch 'knowm:develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
donald-jackson authored Dec 11, 2024
2 parents 1edb694 + da97115 commit 67482f1
Show file tree
Hide file tree
Showing 521 changed files with 6,809 additions and 15,006 deletions.
46 changes: 36 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@
</developer>
</developers>

<prerequisites>
<maven>3.0</maven>
</prerequisites>

<modules>
<module>xchange-ascendex</module>
<module>xchange-bibox</module>
Expand Down Expand Up @@ -88,7 +84,6 @@
<module>xchange-enigma</module>
<module>xchange-examples</module>
<module>xchange-exmo</module>
<module>xchange-ftx</module>
<module>xchange-gateio</module>
<module>xchange-gateio-v4</module>
<module>xchange-gemini</module>
Expand Down Expand Up @@ -125,6 +120,7 @@
<module>xchange-stream-binance</module>
<module>xchange-stream-bitfinex</module>
<module>xchange-stream-bitflyer</module>
<module>xchange-stream-bitget</module>
<module>xchange-stream-bitmex</module>
<module>xchange-stream-bitstamp</module>
<module>xchange-stream-btcmarkets</module>
Expand All @@ -136,7 +132,6 @@
<module>xchange-stream-coinmate</module>
<module>xchange-stream-core</module>
<module>xchange-stream-dydx</module>
<module>xchange-stream-ftx</module>
<module>xchange-stream-gateio</module>
<module>xchange-stream-gemini</module>
<module>xchange-stream-gemini-v2</module>
Expand All @@ -153,7 +148,6 @@
<module>xchange-stream-service-core</module>
<module>xchange-stream-service-netty</module>
<module>xchange-stream-service-pubnub</module>
<module>xchange-therock</module>
<module>xchange-tradeogre</module>
<module>xchange-truefx</module>
<module>xchange-upbit</module>
Expand Down Expand Up @@ -208,6 +202,8 @@
<version.junit>5.10.2</version.junit>
<version.knowm.xchart>3.8.8</version.knowm.xchart>
<version.lombok>1.18.32</version.lombok>
<version.maven-enforcer-plugin>3.2.1</version.maven-enforcer-plugin>
<version.maven-prerequisite>3.6.3</version.maven-prerequisite>
<version.mockito>5.11.0</version.mockito>
<version.qos.logback>1.5.6</version.qos.logback>
<version.reflections>0.10.2</version.reflections>
Expand Down Expand Up @@ -254,6 +250,13 @@
<version>${version.fasterxml}</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>${version.fasterxml}</version>

</dependency>

<!-- Rest client -->
<dependency>
<groupId>com.github.mmazi</groupId>
Expand Down Expand Up @@ -461,7 +464,7 @@
<plugin>
<groupId>com.spotify.fmt</groupId>
<artifactId>fmt-maven-plugin</artifactId>
<version>2.23</version>
<version>2.25</version>
<configuration>
<filesNamePattern>.*\.java</filesNamePattern>
<skip>false</skip>
Expand All @@ -486,6 +489,29 @@
</configuration>
</plugin>

<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<version>${version.maven-enforcer-plugin}</version>
<executions>
<execution>
<id>enforce</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<version>${version.maven-prerequisite}</version>
</requireMavenVersion>
<dependencyConvergence/>
<banDuplicatePomDependencyVersions/>
<reactorModuleConvergence/>
</rules>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
Expand All @@ -508,7 +534,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.7.0</version>
<version>3.10.1</version>
<configuration>
<quiet>true</quiet>
<doclint>none</doclint>
Expand Down Expand Up @@ -590,7 +616,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.7.0</version>
<version>3.10.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,4 @@ public boolean cancelOrder(CancelOrderParams orderParams) throws IOException {
public UserTrades getTradeHistory(TradeHistoryParams params) throws IOException {
return BiboxAdapters.adaptUserTrades(getBiboxOrderHistory());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public class BinanceAdapters {

private static final Map<String, CurrencyPair> SYMBOL_TO_CURRENCY_PAIR = new HashMap<>();


private BinanceAdapters() {}

/**
Expand Down Expand Up @@ -186,17 +185,14 @@ public static OrderType convertType(boolean isBuyer) {
return isBuyer ? OrderType.BID : OrderType.ASK;
}


public static void putSymbolMapping(String symbol, CurrencyPair currencyPair) {
SYMBOL_TO_CURRENCY_PAIR.put(symbol, currencyPair);
}


public static CurrencyPair toCurrencyPair(String symbol) {
return SYMBOL_TO_CURRENCY_PAIR.get(symbol);
}


public static Instrument adaptSymbol(String symbol, boolean isFuture) {
CurrencyPair currencyPair = toCurrencyPair(symbol);

Expand Down Expand Up @@ -247,9 +243,11 @@ public static Order adaptOrder(BinanceOrder order, boolean isFuture) {
return builder.build();
}


public static Ticker toTicker(BinanceTicker24h binanceTicker24h, boolean isFuture) {
Instrument instrument = (isFuture) ? new FuturesContract(binanceTicker24h.getCurrencyPair(), "PERP"): binanceTicker24h.getCurrencyPair();
Instrument instrument =
(isFuture)
? new FuturesContract(binanceTicker24h.getCurrencyPair(), "PERP")
: binanceTicker24h.getCurrencyPair();
return new Ticker.Builder()
.instrument(instrument)
.open(binanceTicker24h.getOpenPrice())
Expand All @@ -269,7 +267,6 @@ public static Ticker toTicker(BinanceTicker24h binanceTicker24h, boolean isFutur
.build();
}


static CurrencyMetaData adaptCurrencyMetaData(
Map<Currency, CurrencyMetaData> currencies,
Currency currency,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,6 @@ BinanceDustLog getDustLog(
@QueryParam(SIGNATURE) ParamsDigest signature)
throws IOException, BinanceException;


@GET
@Path("/sapi/v1/capital/config/getall")
List<BinanceCurrencyInfo> getCurrencyInfos(
Expand All @@ -348,7 +347,6 @@ List<BinanceCurrencyInfo> getCurrencyInfos(
@QueryParam(SIGNATURE) ParamsDigest signature)
throws IOException, BinanceException;


/**
* Submit a withdraw request.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ public void applySpecification(ExchangeSpecification exchangeSpecification) {
}

public boolean isFuturesEnabled() {
return ExchangeType.FUTURES.equals(exchangeSpecification.
getExchangeSpecificParametersItem(EXCHANGE_TYPE));
return ExchangeType.FUTURES.equals(
exchangeSpecification.getExchangeSpecificParametersItem(EXCHANGE_TYPE));
}

public boolean isPortfolioMarginEnabled() {
return ExchangeType.PORTFOLIO_MARGIN.equals(exchangeSpecification
.getExchangeSpecificParametersItem(EXCHANGE_TYPE));
return ExchangeType.PORTFOLIO_MARGIN.equals(
exchangeSpecification.getExchangeSpecificParametersItem(EXCHANGE_TYPE));
}

public boolean usingSandbox() {
Expand All @@ -103,7 +103,8 @@ public boolean usingSandbox() {
@Override
public void remoteInit() {
try {
BinanceMarketDataServiceRaw marketDataServiceRaw = (BinanceMarketDataServiceRaw) marketDataService;
BinanceMarketDataServiceRaw marketDataServiceRaw =
(BinanceMarketDataServiceRaw) marketDataService;
BinanceAccountService accountService = (BinanceAccountService) getAccountService();
Map<String, AssetDetail> assetDetailMap = null;
if (!usingSandbox() && isAuthenticated()) {
Expand All @@ -112,7 +113,10 @@ public void remoteInit() {

BinanceExchangeInfo exchangeInfo;
// get exchange type or SPOT as default
ExchangeType exchangeType = (ExchangeType) ObjectUtils.defaultIfNull(exchangeSpecification.getExchangeSpecificParametersItem(EXCHANGE_TYPE), SPOT);
ExchangeType exchangeType =
(ExchangeType)
ObjectUtils.defaultIfNull(
exchangeSpecification.getExchangeSpecificParametersItem(EXCHANGE_TYPE), SPOT);

switch (exchangeType) {
case FUTURES:
Expand All @@ -126,8 +130,15 @@ public void remoteInit() {

// init symbol mappings
exchangeInfo.getSymbols().stream()
.filter(symbol -> ObjectUtils.allNotNull(symbol.getBaseAsset(), symbol.getQuoteAsset(), symbol.getSymbol()))
.forEach(symbol -> BinanceAdapters.putSymbolMapping(symbol.getSymbol(), new CurrencyPair(symbol.getBaseAsset(), symbol.getQuoteAsset())));
.filter(
symbol ->
ObjectUtils.allNotNull(
symbol.getBaseAsset(), symbol.getQuoteAsset(), symbol.getSymbol()))
.forEach(
symbol ->
BinanceAdapters.putSymbolMapping(
symbol.getSymbol(),
new CurrencyPair(symbol.getBaseAsset(), symbol.getQuoteAsset())));

} catch (Exception e) {
throw new ExchangeException("Failed to initialize: " + e.getMessage(), e);
Expand All @@ -140,38 +151,37 @@ protected boolean isAuthenticated() {
&& exchangeSpecification.getSecretKey() != null;
}

/**
* Adjust host parameters depending on exchange specific parameters
*/
/** Adjust host parameters depending on exchange specific parameters */
private static void concludeHostParams(ExchangeSpecification exchangeSpecification) {
if(exchangeSpecification.getExchangeSpecificParametersItem(EXCHANGE_TYPE) != null) {
switch ((ExchangeType)exchangeSpecification.getExchangeSpecificParametersItem(EXCHANGE_TYPE)) {
case SPOT: {
if (enabledSandbox(exchangeSpecification))
exchangeSpecification.setSslUri(SANDBOX_SPOT_URL);
break;
}
case FUTURES: {
if (!enabledSandbox(exchangeSpecification))
exchangeSpecification.setSslUri(FUTURES_URL);
else
exchangeSpecification.setSslUri(SANDBOX_FUTURES_URL);
break;
}
case INVERSE: {
if (!enabledSandbox(exchangeSpecification))
exchangeSpecification.setSslUri(INVERSE_FUTURES_URL);
else
exchangeSpecification.setSslUri(SANDBOX_INVERSE_FUTURES_URL);
break;
}
if (exchangeSpecification.getExchangeSpecificParametersItem(EXCHANGE_TYPE) != null) {
switch ((ExchangeType)
exchangeSpecification.getExchangeSpecificParametersItem(EXCHANGE_TYPE)) {
case SPOT:
{
if (enabledSandbox(exchangeSpecification))
exchangeSpecification.setSslUri(SANDBOX_SPOT_URL);
break;
}
case FUTURES:
{
if (!enabledSandbox(exchangeSpecification))
exchangeSpecification.setSslUri(FUTURES_URL);
else exchangeSpecification.setSslUri(SANDBOX_FUTURES_URL);
break;
}
case INVERSE:
{
if (!enabledSandbox(exchangeSpecification))
exchangeSpecification.setSslUri(INVERSE_FUTURES_URL);
else exchangeSpecification.setSslUri(SANDBOX_INVERSE_FUTURES_URL);
break;
}
}
}
}


private static boolean enabledSandbox(ExchangeSpecification exchangeSpecification) {
return Boolean.TRUE.equals(exchangeSpecification.getExchangeSpecificParametersItem(USE_SANDBOX));
return Boolean.TRUE.equals(
exchangeSpecification.getExchangeSpecificParametersItem(USE_SANDBOX));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ BinanceTicker24h ticker24h(@QueryParam("symbol") String symbol)
*/
@GET
@Path("fapi/v1/ticker/24hr")
List<BinanceTicker24h> ticker24h()
throws IOException, BinanceException;
List<BinanceTicker24h> ticker24h() throws IOException, BinanceException;

/**
* Get compressed, aggregate trades. Trades that fill at the time, from the same order, with the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ public enum ExchangeType {
INVERSE,
PORTFOLIO_MARGIN;
}

Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public class BinanceCurrencyInfo {
@JsonProperty("networkList")
private List<Network> networks;


@Data
@Builder
@Jacksonized
Expand Down Expand Up @@ -133,6 +132,5 @@ public static class Network {

@JsonProperty("contractAddress")
private String contractAddress;

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,4 @@ public class BinancePrice {
public boolean isValid() {
return currencyPair != null && price != null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,4 @@ public final class BinancePriceQuantity {
public boolean isValid() {
return ObjectUtils.allNotNull(currencyPair, bidPrice, bidQty, askPrice, askQty);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public final class BinanceTicker24h {
@JsonDeserialize(converter = StringToCurrencyPairConverter.class)
private CurrencyPair currencyPair;


public boolean isValid() {
return currencyPair != null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@
public class BinanceSystemStatus {

// 0: normal,1:system maintenance
@JsonProperty
String status;
@JsonProperty String status;

// normal or system maintenance
@JsonProperty
String msg;

@JsonProperty String msg;
}
Loading

0 comments on commit 67482f1

Please sign in to comment.