forked from binance-exchange/binance-java-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolves binance-exchange#5 - Support /exchangeInfo endpoint
- Loading branch information
1 parent
af6ab53
commit 824b2e4
Showing
18 changed files
with
692 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/main/java/com/binance/api/client/domain/general/ExchangeFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.binance.api.client.domain.general; | ||
|
||
import org.apache.commons.lang3.builder.ToStringBuilder; | ||
import org.apache.commons.lang3.builder.ToStringStyle; | ||
|
||
/** | ||
* Exchange Filters define trading rules an exchange. | ||
* | ||
* The MAX_NUM_ORDERS filter defines the maximum number of orders an account is allowed to have open on the exchange. Note that both "algo" orders and normal orders are counted for this filter. | ||
* | ||
* The MAX_ALGO_ORDERS filter defines the maximum number of "algo" orders an account is allowed to have open on the exchange. "Algo" orders are STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, and TAKE_PROFIT_LIMIT orders. | ||
*/ | ||
public class ExchangeFilter { | ||
|
||
private FilterType filterType; | ||
|
||
private Integer limit; | ||
|
||
public FilterType getFilterType() { | ||
return filterType; | ||
} | ||
|
||
public void setFilterType(FilterType filterType) { | ||
this.filterType = filterType; | ||
} | ||
|
||
public Integer getLimit() { | ||
return limit; | ||
} | ||
|
||
public void setLimit(Integer limit) { | ||
this.limit = limit; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) | ||
.append("filterType", filterType) | ||
.append("limit", limit) | ||
.toString(); | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
src/main/java/com/binance/api/client/domain/general/ExchangeInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package com.binance.api.client.domain.general; | ||
|
||
import com.binance.api.client.exception.BinanceApiException; | ||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import org.apache.commons.lang3.builder.ToStringBuilder; | ||
import org.apache.commons.lang3.builder.ToStringStyle; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Current exchange trading rules and symbol information. | ||
* https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md | ||
*/ | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public class ExchangeInfo { | ||
|
||
private String timezone; | ||
|
||
private Long serverTime; | ||
|
||
private List<RateLimit> rateLimits; | ||
|
||
// private List<String> exchangeFilters; | ||
|
||
private List<SymbolInfo> symbols; | ||
|
||
public String getTimezone() { | ||
return timezone; | ||
} | ||
|
||
public void setTimezone(String timezone) { | ||
this.timezone = timezone; | ||
} | ||
|
||
public Long getServerTime() { | ||
return serverTime; | ||
} | ||
|
||
public void setServerTime(Long serverTime) { | ||
this.serverTime = serverTime; | ||
} | ||
|
||
public List<RateLimit> getRateLimits() { | ||
return rateLimits; | ||
} | ||
|
||
public void setRateLimits(List<RateLimit> rateLimits) { | ||
this.rateLimits = rateLimits; | ||
} | ||
|
||
public List<SymbolInfo> getSymbols() { | ||
return symbols; | ||
} | ||
|
||
public void setSymbols(List<SymbolInfo> symbols) { | ||
this.symbols = symbols; | ||
} | ||
|
||
/** | ||
* @param symbol the symbol to obtain information for (e.g. ETHBTC) | ||
* @return symbol exchange information | ||
*/ | ||
public SymbolInfo getSymbolInfo(String symbol) { | ||
return symbols.stream().filter(symbolInfo -> symbolInfo.getSymbol().equals(symbol)) | ||
.findFirst() | ||
.orElseThrow(() -> new BinanceApiException("Unable to obtain information for symbol " + symbol)); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) | ||
.append("timezone", timezone) | ||
.append("serverTime", serverTime) | ||
.append("rateLimits", rateLimits) | ||
.append("symbols", symbols) | ||
.toString(); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/binance/api/client/domain/general/FilterType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.binance.api.client.domain.general; | ||
|
||
/** | ||
* Filters define trading rules on a symbol or an exchange. Filters come in two forms: symbol filters and exchange filters. | ||
*/ | ||
public enum FilterType { | ||
// Symbol | ||
PRICE_FILTER, | ||
LOT_SIZE, | ||
MIN_NOTIONAL, | ||
MAX_NUM_ORDERS, | ||
MAX_ALGO_ORDERS, | ||
|
||
// Exchange | ||
EXCHANGE_MAX_NUM_ORDERS, | ||
EXCHANGE_MAX_ALGO_ORDERS | ||
} |
49 changes: 49 additions & 0 deletions
49
src/main/java/com/binance/api/client/domain/general/RateLimit.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.binance.api.client.domain.general; | ||
|
||
import org.apache.commons.lang3.builder.ToStringBuilder; | ||
import org.apache.commons.lang3.builder.ToStringStyle; | ||
|
||
/** | ||
* Rate limits. | ||
*/ | ||
public class RateLimit { | ||
|
||
private RateLimitType rateLimitType; | ||
|
||
private RateLimitInterval interval; | ||
|
||
private Integer limit; | ||
|
||
public RateLimitType getRateLimitType() { | ||
return rateLimitType; | ||
} | ||
|
||
public void setRateLimitType(RateLimitType rateLimitType) { | ||
this.rateLimitType = rateLimitType; | ||
} | ||
|
||
public RateLimitInterval getInterval() { | ||
return interval; | ||
} | ||
|
||
public void setInterval(RateLimitInterval interval) { | ||
this.interval = interval; | ||
} | ||
|
||
public Integer getLimit() { | ||
return limit; | ||
} | ||
|
||
public void setLimit(Integer limit) { | ||
this.limit = limit; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) | ||
.append("rateLimitType", rateLimitType) | ||
.append("interval", interval) | ||
.append("limit", limit) | ||
.toString(); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/binance/api/client/domain/general/RateLimitInterval.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.binance.api.client.domain.general; | ||
|
||
/** | ||
* Rate limit intervals. | ||
*/ | ||
public enum RateLimitInterval { | ||
SECOND, | ||
MINUTE, | ||
DAY | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/com/binance/api/client/domain/general/RateLimitType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.binance.api.client.domain.general; | ||
|
||
/** | ||
* Rate limiters. | ||
*/ | ||
public enum RateLimitType { | ||
REQUESTS, | ||
ORDERS | ||
} |
Oops, something went wrong.