-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4881 from bigscoop/binance-currencyinfo
[binance] Add getting of currency infos
- Loading branch information
Showing
11 changed files
with
252 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
http-client.private.env.json |
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,11 @@ | ||
## Using IntelliJ Idea HTTP client | ||
|
||
There are *.http files stored in `src/test/resources/rest` that can be used with IntelliJ Idea HTTP Client. | ||
|
||
Some requests need authorization, so the api credentials have to be stored in `http-client.private.env.json` in module's root. Sample content can be found in `example.http-client.private.env.json` | ||
|
||
> [!CAUTION] | ||
> Never commit your api credentials to the repository! | ||
|
||
[HTTP Client documentation](https://www.jetbrains.com/help/idea/http-client-in-product-code-editor.html) |
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,6 @@ | ||
{ | ||
"default": { | ||
"api_key": "replace_me", | ||
"api_secret": "replace_me" | ||
} | ||
} |
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
13 changes: 13 additions & 0 deletions
13
...e/src/main/java/org/knowm/xchange/binance/config/converter/StringToCurrencyConverter.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,13 @@ | ||
package org.knowm.xchange.binance.config.converter; | ||
|
||
import com.fasterxml.jackson.databind.util.StdConverter; | ||
import org.knowm.xchange.currency.Currency; | ||
|
||
/** Converts string value {@code Currency} */ | ||
public class StringToCurrencyConverter extends StdConverter<String, Currency> { | ||
|
||
@Override | ||
public Currency convert(String value) { | ||
return Currency.getInstance(value); | ||
} | ||
} |
138 changes: 138 additions & 0 deletions
138
xchange-binance/src/main/java/org/knowm/xchange/binance/dto/account/BinanceCurrencyInfo.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,138 @@ | ||
package org.knowm.xchange.binance.dto.account; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
import java.math.BigDecimal; | ||
import java.util.List; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.extern.jackson.Jacksonized; | ||
import org.knowm.xchange.binance.config.converter.StringToCurrencyConverter; | ||
import org.knowm.xchange.currency.Currency; | ||
|
||
@Data | ||
@Builder | ||
@Jacksonized | ||
public class BinanceCurrencyInfo { | ||
|
||
@JsonProperty("coin") | ||
@JsonDeserialize(converter = StringToCurrencyConverter.class) | ||
private Currency currency; | ||
|
||
@JsonProperty("depositAllEnable") | ||
private Boolean depositEnabled; | ||
|
||
@JsonProperty("withdrawAllEnable") | ||
private Boolean withdrawEnabled; | ||
|
||
@JsonProperty("name") | ||
private String name; | ||
|
||
@JsonProperty("free") | ||
private BigDecimal free; | ||
|
||
@JsonProperty("locked") | ||
private BigDecimal locked; | ||
|
||
@JsonProperty("freeze") | ||
private BigDecimal freeze; | ||
|
||
@JsonProperty("withdrawing") | ||
private BigDecimal withdrawing; | ||
|
||
@JsonProperty("ipoing") | ||
private BigDecimal ipoing; | ||
|
||
@JsonProperty("ipoable") | ||
private BigDecimal ipoable; | ||
|
||
@JsonProperty("storage") | ||
private BigDecimal storage; | ||
|
||
@JsonProperty("isLegalMoney") | ||
private Boolean isLegalMoney; | ||
|
||
@JsonProperty("trading") | ||
private Boolean trading; | ||
|
||
@JsonProperty("networkList") | ||
private List<Network> networks; | ||
|
||
|
||
@Data | ||
@Builder | ||
@Jacksonized | ||
public static class Network { | ||
|
||
@JsonProperty("network") | ||
private String id; | ||
|
||
@JsonProperty("coin") | ||
@JsonDeserialize(converter = StringToCurrencyConverter.class) | ||
private Currency currency; | ||
|
||
@JsonProperty("withdrawIntegerMultiple") | ||
private BigDecimal withdrawIntegerMultiple; | ||
|
||
@JsonProperty("isDefault") | ||
private Boolean isDefault; | ||
|
||
@JsonProperty("depositEnable") | ||
private Boolean depositEnabled; | ||
|
||
@JsonProperty("withdrawEnable") | ||
private Boolean withdrawEnabled; | ||
|
||
@JsonProperty("depositDesc") | ||
private String depositDesc; | ||
|
||
@JsonProperty("withdrawDesc") | ||
private String withdrawDesc; | ||
|
||
@JsonProperty("specialTips") | ||
private String specialTips; | ||
|
||
@JsonProperty("name") | ||
private String name; | ||
|
||
@JsonProperty("resetAddressStatus") | ||
private Boolean resetAddressStatus; | ||
|
||
@JsonProperty("addressRegex") | ||
private String addressRegex; | ||
|
||
@JsonProperty("memoRegex") | ||
private String memoRegex; | ||
|
||
@JsonProperty("withdrawFee") | ||
private BigDecimal withdrawFee; | ||
|
||
@JsonProperty("withdrawMin") | ||
private BigDecimal withdrawMin; | ||
|
||
@JsonProperty("withdrawMax") | ||
private BigDecimal withdrawMax; | ||
|
||
@JsonProperty("minConfirm") | ||
private Integer minConfirm; | ||
|
||
@JsonProperty("unLockConfirm") | ||
private Integer unLockConfirm; | ||
|
||
@JsonProperty("sameAddress") | ||
private Boolean sameAddress; | ||
|
||
@JsonProperty("estimatedArrivalTime") | ||
private Integer estimatedArrivalTime; | ||
|
||
@JsonProperty("busy") | ||
private Boolean busy; | ||
|
||
@JsonProperty("contractAddressUrl") | ||
private String contractAddressUrl; | ||
|
||
@JsonProperty("contractAddress") | ||
private String contractAddress; | ||
|
||
} | ||
} |
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
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,16 @@ | ||
export function gen_sign(request) { | ||
const pattern = RegExp("^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?"); | ||
const url = request.url.tryGetSubstituted(); | ||
const matches = url.match(pattern); | ||
|
||
const timestamp = Math.floor(Date.now()).toFixed(); | ||
const query = matches[7] || ""; | ||
|
||
const payloadToSign = query.replace("&signature={{signature}}", "").replace("{{timestamp}}", timestamp); | ||
|
||
const apiSecret = request.environment.get("api_secret"); | ||
const sign = crypto.hmac.sha256().withTextSecret(apiSecret).updateWithText(payloadToSign).digest().toHex(); | ||
|
||
request.variables.set("timestamp", timestamp); | ||
request.variables.set("signature", sign); | ||
} |
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,8 @@ | ||
### All Coins' Information (USER_DATA) | ||
< {% | ||
import {gen_sign} from 'sign.js' | ||
gen_sign(request); | ||
%} | ||
|
||
GET {{api_host}}/sapi/v1/capital/config/getall?timestamp={{timestamp}}&signature={{signature}} | ||
X-MBX-APIKEY: {{api_key}} |