proj_name
stringclasses 131
values | relative_path
stringlengths 30
228
| class_name
stringlengths 1
68
| func_name
stringlengths 1
48
| masked_class
stringlengths 78
9.82k
| func_body
stringlengths 46
9.61k
| len_input
int64 29
2.01k
| len_output
int64 14
1.94k
| total
int64 55
2.05k
| relevant_context
stringlengths 0
38.4k
|
|---|---|---|---|---|---|---|---|---|---|
knowm_XChange
|
XChange/xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/dto/account/CoinbaseUser.java
|
CoinbaseUserInfo
|
toString
|
class CoinbaseUserInfo {
private final String id;
@JsonProperty("password")
private final String password;
private final String receiveAddress;
@JsonProperty("referrer_id")
private final String referrerId;
private final CoinbaseMoney balance;
private final CoinbaseBuySellLevel buyLevel;
private final CoinbaseBuySellLevel sellLevel;
private final CoinbaseMoney buyLimit;
private final CoinbaseMoney sellLimit;
private final CoinbaseMerchant merchant;
@JsonProperty("email")
private String email;
@JsonProperty("name")
private String name;
@JsonProperty("time_zone")
private String timeZone;
@JsonProperty("native_currency")
private String nativeCurrency;
@JsonProperty("pin")
private String pin;
private CoinbaseUserInfo(
@JsonProperty("id") final String id,
@JsonProperty("email") final String email,
@JsonProperty("name") final String name,
@JsonProperty("password") final String password,
@JsonProperty("receive_address") final String receiveAddress,
@JsonProperty("referrer_id") final String referrerId,
@JsonProperty("time_zone") final String timeZone,
@JsonProperty("balance") @JsonDeserialize(using = CoinbaseMoneyDeserializer.class)
final CoinbaseMoney balance,
@JsonProperty("native_currency") final String nativeCurrency,
@JsonProperty("buy_level") final CoinbaseBuySellLevel buyLevel,
@JsonProperty("sell_level") final CoinbaseBuySellLevel sellLevel,
@JsonProperty("buy_limit") @JsonDeserialize(using = CoinbaseMoneyDeserializer.class)
final CoinbaseMoney buyLimit,
@JsonProperty("sell_limit") @JsonDeserialize(using = CoinbaseMoneyDeserializer.class)
final CoinbaseMoney sellLimit,
@JsonProperty("pin") final String pin,
@JsonProperty("merchant") final CoinbaseMerchant merchant) {
this.id = id;
this.email = email;
this.name = name;
this.password = password;
this.receiveAddress = receiveAddress;
this.referrerId = referrerId;
this.timeZone = timeZone;
this.balance = balance;
this.nativeCurrency = nativeCurrency;
this.buyLevel = buyLevel;
this.sellLevel = sellLevel;
this.buyLimit = buyLimit;
this.sellLimit = sellLimit;
this.pin = pin;
this.merchant = merchant;
}
private CoinbaseUserInfo(String email, final String password, final String referrerId) {
this.email = email;
this.password = password;
this.referrerId = referrerId;
this.id = null;
this.name = null;
this.receiveAddress = null;
this.timeZone = null;
this.balance = null;
this.nativeCurrency = null;
this.buyLevel = null;
this.sellLevel = null;
this.buyLimit = null;
this.sellLimit = null;
this.pin = null;
this.merchant = null;
}
@JsonIgnore
public String getId() {
return id;
}
public String getEmail() {
return email;
}
private void setEmail(String email) {
this.email = email;
}
public String getName() {
return name;
}
private void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
@JsonIgnore
public String getReceiveAddress() {
return receiveAddress;
}
public String getReferrerId() {
return referrerId;
}
public String getTimeZone() {
return timeZone;
}
private void setTimeZone(String timeZone) {
this.timeZone = timeZone;
}
@JsonIgnore
public CoinbaseMoney getBalance() {
return balance;
}
public String getNativeCurrency() {
return nativeCurrency;
}
private void setNativeCurrency(String nativeCurrency) {
this.nativeCurrency = nativeCurrency;
}
@JsonIgnore
public CoinbaseBuySellLevel getBuyLevel() {
return buyLevel;
}
@JsonIgnore
public CoinbaseBuySellLevel getSellLevel() {
return sellLevel;
}
@JsonIgnore
public CoinbaseMoney getBuyLimit() {
return buyLimit;
}
@JsonIgnore
public CoinbaseMoney getSellLimit() {
return sellLimit;
}
public String getPin() {
return pin;
}
private void setPin(String pin) {
this.pin = pin;
}
@JsonIgnore
public CoinbaseMerchant getMerchant() {
return merchant;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
return "CoinbaseUserInfo [id="
+ id
+ ", email="
+ email
+ ", name="
+ name
+ ", password="
+ password
+ ", receiveAddress="
+ receiveAddress
+ ", referrerId="
+ referrerId
+ ", timeZone="
+ timeZone
+ ", balance="
+ balance
+ ", nativeCurrency="
+ nativeCurrency
+ ", buyLevel="
+ buyLevel
+ ", sellLevel="
+ sellLevel
+ ", buyLimit="
+ buyLimit
+ ", sellLimit="
+ sellLimit
+ ", pin="
+ pin
+ ", merchant="
+ merchant
+ "]";
| 1,378
| 201
| 1,579
|
<methods>public List<java.lang.String> getErrors() ,public boolean isSuccess() ,public java.lang.String toString() <variables>private final non-sealed List<java.lang.String> errors,private final non-sealed boolean success
|
knowm_XChange
|
XChange/xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/dto/marketdata/CoinbaseCurrency.java
|
CoinbaseCurrencyDeserializer
|
deserialize
|
class CoinbaseCurrencyDeserializer extends JsonDeserializer<CoinbaseCurrency> {
@Override
public CoinbaseCurrency deserialize(JsonParser jp, DeserializationContext ctxt)
throws IOException, JsonProcessingException {<FILL_FUNCTION_BODY>}
}
|
ObjectCodec oc = jp.getCodec();
JsonNode node = oc.readTree(jp);
if (node.isArray()) {
String name = node.path(0).asText();
String isoCode = node.path(1).asText();
return new CoinbaseCurrency(name, isoCode);
}
return null;
| 77
| 96
| 173
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/dto/merchant/CoinbaseSubscription.java
|
CoinbaseSubscriptionInfo
|
toString
|
class CoinbaseSubscriptionInfo {
private final String id;
private final Date createdAt;
private final CoinbaseRecurringPaymentStatus status;
private final String custom;
private final CoinbaseButton button;
private CoinbaseSubscriptionInfo(
@JsonProperty("id") final String id,
@JsonProperty("created_at") @JsonDeserialize(using = ISO8601DateDeserializer.class)
final Date createdAt,
@JsonProperty("status") final CoinbaseRecurringPaymentStatus status,
@JsonProperty("custom") final String custom,
@JsonProperty("button") final CoinbaseButtonInfo button) {
this.id = id;
this.createdAt = createdAt;
this.status = status;
this.custom = custom;
this.button = new CoinbaseButton(button);
}
public String getId() {
return id;
}
public Date getCreatedAt() {
return createdAt;
}
public CoinbaseRecurringPaymentStatus getStatus() {
return status;
}
public String getCustom() {
return custom;
}
public CoinbaseButton getButton() {
return button;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
return "CoinbaseSubscriptionInfo [id="
+ id
+ ", createdAt="
+ createdAt
+ ", status="
+ status
+ ", custom="
+ custom
+ ", button="
+ button
+ "]";
| 349
| 74
| 423
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/service/CoinbaseBaseService.java
|
CoinbaseBaseService
|
handleResponse
|
class CoinbaseBaseService extends BaseExchangeService implements BaseService {
protected final CoinbaseAuthenticated coinbase;
protected final ParamsDigest signatureCreator;
/**
* Constructor
*
* @param exchange
*/
protected CoinbaseBaseService(Exchange exchange) {
super(exchange);
coinbase =
ExchangeRestProxyBuilder.forInterface(
CoinbaseAuthenticated.class, exchange.getExchangeSpecification())
.build();
signatureCreator =
CoinbaseDigest.createInstance(exchange.getExchangeSpecification().getSecretKey());
}
/**
* Unauthenticated resource that returns currencies supported on Coinbase.
*
* @return A list of currency names and their corresponding ISO code.
* @throws IOException
*/
public List<CoinbaseCurrency> getCoinbaseCurrencies() throws IOException {
return coinbase.getCurrencies();
}
/**
* Unauthenticated resource that creates a user with an email and password.
*
* @param user New Coinbase User information.
* @return Information for the newly created user.
* @throws IOException
* @see <a
* href="https://coinbase.com/api/doc/1.0/users/create.html">coinbase.com/api/doc/1.0/users/create.html</a>
* @see {@link CoinbaseUser#createNewCoinbaseUser} and {@link
* CoinbaseUser#createCoinbaseNewUserWithReferrerId}
*/
public CoinbaseUser createCoinbaseUser(CoinbaseUser user) throws IOException {
final CoinbaseUser createdUser = coinbase.createUser(user);
return handleResponse(createdUser);
}
/**
* Unauthenticated resource that creates a user with an email and password.
*
* @param user New Coinbase User information.
* @param oAuthClientId Optional client id that corresponds to your OAuth2 application.
* @return Information for the newly created user, including information to perform future OAuth
* requests for the user.
* @throws IOException
* @see <a
* href="https://coinbase.com/api/doc/1.0/users/create.html">coinbase.com/api/doc/1.0/users/create.html</a>
* @see {@link CoinbaseUser#createNewCoinbaseUser} and {@link
* CoinbaseUser#createCoinbaseNewUserWithReferrerId}
*/
public CoinbaseUser createCoinbaseUser(CoinbaseUser user, final String oAuthClientId)
throws IOException {
final CoinbaseUser createdUser = coinbase.createUser(user.withoAuthClientId(oAuthClientId));
return handleResponse(createdUser);
}
/**
* Creates tokens redeemable for Bitcoin.
*
* @return The returned Bitcoin address can be used to send money to the token, and will be
* credited to the account of the token redeemer if money is sent both before or after
* redemption.
* @throws IOException
* @see <a
* href="https://coinbase.com/api/doc/1.0/tokens/create.html">coinbase.com/api/doc/1.0/tokens/create.html</a>
*/
public CoinbaseToken createCoinbaseToken() throws IOException {
final CoinbaseToken token = coinbase.createToken();
return handleResponse(token);
}
protected <R extends CoinbaseBaseResponse> R handleResponse(R response) {<FILL_FUNCTION_BODY>}
}
|
final List<String> errors = response.getErrors();
if (errors != null && !errors.isEmpty()) {
throw new ExchangeException(errors.toString());
}
return response;
| 947
| 53
| 1,000
|
<methods>public void verifyOrder(org.knowm.xchange.dto.trade.LimitOrder) ,public void verifyOrder(org.knowm.xchange.dto.trade.MarketOrder) <variables>protected final non-sealed org.knowm.xchange.Exchange exchange
|
knowm_XChange
|
XChange/xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/v2/CoinbaseV2Digest.java
|
CoinbaseV2Digest
|
digestParams
|
class CoinbaseV2Digest extends BaseParamsDigest {
private CoinbaseV2Digest(String secretKey) {
super(secretKey, HMAC_SHA_256);
}
public static CoinbaseV2Digest createInstance(String secretKey) {
return secretKey == null ? null : new CoinbaseV2Digest(secretKey);
}
@Override
public String digestParams(RestInvocation restInvocation) {<FILL_FUNCTION_BODY>}
}
|
final String pathWithQueryString =
restInvocation.getInvocationUrl().replace(restInvocation.getBaseUrl(), "");
final String timestamp =
restInvocation.getParamValue(HeaderParam.class, CB_ACCESS_TIMESTAMP).toString();
final String message = timestamp + restInvocation.getHttpMethod() + pathWithQueryString;
return DigestUtils.bytesToHex(getMac().doFinal(message.getBytes()));
| 131
| 114
| 245
|
<methods>public javax.crypto.Mac getMac() <variables>public static final java.lang.String HMAC_MD5,public static final java.lang.String HMAC_SHA_1,public static final java.lang.String HMAC_SHA_256,public static final java.lang.String HMAC_SHA_384,public static final java.lang.String HMAC_SHA_512,private final non-sealed javax.crypto.Mac mac
|
knowm_XChange
|
XChange/xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/v2/dto/CoinbaseAmount.java
|
CoinbaseAmount
|
equals
|
class CoinbaseAmount {
private final String currency;
private final BigDecimal amount;
private final String toString;
@JsonCreator
public CoinbaseAmount(
@JsonProperty("currency") String currency, @JsonProperty("amount") BigDecimal amount) {
Assert.notNull(currency, "Null currency");
Assert.notNull(amount, "Null amount");
this.currency = currency;
this.amount = amount;
toString = String.format("%.8f %s", amount, currency);
}
public String getCurrency() {
return currency;
}
public BigDecimal getAmount() {
return amount;
}
@Override
public int hashCode() {
return toString().hashCode();
}
@Override
public boolean equals(Object obj) {<FILL_FUNCTION_BODY>}
@Override
public String toString() {
return toString;
}
}
|
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
CoinbaseAmount other = (CoinbaseAmount) obj;
return amount.compareTo(other.amount) == 0 && currency.equals(other.currency);
| 248
| 81
| 329
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/v2/dto/account/CoinbaseWalletResponseData.java
|
CoinbaseWalletResponse
|
toString
|
class CoinbaseWalletResponse {
private final String id;
private final String status;
private final String transaction;
private final boolean committed;
private CoinbaseAmount amount;
private CoinbasePrice fee;
private CoinbasePrice total;
private CoinbasePrice subtotal;
@JsonCreator
CoinbaseWalletResponse(
@JsonProperty("id") String id,
@JsonProperty("status") String status,
@JsonProperty("transaction") String transaction,
@JsonProperty("commited") boolean committed) {
this.id = id;
this.status = status;
this.transaction = transaction;
this.committed = committed;
}
public String getId() {
return id;
}
public String getStatus() {
return status;
}
public String getTransaction() {
return transaction;
}
public boolean isCommitted() {
return committed;
}
public CoinbasePrice getFee() {
return fee;
}
void setFee(CoinbasePrice fee) {
this.fee = fee;
}
public CoinbaseAmount getAmount() {
return amount;
}
void setAmount(CoinbaseAmount amount) {
this.amount = amount;
}
public CoinbasePrice getTotal() {
return total;
}
void setTotal(CoinbasePrice total) {
this.total = total;
}
public CoinbasePrice getSubtotal() {
return subtotal;
}
void setSubtotal(CoinbasePrice subtotal) {
this.subtotal = subtotal;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
String curr = amount.getCurrency();
int scale = "EUR".equals(curr) || "USD".equals(curr) ? 2 : 8;
String astr = String.format("amount=%." + scale + "f %s", amount.getAmount(), curr);
String prices = "fee=" + fee + ",subtotal=" + subtotal + ",total=" + total;
return getClass().getSimpleName()
+ "[id="
+ id
+ ",status="
+ status
+ ",committed="
+ committed
+ ","
+ astr
+ ","
+ prices
+ "]";
| 458
| 172
| 630
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/v2/dto/account/transactions/CoinbaseTransactionV2.java
|
CoinbaseTransactionV2
|
toString
|
class CoinbaseTransactionV2 {
private final String id;
private final String idem;
private final String type;
private final String status;
private final CoinbaseAmount amount;
private final CoinbaseAmount nativeAmount;
private final String description;
private final String createdAt;
private final String updatedAt;
private final String resource;
private final String resourcePath;
private final boolean instantExchange;
private final CoinbaseTransactionV2Field buy;
private final CoinbaseTransactionV2Field sell;
private final CoinbaseTransactionV2Field trade;
private final CoinbaseTransactionV2FromField from;
private final CoinbaseTransactionV2ToField to;
private final CoinbaseTransactionV2NetworkField network;
private final CoinbaseTransactionV2Field application;
private final CoinbaseTransactionDetails details;
public CoinbaseTransactionV2(
@JsonProperty("id") String id,
@JsonProperty("idem") String idem,
@JsonProperty("type") String type,
@JsonProperty("status") String status,
@JsonProperty("amount") CoinbaseAmount amount,
@JsonProperty("native_amount") CoinbaseAmount nativeAmount,
@JsonProperty("description") String description,
@JsonProperty("created_at") String createdAt,
@JsonProperty("updated_at") String updatedAt,
@JsonProperty("resource") String resource,
@JsonProperty("resource_path") String resourcePath,
@JsonProperty("instant_exchange") boolean instantExchange,
@JsonProperty("buy") CoinbaseTransactionV2Field buy,
@JsonProperty("sell") CoinbaseTransactionV2Field sell,
@JsonProperty("trade") CoinbaseTransactionV2Field trade,
@JsonProperty("from") CoinbaseTransactionV2FromField from,
@JsonProperty("to") CoinbaseTransactionV2ToField to,
@JsonProperty("network") CoinbaseTransactionV2NetworkField network,
@JsonProperty("application") CoinbaseTransactionV2Field application,
@JsonProperty("details") CoinbaseTransactionDetails details) {
this.id = id;
this.idem = idem;
this.type = type;
this.status = status;
this.amount = amount;
this.nativeAmount = nativeAmount;
this.description = description;
this.createdAt = createdAt;
this.updatedAt = updatedAt;
this.resource = resource;
this.resourcePath = resourcePath;
this.instantExchange = instantExchange;
this.buy = buy;
this.sell = sell;
this.trade = trade;
this.from = from;
this.to = to;
this.network = network;
this.application = application;
this.details = details;
}
public ZonedDateTime getCreatedAt() {
return ZonedDateTime.parse(createdAt);
}
public ZonedDateTime getUpdatedAt() {
return ZonedDateTime.parse(updatedAt);
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
@Getter
public static class CoinbaseTransactionDetails {
private final String title;
private final String subtitle;
private final String paymentMethodName;
public CoinbaseTransactionDetails(
@JsonProperty("title") String title,
@JsonProperty("subtitle") String subtitle,
@JsonProperty("payment_method_name") String paymentMethodName) {
this.title = title;
this.subtitle = subtitle;
this.paymentMethodName = paymentMethodName;
}
@Override
public String toString() {
return "{"
+ "\"title\":"
+ '\"'
+ title
+ '\"'
+ ",\"subtitle\":"
+ '\"'
+ subtitle
+ '\"'
+ ",\"paymentMethodName\":"
+ '\"'
+ paymentMethodName
+ '\"'
+ "}";
}
}
}
|
return "{"
+ "\"id\":"
+ '\"'
+ id
+ '\"'
+ ",\"idem\":"
+ '\"'
+ idem
+ '\"'
+ ",\"type\":"
+ '\"'
+ type
+ '\"'
+ ",\"status\":"
+ '\"'
+ status
+ '\"'
+ ",\"amount\":"
+ '\"'
+ amount
+ '\"'
+ ",\"nativeAmount\":"
+ '\"'
+ nativeAmount
+ '\"'
+ ",\"description\":"
+ '\"'
+ description
+ '\"'
+ ",\"createdAt\":"
+ '\"'
+ createdAt
+ '\"'
+ ",\"updatedAt\":"
+ '\"'
+ updatedAt
+ '\"'
+ ",\"resource\":"
+ '\"'
+ resource
+ '\"'
+ ",\"resourcePath\":"
+ '\"'
+ resourcePath
+ '\"'
+ ",\"instantExchange\":"
+ '\"'
+ instantExchange
+ '\"'
+ ",\"buy\":"
+ buy
+ ",\"sell\":"
+ sell
+ ",\"trade\":"
+ trade
+ ",\"from\":"
+ from
+ ",\"to\":"
+ to
+ ",\"details\":"
+ details
+ ",\"network\":"
+ network
+ ",\"application\":"
+ application
+ '}';
| 1,022
| 435
| 1,457
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/v2/service/CoinbaseAccountServiceRaw.java
|
CoinbaseAccountServiceRaw
|
createCoinbaseAccount
|
class CoinbaseAccountServiceRaw extends CoinbaseBaseService {
public CoinbaseAccountServiceRaw(Exchange exchange) {
super(exchange);
}
public CoinbaseTransactionsResponse getTransactions(String accountId) throws IOException {
String apiKey = exchange.getExchangeSpecification().getApiKey();
BigDecimal timestamp = coinbase.getTime(Coinbase.CB_VERSION_VALUE).getData().getEpoch();
return coinbase.getTransactions(
Coinbase.CB_VERSION_VALUE, apiKey, signatureCreator2, timestamp, accountId);
}
public Map getDeposits(String accountId) throws IOException {
String apiKey = exchange.getExchangeSpecification().getApiKey();
BigDecimal timestamp = coinbase.getTime(Coinbase.CB_VERSION_VALUE).getData().getEpoch();
return coinbase.getDeposits(
Coinbase.CB_VERSION_VALUE, apiKey, signatureCreator2, timestamp, accountId);
}
public Map getWithdrawals(String accountId) throws IOException {
String apiKey = exchange.getExchangeSpecification().getApiKey();
BigDecimal timestamp = coinbase.getTime(Coinbase.CB_VERSION_VALUE).getData().getEpoch();
return coinbase.getWithdrawals(
Coinbase.CB_VERSION_VALUE, apiKey, signatureCreator2, timestamp, accountId);
}
/**
* Authenticated resource that shows the current user accounts.
*
* @see <a
* href="https://developers.coinbase.com/api/v2#list-accounts">developers.coinbase.com/api/v2#list-accounts</a>
*/
public List<CoinbaseAccount> getCoinbaseAccounts() throws IOException {
String apiKey = exchange.getExchangeSpecification().getApiKey();
List<CoinbaseAccount> returnList = new ArrayList<>();
List<CoinbaseAccount> tmpList = null;
String lastAccount = null;
do {
BigDecimal timestamp = coinbase.getTime(Coinbase.CB_VERSION_VALUE).getData().getEpoch();
tmpList =
coinbase
.getAccounts(
Coinbase.CB_VERSION_VALUE, apiKey, signatureCreator2, timestamp, 100, lastAccount)
.getData();
lastAccount = null;
if (tmpList != null && tmpList.size() > 0) {
returnList.addAll(tmpList);
lastAccount = tmpList.get(tmpList.size() - 1).getId();
}
} while (lastAccount != null && isValidUUID(lastAccount));
return returnList;
}
private boolean isValidUUID(String uuid) {
try {
UUID.fromString(uuid);
return true;
} catch (IllegalArgumentException exception) {
return false;
}
}
/**
* Authenticated resource that shows the current user account for the give currency.
*
* @see <a
* href="https://developers.coinbase.com/api/v2#show-an-account">developers.coinbase.com/api/v2#show-an-account</a>
*/
public CoinbaseAccount getCoinbaseAccount(Currency currency) throws IOException {
String apiKey = exchange.getExchangeSpecification().getApiKey();
BigDecimal timestamp = coinbase.getTime(Coinbase.CB_VERSION_VALUE).getData().getEpoch();
return coinbase
.getAccount(
Coinbase.CB_VERSION_VALUE,
apiKey,
signatureCreator2,
timestamp,
currency.getCurrencyCode())
.getData();
}
/**
* Authenticated resource that creates a new BTC account for the current user.
*
* @see <a
* href="https://developers.coinbase.com/api/v2#create-account">developers.coinbase.com/api/v2#create-account</a>
*/
public CoinbaseAccount createCoinbaseAccount(String name) throws IOException {<FILL_FUNCTION_BODY>}
/**
* Authenticated resource that shows the current user payment methods.
*
* @see <a
* href="https://developers.coinbase.com/api/v2#list-payment-methods">developers.coinbase.com/api/v2?shell#list-payment-methods</a>
*/
public List<CoinbasePaymentMethod> getCoinbasePaymentMethods() throws IOException {
String apiKey = exchange.getExchangeSpecification().getApiKey();
BigDecimal timestamp = coinbase.getTime(Coinbase.CB_VERSION_VALUE).getData().getEpoch();
return coinbase
.getPaymentMethods(Coinbase.CB_VERSION_VALUE, apiKey, signatureCreator2, timestamp)
.getData();
}
public static class CreateCoinbaseAccountPayload {
@JsonProperty String name;
CreateCoinbaseAccountPayload(String name) {
this.name = name;
}
}
}
|
CreateCoinbaseAccountPayload payload = new CreateCoinbaseAccountPayload(name);
String path = "/v2/accounts";
String apiKey = exchange.getExchangeSpecification().getApiKey();
BigDecimal timestamp = coinbase.getTime(Coinbase.CB_VERSION_VALUE).getData().getEpoch();
String body = new ObjectMapper().writeValueAsString(payload);
String signature = getSignature(timestamp, HttpMethod.POST, path, body);
showCurl(HttpMethod.POST, apiKey, timestamp, signature, path, body);
return coinbase
.createAccount(
MediaType.APPLICATION_JSON,
Coinbase.CB_VERSION_VALUE,
apiKey,
signature,
timestamp,
payload)
.getData();
| 1,329
| 203
| 1,532
|
<methods>public List<org.knowm.xchange.coinbase.v2.dto.marketdata.CoinbaseCurrencyData.CoinbaseCurrency> getCoinbaseCurrencies() throws java.io.IOException,public org.knowm.xchange.coinbase.v2.dto.marketdata.CoinbaseTimeData.CoinbaseTime getCoinbaseTime() throws java.io.IOException<variables>protected final non-sealed org.knowm.xchange.coinbase.v2.CoinbaseAuthenticated coinbase,protected final non-sealed org.knowm.xchange.coinbase.v2.CoinbaseV2Digest signatureCreator2
|
knowm_XChange
|
XChange/xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/v2/service/CoinbaseBaseService.java
|
CoinbaseBaseService
|
showCurl
|
class CoinbaseBaseService extends BaseExchangeService implements BaseService {
protected final CoinbaseAuthenticated coinbase;
protected final CoinbaseV2Digest signatureCreator2;
protected CoinbaseBaseService(Exchange exchange) {
super(exchange);
coinbase =
ExchangeRestProxyBuilder.forInterface(
CoinbaseAuthenticated.class, exchange.getExchangeSpecification())
.build();
signatureCreator2 =
CoinbaseV2Digest.createInstance(exchange.getExchangeSpecification().getSecretKey());
}
/**
* Unauthenticated resource that returns currencies supported on Coinbase.
*
* @return A list of currency names and their corresponding ISO code.
* @see <a
* href="https://developers.coinbase.com/api/v2#get-currencies">developers.coinbase.com/api/v2#get-currencies</a>
*/
public List<CoinbaseCurrency> getCoinbaseCurrencies() throws IOException {
return coinbase.getCurrencies(Coinbase.CB_VERSION_VALUE).getData();
}
/**
* Unauthenticated resource that tells you the server time.
*
* @return The current server time.
* @see <a
* href="https://developers.coinbase.com/api/v2#get-current-time">developers.coinbase.com/api/v2#get-current-time</a>
*/
public CoinbaseTime getCoinbaseTime() throws IOException {
return coinbase.getTime(Coinbase.CB_VERSION_VALUE).getData();
}
protected String getSignature(BigDecimal timestamp, HttpMethod method, String path, String body) {
String secretKey = exchange.getExchangeSpecification().getSecretKey();
String message = timestamp + method.toString() + path + (body != null ? body : "");
final Mac mac = CoinbaseDigest.createInstance(secretKey).getMac();
byte[] bytes = mac.doFinal(message.getBytes(StandardCharsets.UTF_8));
return DigestUtils.bytesToHex(bytes);
}
protected void showCurl(
HttpMethod method,
String apiKey,
BigDecimal timestamp,
String signature,
String path,
String json) {<FILL_FUNCTION_BODY>}
public enum HttpMethod {
GET,
POST
}
}
|
String headers =
String.format(
"-H 'CB-VERSION: 2017-11-26' -H 'CB-ACCESS-KEY: %s' -H 'CB-ACCESS-SIGN: %s' -H 'CB-ACCESS-TIMESTAMP: %s'",
apiKey, signature, timestamp);
if (method == HttpMethod.GET) {
Coinbase.LOG.debug(String.format("curl %s https://api.coinbase.com%s", headers, path));
} else if (method == HttpMethod.POST) {
String payload = "-d '" + json + "'";
Coinbase.LOG.debug(
String.format(
"curl -X %s -H 'Content-Type: %s' %s %s https://api.coinbase.com%s",
method, MediaType.APPLICATION_JSON, headers, payload, path));
}
| 637
| 229
| 866
|
<methods>public void verifyOrder(org.knowm.xchange.dto.trade.LimitOrder) ,public void verifyOrder(org.knowm.xchange.dto.trade.MarketOrder) <variables>protected final non-sealed org.knowm.xchange.Exchange exchange
|
knowm_XChange
|
XChange/xchange-coinbasepro/src/main/java/org/knowm/xchange/coinbasepro/dto/trade/CoinbaseProIdResponse.java
|
CoinbaseProIdResponse
|
toString
|
class CoinbaseProIdResponse {
private final String id;
public CoinbaseProIdResponse(@JsonProperty("id") String id) {
this.id = id;
}
public String getId() {
return id;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
StringBuilder builder = new StringBuilder();
builder.append("CoinbaseExIdResponse [id=");
builder.append(id);
builder.append("]");
return builder.toString();
| 91
| 52
| 143
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-coinbasepro/src/main/java/org/knowm/xchange/coinbasepro/service/CoinbaseProAccountServiceRaw.java
|
CoinbaseProAccountServiceRaw
|
requestNewReport
|
class CoinbaseProAccountServiceRaw extends CoinbaseProBaseService {
public CoinbaseProAccountServiceRaw(
CoinbaseProExchange exchange, ResilienceRegistries resilienceRegistries) {
super(exchange, resilienceRegistries);
}
public org.knowm.xchange.coinbasepro.dto.account.CoinbaseProAccount[] getCoinbaseProAccountInfo()
throws CoinbaseProException, IOException {
return decorateApiCall(
() ->
coinbasePro.getAccounts(
apiKey, digest, UnixTimestampFactory.INSTANCE.createValue(), passphrase))
.withRateLimiter(rateLimiter(PRIVATE_REST_ENDPOINT_RATE_LIMITER))
.call();
}
/** https://docs.pro.coinbase.com/#fees */
public CoinbaseProFee getCoinbaseProFees() throws CoinbaseProException, IOException {
return decorateApiCall(
() ->
coinbasePro.getFees(
apiKey, digest, UnixTimestampFactory.INSTANCE.createValue(), passphrase))
.withRateLimiter(rateLimiter(PRIVATE_REST_ENDPOINT_RATE_LIMITER))
.call();
}
public CoinbaseProSendMoneyResponse sendMoney(
String accountId, String to, BigDecimal amount, Currency currency)
throws CoinbaseProException, IOException {
return decorateApiCall(
() ->
coinbasePro.sendMoney(
new CoinbaseProSendMoneyRequest(to, amount, currency.getCurrencyCode()),
apiKey,
digest,
UnixTimestampFactory.INSTANCE.createValue(),
passphrase,
accountId))
.withRateLimiter(rateLimiter(PRIVATE_REST_ENDPOINT_RATE_LIMITER))
.call();
}
/** https://docs.pro.coinbase.com/#crypto */
public CoinbaseProWithdrawCryptoResponse withdrawCrypto(
String address,
BigDecimal amount,
Currency currency,
String destinationTag,
boolean noDestinationTag)
throws CoinbaseProException, IOException {
return decorateApiCall(
() ->
coinbasePro.withdrawCrypto(
apiKey,
digest,
UnixTimestampFactory.INSTANCE.createValue(),
passphrase,
new CoinbaseProWithdrawFundsRequest(
amount,
currency.getCurrencyCode(),
address,
destinationTag,
noDestinationTag)))
.withRateLimiter(rateLimiter(PRIVATE_REST_ENDPOINT_RATE_LIMITER))
.call();
}
/** https://docs.pro.coinbase.com/#get-an-account */
public List<Map<?, ?>> ledger(String accountId, String startingOrderId) throws IOException {
return decorateApiCall(
() ->
coinbasePro.ledger(
apiKey,
digest,
UnixTimestampFactory.INSTANCE.createValue(),
passphrase,
accountId,
startingOrderId))
.withRateLimiter(rateLimiter(PRIVATE_REST_ENDPOINT_RATE_LIMITER))
.call();
}
/** https://docs.pro.coinbase.com/#create-a-new-report */
public String requestNewReport(CoinbasePro.CoinbaseProReportRequest reportRequest)
throws IOException {<FILL_FUNCTION_BODY>}
/** https://docs.pro.coinbase.com/#get-report-status */
public Map<?, ?> report(String reportId) throws IOException {
return decorateApiCall(
() ->
coinbasePro.getReport(
apiKey,
digest,
UnixTimestampFactory.INSTANCE.createValue(),
passphrase,
reportId))
.withRateLimiter(rateLimiter(PRIVATE_REST_ENDPOINT_RATE_LIMITER))
.call();
}
/** https://docs.pro.coinbase.com/#get-current-exchange-limits */
public CoinbaseProTransfers transfers(String accountId, String profileId, int limit, String after)
throws IOException {
return decorateApiCall(
() ->
coinbasePro.transfers(
apiKey,
digest,
UnixTimestampFactory.INSTANCE.createValue(),
passphrase,
accountId,
profileId,
limit,
after))
.withRateLimiter(rateLimiter(PRIVATE_REST_ENDPOINT_RATE_LIMITER))
.call();
}
/** https://docs.pro.coinbase.com/#get-current-exchange-limits */
public CoinbaseProTransfers transfers(
String type, String profileId, String before, String after, int limit) throws IOException {
return decorateApiCall(
() ->
coinbasePro.transfers(
apiKey,
digest,
UnixTimestampFactory.INSTANCE.createValue(),
passphrase,
type,
profileId,
before,
after,
limit))
.withRateLimiter(rateLimiter(PRIVATE_REST_ENDPOINT_RATE_LIMITER))
.call();
}
/** https://docs.pro.coinbase.com/#coinbase-accounts */
public CoinbaseProAccount[] getCoinbaseAccounts() throws IOException {
return decorateApiCall(
() ->
coinbasePro.getCoinbaseProAccounts(
apiKey, digest, UnixTimestampFactory.INSTANCE.createValue(), passphrase))
.withRateLimiter(rateLimiter(PRIVATE_REST_ENDPOINT_RATE_LIMITER))
.call();
}
public CoinbaseProAccountAddress getCoinbaseAccountAddress(String accountId) throws IOException {
return decorateApiCall(
() ->
coinbasePro.getCoinbaseProAccountAddress(
apiKey,
digest,
UnixTimestampFactory.INSTANCE.createValue(),
passphrase,
accountId))
.withRateLimiter(rateLimiter(PRIVATE_REST_ENDPOINT_RATE_LIMITER))
.call();
}
public CoinbaseProWebsocketAuthData getWebsocketAuthData()
throws CoinbaseProException, IOException {
long timestamp = UnixTimestampFactory.INSTANCE.createValue();
WebhookAuthDataParamsDigestProxy digestProxy = new WebhookAuthDataParamsDigestProxy();
JsonNode json =
decorateApiCall(() -> coinbasePro.getVerifyId(apiKey, digestProxy, timestamp, passphrase))
.withRateLimiter(rateLimiter(PRIVATE_REST_ENDPOINT_RATE_LIMITER))
.call();
String userId = json.get("id").asText();
return new CoinbaseProWebsocketAuthData(
userId, apiKey, passphrase, digestProxy.getSignature(), timestamp);
}
private class WebhookAuthDataParamsDigestProxy implements ParamsDigest {
private String signature;
@Override
public String digestParams(RestInvocation restInvocation) {
signature = digest.digestParams(restInvocation);
return signature;
}
public String getSignature() {
return signature;
}
}
}
|
return decorateApiCall(
() ->
coinbasePro
.createReport(
apiKey,
digest,
UnixTimestampFactory.INSTANCE.createValue(),
passphrase,
reportRequest)
.get("id")
.toString())
.withRateLimiter(rateLimiter(PRIVATE_REST_ENDPOINT_RATE_LIMITER))
.call();
| 1,918
| 108
| 2,026
|
<methods><variables>protected final non-sealed java.lang.String apiKey,protected final non-sealed org.knowm.xchange.coinbasepro.CoinbasePro coinbasePro,protected final non-sealed ParamsDigest digest,protected final non-sealed java.lang.String passphrase
|
knowm_XChange
|
XChange/xchange-coinbasepro/src/main/java/org/knowm/xchange/coinbasepro/service/CoinbaseProMarketDataServiceRaw.java
|
CoinbaseProMarketDataServiceRaw
|
checkProductExists
|
class CoinbaseProMarketDataServiceRaw extends CoinbaseProBaseService {
public CoinbaseProMarketDataServiceRaw(
CoinbaseProExchange exchange, ResilienceRegistries resilienceRegistries) {
super(exchange, resilienceRegistries);
}
/** https://docs.pro.coinbase.com/#get-product-ticker */
public CoinbaseProProductTicker getCoinbaseProProductTicker(CurrencyPair currencyPair)
throws IOException {
if (!checkProductExists(currencyPair)) {
throw new InstrumentNotValidException("Pair does not exist on CoinbasePro");
}
try {
return decorateApiCall(
() ->
coinbasePro.getProductTicker(
currencyPair.base.getCurrencyCode(), currencyPair.counter.getCurrencyCode()))
.withRateLimiter(rateLimiter(PUBLIC_REST_ENDPOINT_RATE_LIMITER))
.call();
} catch (CoinbaseProException e) {
throw handleError(e);
}
}
/** https://docs.pro.coinbase.com/#get-24hr-stats */
public CoinbaseProProductStats getCoinbaseProProductStats(CurrencyPair currencyPair)
throws IOException {
if (!checkProductExists(currencyPair)) {
throw new InstrumentNotValidException("Pair does not exist on CoinbasePro");
}
try {
return decorateApiCall(
() ->
coinbasePro.getProductStats(
currencyPair.base.getCurrencyCode(), currencyPair.counter.getCurrencyCode()))
.withRateLimiter(rateLimiter(PUBLIC_REST_ENDPOINT_RATE_LIMITER))
.call();
} catch (CoinbaseProException e) {
throw handleError(e);
}
}
public Map<String, CoinbaseProStats> getCoinbaseProStats() throws IOException {
try {
return decorateApiCall(coinbasePro::getStats)
.withRateLimiter(rateLimiter(PUBLIC_REST_ENDPOINT_RATE_LIMITER))
.call();
} catch (CoinbaseProException e) {
throw handleError(e);
}
}
/** https://docs.pro.coinbase.com/#get-product-order-book */
public CoinbaseProProductBook getCoinbaseProProductOrderBook(CurrencyPair currencyPair, int level)
throws IOException {
try {
return decorateApiCall(
() ->
coinbasePro.getProductOrderBook(
currencyPair.base.getCurrencyCode(),
currencyPair.counter.getCurrencyCode(),
String.valueOf(level)))
.withRateLimiter(rateLimiter(PUBLIC_REST_ENDPOINT_RATE_LIMITER))
.call();
} catch (CoinbaseProException e) {
throw handleError(e);
}
}
/** https://docs.pro.coinbase.com/#get-trades */
public CoinbaseProTrade[] getCoinbaseProTrades(CurrencyPair currencyPair) throws IOException {
try {
return decorateApiCall(
() ->
coinbasePro.getTrades(
currencyPair.base.getCurrencyCode(), currencyPair.counter.getCurrencyCode()))
.withRateLimiter(rateLimiter(PUBLIC_REST_ENDPOINT_RATE_LIMITER))
.call();
} catch (CoinbaseProException e) {
throw handleError(e);
}
}
/** https://docs.pro.coinbase.com/#get-historic-rates */
public CoinbaseProCandle[] getCoinbaseProHistoricalCandles(
CurrencyPair currencyPair, String start, String end, String granularity) throws IOException {
try {
return decorateApiCall(
() ->
coinbasePro.getHistoricalCandles(
currencyPair.base.getCurrencyCode(),
currencyPair.counter.getCurrencyCode(),
start,
end,
granularity))
.withRateLimiter(rateLimiter(PUBLIC_REST_ENDPOINT_RATE_LIMITER))
.call();
} catch (CoinbaseProException e) {
throw handleError(e);
}
}
/** https://docs.pro.coinbase.com/#get-products */
public CoinbaseProProduct[] getCoinbaseProProducts() throws IOException {
try {
return decorateApiCall(coinbasePro::getProducts)
.withRateLimiter(rateLimiter(PUBLIC_REST_ENDPOINT_RATE_LIMITER))
.call();
} catch (CoinbaseProException e) {
throw handleError(e);
}
}
/** https://docs.pro.coinbase.com/#get-currencies */
public CoinbaseProCurrency[] getCoinbaseProCurrencies() throws IOException {
try {
return decorateApiCall(coinbasePro::getCurrencies)
.withRateLimiter(rateLimiter(PUBLIC_REST_ENDPOINT_RATE_LIMITER))
.call();
} catch (CoinbaseProException e) {
throw handleError(e);
}
}
/** https://docs.pro.coinbase.com/#get-trades */
public CoinbaseProTrades getCoinbaseProTradesExtended(
CurrencyPair currencyPair, Long after, Integer limit) throws IOException {
return decorateApiCall(
() ->
coinbasePro.getTradesPageable(
currencyPair.base.getCurrencyCode(),
currencyPair.counter.getCurrencyCode(),
after,
limit))
.withRateLimiter(rateLimiter(PUBLIC_REST_ENDPOINT_RATE_LIMITER))
.call();
}
public boolean checkProductExists(Instrument currencyPair) {<FILL_FUNCTION_BODY>}
}
|
for (Instrument cp : exchange.getExchangeInstruments()) {
if (cp.getBase().getCurrencyCode().equalsIgnoreCase(currencyPair.getBase().getCurrencyCode())
&& cp.getCounter()
.getCurrencyCode()
.equalsIgnoreCase(currencyPair.getCounter().getCurrencyCode())) {
return true;
}
}
return false;
| 1,564
| 102
| 1,666
|
<methods><variables>protected final non-sealed java.lang.String apiKey,protected final non-sealed org.knowm.xchange.coinbasepro.CoinbasePro coinbasePro,protected final non-sealed ParamsDigest digest,protected final non-sealed java.lang.String passphrase
|
knowm_XChange
|
XChange/xchange-coinbasepro/src/main/java/org/knowm/xchange/coinbasepro/service/CoinbaseProTradeService.java
|
CoinbaseProTradeService
|
getOpenOrders
|
class CoinbaseProTradeService extends CoinbaseProTradeServiceRaw implements TradeService {
public CoinbaseProTradeService(
CoinbaseProExchange exchange, ResilienceRegistries resilienceRegistries) {
super(exchange, resilienceRegistries);
}
@Override
public OpenOrders getOpenOrders() throws IOException {
return CoinbaseProAdapters.adaptOpenOrders(getCoinbaseProOpenOrders());
}
@Override
public OpenOrdersParams createOpenOrdersParams() {
return new DefaultOpenOrdersParamCurrencyPair();
}
@Override
public OpenOrders getOpenOrders(OpenOrdersParams params) throws IOException {<FILL_FUNCTION_BODY>}
@Override
public String placeMarketOrder(MarketOrder marketOrder) throws IOException {
return placeCoinbaseProOrder(CoinbaseProAdapters.adaptCoinbaseProPlaceMarketOrder(marketOrder))
.getId();
}
@Override
public String placeLimitOrder(LimitOrder limitOrder) throws IOException, FundsExceededException {
return placeCoinbaseProOrder(CoinbaseProAdapters.adaptCoinbaseProPlaceLimitOrder(limitOrder))
.getId();
}
@Override
public String placeStopOrder(StopOrder stopOrder) throws IOException, FundsExceededException {
return placeCoinbaseProOrder(CoinbaseProAdapters.adaptCoinbaseProStopOrder(stopOrder)).getId();
}
@Override
public boolean cancelOrder(String orderId) throws IOException {
return cancelCoinbaseProOrder(orderId);
}
@Override
public boolean cancelOrder(CancelOrderParams orderParams) throws IOException {
if (orderParams instanceof CancelOrderByIdParams) {
return cancelOrder(((CancelOrderByIdParams) orderParams).getOrderId());
} else {
return false;
}
}
@Override
public UserTrades getTradeHistory(TradeHistoryParams params) throws IOException {
return CoinbaseProAdapters.adaptTradeHistory(getCoinbaseProFills(params));
}
@Override
public TradeHistoryParams createTradeHistoryParams() {
return new CoinbaseProTradeHistoryParams();
}
@Override
public Collection<Order> getOrder(OrderQueryParams... orderQueryParams) throws IOException {
final String[] orderIds =
Arrays.stream(orderQueryParams).map(OrderQueryParams::getOrderId).toArray(String[]::new);
Collection<Order> orders = new ArrayList<>(orderIds.length);
for (String orderId : orderIds) {
orders.add(CoinbaseProAdapters.adaptOrder(super.getOrder(orderId)));
}
return orders;
}
}
|
if (params instanceof OpenOrdersParamCurrencyPair) {
OpenOrdersParamCurrencyPair pairParams = (OpenOrdersParamCurrencyPair) params;
String productId = CoinbaseProAdapters.adaptProductID(pairParams.getCurrencyPair());
return CoinbaseProAdapters.adaptOpenOrders(getCoinbaseProOpenOrders(productId));
}
return CoinbaseProAdapters.adaptOpenOrders(getCoinbaseProOpenOrders());
| 710
| 123
| 833
|
<methods>public void <init>(org.knowm.xchange.coinbasepro.CoinbaseProExchange, org.knowm.xchange.client.ResilienceRegistries) ,public boolean cancelCoinbaseProOrder(java.lang.String) throws java.io.IOException,public CoinbasePagedResponse<org.knowm.xchange.coinbasepro.dto.trade.CoinbaseProFill> getCoinbaseProFills(org.knowm.xchange.service.trade.params.TradeHistoryParams) throws java.io.IOException,public org.knowm.xchange.coinbasepro.dto.trade.CoinbaseProOrder[] getCoinbaseProOpenOrders() throws java.io.IOException,public org.knowm.xchange.coinbasepro.dto.trade.CoinbaseProOrder[] getCoinbaseProOpenOrders(java.lang.String) throws java.io.IOException,public org.knowm.xchange.coinbasepro.dto.trade.CoinbaseProOrder getOrder(java.lang.String) throws java.io.IOException,public CoinbasePagedResponse<org.knowm.xchange.coinbasepro.dto.trade.CoinbaseProOrder> getOrders(java.lang.String, java.lang.Integer, java.lang.String) throws java.io.IOException,public org.knowm.xchange.coinbasepro.dto.trade.CoinbaseProIdResponse placeCoinbaseProOrder(org.knowm.xchange.coinbasepro.dto.trade.CoinbaseProPlaceOrder) throws java.io.IOException<variables>
|
knowm_XChange
|
XChange/xchange-coincheck/src/main/java/org/knowm/xchange/coincheck/CoincheckUtil.java
|
CoincheckUtil
|
getArg
|
class CoincheckUtil {
public static <T> Optional<T> getArg(Object[] args, Class<T> desired) {<FILL_FUNCTION_BODY>}
}
|
if (args == null || args.length == 0) {
return Optional.empty();
}
return Stream.of(args)
.filter(a -> a != null)
.filter(a -> desired.isAssignableFrom(a.getClass()))
.map(a -> (T) a)
.findFirst();
| 47
| 90
| 137
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-coincheck/src/main/java/org/knowm/xchange/coincheck/dto/marketdata/CoincheckPair.java
|
CoincheckPair
|
stringToPair
|
class CoincheckPair {
CurrencyPair pair;
public String toString() {
return pairToString(this);
}
public static String pairToString(CoincheckPair pair) {
String base = pair.getPair().base.toString().toLowerCase(Locale.ROOT);
String counter = pair.getPair().counter.toString().toLowerCase(Locale.ROOT);
return base + '_' + counter;
}
public static CoincheckPair stringToPair(String str) {<FILL_FUNCTION_BODY>}
}
|
String sanitized = str.replace("_", "");
CurrencyPair pair = CurrencyPairDeserializer.getCurrencyPairFromString(sanitized);
return new CoincheckPair(pair);
| 145
| 56
| 201
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-coincheck/src/main/java/org/knowm/xchange/coincheck/service/CoincheckMarketDataServiceRaw.java
|
CoincheckMarketDataServiceRaw
|
getCoincheckTrades
|
class CoincheckMarketDataServiceRaw extends CoincheckBaseService {
private final Coincheck coincheck;
public CoincheckMarketDataServiceRaw(Exchange exchange) {
super(exchange);
coincheck =
ExchangeRestProxyBuilder.forInterface(Coincheck.class, exchange.getExchangeSpecification())
.build();
}
public CoincheckTicker getCoincheckTicker(CoincheckPair pair) throws IOException {
return coincheck.getTicker(pair);
}
public CoincheckOrderBook getCoincheckOrderBook(CoincheckPair pair) throws IOException {
return coincheck.getOrderBook(pair);
}
public CoincheckTradesContainer getCoincheckTrades(
CoincheckPair pair, CoincheckPagination pagination) throws IOException {<FILL_FUNCTION_BODY>}
}
|
if (pagination == null) {
pagination = CoincheckPagination.builder().build();
}
return coincheck.getTrades(
pair,
pagination.getLimit(),
pagination.getOrder(),
pagination.getStartingAfter(),
pagination.getEndingBefore());
| 239
| 84
| 323
|
<methods>public void <init>(org.knowm.xchange.Exchange) <variables>protected final Logger LOG
|
knowm_XChange
|
XChange/xchange-coindeal/src/main/java/org/knowm/xchange/coindeal/CoindealAdapters.java
|
CoindealAdapters
|
adaptToAccountInfo
|
class CoindealAdapters {
public static UserTrades adaptToUserTrades(List<CoindealTradeHistory> coindealTradeHistoryList)
throws InvalidFormatException {
List<UserTrade> userTrades = new ArrayList<>();
for (CoindealTradeHistory coindealTradeHistory : coindealTradeHistoryList) {
CurrencyPair currencyPair =
CurrencyPairDeserializer.getCurrencyPairFromString(coindealTradeHistory.getSymbol());
userTrades.add(
UserTrade.builder()
.type(
(coindealTradeHistory.getSide().equals("BUY"))
? Order.OrderType.BID
: Order.OrderType.ASK)
.originalAmount(coindealTradeHistory.getQuantity())
.currencyPair(currencyPair)
.price(coindealTradeHistory.getPrice())
.timestamp(DateUtils.fromRfc3339DateString(coindealTradeHistory.getTimestamp()))
.id(coindealTradeHistory.getId())
.orderId(coindealTradeHistory.getOrderId())
.feeAmount(coindealTradeHistory.getFee())
.feeCurrency(
(coindealTradeHistory.getSide().equals("BUY")
? currencyPair.base
: currencyPair.counter))
.build());
}
return new UserTrades(userTrades, Trades.TradeSortType.SortByTimestamp);
}
public static AccountInfo adaptToAccountInfo(List<CoindealBalance> coindealBalances) {<FILL_FUNCTION_BODY>}
public static OrderBook adaptOrderBook(
CoindealOrderBook coindealOrderBook, CurrencyPair currencyPair) {
List<LimitOrder> asks = new ArrayList<>();
coindealOrderBook
.getAsks()
.forEach(
coindealOrderBookEntry -> {
asks.add(
new LimitOrder(
Order.OrderType.ASK,
coindealOrderBookEntry.getAmount(),
currencyPair,
null,
null,
coindealOrderBookEntry.getPrice()));
});
List<LimitOrder> bids = new ArrayList<>();
coindealOrderBook
.getBids()
.forEach(
coindealOrderBookEntry -> {
bids.add(
new LimitOrder(
Order.OrderType.BID,
coindealOrderBookEntry.getAmount(),
currencyPair,
null,
null,
coindealOrderBookEntry.getPrice()));
});
return new OrderBook(null, asks, bids, true);
}
public static OpenOrders adaptToOpenOrders(List<CoindealOrder> coindealActiveOrders)
throws InvalidFormatException {
List<LimitOrder> limitOrders = new ArrayList<>();
for (CoindealOrder coindealOrder : coindealActiveOrders) {
limitOrders.add(
new LimitOrder.Builder(
adaptOrderType(coindealOrder.getSide()),
CurrencyPairDeserializer.getCurrencyPairFromString(coindealOrder.getSymbol()))
.limitPrice(coindealOrder.getPrice())
.originalAmount(coindealOrder.getQuantity())
.cumulativeAmount(coindealOrder.getCumQuantity())
.timestamp(DateUtils.fromISODateString(coindealOrder.getCreatedAt()))
.id(coindealOrder.getClientOrderId())
.build());
}
return new OpenOrders(limitOrders);
}
public static Order adaptOrder(CoindealOrder coindealOrder) throws InvalidFormatException {
return new LimitOrder.Builder(
adaptOrderType(coindealOrder.getSide()),
CurrencyPairDeserializer.getCurrencyPairFromString(coindealOrder.getSymbol()))
.limitPrice(coindealOrder.getPrice())
.originalAmount(coindealOrder.getQuantity())
.cumulativeAmount(coindealOrder.getCumQuantity())
.timestamp(DateUtils.fromISODateString(coindealOrder.getCreatedAt()))
.id(coindealOrder.getClientOrderId())
.build();
}
public static String adaptCurrencyPairToString(CurrencyPair currencyPair) {
if (currencyPair == null) {
return null;
} else {
return currencyPair.toString().replace("/", "").toUpperCase();
}
}
public static String adaptOrderType(Order.OrderType orderType) {
return orderType.equals(Order.OrderType.ASK) ? "sell" : "buy";
}
public static Order.OrderType adaptOrderType(String coindealOrderType) {
return coindealOrderType.equals("sell") ? Order.OrderType.ASK : Order.OrderType.BID;
}
}
|
List<Balance> balances = new ArrayList<>();
Currency currency = null;
for (CoindealBalance coindealBalance : coindealBalances) {
switch (coindealBalance.getCurrency()) {
case "Bitcoin":
currency = Currency.BTC;
break;
case "Ethereum":
currency = Currency.ETH;
break;
case "Bitcoin Cash ABC":
currency = Currency.BCH;
break;
case "Euro":
currency = Currency.EUR;
break;
case "Litecoin":
currency = Currency.LTC;
break;
case "US Dollar":
currency = Currency.USD;
break;
}
if (currency != null) {
balances.add(
new Balance(
currency,
coindealBalance.getAvailable().add(coindealBalance.getReserved()),
coindealBalance.getAvailable(),
coindealBalance.getReserved()));
}
currency = null;
}
return new AccountInfo(Wallet.Builder.from(balances).build());
| 1,297
| 307
| 1,604
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-coindeal/src/main/java/org/knowm/xchange/coindeal/CoindealExchange.java
|
CoindealExchange
|
getDefaultExchangeSpecification
|
class CoindealExchange extends BaseExchange implements Exchange {
@Override
protected void initServices() {
this.marketDataService = new CoindealMarketDataService(this);
this.accountService = new CoindealAccountService(this);
this.tradeService = new CoindealTradeService(this);
}
@Override
public ExchangeSpecification getDefaultExchangeSpecification() {<FILL_FUNCTION_BODY>}
@Override
public void remoteInit() throws IOException, ExchangeException {
super.remoteInit();
}
}
|
ExchangeSpecification exchangeSpecification = new ExchangeSpecification(this.getClass());
exchangeSpecification.setSslUri("https://apigateway.coindeal.com");
exchangeSpecification.setHost("www.coindeal.com");
exchangeSpecification.setPort(80);
exchangeSpecification.setExchangeName("Coindeal");
exchangeSpecification.setExchangeDescription("Coindeal is a exchange based in Malta.");
return exchangeSpecification;
| 148
| 122
| 270
|
<methods>public non-sealed void <init>() ,public void applySpecification(org.knowm.xchange.ExchangeSpecification) ,public org.knowm.xchange.service.account.AccountService getAccountService() ,public List<org.knowm.xchange.instrument.Instrument> getExchangeInstruments() ,public org.knowm.xchange.dto.meta.ExchangeMetaData getExchangeMetaData() ,public org.knowm.xchange.ExchangeSpecification getExchangeSpecification() ,public org.knowm.xchange.service.marketdata.MarketDataService getMarketDataService() ,public java.lang.String getMetaDataFileName(org.knowm.xchange.ExchangeSpecification) ,public SynchronizedValueFactory<java.lang.Long> getNonceFactory() ,public org.knowm.xchange.service.trade.TradeService getTradeService() ,public void remoteInit() throws java.io.IOException, org.knowm.xchange.exceptions.ExchangeException,public java.lang.String toString() <variables>protected org.knowm.xchange.service.account.AccountService accountService,protected org.knowm.xchange.dto.meta.ExchangeMetaData exchangeMetaData,protected org.knowm.xchange.ExchangeSpecification exchangeSpecification,protected final Logger logger,protected org.knowm.xchange.service.marketdata.MarketDataService marketDataService,private final SynchronizedValueFactory<java.lang.Long> nonceFactory,protected org.knowm.xchange.service.trade.TradeService tradeService
|
knowm_XChange
|
XChange/xchange-coindeal/src/main/java/org/knowm/xchange/coindeal/dto/account/CoindealBalance.java
|
CoindealBalance
|
toString
|
class CoindealBalance {
@JsonProperty("currency")
private final String currency;
@JsonProperty("available")
private final BigDecimal available;
@JsonProperty("reserved")
private final BigDecimal reserved;
public CoindealBalance(
@JsonProperty("currency") String currency,
@JsonProperty("available") BigDecimal available,
@JsonProperty("reserved") BigDecimal reserved) {
this.currency = currency;
this.available = available;
this.reserved = reserved;
}
public String getCurrency() {
return currency;
}
public BigDecimal getAvailable() {
return available;
}
public BigDecimal getReserved() {
return reserved;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
return "CoindealBalance{"
+ "currency='"
+ currency
+ '\''
+ ", available='"
+ available
+ '\''
+ ", reserved='"
+ reserved
+ '\''
+ '}';
| 224
| 68
| 292
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-coindeal/src/main/java/org/knowm/xchange/coindeal/dto/marketdata/CoindealOrderBook.java
|
CoindealOrderBook
|
toString
|
class CoindealOrderBook {
@JsonProperty("asks")
private final List<CoindealOrderBookEntry> asks;
@JsonProperty("bids")
private final List<CoindealOrderBookEntry> bids;
public CoindealOrderBook(
@JsonProperty("ask") List<CoindealOrderBookEntry> askList,
@JsonProperty("bid") List<CoindealOrderBookEntry> bidList) {
this.asks = askList;
this.bids = bidList;
}
public List<CoindealOrderBookEntry> getAsks() {
return asks;
}
public List<CoindealOrderBookEntry> getBids() {
return bids;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
return "CoindealOrderBook{" + "asks=" + asks + ", bids=" + bids + '}';
| 219
| 34
| 253
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-coindeal/src/main/java/org/knowm/xchange/coindeal/service/CoindealAccountServiceRaw.java
|
CoindealAccountServiceRaw
|
getCoindealBalances
|
class CoindealAccountServiceRaw extends CoindealBaseService {
public CoindealAccountServiceRaw(Exchange exchange) {
super(exchange);
}
public List<CoindealBalance> getCoindealBalances() throws IOException, CoindealException {<FILL_FUNCTION_BODY>}
}
|
try {
return coindeal.getBalances(basicAuthentication);
} catch (CoindealException e) {
throw CoindealErrorAdapter.adapt(e);
}
| 88
| 52
| 140
|
<methods>public void <init>(org.knowm.xchange.Exchange) <variables>protected ParamsDigest basicAuthentication,protected org.knowm.xchange.coindeal.CoindealAuthenticated coindeal
|
knowm_XChange
|
XChange/xchange-coindeal/src/main/java/org/knowm/xchange/coindeal/service/CoindealDigest.java
|
CoindealDigest
|
createInstance
|
class CoindealDigest implements ParamsDigest {
private final String secret;
private final String apiKey;
private CoindealDigest(String secret, String apiKey) {
this.secret = secret;
this.apiKey = apiKey;
}
public static CoindealDigest createInstance(String secret, String apiKey) {<FILL_FUNCTION_BODY>}
@Override
public String digestParams(RestInvocation restInvocation) {
return new BasicAuthCredentials(apiKey, secret).digestParams(restInvocation);
}
}
|
if (secret != null || apiKey != null) {
return new CoindealDigest(secret, apiKey);
} else return null;
| 151
| 42
| 193
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-coindeal/src/main/java/org/knowm/xchange/coindeal/service/CoindealMarketDataServiceRaw.java
|
CoindealMarketDataServiceRaw
|
getCoindealOrderbook
|
class CoindealMarketDataServiceRaw extends CoindealBaseService {
private final Coindeal coindeal;
public CoindealMarketDataServiceRaw(Exchange exchange) {
super(exchange);
this.coindeal =
ExchangeRestProxyBuilder.forInterface(Coindeal.class, exchange.getExchangeSpecification())
.build();
}
public CoindealOrderBook getCoindealOrderbook(CurrencyPair currencyPair) throws IOException {<FILL_FUNCTION_BODY>}
}
|
try {
return coindeal.getOrderBook(CoindealAdapters.adaptCurrencyPairToString(currencyPair));
} catch (CoindealException e) {
throw CoindealErrorAdapter.adapt(e);
}
| 142
| 66
| 208
|
<methods>public void <init>(org.knowm.xchange.Exchange) <variables>protected ParamsDigest basicAuthentication,protected org.knowm.xchange.coindeal.CoindealAuthenticated coindeal
|
knowm_XChange
|
XChange/xchange-coindeal/src/main/java/org/knowm/xchange/coindeal/service/CoindealTradeServiceRaw.java
|
CoindealTradeServiceRaw
|
getCoindealTradeHistory
|
class CoindealTradeServiceRaw extends CoindealBaseService {
public CoindealTradeServiceRaw(Exchange exchange) {
super(exchange);
}
public List<CoindealTradeHistory> getCoindealTradeHistory(
CurrencyPair currencyPair, Integer limit) throws IOException {<FILL_FUNCTION_BODY>}
public CoindealOrder placeOrder(LimitOrder limitOrder) throws IOException {
try {
return coindeal.placeOrder(
basicAuthentication,
CoindealAdapters.adaptCurrencyPairToString(limitOrder.getCurrencyPair()),
CoindealAdapters.adaptOrderType(limitOrder.getType()),
"limit",
"GTC",
limitOrder.getOriginalAmount().doubleValue(),
limitOrder.getLimitPrice().doubleValue());
} catch (CoindealException e) {
throw CoindealErrorAdapter.adapt(e);
}
}
public List<CoindealOrder> cancelCoindealOrders(CurrencyPair currencyPair) throws IOException {
try {
return coindeal.cancelOrders(
basicAuthentication, CoindealAdapters.adaptCurrencyPairToString(currencyPair));
} catch (CoindealException e) {
throw CoindealErrorAdapter.adapt(e);
}
}
public CoindealOrder cancelCoindealOrderById(String orderId) throws IOException {
try {
return coindeal.cancelOrderById(basicAuthentication, orderId);
} catch (CoindealException e) {
throw CoindealErrorAdapter.adapt(e);
}
}
public List<CoindealOrder> getCoindealActiveOrders(CurrencyPair currencyPair) throws IOException {
try {
return coindeal.getActiveOrders(
basicAuthentication, CoindealAdapters.adaptCurrencyPairToString(currencyPair));
} catch (CoindealException e) {
throw CoindealErrorAdapter.adapt(e);
}
}
public CoindealOrder getCoindealOrderById(String orderId) throws IOException {
try {
return coindeal.getOrderById(basicAuthentication, orderId);
} catch (CoindealException e) {
throw CoindealErrorAdapter.adapt(e);
}
}
}
|
try {
return coindeal.getTradeHistory(
basicAuthentication, CoindealAdapters.adaptCurrencyPairToString(currencyPair), limit);
} catch (CoindealException e) {
throw CoindealErrorAdapter.adapt(e);
}
| 609
| 74
| 683
|
<methods>public void <init>(org.knowm.xchange.Exchange) <variables>protected ParamsDigest basicAuthentication,protected org.knowm.xchange.coindeal.CoindealAuthenticated coindeal
|
knowm_XChange
|
XChange/xchange-coindirect/src/main/java/org/knowm/xchange/coindirect/CoindirectAdapters.java
|
CoindirectAdapters
|
adaptOrderStatus
|
class CoindirectAdapters {
public static String toSymbol(CurrencyPair pair) {
return pair.base.getCurrencyCode() + "-" + pair.counter.getCurrencyCode();
}
public static CurrencyPair toCurrencyPair(String symbol) {
int token = symbol.indexOf('-');
String left = symbol.substring(0, token);
String right = symbol.substring(token + 1);
return new CurrencyPair(left, right);
}
public static Currency toCurrency(String code) {
return Currency.getInstance(code);
}
public static Order.OrderType convert(CoindirectOrder.Side side) {
switch (side) {
case BUY:
return Order.OrderType.BID;
case SELL:
return Order.OrderType.ASK;
default:
throw new RuntimeException("Not supported order side: " + side);
}
}
public static CoindirectOrder.Side convert(Order.OrderType type) {
switch (type) {
case BID:
return CoindirectOrder.Side.BUY;
case ASK:
return CoindirectOrder.Side.SELL;
default:
throw new RuntimeException("Not supported order side: " + type);
}
}
public static Order.OrderStatus adaptOrderStatus(CoindirectOrder.Status orderStatus) {<FILL_FUNCTION_BODY>}
public static OrderBook adaptOrderBook(
CurrencyPair currencyPair, CoindirectOrderbook coindirectOrderbook) {
List<LimitOrder> bids =
coindirectOrderbook.bids.stream()
.map(
e -> new LimitOrder(Order.OrderType.BID, e.size, currencyPair, null, null, e.price))
.collect(Collectors.toList());
List<LimitOrder> asks =
coindirectOrderbook.asks.stream()
.map(
e -> new LimitOrder(Order.OrderType.ASK, e.size, currencyPair, null, null, e.price))
.collect(Collectors.toList());
return new OrderBook(null, asks, bids);
}
public static Order adaptOrder(CoindirectOrder order) {
Order.OrderType type = convert(order.side);
CurrencyPair currencyPair = toCurrencyPair(order.symbol);
Order.OrderStatus orderStatus = adaptOrderStatus(order.status);
final BigDecimal averagePrice;
if (order.executedAmount.signum() == 0) {
averagePrice = BigDecimal.ZERO;
} else {
averagePrice = order.executedPrice;
}
Order result = null;
if (order.type.equals(CoindirectOrder.Type.MARKET)) {
result =
new MarketOrder(
type,
order.amount,
currencyPair,
order.uuid,
order.dateCreated,
averagePrice,
order.executedAmount,
order.executedFees,
orderStatus);
} else if (order.type.equals(CoindirectOrder.Type.LIMIT)) {
result =
new LimitOrder(
type,
order.amount,
currencyPair,
order.uuid,
order.dateCreated,
order.price,
averagePrice,
order.executedAmount,
order.executedFees,
orderStatus);
}
return result;
}
}
|
switch (orderStatus) {
case PLACED:
case SUBMITTED:
return Order.OrderStatus.NEW;
case COMPLETED:
return Order.OrderStatus.FILLED;
case PARTIAL_CANCEL:
case CANCELLED:
return Order.OrderStatus.CANCELED;
case PENDING_CANCEL:
return Order.OrderStatus.PENDING_CANCEL;
case PARTIAL:
return Order.OrderStatus.PARTIALLY_FILLED;
case ERROR:
return Order.OrderStatus.REJECTED;
default:
return Order.OrderStatus.UNKNOWN;
}
| 879
| 175
| 1,054
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-coindirect/src/main/java/org/knowm/xchange/coindirect/CoindirectExchange.java
|
CoindirectExchange
|
remoteInit
|
class CoindirectExchange extends BaseExchange {
@Override
protected void initServices() {
this.marketDataService = new CoindirectMarketDataService(this);
this.accountService = new CoindirectAccountService(this);
this.tradeService = new CoindirectTradeService(this);
}
@Override
public ExchangeSpecification getDefaultExchangeSpecification() {
ExchangeSpecification spec = new ExchangeSpecification(this.getClass());
spec.setSslUri("https://api.coindirect.com");
spec.setHost("www.coindirect.com");
spec.setPort(80);
spec.setExchangeName("Coindirect");
spec.setExchangeDescription("Coindirect Exchange.");
AuthUtils.setApiAndSecretKey(spec, "coindirect");
return spec;
}
@Override
public void remoteInit() {<FILL_FUNCTION_BODY>}
}
|
Map<Instrument, InstrumentMetaData> currencyPairs = exchangeMetaData.getInstruments();
CoindirectMarketDataService coindirectMarketDataService =
(CoindirectMarketDataService) marketDataService;
try {
List<CoindirectMarket> coindirectMarketList =
coindirectMarketDataService.getCoindirectMarkets(1000);
for (CoindirectMarket market : coindirectMarketList) {
CurrencyPair currencyPair = CoindirectAdapters.toCurrencyPair(market.symbol);
InstrumentMetaData staticMeta = currencyPairs.get(currencyPair);
currencyPairs.put(
currencyPair,
new InstrumentMetaData.Builder()
.tradingFee(staticMeta.getTradingFee())
.minimumAmount(market.minimumQuantity)
.maximumAmount(market.maximumQuantity)
.priceScale(staticMeta.getPriceScale())
.feeTiers(staticMeta.getFeeTiers())
.build());
}
} catch (IOException exception) {
}
| 241
| 285
| 526
|
<methods>public non-sealed void <init>() ,public void applySpecification(org.knowm.xchange.ExchangeSpecification) ,public org.knowm.xchange.service.account.AccountService getAccountService() ,public List<org.knowm.xchange.instrument.Instrument> getExchangeInstruments() ,public org.knowm.xchange.dto.meta.ExchangeMetaData getExchangeMetaData() ,public org.knowm.xchange.ExchangeSpecification getExchangeSpecification() ,public org.knowm.xchange.service.marketdata.MarketDataService getMarketDataService() ,public java.lang.String getMetaDataFileName(org.knowm.xchange.ExchangeSpecification) ,public SynchronizedValueFactory<java.lang.Long> getNonceFactory() ,public org.knowm.xchange.service.trade.TradeService getTradeService() ,public void remoteInit() throws java.io.IOException, org.knowm.xchange.exceptions.ExchangeException,public java.lang.String toString() <variables>protected org.knowm.xchange.service.account.AccountService accountService,protected org.knowm.xchange.dto.meta.ExchangeMetaData exchangeMetaData,protected org.knowm.xchange.ExchangeSpecification exchangeSpecification,protected final Logger logger,protected org.knowm.xchange.service.marketdata.MarketDataService marketDataService,private final SynchronizedValueFactory<java.lang.Long> nonceFactory,protected org.knowm.xchange.service.trade.TradeService tradeService
|
knowm_XChange
|
XChange/xchange-coindirect/src/main/java/org/knowm/xchange/coindirect/dto/account/CoindirectWallet.java
|
CoindirectWallet
|
toString
|
class CoindirectWallet {
public final long id;
public final String description;
public final CoindirectCurrency currency;
public final boolean supportsWithdrawals;
public final boolean supportsDeposits;
public final String address;
public final String lookup;
public final BigDecimal balance;
public CoindirectWallet(
@JsonProperty("id") long id,
@JsonProperty("description") String description,
@JsonProperty("currency") CoindirectCurrency currency,
@JsonProperty("supportsWithdrawals") boolean supportsWithdrawals,
@JsonProperty("supportsDeposits") boolean supportsDeposits,
@JsonProperty("address") String address,
@JsonProperty("lookup") String lookup,
@JsonProperty("balance") BigDecimal balance) {
this.id = id;
this.description = description;
this.currency = currency;
this.supportsWithdrawals = supportsWithdrawals;
this.supportsDeposits = supportsDeposits;
this.address = address;
this.lookup = lookup;
this.balance = balance;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
return "CoindirectWallet{"
+ "id="
+ id
+ ", description='"
+ description
+ '\''
+ ", currency="
+ currency
+ ", supportsWithdrawals="
+ supportsWithdrawals
+ ", supportsDeposits="
+ supportsDeposits
+ ", address='"
+ address
+ '\''
+ ", lookup='"
+ lookup
+ '\''
+ ", balance="
+ balance
+ '}';
| 303
| 133
| 436
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-coindirect/src/main/java/org/knowm/xchange/coindirect/dto/errors/CoindirectError.java
|
CoindirectError
|
toString
|
class CoindirectError {
public final String parameter;
public final String message;
public final String code;
public CoindirectError(String parameter, String message, String code) {
this.parameter = parameter;
this.message = message;
this.code = code;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
return "CoindirectError{"
+ "parameter='"
+ parameter
+ '\''
+ ", message='"
+ message
+ '\''
+ ", code='"
+ code
+ '\''
+ '}';
| 101
| 66
| 167
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-coindirect/src/main/java/org/knowm/xchange/coindirect/dto/marketdata/CoindirectMarket.java
|
CoindirectMarket
|
toString
|
class CoindirectMarket {
public final long id;
public final BigDecimal maximumPrice;
public final BigDecimal minimumPrice;
public final BigDecimal maximumQuantity;
public final BigDecimal minimumQuantity;
public final String status;
public final BigDecimal stepSize;
public final BigDecimal tickSize;
public final String symbol;
public final CoindirectMarketSummary summary;
public CoindirectMarket(
@JsonProperty("id") long id,
@JsonProperty("maximumPrice") BigDecimal maximumPrice,
@JsonProperty("minimumPrice") BigDecimal minimumPrice,
@JsonProperty("maximumQuantity") BigDecimal maximumQuantity,
@JsonProperty("minimumQuantity") BigDecimal minimumQuantity,
@JsonProperty("status") String status,
@JsonProperty("stepSize") BigDecimal stepSize,
@JsonProperty("tickSize") BigDecimal tickSize,
@JsonProperty("symbol") String symbol,
@JsonProperty("summary") CoindirectMarketSummary summary) {
this.id = id;
this.maximumPrice = maximumPrice;
this.minimumPrice = minimumPrice;
this.maximumQuantity = maximumQuantity;
this.minimumQuantity = minimumQuantity;
this.status = status;
this.stepSize = stepSize;
this.tickSize = tickSize;
this.symbol = symbol;
this.summary = summary;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
return "CoindirectMarket{"
+ "id="
+ id
+ ", maximumPrice="
+ maximumPrice
+ ", minimumPrice="
+ minimumPrice
+ ", maximumQuantity="
+ maximumQuantity
+ ", minimumQuantity="
+ minimumQuantity
+ ", status='"
+ status
+ '\''
+ ", stepSize="
+ stepSize
+ ", tickSize="
+ tickSize
+ ", symbol='"
+ symbol
+ '\''
+ ", summary="
+ summary
+ '}';
| 389
| 155
| 544
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-coindirect/src/main/java/org/knowm/xchange/coindirect/dto/marketdata/CoindirectMarketSummary.java
|
CoindirectMarketSummary
|
toString
|
class CoindirectMarketSummary {
public final BigDecimal change24h;
public final long id;
public final BigDecimal lastPrice;
public final BigDecimal volume24h;
public CoindirectMarketSummary(
@JsonProperty("change24h") BigDecimal change24h,
@JsonProperty("id") long id,
@JsonProperty("lastPrice") BigDecimal lastPrice,
@JsonProperty("volume24h") BigDecimal volume24h) {
this.change24h = change24h;
this.id = id;
this.lastPrice = lastPrice;
this.volume24h = volume24h;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
return "CoindirectMarketSummary{"
+ "change24h="
+ change24h
+ ", id="
+ id
+ ", lastPrice="
+ lastPrice
+ ", volume24h="
+ volume24h
+ '}';
| 202
| 78
| 280
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-coindirect/src/main/java/org/knowm/xchange/coindirect/dto/marketdata/CoindirectOrderbook.java
|
CoindirectOrderbook
|
toString
|
class CoindirectOrderbook {
public final long sequence;
public final List<CoindirectPriceLevel> bids;
public final List<CoindirectPriceLevel> asks;
public CoindirectOrderbook(
@JsonProperty("sequence") long sequence,
@JsonProperty("bids") List<CoindirectPriceLevel> bids,
@JsonProperty("asks") List<CoindirectPriceLevel> asks) {
this.sequence = sequence;
this.bids = bids;
this.asks = asks;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
return "CoindirectOrderbook{"
+ "sequence="
+ sequence
+ ", bids="
+ bids
+ ", asks="
+ asks
+ '}';
| 160
| 54
| 214
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-coindirect/src/main/java/org/knowm/xchange/coindirect/dto/marketdata/CoindirectTicker.java
|
CoindirectTicker
|
toString
|
class CoindirectTicker {
public final List<CoindirectTickerData> data;
public final CoindirectTickerMetadata metaData;
public CoindirectTicker(
@JsonProperty("data") List<CoindirectTickerData> data,
@JsonProperty("metaData") CoindirectTickerMetadata metaData) {
this.data = data;
this.metaData = metaData;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
return "CoindirectTicker{" + "data=" + data + ", metaData=" + metaData + '}';
| 132
| 33
| 165
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-coindirect/src/main/java/org/knowm/xchange/coindirect/dto/marketdata/CoindirectTickerData.java
|
CoindirectTickerData
|
toString
|
class CoindirectTickerData {
public final long time;
public final BigDecimal open;
public final BigDecimal high;
public final BigDecimal low;
public final BigDecimal close;
public final BigDecimal volume;
public CoindirectTickerData(
@JsonProperty("time") long time,
@JsonProperty("open") BigDecimal open,
@JsonProperty("high") BigDecimal high,
@JsonProperty("low") BigDecimal low,
@JsonProperty("close") BigDecimal close,
@JsonProperty("volume") BigDecimal volume) {
this.time = time;
this.open = open;
this.high = high;
this.low = low;
this.close = close;
this.volume = volume;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
return "CoindirectTickerData{"
+ "time="
+ time
+ ", open="
+ open
+ ", high="
+ high
+ ", low="
+ low
+ ", close="
+ close
+ ", volume="
+ volume
+ '}';
| 227
| 86
| 313
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-coindirect/src/main/java/org/knowm/xchange/coindirect/dto/marketdata/CoindirectTrade.java
|
CoindirectTrade
|
toString
|
class CoindirectTrade {
public final long time;
public final BigDecimal price;
public final BigDecimal volume;
public CoindirectTrade(
@JsonProperty("time") long time,
@JsonProperty("price") BigDecimal price,
@JsonProperty("volume") BigDecimal volume) {
this.time = time;
this.price = price;
this.volume = volume;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
return "CoindirectTrade{" + "time=" + time + ", price=" + price + ", volume=" + volume + '}';
| 135
| 38
| 173
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-coindirect/src/main/java/org/knowm/xchange/coindirect/dto/marketdata/CoindirectTradesMetadata.java
|
CoindirectTradesMetadata
|
toString
|
class CoindirectTradesMetadata {
public final String market;
public final String history;
public final long limit;
public CoindirectTradesMetadata(
@JsonProperty("market") String market,
@JsonProperty("history") String history,
@JsonProperty("limit") long limit) {
this.market = market;
this.history = history;
this.limit = limit;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
return "CoindirectTradesMetadata{"
+ "market='"
+ market
+ '\''
+ ", history='"
+ history
+ '\''
+ ", limit="
+ limit
+ '}';
| 129
| 63
| 192
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-coindirect/src/main/java/org/knowm/xchange/coindirect/service/CoindirectHawkDigest.java
|
CoindirectHawkDigest
|
digestParams
|
class CoindirectHawkDigest extends BaseParamsDigest {
private String apiKey;
private String apiSecret;
private CoindirectHawkDigest(String apiKey, String secretKeyBase64) {
super(secretKeyBase64, HMAC_SHA_256);
this.apiKey = apiKey;
this.apiSecret = secretKeyBase64;
}
public static CoindirectHawkDigest createInstance(String apiKey, String secretKey) {
return secretKey == null || apiKey == null ? null : new CoindirectHawkDigest(apiKey, secretKey);
}
@Override
public String digestParams(RestInvocation restInvocation) {<FILL_FUNCTION_BODY>}
private String generateHash(String key, String data) {
Mac sha256_HMAC = null;
String result = null;
try {
byte[] byteKey = key.getBytes("UTF-8");
final String HMAC_SHA256 = "HmacSHA256";
sha256_HMAC = Mac.getInstance(HMAC_SHA256);
SecretKeySpec keySpec = new SecretKeySpec(byteKey, HMAC_SHA256);
sha256_HMAC.init(keySpec);
byte[] mac_data = sha256_HMAC.doFinal(data.getBytes());
return Base64.getEncoder().encodeToString(mac_data);
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvalidKeyException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
}
return "";
}
}
|
long timestamp = Math.round(System.currentTimeMillis() / 1000);
try {
URL url = new URL(restInvocation.getInvocationUrl());
String nonce = UUID.randomUUID().toString().substring(0, 8);
String method = restInvocation.getHttpMethod().toUpperCase();
String path = url.getPath();
String query = url.getQuery();
String host = url.getHost();
int port = url.getPort();
if (port == -1) {
port = url.getDefaultPort();
}
StringBuilder hawkHeader = new StringBuilder();
hawkHeader.append("hawk.1.header\n");
hawkHeader.append(timestamp);
hawkHeader.append("\n");
hawkHeader.append(nonce);
hawkHeader.append("\n");
hawkHeader.append(method);
hawkHeader.append("\n");
hawkHeader.append(path);
if (query != null) {
hawkHeader.append("?");
hawkHeader.append(query);
}
hawkHeader.append("\n");
hawkHeader.append(host);
hawkHeader.append("\n");
hawkHeader.append(port);
hawkHeader.append("\n");
// body
hawkHeader.append("\n");
// app data
hawkHeader.append("\n");
String mac = generateHash(apiSecret, hawkHeader.toString());
String authorization =
"Hawk id=\""
+ apiKey
+ "\", ts=\""
+ timestamp
+ "\", nonce=\""
+ nonce
+ "\", mac=\""
+ mac
+ "\"";
return authorization;
} catch (MalformedURLException ignored) {
}
return null;
| 476
| 498
| 974
|
<methods>public javax.crypto.Mac getMac() <variables>public static final java.lang.String HMAC_MD5,public static final java.lang.String HMAC_SHA_1,public static final java.lang.String HMAC_SHA_256,public static final java.lang.String HMAC_SHA_384,public static final java.lang.String HMAC_SHA_512,private final non-sealed javax.crypto.Mac mac
|
knowm_XChange
|
XChange/xchange-coindirect/src/main/java/org/knowm/xchange/coindirect/service/CoindirectMarketDataService.java
|
CoindirectMarketDataService
|
getTicker
|
class CoindirectMarketDataService extends CoindirectMarketDataServiceRaw
implements MarketDataService {
/**
* Constructor
*
* @param exchange
*/
public CoindirectMarketDataService(Exchange exchange) {
super(exchange);
}
@Override
public OrderBook getOrderBook(CurrencyPair currencyPair, Object... args) throws IOException {
CoindirectOrderbook coindirectOrderbook = getCoindirectOrderbook(currencyPair);
return CoindirectAdapters.adaptOrderBook(currencyPair, coindirectOrderbook);
}
@Override
public Trades getTrades(CurrencyPair pair, Object... args) throws IOException {
String history = "1h";
try {
if (args[0] != null) history = args[0].toString();
} catch (Throwable ignored) {
}
CoindirectTrades coindirectTrades = getCoindirectTrades(pair, history);
List<Trade> trades;
if (coindirectTrades.data == null) {
trades = new ArrayList<>();
} else {
trades =
coindirectTrades.data.stream()
.map(
at ->
new Trade.Builder()
.type(Order.OrderType.BID)
.originalAmount(at.volume)
.currencyPair(pair)
.price(at.price)
.timestamp(new Date(at.time))
.id(Long.toString(at.time))
.build())
.collect(Collectors.toList());
}
return new Trades(trades, Trades.TradeSortType.SortByTimestamp);
}
@Override
public Ticker getTicker(CurrencyPair currencyPair, Object... args) throws IOException {<FILL_FUNCTION_BODY>}
@Override
public List<Ticker> getTickers(Params params) throws IOException {
List<CoindirectMarket> coindirectMarkets = getCoindirectMarkets(1000); /* default max */
List<Ticker> tickerList = new ArrayList<>();
for (int i = 0; i < coindirectMarkets.size(); i++) {
tickerList.add(getTicker(CoindirectAdapters.toCurrencyPair(coindirectMarkets.get(i).symbol)));
}
return tickerList;
}
}
|
String history = "24h";
String grouping = "d";
try {
if (args[0] != null) history = args[0].toString();
} catch (Throwable ignored) {
}
try {
if (args[1] != null) grouping = args[1].toString();
} catch (Throwable ignored) {
}
CoindirectTicker coindirectTicker = getCoindirectTicker(currencyPair, history, grouping);
if (coindirectTicker.data.size() > 0) {
CoindirectTickerData coindirectTickerData = coindirectTicker.data.get(0);
return new Ticker.Builder()
.currencyPair(currencyPair)
.open(coindirectTickerData.open)
.last(coindirectTickerData.close)
.high(coindirectTickerData.high)
.low(coindirectTickerData.low)
.volume(coindirectTickerData.volume)
.build();
}
return new Ticker.Builder().currencyPair(currencyPair).build();
| 613
| 288
| 901
|
<methods>public void <init>(org.knowm.xchange.Exchange) ,public List<org.knowm.xchange.coindirect.dto.marketdata.CoindirectMarket> getCoindirectMarkets(long) throws java.io.IOException,public org.knowm.xchange.coindirect.dto.marketdata.CoindirectOrderbook getCoindirectOrderbook(org.knowm.xchange.currency.CurrencyPair) throws java.io.IOException,public org.knowm.xchange.coindirect.dto.marketdata.CoindirectTicker getCoindirectTicker(org.knowm.xchange.currency.CurrencyPair, java.lang.String, java.lang.String) throws java.io.IOException,public org.knowm.xchange.coindirect.dto.marketdata.CoindirectTrades getCoindirectTrades(org.knowm.xchange.currency.CurrencyPair, java.lang.String) throws java.io.IOException<variables>
|
knowm_XChange
|
XChange/xchange-coinegg/src/main/java/org/knowm/xchange/coinegg/service/CoinEggTradeService.java
|
CoinEggTradeService
|
placeLimitOrder
|
class CoinEggTradeService extends CoinEggTradeServiceRaw implements TradeService {
public CoinEggTradeService(Exchange exchange) {
super(exchange);
}
@Override
public String placeLimitOrder(LimitOrder limitOrder) throws IOException {<FILL_FUNCTION_BODY>}
@Override
public boolean cancelOrder(CancelOrderParams orderParams) throws IOException {
if ((orderParams instanceof CancelOrderByIdParams)
&& (orderParams instanceof CancelOrderByCurrencyPair)) {
String id = ((CancelOrderByIdParams) orderParams).getOrderId();
String coin =
((CancelOrderByCurrencyPair) orderParams)
.getCurrencyPair()
.base
.getCurrencyCode()
.toLowerCase();
return CoinEggAdapters.adaptTradeCancel(getCoinEggTradeCancel(id, coin));
}
throw new ExchangeException("Incorrect CancelOrderParams!");
}
@Override
public TradeHistoryParams createTradeHistoryParams() {
return new TradeHistoryParamsAll();
}
@Override
public UserTrades getTradeHistory(TradeHistoryParams params)
throws IOException, ExchangeException {
if ((params instanceof TradeHistoryParamCurrency)
&& (params instanceof TradeHistoryParamTransactionId)) {
String tradeID = ((TradeHistoryParamTransactionId) params).getTransactionId();
String coin =
((TradeHistoryParamCurrency) params).getCurrency().getCurrencyCode().toLowerCase();
return CoinEggAdapters.adaptTradeHistory(getCoinEggTradeView(tradeID, coin));
}
throw new ExchangeException("Incorrect TradeHistoryParams!");
}
@Override
public String placeMarketOrder(MarketOrder marketOrder) throws IOException {
throw new NotAvailableFromExchangeException();
}
@Override
public boolean cancelOrder(String orderId) throws IOException {
throw new NotAvailableFromExchangeException();
}
@Override
public void verifyOrder(MarketOrder marketOrder) {
throw new NotAvailableFromExchangeException();
}
}
|
BigDecimal amount = limitOrder.getOriginalAmount();
BigDecimal price = limitOrder.getAveragePrice();
String type = limitOrder.getType() == OrderType.ASK ? "buy" : "sell";
String coin = limitOrder.getCurrencyPair().base.getCurrencyCode().toLowerCase();
return CoinEggAdapters.adaptTradeAdd(getCoinEggTradeAdd(amount, price, type, coin));
| 544
| 117
| 661
|
<methods>public void <init>(org.knowm.xchange.Exchange) ,public org.knowm.xchange.coinegg.dto.trade.CoinEggTradeAdd getCoinEggTradeAdd(java.math.BigDecimal, java.math.BigDecimal, java.lang.String, java.lang.String) throws java.io.IOException,public org.knowm.xchange.coinegg.dto.trade.CoinEggTradeCancel getCoinEggTradeCancel(java.lang.String, java.lang.String) throws java.io.IOException,public org.knowm.xchange.coinegg.dto.trade.CoinEggTradeView getCoinEggTradeView(java.lang.String, java.lang.String) throws java.io.IOException<variables>private java.lang.String apiKey,private org.knowm.xchange.coinegg.CoinEggAuthenticated coinEggAuthenticated,private SynchronizedValueFactory<java.lang.Long> nonceFactory,private org.knowm.xchange.coinegg.service.CoinEggDigest signer,private java.lang.String tradePassword
|
knowm_XChange
|
XChange/xchange-coinex/src/main/java/org/knowm/xchange/coinex/CoinexAdapters.java
|
CoinexAdapters
|
adaptWallet
|
class CoinexAdapters {
public static Wallet adaptWallet(Map<String, CoinexBalanceInfo> coinexBalances) {<FILL_FUNCTION_BODY>}
}
|
List<Balance> balances = new ArrayList<>(coinexBalances.size());
for (Map.Entry<String, CoinexBalanceInfo> balancePair : coinexBalances.entrySet()) {
Currency currency = new Currency(balancePair.getKey());
BigDecimal total =
balancePair.getValue().getAvailable().add(balancePair.getValue().getFrozen());
Balance balance =
new Balance(
currency,
total,
balancePair.getValue().getAvailable(),
balancePair.getValue().getFrozen());
balances.add(balance);
}
return Wallet.Builder.from(balances).build();
| 51
| 170
| 221
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-coinex/src/main/java/org/knowm/xchange/coinex/CoinexExchange.java
|
CoinexExchange
|
getDefaultExchangeSpecification
|
class CoinexExchange extends BaseExchange implements Exchange {
@Override
protected void initServices() {
this.accountService = new CoinexAccountService(this);
}
@Override
public ExchangeSpecification getDefaultExchangeSpecification() {<FILL_FUNCTION_BODY>}
}
|
ExchangeSpecification exchangeSpecification = new ExchangeSpecification(this.getClass());
exchangeSpecification.setSslUri("https://api.coinex.com");
exchangeSpecification.setHost("www.coinex.com");
exchangeSpecification.setPort(80);
exchangeSpecification.setExchangeName("Coinex");
exchangeSpecification.setExchangeDescription("Bitstamp is a crypto-to-crypto exchange.");
return exchangeSpecification;
| 79
| 119
| 198
|
<methods>public non-sealed void <init>() ,public void applySpecification(org.knowm.xchange.ExchangeSpecification) ,public org.knowm.xchange.service.account.AccountService getAccountService() ,public List<org.knowm.xchange.instrument.Instrument> getExchangeInstruments() ,public org.knowm.xchange.dto.meta.ExchangeMetaData getExchangeMetaData() ,public org.knowm.xchange.ExchangeSpecification getExchangeSpecification() ,public org.knowm.xchange.service.marketdata.MarketDataService getMarketDataService() ,public java.lang.String getMetaDataFileName(org.knowm.xchange.ExchangeSpecification) ,public SynchronizedValueFactory<java.lang.Long> getNonceFactory() ,public org.knowm.xchange.service.trade.TradeService getTradeService() ,public void remoteInit() throws java.io.IOException, org.knowm.xchange.exceptions.ExchangeException,public java.lang.String toString() <variables>protected org.knowm.xchange.service.account.AccountService accountService,protected org.knowm.xchange.dto.meta.ExchangeMetaData exchangeMetaData,protected org.knowm.xchange.ExchangeSpecification exchangeSpecification,protected final Logger logger,protected org.knowm.xchange.service.marketdata.MarketDataService marketDataService,private final SynchronizedValueFactory<java.lang.Long> nonceFactory,protected org.knowm.xchange.service.trade.TradeService tradeService
|
knowm_XChange
|
XChange/xchange-coinex/src/main/java/org/knowm/xchange/coinex/service/CoinexDigest.java
|
CoinexDigest
|
createInstance
|
class CoinexDigest extends BaseParamsDigest {
private ThreadLocal<byte[]> threadLocalMac;
private final String secret;
private final String apiKey;
private CoinexDigest(String secretKeyBase64, String apiKey) {
super(secretKeyBase64, HMAC_MD5);
this.secret = secretKeyBase64;
this.apiKey = apiKey;
}
public static CoinexDigest createInstance(String secretKeyBase64, String apiKey) {<FILL_FUNCTION_BODY>}
@Override
public String digestParams(RestInvocation restInvocation) {
return new BasicAuthCredentials(apiKey, secret).digestParams(restInvocation);
}
}
|
return secretKeyBase64 == null ? null : new CoinexDigest(secretKeyBase64, apiKey);
| 190
| 33
| 223
|
<methods>public javax.crypto.Mac getMac() <variables>public static final java.lang.String HMAC_MD5,public static final java.lang.String HMAC_SHA_1,public static final java.lang.String HMAC_SHA_256,public static final java.lang.String HMAC_SHA_384,public static final java.lang.String HMAC_SHA_512,private final non-sealed javax.crypto.Mac mac
|
knowm_XChange
|
XChange/xchange-coinfloor/src/main/java/org/knowm/xchange/coinfloor/CoinfloorUtils.java
|
CoinfloorUtils
|
parseDate
|
class CoinfloorUtils {
private static final FastDateFormat DATE_FORMAT =
FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss", TimeZone.getTimeZone("UTC"));
private CoinfloorUtils() {}
public static Date parseDate(final String date) {<FILL_FUNCTION_BODY>}
}
|
try {
return DATE_FORMAT.parse(date);
} catch (final ParseException e) {
throw new ExchangeException("Illegal date/time format: " + date, e);
}
| 90
| 54
| 144
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-coinfloor/src/main/java/org/knowm/xchange/coinfloor/dto/account/CoinfloorBalance.java
|
CoinfloorBalance
|
hasCurrency
|
class CoinfloorBalance {
@JsonProperty("gbp_balance")
public BigDecimal gbpBalance = BigDecimal.ZERO;
@JsonProperty("usd_balance")
public BigDecimal usdBalance = BigDecimal.ZERO;
@JsonProperty("eur_balance")
public BigDecimal eurBalance = BigDecimal.ZERO;
@JsonProperty("xbt_balance")
public BigDecimal btcBalance = BigDecimal.ZERO;
@JsonProperty("bch_balance")
public BigDecimal bchBalance = BigDecimal.ZERO;
@JsonProperty("eth_balance")
public BigDecimal ethBalance = BigDecimal.ZERO;
@JsonProperty("ltc_balance")
public BigDecimal ltcBalance = BigDecimal.ZERO;
@JsonProperty("xrp_balance")
public BigDecimal xrpBalance = BigDecimal.ZERO;
@JsonProperty("gbp_reserved")
public BigDecimal gbpReserved = BigDecimal.ZERO;
@JsonProperty("usd_reserved")
public BigDecimal usdReserved = BigDecimal.ZERO;
@JsonProperty("eur_reserved")
public BigDecimal eurReserved = BigDecimal.ZERO;
@JsonProperty("xbt_reserved")
public BigDecimal btcReserved = BigDecimal.ZERO;
@JsonProperty("bch_reserved")
public BigDecimal bchReserved = BigDecimal.ZERO;
@JsonProperty("eth_reserved")
public BigDecimal ethReserved = BigDecimal.ZERO;
@JsonProperty("ltc_reserved")
public BigDecimal ltcReserved = BigDecimal.ZERO;
@JsonProperty("xrp_reserved")
public BigDecimal xrpReserved = BigDecimal.ZERO;
@JsonProperty("gbp_available")
public BigDecimal gbpAvailable = BigDecimal.ZERO;
@JsonProperty("usd_available")
public BigDecimal usdAvailable = BigDecimal.ZERO;
@JsonProperty("eur_available")
public BigDecimal eurAvailable = BigDecimal.ZERO;
@JsonProperty("xbt_available")
public BigDecimal btcAvailable = BigDecimal.ZERO;
@JsonProperty("bch_available")
public BigDecimal bchAvailable = BigDecimal.ZERO;
@JsonProperty("eth_available")
public BigDecimal ethAvailable = BigDecimal.ZERO;
@JsonProperty("ltc_available")
public BigDecimal ltcAvailable = BigDecimal.ZERO;
@JsonProperty("xrp_available")
public BigDecimal xrpAvailable = BigDecimal.ZERO;
public boolean hasCurrency(Currency currency) {<FILL_FUNCTION_BODY>}
public Balance getBalance(Currency currency) {
if (currency.equals(Currency.XBT)) {
return new Balance(currency, btcBalance, btcAvailable, btcReserved);
} else if (currency.equals(Currency.GBP)) {
return new Balance(currency, gbpBalance, gbpAvailable, gbpReserved);
} else if (currency.equals(Currency.EUR)) {
return new Balance(currency, eurBalance, eurAvailable, eurReserved);
} else if (currency.equals(Currency.USD)) {
return new Balance(currency, usdBalance, usdAvailable, usdReserved);
} else if (currency.equals(Currency.BCH)) {
return new Balance(currency, bchBalance, bchAvailable, bchReserved);
} else if (currency.equals(Currency.XRP)) {
return new Balance(currency, xrpBalance, xrpAvailable, xrpReserved);
} else if (currency.equals(Currency.LTC)) {
return new Balance(currency, ltcBalance, ltcAvailable, ltcReserved);
} else if (currency.equals(Currency.ETH)) {
return new Balance(currency, ethBalance, ethAvailable, ethReserved);
} else {
throw new IllegalArgumentException("Unsupported currency: " + currency);
}
}
}
|
if (currency.equals(Currency.BTC)) {
return !Objects.equals(btcBalance, BigDecimal.ZERO);
} else if (currency.equals(Currency.GBP)) {
return !Objects.equals(gbpBalance, BigDecimal.ZERO);
} else if (currency.equals(Currency.EUR)) {
return !Objects.equals(eurBalance, BigDecimal.ZERO);
} else if (currency.equals(Currency.USD)) {
return !Objects.equals(usdBalance, BigDecimal.ZERO);
} else if (currency.equals(Currency.BCH)) {
return !Objects.equals(bchBalance, BigDecimal.ZERO);
} else if (currency.equals(Currency.XRP)) {
return !Objects.equals(xrpBalance, BigDecimal.ZERO);
} else if (currency.equals(Currency.LTC)) {
return !Objects.equals(ltcBalance, BigDecimal.ZERO);
} else if (currency.equals(Currency.ETH)) {
return !Objects.equals(ethBalance, BigDecimal.ZERO);
} else {
return false;
}
| 1,126
| 316
| 1,442
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-coinfloor/src/main/java/org/knowm/xchange/coinfloor/dto/trade/CoinfloorUserTransaction.java
|
CoinfloorTransactionTypeDeserializer
|
deserialize
|
class CoinfloorTransactionTypeDeserializer
extends JsonDeserializer<TransactionType> {
@Override
public TransactionType deserialize(JsonParser jp, DeserializationContext ctxt)
throws IOException, JsonProcessingException {<FILL_FUNCTION_BODY>}
}
|
switch (jp.getValueAsInt()) {
case 0:
return TransactionType.DEPOSIT;
case 1:
return TransactionType.WITHDRAWAL;
case 2:
return TransactionType.TRADE;
default:
return TransactionType.UNKNOWN;
}
| 74
| 87
| 161
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-coinfloor/src/main/java/org/knowm/xchange/coinfloor/service/CoinfloorTradeService.java
|
CoinfloorTradeService
|
getOpenOrders
|
class CoinfloorTradeService extends CoinfloorTradeServiceRaw implements TradeService {
private static final CurrencyPair NO_CURRENCY_PAIR = null;
private static final Collection<CurrencyPair> NO_CURRENCY_PAIR_COLLECTION =
Collections.emptySet();
private static final Collection<Instrument> NO_INSTRUMENT_COLLECTION = Collections.emptySet();
private final Collection<Instrument> allConfiguredCurrencyPairs;
public CoinfloorTradeService(Exchange exchange) {
super(exchange);
allConfiguredCurrencyPairs = exchange.getExchangeMetaData().getInstruments().keySet();
}
@Override
public OpenOrders getOpenOrders() throws IOException {
// no currency pairs have been supplied - search them all
return getOpenOrders(NO_CURRENCY_PAIR, allConfiguredCurrencyPairs);
}
@Override
public OpenOrders getOpenOrders(OpenOrdersParams params) throws IOException {<FILL_FUNCTION_BODY>}
private OpenOrders getOpenOrders(CurrencyPair pair, Collection<Instrument> pairs)
throws IOException {
Collection<CoinfloorOrder> orders = new ArrayList<>();
if (pair == NO_CURRENCY_PAIR) {
if (pairs.isEmpty()) {
// no currency pairs have been supplied - search them all
pairs = allConfiguredCurrencyPairs;
}
} else {
CoinfloorOrder[] orderArray = getOpenOrders(pair);
for (CoinfloorOrder order : orderArray) {
order.setCurrencyPair(pair);
orders.add(order);
}
}
for (Instrument currencyPair : pairs) {
CoinfloorOrder[] orderArray = getOpenOrders((CurrencyPair) currencyPair);
for (CoinfloorOrder order : orderArray) {
order.setCurrencyPair((CurrencyPair) currencyPair);
orders.add(order);
}
}
return CoinfloorAdapters.adaptOpenOrders(orders);
}
/**
* By default if no CurrencyPairs are specified then the trade history for all markets will be
* returned.
*/
@Override
public OpenOrdersParams createOpenOrdersParams() {
return new CoinfloorOpenOrdersParams();
}
@Override
public UserTrades getTradeHistory(TradeHistoryParams params) throws IOException {
Integer limit;
if (params instanceof TradeHistoryParamPaging) {
limit = ((TradeHistoryParamPaging) params).getPageLength();
} else {
limit = null;
}
Long offset;
if (params instanceof TradeHistoryParamOffset) {
offset = ((TradeHistoryParamOffset) params).getOffset();
} else {
offset = null;
}
TradeHistoryParamsSorted.Order sort;
if (params instanceof TradeHistoryParamsSorted) {
sort = ((TradeHistoryParamsSorted) params).getOrder();
} else {
sort = null;
}
CurrencyPair pair;
if (params instanceof TradeHistoryParamCurrencyPair) {
pair = ((TradeHistoryParamCurrencyPair) params).getCurrencyPair();
} else {
pair = NO_CURRENCY_PAIR;
}
Collection<CurrencyPair> pairs;
if (params instanceof TradeHistoryParamMultiCurrencyPair) {
pairs = ((TradeHistoryParamMultiCurrencyPair) params).getCurrencyPairs();
} else {
pairs = NO_CURRENCY_PAIR_COLLECTION;
}
Collection<CoinfloorUserTransaction> transactions = new ArrayList<>();
if (pair == NO_CURRENCY_PAIR) {
if (pairs.isEmpty()) {
// no currency pairs have been supplied - search them all
allConfiguredCurrencyPairs.forEach(instrument -> pairs.add((CurrencyPair) instrument));
}
for (Instrument currencyPair : pairs) {
transactions.addAll(Arrays.asList(getUserTransactions(currencyPair, limit, offset, sort)));
}
} else {
transactions.addAll(Arrays.asList(getUserTransactions(pair, limit, offset, sort)));
}
return CoinfloorAdapters.adaptTradeHistory(transactions);
}
/**
* By default if no CurrencyPairs are specified then the trade history for all markets will be
* returned.
*/
@Override
public TradeHistoryParams createTradeHistoryParams() {
return new CoinfloorTradeHistoryParams();
}
@Override
public String placeLimitOrder(LimitOrder order) throws IOException {
CoinfloorOrder rawOrder =
placeLimitOrder(
order.getCurrencyPair(),
order.getType(),
order.getOriginalAmount(),
order.getLimitPrice());
return Long.toString(rawOrder.getId());
}
@Override
public String placeMarketOrder(MarketOrder order) throws IOException {
placeMarketOrder(order.getCurrencyPair(), order.getType(), order.getOriginalAmount());
return ""; // coinfloor does not return an id for market orders
}
@Override
public boolean cancelOrder(String orderId) throws IOException {
// API requires currency pair but value seems to be ignored - only the order ID is used for
// lookup.
CurrencyPair currencyPairValueIsIgnored = CurrencyPair.BTC_GBP;
return cancelOrder(currencyPairValueIsIgnored, Long.parseLong(orderId));
}
@Override
public boolean cancelOrder(CancelOrderParams orderParams) throws IOException {
if (orderParams instanceof CancelOrderByIdParams) {
return cancelOrder(((CancelOrderByIdParams) orderParams).getOrderId());
} else {
return false;
}
}
}
|
CurrencyPair pair;
if (params instanceof OpenOrdersParamCurrencyPair) {
pair = ((OpenOrdersParamCurrencyPair) params).getCurrencyPair();
} else {
pair = NO_CURRENCY_PAIR;
}
Collection<Instrument> pairs;
if (params instanceof OpenOrdersParamMultiCurrencyPair) {
pairs = ((OpenOrdersParamMultiInstrument) params).getInstruments();
} else {
pairs = NO_INSTRUMENT_COLLECTION;
}
return getOpenOrders(pair, pairs);
| 1,481
| 149
| 1,630
|
<methods>public boolean cancelOrder(org.knowm.xchange.currency.CurrencyPair, long) throws java.io.IOException,public org.knowm.xchange.coinfloor.dto.trade.CoinfloorOrder[] getOpenOrders(org.knowm.xchange.currency.CurrencyPair) throws java.io.IOException,public org.knowm.xchange.coinfloor.dto.trade.CoinfloorUserTransaction[] getUserTransactions(org.knowm.xchange.instrument.Instrument, java.lang.Integer, java.lang.Long, org.knowm.xchange.service.trade.params.TradeHistoryParamsSorted.Order) throws java.io.IOException,public org.knowm.xchange.coinfloor.dto.trade.CoinfloorOrder placeLimitOrder(org.knowm.xchange.currency.CurrencyPair, org.knowm.xchange.dto.Order.OrderType, java.math.BigDecimal, java.math.BigDecimal) throws java.io.IOException,public org.knowm.xchange.coinfloor.dto.trade.CoinfloorMarketOrderResponse placeMarketOrder(org.knowm.xchange.currency.CurrencyPair, org.knowm.xchange.dto.Order.OrderType, java.math.BigDecimal) throws java.io.IOException<variables>
|
knowm_XChange
|
XChange/xchange-coinfloor/src/main/java/org/knowm/xchange/coinfloor/service/CoinfloorTradeServiceRaw.java
|
CoinfloorTradeServiceRaw
|
placeMarketOrder
|
class CoinfloorTradeServiceRaw extends CoinfloorAuthenticatedService {
protected CoinfloorTradeServiceRaw(Exchange exchange) {
super(exchange);
}
public CoinfloorUserTransaction[] getUserTransactions(
Instrument pair,
Integer numberOfTransactions,
Long offset,
TradeHistoryParamsSorted.Order sort)
throws IOException {
try {
return coinfloor.getUserTransactions(
normalise(pair.getBase()),
normalise(pair.getCounter()),
numberOfTransactions,
offset,
sort == null ? null : sort.toString());
} catch (HttpStatusIOException e) {
if (e.getHttpStatusCode() == HttpURLConnection.HTTP_BAD_REQUEST) {
throw new ExchangeException(e.getHttpBody(), e);
} else {
throw e;
}
}
}
public CoinfloorOrder[] getOpenOrders(CurrencyPair pair) throws IOException {
try {
return coinfloor.getOpenOrders(normalise(pair.base), normalise(pair.counter));
} catch (HttpStatusIOException e) {
if (e.getHttpStatusCode() == HttpURLConnection.HTTP_BAD_REQUEST) {
throw new ExchangeException(e.getHttpBody(), e);
} else {
throw e;
}
}
}
public CoinfloorOrder placeLimitOrder(
CurrencyPair pair, OrderType side, BigDecimal amount, BigDecimal price) throws IOException {
Currency base = normalise(pair.base);
Currency counter = normalise(pair.counter);
try {
if (side == OrderType.BID) {
return coinfloor.buy(base, counter, amount, price);
} else {
return coinfloor.sell(base, counter, amount, price);
}
} catch (HttpStatusIOException e) {
if (e.getHttpStatusCode() == HttpURLConnection.HTTP_BAD_REQUEST) {
// e.g. if too many decimal places are specified in the quantity field the HTTP body
// contains the message: "amount" parameter must not have more than 4 fractional digits
throw new ExchangeException(e.getHttpBody(), e);
} else {
throw e;
}
}
}
public CoinfloorMarketOrderResponse placeMarketOrder(
CurrencyPair pair, OrderType side, BigDecimal amount) throws IOException {<FILL_FUNCTION_BODY>}
public boolean cancelOrder(CurrencyPair pair, long id) throws IOException {
try {
return coinfloor.cancelOrder(normalise(pair.base), normalise(pair.counter), id);
} catch (HttpStatusIOException e) {
if (e.getHttpStatusCode() == HttpURLConnection.HTTP_BAD_REQUEST) {
throw new ExchangeException(e.getHttpBody(), e);
} else {
throw e;
}
}
}
}
|
Currency base = normalise(pair.base);
Currency counter = normalise(pair.counter);
try {
if (side == OrderType.BID) {
return coinfloor.buyMarket(base, counter, amount);
} else {
return coinfloor.sellMarket(base, counter, amount);
}
} catch (HttpStatusIOException e) {
if (e.getHttpStatusCode() == HttpURLConnection.HTTP_BAD_REQUEST) {
// e.g. if too many decimal places are specified in the quantity field the HTTP body
// contains the message: "quantity" parameter must not have more than 4 fractional digits
throw new ExchangeException(e.getHttpBody(), e);
} else {
throw e;
}
}
| 742
| 198
| 940
|
<methods><variables>protected org.knowm.xchange.coinfloor.CoinfloorAuthenticated coinfloor,private final Logger logger
|
knowm_XChange
|
XChange/xchange-coingi/src/main/java/org/knowm/xchange/coingi/CoingiErrorAdapter.java
|
CoingiErrorAdapter
|
adapt
|
class CoingiErrorAdapter {
public static ExchangeException adapt(CoingiException e) {<FILL_FUNCTION_BODY>}
}
|
String message = e.getMessage();
if (message == null || "".equals(message)) {
return new ExchangeException("Operation failed without any error message");
}
if (message.contains("Invalid value for parameter \"currencyPair\"")) {
return new CurrencyPairNotValidException(message);
}
return new ExchangeException(message);
| 37
| 90
| 127
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-coingi/src/main/java/org/knowm/xchange/coingi/CoingiExchange.java
|
CoingiExchange
|
initServices
|
class CoingiExchange extends BaseExchange implements Exchange {
@Override
protected void initServices() {<FILL_FUNCTION_BODY>}
@Override
public ExchangeSpecification getDefaultExchangeSpecification() {
ExchangeSpecification exchangeSpecification = new ExchangeSpecification(this.getClass());
exchangeSpecification.setSslUri("https://api.coingi.com");
exchangeSpecification.setHost("api.coingi.com");
exchangeSpecification.setPort(80);
exchangeSpecification.setExchangeName("Coingi");
exchangeSpecification.setExchangeDescription("Coingi is a cryptocurrency exchange.");
return exchangeSpecification;
}
}
|
this.marketDataService = new CoingiMarketDataService(this);
this.tradeService = new CoingiTradeService(this);
this.accountService = new CoingiAccountService(this);
| 175
| 56
| 231
|
<methods>public non-sealed void <init>() ,public void applySpecification(org.knowm.xchange.ExchangeSpecification) ,public org.knowm.xchange.service.account.AccountService getAccountService() ,public List<org.knowm.xchange.instrument.Instrument> getExchangeInstruments() ,public org.knowm.xchange.dto.meta.ExchangeMetaData getExchangeMetaData() ,public org.knowm.xchange.ExchangeSpecification getExchangeSpecification() ,public org.knowm.xchange.service.marketdata.MarketDataService getMarketDataService() ,public java.lang.String getMetaDataFileName(org.knowm.xchange.ExchangeSpecification) ,public SynchronizedValueFactory<java.lang.Long> getNonceFactory() ,public org.knowm.xchange.service.trade.TradeService getTradeService() ,public void remoteInit() throws java.io.IOException, org.knowm.xchange.exceptions.ExchangeException,public java.lang.String toString() <variables>protected org.knowm.xchange.service.account.AccountService accountService,protected org.knowm.xchange.dto.meta.ExchangeMetaData exchangeMetaData,protected org.knowm.xchange.ExchangeSpecification exchangeSpecification,protected final Logger logger,protected org.knowm.xchange.service.marketdata.MarketDataService marketDataService,private final SynchronizedValueFactory<java.lang.Long> nonceFactory,protected org.knowm.xchange.service.trade.TradeService tradeService
|
knowm_XChange
|
XChange/xchange-coingi/src/main/java/org/knowm/xchange/coingi/dto/CoingiException.java
|
CoingiException
|
getMessage
|
class CoingiException extends HttpStatusExceptionSupport {
private List<Map<String, Object>> errors;
public CoingiException(@JsonProperty("errors") Object errors) {
super(getMessage(errors));
if (errors instanceof List) {
try {
this.errors = (List<Map<String, Object>>) errors;
} catch (Exception ignore) {
}
}
}
private static String getMessage(Object errors) {<FILL_FUNCTION_BODY>}
public List<Map<String, Object>> getErrors() {
return errors;
}
}
|
if (errors instanceof Map) {
try {
List<Map<String, Object>> err = (List<Map<String, Object>>) errors;
final StringBuilder sb = new StringBuilder();
for (Map<String, Object> error : err) {
for (String key : error.keySet()) {
if (sb.length() > 0) {
sb.append(" -- ");
}
sb.append(error.get(key));
}
}
return sb.toString();
} catch (Exception ignore) {
}
}
return String.valueOf(errors);
| 152
| 154
| 306
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-coingi/src/main/java/org/knowm/xchange/coingi/dto/marketdata/CoingiDepthRange.java
|
CoingiDepthRange
|
equals
|
class CoingiDepthRange {
private BigDecimal price;
private BigDecimal amount;
public CoingiDepthRange(
@JsonProperty("price") BigDecimal price, @JsonProperty("amount") BigDecimal amount) {
this.price = Objects.requireNonNull(price);
this.amount = Objects.requireNonNull(amount);
}
public BigDecimal getPrice() {
return price;
}
public BigDecimal getAmount() {
return amount;
}
@Override
public boolean equals(final Object o) {<FILL_FUNCTION_BODY>}
@Override
public int hashCode() {
return Objects.hash(price, amount);
}
}
|
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
CoingiDepthRange that = (CoingiDepthRange) o;
return Objects.equals(price, that.price) && Objects.equals(amount, that.amount);
| 189
| 81
| 270
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-coingi/src/main/java/org/knowm/xchange/coingi/dto/marketdata/CoingiOrderBook.java
|
CoingiOrderBook
|
equals
|
class CoingiOrderBook {
private Collection<CoingiOrderGroup> asks;
private Collection<CoingiOrderGroup> bids;
private List<CoingiDepthRange> askDepthRange;
private List<CoingiDepthRange> bidDepthRange;
public CoingiOrderBook(
@JsonProperty("asks") Collection<CoingiOrderGroup> asks,
@JsonProperty("bids") Collection<CoingiOrderGroup> bids,
@JsonProperty("askDepthRange") List<CoingiDepthRange> askDepthRange,
@JsonProperty("bidDepthRange") List<CoingiDepthRange> bidDepthRange) {
this.asks = Objects.requireNonNull(asks);
this.bids = Objects.requireNonNull(bids);
this.askDepthRange = Objects.requireNonNull(askDepthRange);
this.bidDepthRange = Objects.requireNonNull(bidDepthRange);
}
public Collection<CoingiOrderGroup> getAsks() {
return Collections.unmodifiableCollection(asks);
}
public Collection<CoingiOrderGroup> getBids() {
return Collections.unmodifiableCollection(bids);
}
public Collection<CoingiDepthRange> getAskDepthRange() {
return Collections.unmodifiableCollection(askDepthRange);
}
public Collection<CoingiDepthRange> getBidDepthRange() {
return Collections.unmodifiableCollection(bidDepthRange);
}
@Override
public boolean equals(final Object o) {<FILL_FUNCTION_BODY>}
@Override
public int hashCode() {
return Objects.hash(asks, bids, askDepthRange, bidDepthRange);
}
}
|
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
CoingiOrderBook coingiOrderBook = (CoingiOrderBook) o;
return Objects.equals(asks, coingiOrderBook.asks)
&& Objects.equals(bids, coingiOrderBook.bids)
&& Objects.equals(askDepthRange, coingiOrderBook.askDepthRange)
&& Objects.equals(bidDepthRange, coingiOrderBook.bidDepthRange);
| 442
| 139
| 581
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-coingi/src/main/java/org/knowm/xchange/coingi/dto/trade/CoingiGetOrderHistoryRequest.java
|
CoingiGetOrderHistoryRequest
|
setCurrencyPair
|
class CoingiGetOrderHistoryRequest extends CoingiAuthenticatedRequest {
private int pageNumber;
private int pageSize;
private int type;
private String currencyPair;
private Integer status;
public int getPageNumber() {
return pageNumber;
}
public CoingiGetOrderHistoryRequest setPageNumber(int pageNumber) {
this.pageNumber = pageNumber;
return this;
}
public int getPageSize() {
return pageSize;
}
public CoingiGetOrderHistoryRequest setPageSize(int pageSize) {
this.pageSize = pageSize;
return this;
}
public Integer getType() {
return type;
}
public CoingiGetOrderHistoryRequest setType(Integer type) {
this.type = type;
return this;
}
public String getCurrencyPair() {
return currencyPair;
}
public CoingiGetOrderHistoryRequest setCurrencyPair(CurrencyPair currencyPair) {<FILL_FUNCTION_BODY>}
public Integer getStatus() {
return status;
}
public CoingiGetOrderHistoryRequest setStatus(Integer status) {
this.status = status;
return this;
}
}
|
if (currencyPair != null)
this.currencyPair = currencyPair.toString().replace('/', '-').toLowerCase();
return this;
| 324
| 40
| 364
|
<methods>public non-sealed void <init>() ,public java.lang.Long getNonce() ,public java.lang.String getSignature() ,public java.lang.String getToken() ,public org.knowm.xchange.coingi.dto.CoingiAuthenticatedRequest setNonce(java.lang.Long) ,public org.knowm.xchange.coingi.dto.CoingiAuthenticatedRequest setSignature(java.lang.String) ,public org.knowm.xchange.coingi.dto.CoingiAuthenticatedRequest setToken(java.lang.String) <variables>private java.lang.Long nonce,private java.lang.String signature,private java.lang.String token
|
knowm_XChange
|
XChange/xchange-coingi/src/main/java/org/knowm/xchange/coingi/dto/trade/CoingiPaginatedResultList.java
|
CoingiPaginatedResultList
|
equals
|
class CoingiPaginatedResultList<T> implements Iterable<T> {
private boolean hasMore;
public CoingiPaginatedResultList(boolean hasMore) {
this.hasMore = hasMore;
}
public final boolean hasMore() {
return hasMore;
}
protected abstract List<T> getResultsList();
public final List<T> getList() {
return Collections.unmodifiableList(getResultsList());
}
@Override
public Iterator<T> iterator() {
return getList().iterator();
}
@Override
public final boolean equals(Object o) {<FILL_FUNCTION_BODY>}
@Override
public final int hashCode() {
return Objects.hash(hasMore, getResultsList());
}
}
|
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
CoingiPaginatedResultList<?> that = (CoingiPaginatedResultList<?>) o;
return hasMore == that.hasMore && Objects.equals(getResultsList(), that.getResultsList());
| 211
| 93
| 304
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-coingi/src/main/java/org/knowm/xchange/coingi/dto/trade/CoingiTransactionHistoryRequest.java
|
CoingiTransactionHistoryRequest
|
setCurrencyPair
|
class CoingiTransactionHistoryRequest extends CoingiAuthenticatedRequest {
private int pageNumber;
private int pageSize;
private int type;
private String currencyPair;
private int status;
public int getPageNumber() {
return pageNumber;
}
public CoingiTransactionHistoryRequest setPageNumber(int pageNumber) {
this.pageNumber = pageNumber;
return this;
}
public int getPageSize() {
return pageSize;
}
public CoingiTransactionHistoryRequest setPageSize(int pageSize) {
this.pageSize = pageSize;
return this;
}
public Integer getType() {
return type;
}
public CoingiTransactionHistoryRequest setType(Integer type) {
this.type = type;
return this;
}
public String getCurrencyPair() {
return currencyPair;
}
public CoingiTransactionHistoryRequest setCurrencyPair(CurrencyPair currencyPair) {<FILL_FUNCTION_BODY>}
public Integer getStatus() {
return status;
}
public CoingiTransactionHistoryRequest setStatus(Integer status) {
this.status = status;
return this;
}
}
|
if (currencyPair != null) this.currencyPair = CoingiAdapters.adaptCurrency(currencyPair);
return this;
| 318
| 38
| 356
|
<methods>public non-sealed void <init>() ,public java.lang.Long getNonce() ,public java.lang.String getSignature() ,public java.lang.String getToken() ,public org.knowm.xchange.coingi.dto.CoingiAuthenticatedRequest setNonce(java.lang.Long) ,public org.knowm.xchange.coingi.dto.CoingiAuthenticatedRequest setSignature(java.lang.String) ,public org.knowm.xchange.coingi.dto.CoingiAuthenticatedRequest setToken(java.lang.String) <variables>private java.lang.Long nonce,private java.lang.String signature,private java.lang.String token
|
knowm_XChange
|
XChange/xchange-coingi/src/main/java/org/knowm/xchange/coingi/service/CoingiBaseService.java
|
CoingiBaseService
|
handleAuthentication
|
class CoingiBaseService extends BaseExchangeService implements BaseService {
protected CoingiDigest signatureCreator;
protected CoingiBaseService(Exchange exchange) {
super(exchange);
}
protected void handleAuthentication(Object obj) {<FILL_FUNCTION_BODY>}
}
|
if (obj instanceof CoingiAuthenticatedRequest) {
CoingiAuthenticatedRequest request = (CoingiAuthenticatedRequest) obj;
Long nonce = exchange.getNonceFactory().createValue();
request.setToken(exchange.getExchangeSpecification().getApiKey());
request.setNonce(nonce);
request.setSignature(signatureCreator.sign(nonce));
}
| 79
| 106
| 185
|
<methods>public void verifyOrder(org.knowm.xchange.dto.trade.LimitOrder) ,public void verifyOrder(org.knowm.xchange.dto.trade.MarketOrder) <variables>protected final non-sealed org.knowm.xchange.Exchange exchange
|
knowm_XChange
|
XChange/xchange-coingi/src/main/java/org/knowm/xchange/coingi/service/CoingiDefaultIdentityProvider.java
|
HexEncoder
|
encode
|
class HexEncoder {
private static final char[] hexArray = "0123456789ABCDEF".toCharArray();
/**
* Converts given binary data to a hexadecimal string representation.
*
* @param data Binary data
* @return Hexadecimal representation
*/
public static String encode(byte[] data) {<FILL_FUNCTION_BODY>}
}
|
final char[] hexChars = new char[data.length * 2];
int position = 0;
for (byte bt : data) {
hexChars[position++] = hexArray[(bt & 0xF0) >>> 4];
hexChars[position++] = hexArray[bt & 0x0F];
}
return String.valueOf(hexChars);
| 111
| 104
| 215
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-coinjar/src/main/java/org/knowm/xchange/coinjar/dto/data/CoinjarTicker.java
|
CoinjarTicker
|
equals
|
class CoinjarTicker {
public final String volume24h;
public final String volume;
public final String transitionTime;
public final String status;
public final Integer session;
public final String prevClose;
public final String last;
public final String currentTime;
public final String bid;
public final String ask;
/**
* @param currentTime
* @param volume24h
* @param prevClose
* @param last
* @param session
* @param status
* @param transitionTime
* @param volume
* @param ask
* @param bid
*/
public CoinjarTicker(
@JsonProperty("volume_24h") String volume24h,
@JsonProperty("volume") String volume,
@JsonProperty("transition_time") String transitionTime,
@JsonProperty("status") String status,
@JsonProperty("session") Integer session,
@JsonProperty("prev_close") String prevClose,
@JsonProperty("last") String last,
@JsonProperty("current_time") String currentTime,
@JsonProperty("bid") String bid,
@JsonProperty("ask") String ask) {
super();
this.volume24h = volume24h;
this.volume = volume;
this.transitionTime = transitionTime;
this.status = status;
this.session = session;
this.prevClose = prevClose;
this.last = last;
this.currentTime = currentTime;
this.bid = bid;
this.ask = ask;
}
@Override
public String toString() {
return new ToStringBuilder(this)
.append("volume24h", volume24h)
.append("volume", volume)
.append("transitionTime", transitionTime)
.append("status", status)
.append("session", session)
.append("prevClose", prevClose)
.append("last", last)
.append("currentTime", currentTime)
.append("bid", bid)
.append("ask", ask)
.toString();
}
@Override
public boolean equals(Object o) {<FILL_FUNCTION_BODY>}
@Override
public int hashCode() {
return new HashCodeBuilder(17, 37)
.append(volume24h)
.append(volume)
.append(transitionTime)
.append(status)
.append(session)
.append(prevClose)
.append(last)
.append(currentTime)
.append(bid)
.append(ask)
.toHashCode();
}
}
|
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
CoinjarTicker ticker = (CoinjarTicker) o;
return new EqualsBuilder()
.append(volume24h, ticker.volume24h)
.append(volume, ticker.volume)
.append(transitionTime, ticker.transitionTime)
.append(status, ticker.status)
.append(session, ticker.session)
.append(prevClose, ticker.prevClose)
.append(last, ticker.last)
.append(currentTime, ticker.currentTime)
.append(bid, ticker.bid)
.append(ask, ticker.ask)
.isEquals();
| 678
| 203
| 881
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-coinmarketcap/src/main/java/org/knowm/xchange/coinmarketcap/deprecated/v2/dto/marketdata/CoinMarketCapHistoricalSpotPrice.java
|
CoinMarketCapHistoricalSpotPrice
|
toString
|
class CoinMarketCapHistoricalSpotPrice
implements Comparable<CoinMarketCapHistoricalSpotPrice> {
private final Date timestamp;
private final BigDecimal spotRate;
CoinMarketCapHistoricalSpotPrice(Date timestamp, final BigDecimal spotRate) {
this.timestamp = timestamp;
this.spotRate = spotRate;
}
public Date getTimestamp() {
return timestamp;
}
public BigDecimal getSpotRate() {
return spotRate;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
@Override
public int compareTo(CoinMarketCapHistoricalSpotPrice o) {
return this.timestamp.compareTo(o.timestamp);
}
}
|
return "CoinbaseHistoricalPrice [timestamp=" + timestamp + ", spotRate=" + spotRate + "]";
| 204
| 32
| 236
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-coinmarketcap/src/main/java/org/knowm/xchange/coinmarketcap/deprecated/v2/service/CoinMarketCapMarketDataServiceRaw.java
|
CoinMarketCapMarketDataServiceRaw
|
getCoinMarketCapCurrencies
|
class CoinMarketCapMarketDataServiceRaw extends BaseExchangeService implements BaseService {
private final CoinMarketCap coinmarketcap;
public CoinMarketCapMarketDataServiceRaw(Exchange exchange) {
super(exchange);
this.coinmarketcap =
ExchangeRestProxyBuilder.forInterface(
CoinMarketCap.class, exchange.getExchangeSpecification())
.build();
}
public CoinMarketCapTicker getCoinMarketCapTicker(CurrencyPair pair) {
return coinmarketcap.getTicker(new CoinMarketCap.Pair(pair));
}
/**
* Unauthenticated resource that returns currencies supported on CoinMarketCap.
*
* @return A list of currency names and their corresponding ISO code.
* @throws IOException
*/
public List<CoinMarketCapCurrency> getCoinMarketCapCurrencies() throws IOException {<FILL_FUNCTION_BODY>}
/** Retrieves all tickers from CoinMarketCap */
public List<CoinMarketCapTicker> getCoinMarketCapTickers() throws IOException {
return getCoinMarketCapTickers(0);
}
/**
* Retrieves limited amount of tickers from CoinMarketCap
*
* @param limit count of tickers to be retrieved
*/
public List<CoinMarketCapTicker> getCoinMarketCapTickers(final int limit) throws IOException {
return coinmarketcap.getTickers(limit, "array").getData();
}
/**
* Retrieves limited amount of tickers from CoinMarketCap
*
* @param limit count of tickers to be retrieved
* @param convert currency to get price converted to
*/
public List<CoinMarketCapTicker> getCoinMarketCapTickers(final int limit, Currency convert)
throws IOException {
return coinmarketcap.getTickers(limit, convert.toString(), "array").getData();
}
public List<CoinMarketCapTicker> getCoinMarketCapTickers(int start, int limit)
throws IOException {
return coinmarketcap.getTickers(start, limit, "array").getData();
}
public List<CoinMarketCapTicker> getCoinMarketCapTickers(int start, int limit, Currency convert)
throws IOException {
return coinmarketcap.getTickers(start, limit, convert.toString(), "array").getData();
}
}
|
List<CoinMarketCapTicker> tickers = getCoinMarketCapTickers();
List<CoinMarketCapCurrency> currencies = new ArrayList<>();
for (CoinMarketCapTicker ticker : tickers) currencies.add(ticker.getBaseCurrency());
return currencies;
| 653
| 87
| 740
|
<methods>public void verifyOrder(org.knowm.xchange.dto.trade.LimitOrder) ,public void verifyOrder(org.knowm.xchange.dto.trade.MarketOrder) <variables>protected final non-sealed org.knowm.xchange.Exchange exchange
|
knowm_XChange
|
XChange/xchange-coinmarketcap/src/main/java/org/knowm/xchange/coinmarketcap/pro/v1/dto/marketdata/CmcStatus.java
|
CmcStatus
|
toString
|
class CmcStatus {
private final Date timestamp;
private final int errorCode;
private final String errorMessage;
private final int elapsed;
private final int creditCount;
public CmcStatus(
@JsonProperty("timestamp") @JsonDeserialize(using = ISO8601DateDeserializer.class)
Date timestamp,
@JsonProperty("error_code") int errorCode,
@JsonProperty("error_message") String errorMessage,
@JsonProperty("elapsed") int elapsed,
@JsonProperty("credit_count") int creditCount) {
this.timestamp = timestamp;
this.errorCode = errorCode;
this.errorMessage = errorMessage;
this.elapsed = elapsed;
this.creditCount = creditCount;
}
public Date getTimestamp() {
return timestamp;
}
public int getErrorCode() {
return errorCode;
}
public String getErrorMessage() {
return errorMessage;
}
public int getElapsed() {
return elapsed;
}
public int getCreditCount() {
return creditCount;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
return "CmcStatus{"
+ "timestamp='"
+ timestamp
+ '\''
+ ", errorCode="
+ errorCode
+ ", errorMessage='"
+ errorMessage
+ '\''
+ ", elapsed="
+ elapsed
+ ", creditCount="
+ creditCount
+ '}';
| 317
| 90
| 407
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-coinmarketcap/src/main/java/org/knowm/xchange/coinmarketcap/pro/v1/dto/marketdata/CmcUrls.java
|
CmcUrls
|
toString
|
class CmcUrls {
private final List<String> website;
private final List<String> explorer;
private final List<String> sourceCode;
private final List<String> messageBoard;
private final List<Object> chat;
private final List<Object> announcement;
private final List<String> reddit;
private final List<String> twitter;
public CmcUrls(
@JsonProperty("website") List<String> website,
@JsonProperty("explorer") List<String> explorer,
@JsonProperty("source_code") List<String> sourceCode,
@JsonProperty("message_board") List<String> messageBoard,
@JsonProperty("chat") List<Object> chat,
@JsonProperty("announcement") List<Object> announcement,
@JsonProperty("reddit") List<String> reddit,
@JsonProperty("twitter") List<String> twitter) {
this.website = website;
this.explorer = explorer;
this.sourceCode = sourceCode;
this.messageBoard = messageBoard;
this.chat = chat;
this.announcement = announcement;
this.reddit = reddit;
this.twitter = twitter;
}
public List<String> getWebsite() {
return website;
}
public List<String> getExplorer() {
return explorer;
}
public List<String> getSourceCode() {
return sourceCode;
}
public List<String> getMessageBoard() {
return messageBoard;
}
public List<Object> getChat() {
return chat;
}
public List<Object> getAnnouncement() {
return announcement;
}
public List<String> getReddit() {
return reddit;
}
public List<String> getTwitter() {
return twitter;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
return "CmcUrls{"
+ "website="
+ website
+ ", explorer="
+ explorer
+ ", sourceCode="
+ sourceCode
+ ", messageBoard="
+ messageBoard
+ ", chat="
+ chat
+ ", announcement="
+ announcement
+ ", reddit="
+ reddit
+ ", twitter="
+ twitter
+ '}';
| 522
| 121
| 643
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-coinmate/src/main/java/org/knowm/xchange/coinmate/service/CoinmateAccountService.java
|
CoinmateAccountService
|
requestDepositAddress
|
class CoinmateAccountService extends CoinmateAccountServiceRaw implements AccountService {
public static final int DEFAULT_RESULT_LIMIT = 100;
public CoinmateAccountService(Exchange exchange) {
super(exchange);
}
@Override
public AccountInfo getAccountInfo() throws IOException {
return new AccountInfo(CoinmateAdapters.adaptWallet(getCoinmateBalance()));
}
@Override
public Map<Instrument, Fee> getDynamicTradingFeesByInstrument() throws IOException {
Set<Instrument> instruments = exchange.getExchangeMetaData().getInstruments().keySet();
HashMap<Instrument, Fee> result = new HashMap<>();
for (Instrument instrument : instruments) {
CoinmateTradingFeesResponseData data =
getCoinmateTraderFees(CoinmateUtils.getPair(instrument));
Fee fee = new Fee(data.getMaker(), data.getTaker());
result.put(instrument, fee);
}
return result;
}
@Override
public String withdrawFunds(Currency currency, BigDecimal amount, String address)
throws IOException {
CoinmateTradeResponse response;
if (currency.equals(Currency.BTC)) {
response = coinmateBitcoinWithdrawal(amount, address);
} else if (currency.equals(Currency.LTC)) {
response = coinmateLitecoinWithdrawal(amount, address);
} else if (currency.equals(Currency.ETH)) {
response = coinmateEthereumWithdrawal(amount, address);
} else if (currency.equals(Currency.XRP)) {
response = coinmateRippleWithdrawal(amount, address);
} else if (currency.equals(Currency.ADA)) {
response = coinmateCardanoWithdrawal(amount, address);
} else if (currency.equals(Currency.SOL)) {
response = coinmateSolanaWithdrawal(amount, address);
} else if (currency.equals(Currency.USDT)) {
Long tradeId = coinmateWithdrawVirtualCurrency(amount, address, Currency.USDT.getCurrencyCode(), AmountType.GROSS, FeePriority.HIGH, null);
return Long.toString(tradeId);
} else {
throw new IOException(
"Wallet for currency" + currency.getCurrencyCode() + " is currently not supported");
}
return Long.toString(response.getData());
}
@Override
public String withdrawFunds(Currency currency, BigDecimal amount, AddressWithTag address)
throws IOException {
if (currency.equals(Currency.XRP)) {
Long tradeId = coinmateWithdrawVirtualCurrency(amount, address.getAddress(), currency.getCurrencyCode(), AmountType.GROSS, FeePriority.HIGH, address.getAddressTag());
return Long.toString(tradeId);
} else {
return withdrawFunds(currency, amount, address.getAddress());
}
}
@Override
public String withdrawFunds(WithdrawFundsParams params) throws IOException {
if (params instanceof DefaultWithdrawFundsParams) {
DefaultWithdrawFundsParams defaultParams = (DefaultWithdrawFundsParams) params;
if (defaultParams.getCurrency().equals(Currency.XRP)) {
Long tradeId = coinmateWithdrawVirtualCurrency(defaultParams.getAmount(), defaultParams.getAddress(), defaultParams.getCurrency().getCurrencyCode(), AmountType.GROSS, FeePriority.HIGH, defaultParams.getAddressTag());
return Long.toString(tradeId);
}
return withdrawFunds(
defaultParams.getCurrency(), defaultParams.getAmount(), defaultParams.getAddress());
}
throw new IllegalStateException("Don't know how to withdraw: " + params);
}
@Override
public String requestDepositAddress(Currency currency, String... args) throws IOException {<FILL_FUNCTION_BODY>}
@Override
public TradeHistoryParams createFundingHistoryParams() {
return new CoinmateFundingHistoryParams();
}
@Override
public List<FundingRecord> getFundingHistory(TradeHistoryParams params) throws IOException {
TradeHistoryParamsSorted.Order order = TradeHistoryParamsSorted.Order.asc;
Integer limit = 1000;
int offset = 0;
Long timestampFrom = null;
Long timestampTo = null;
if (params instanceof TradeHistoryParamsIdSpan) {
String transactionId = ((TradeHistoryParamsIdSpan) params).getStartId();
if (transactionId != null) {
CoinmateTransferDetail coinmateTransferDetail =
getCoinmateTransferDetail(toLong(transactionId));
return CoinmateAdapters.adaptFundingDetail(coinmateTransferDetail);
}
}
if (params instanceof TradeHistoryParamOffset) {
offset = Math.toIntExact(((TradeHistoryParamOffset) params).getOffset());
}
if (params instanceof TradeHistoryParamLimit) {
limit = ((TradeHistoryParamLimit) params).getLimit();
}
if (params instanceof TradeHistoryParamsSorted) {
order = ((TradeHistoryParamsSorted) params).getOrder();
}
if (params instanceof TradeHistoryParamsTimeSpan) {
TradeHistoryParamsTimeSpan thpts = (TradeHistoryParamsTimeSpan) params;
if (thpts.getStartTime() != null) {
timestampFrom = thpts.getStartTime().getTime();
}
if (thpts.getEndTime() != null) {
timestampTo = thpts.getEndTime().getTime();
}
}
CoinmateTransferHistory coinmateTransferHistory =
getTransfersData(limit, timestampFrom, timestampTo);
CoinmateTransactionHistory coinmateTransactionHistory =
getCoinmateTransactionHistory(
offset,
limit,
CoinmateAdapters.adaptSortOrder(order),
timestampFrom,
timestampTo,
null);
return CoinmateAdapters.adaptFundingHistory(
coinmateTransactionHistory, coinmateTransferHistory);
}
public static class CoinmateFundingHistoryParams
extends CoinmateTradeService.CoinmateTradeHistoryHistoryParams {}
}
|
CoinmateDepositAddresses addresses;
if (currency.equals(Currency.BTC)) {
addresses = coinmateBitcoinDepositAddresses();
} else if (currency.equals(Currency.LTC)) {
addresses = coinmateLitecoinDepositAddresses();
} else if (currency.equals(Currency.ETH)) {
addresses = coinmateEthereumDepositAddresses();
} else if (currency.equals(Currency.XRP)) {
addresses = coinmateRippleDepositAddresses();
} else if (currency.equals(Currency.ADA)) {
addresses = coinmateCardanoDepositAddresses();
} else if (currency.equals(Currency.SOL)) {
addresses = coinmateSolanaDepositAddresses();
} else if (currency.equals(Currency.USDT)) {
List<String> addressesAll = coinmateVirtualCurrencyDepositAddresses(currency.getCurrencyCode());
if (addressesAll.isEmpty()) {
return null;
}
return addressesAll.get(0);
} else {
throw new IOException(
"Wallet for currency" + currency.getCurrencyCode() + " is currently not supported");
}
if (addresses.getData().isEmpty()) {
return null;
} else {
// here we return only the first address
return addresses.getData().get(0);
}
| 1,618
| 360
| 1,978
|
<methods>public void <init>(org.knowm.xchange.Exchange) ,public org.knowm.xchange.coinmate.dto.account.CoinmateDepositAddresses coinmateBitcoinDepositAddresses() throws java.io.IOException,public org.knowm.xchange.coinmate.dto.trade.CoinmateTradeResponse coinmateBitcoinWithdrawal(java.math.BigDecimal, java.lang.String) throws java.io.IOException,public org.knowm.xchange.coinmate.dto.trade.CoinmateTradeResponse coinmateBitcoinWithdrawal(java.math.BigDecimal, java.lang.String, org.knowm.xchange.coinmate.dto.account.FeePriority) throws java.io.IOException,public org.knowm.xchange.coinmate.dto.account.CoinmateDepositAddresses coinmateCardanoDepositAddresses() throws java.io.IOException,public org.knowm.xchange.coinmate.dto.trade.CoinmateTradeResponse coinmateCardanoWithdrawal(java.math.BigDecimal, java.lang.String) throws java.io.IOException,public org.knowm.xchange.coinmate.dto.account.CoinmateDepositAddresses coinmateEthereumDepositAddresses() throws java.io.IOException,public org.knowm.xchange.coinmate.dto.trade.CoinmateTradeResponse coinmateEthereumWithdrawal(java.math.BigDecimal, java.lang.String) throws java.io.IOException,public org.knowm.xchange.coinmate.dto.account.CoinmateDepositAddresses coinmateLitecoinDepositAddresses() throws java.io.IOException,public org.knowm.xchange.coinmate.dto.trade.CoinmateTradeResponse coinmateLitecoinWithdrawal(java.math.BigDecimal, java.lang.String) throws java.io.IOException,public org.knowm.xchange.coinmate.dto.account.CoinmateDepositAddresses coinmateRippleDepositAddresses() throws java.io.IOException,public org.knowm.xchange.coinmate.dto.trade.CoinmateTradeResponse coinmateRippleWithdrawal(java.math.BigDecimal, java.lang.String) throws java.io.IOException,public org.knowm.xchange.coinmate.dto.account.CoinmateDepositAddresses coinmateSolanaDepositAddresses() throws java.io.IOException,public org.knowm.xchange.coinmate.dto.trade.CoinmateTradeResponse coinmateSolanaWithdrawal(java.math.BigDecimal, java.lang.String) throws java.io.IOException,public List<org.knowm.xchange.coinmate.dto.account.UnconfirmedDeposits> coinmateUnconfirmedVirtualCurrencyDeposits(java.lang.String) throws java.io.IOException,public ArrayList<java.lang.String> coinmateVirtualCurrencyDepositAddresses(java.lang.String) throws java.io.IOException,public java.lang.Long coinmateWithdrawVirtualCurrency(java.math.BigDecimal, java.lang.String, java.lang.String, org.knowm.xchange.coinmate.dto.account.AmountType, org.knowm.xchange.coinmate.dto.account.FeePriority, java.lang.String) throws java.io.IOException,public org.knowm.xchange.coinmate.dto.account.CoinmateBalance getCoinmateBalance() throws java.io.IOException,public org.knowm.xchange.coinmate.dto.account.CoinmateTradingFeesResponseData getCoinmateTraderFees(java.lang.String) throws java.io.IOException,public org.knowm.xchange.coinmate.dto.trade.CoinmateTransactionHistory getCoinmateTransactionHistory(int, java.lang.Integer, java.lang.String, java.lang.Long, java.lang.Long, java.lang.String) throws java.io.IOException,public org.knowm.xchange.coinmate.dto.trade.CoinmateTransferDetail getCoinmateTransferDetail(java.lang.Long) throws java.io.IOException,public org.knowm.xchange.coinmate.dto.trade.CoinmateTransferHistory getCoinmateTransferHistory(java.lang.Integer, java.lang.Integer, org.knowm.xchange.coinmate.dto.account.TransferHistoryOrder, java.lang.Long, java.lang.Long, java.lang.String) throws java.io.IOException,public org.knowm.xchange.coinmate.dto.trade.CoinmateTransferHistory getTransfersData(java.lang.Integer, java.lang.Long, java.lang.Long) throws java.io.IOException<variables>private final non-sealed org.knowm.xchange.coinmate.CoinmateAuthenticated coinmateAuthenticated,private final non-sealed org.knowm.xchange.coinmate.service.CoinmateDigest signatureCreator
|
knowm_XChange
|
XChange/xchange-coinmate/src/main/java/org/knowm/xchange/coinmate/service/CoinmateMarketDataService.java
|
CoinmateMarketDataService
|
getTrades
|
class CoinmateMarketDataService extends CoinmateMarketDataServiceRaw
implements MarketDataService {
private static final int TRANSACTIONS_MINUTES_INTO_HISTORY = 60;
public CoinmateMarketDataService(Exchange exchange) {
super(exchange);
}
@Override
public Ticker getTicker(CurrencyPair currencyPair, Object... args) throws IOException {
return CoinmateAdapters.adaptTicker(
getCoinmateTicker(CoinmateUtils.getPair(currencyPair)), currencyPair);
}
@Override
public List<Ticker> getTickers(Params params) throws IOException {
return CoinmateAdapters.adaptTickers(getCoinmateTickers());
}
@Override
public OrderBook getOrderBook(CurrencyPair currencyPair, Object... args) throws IOException {
return CoinmateAdapters.adaptOrderBook(
getCoinmateOrderBook(CoinmateUtils.getPair(currencyPair), true), currencyPair);
}
@Override
public Trades getTrades(CurrencyPair currencyPair, Object... args) throws IOException {<FILL_FUNCTION_BODY>}
}
|
int minutesIntoHistory = TRANSACTIONS_MINUTES_INTO_HISTORY;
if (args.length == 1 && (args[0] instanceof Integer)) {
minutesIntoHistory = (int) args[0];
}
return CoinmateAdapters.adaptTrades(
getCoinmateTransactions(minutesIntoHistory, CoinmateUtils.getPair(currencyPair)));
| 308
| 104
| 412
|
<methods>public void <init>(org.knowm.xchange.Exchange) ,public org.knowm.xchange.coinmate.dto.marketdata.CoinmateQuickRate getCoinmateBuyQuickRate(java.math.BigDecimal, java.lang.String) throws java.io.IOException,public org.knowm.xchange.coinmate.dto.marketdata.CoinmateOrderBook getCoinmateOrderBook(java.lang.String, boolean) throws java.io.IOException,public org.knowm.xchange.coinmate.dto.marketdata.CoinmateQuickRate getCoinmateSellQuickRate(java.math.BigDecimal, java.lang.String) throws java.io.IOException,public org.knowm.xchange.coinmate.dto.marketdata.CoinmateTicker getCoinmateTicker(java.lang.String) throws java.io.IOException,public org.knowm.xchange.coinmate.dto.marketdata.CoinmateTickers getCoinmateTickers() throws java.io.IOException,public org.knowm.xchange.coinmate.dto.marketdata.CoinmateTransactions getCoinmateTransactions(int, java.lang.String) throws java.io.IOException<variables>private final non-sealed org.knowm.xchange.coinmate.Coinmate coinmate
|
knowm_XChange
|
XChange/xchange-coinone/src/main/java/org/knowm/xchange/coinone/dto/marketdata/CoinoneOrderBookData.java
|
CoinoneOrderBookData
|
toString
|
class CoinoneOrderBookData {
private final BigDecimal price;
private final BigDecimal qty;
/**
* @param price
* @param qty
*/
public CoinoneOrderBookData(
@JsonProperty("price") String price, @JsonProperty("qty") String qty) {
this.price = new BigDecimal(price);
this.qty = new BigDecimal(qty);
}
public BigDecimal getPrice() {
return price;
}
public BigDecimal getQty() {
return qty;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
return "CoinoneOrderBook{" + "price=" + price + ", qty=" + qty + "}";
| 180
| 34
| 214
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-coinone/src/main/java/org/knowm/xchange/coinone/service/CoinoneMarketDataService.java
|
CoinoneMarketDataService
|
getTrades
|
class CoinoneMarketDataService extends CoinoneMarketDataServiceRaw
implements MarketDataService {
/**
* Constructor
*
* @param exchange
*/
public CoinoneMarketDataService(Exchange exchange) {
super(exchange);
}
@Override
public Ticker getTicker(CurrencyPair currencyPair, Object... args) throws IOException {
return CoinoneAdapters.adaptTicker(super.getTicker(currencyPair));
}
@Override
public OrderBook getOrderBook(CurrencyPair currencyPair, Object... args)
throws ExchangeException,
NotAvailableFromExchangeException,
NotYetImplementedForExchangeException,
IOException {
return CoinoneAdapters.adaptOrderBook(getCoinoneOrderBook(currencyPair), currencyPair);
}
@Override
public Trades getTrades(CurrencyPair currencyPair, Object... args)
throws ExchangeException,
NotAvailableFromExchangeException,
NotYetImplementedForExchangeException,
IOException {<FILL_FUNCTION_BODY>}
}
|
String period = "hour";
if (args[0] != null) {
try {
period = CoinoneExchange.period.valueOf(args[0].toString()).name();
} catch (IllegalArgumentException e) {
}
}
return CoinoneAdapters.adaptTrades(super.getTrades(currencyPair, period), currencyPair);
| 280
| 96
| 376
|
<methods>public void <init>(org.knowm.xchange.Exchange) ,public org.knowm.xchange.coinone.dto.marketdata.CoinoneOrderBook getCoinoneOrderBook(org.knowm.xchange.currency.CurrencyPair) throws java.io.IOException,public org.knowm.xchange.coinone.dto.marketdata.CoinoneTicker getTicker(org.knowm.xchange.currency.CurrencyPair) throws java.io.IOException,public org.knowm.xchange.coinone.dto.marketdata.CoinoneTrades getTrades(org.knowm.xchange.currency.CurrencyPair, java.lang.String) throws java.io.IOException<variables>
|
knowm_XChange
|
XChange/xchange-core/src/main/java/org/knowm/xchange/client/ResilienceRegistries.java
|
ResilienceRegistries
|
retryRegistryOf
|
class ResilienceRegistries {
public static final RetryConfig DEFAULT_RETRY_CONFIG =
RetryConfig.custom()
.maxAttempts(3)
.intervalFunction(IntervalFunction.ofExponentialBackoff(Duration.ofMillis(50), 4))
.retryExceptions(
IOException.class,
ExchangeUnavailableException.class,
InternalServerException.class,
OperationTimeoutException.class)
.build();
public static final String NON_IDEMPOTENT_CALLS_RETRY_CONFIG_NAME = "nonIdempotentCallsBase";
/**
* Suggested for calls that are not idempotent like placing order or withdrawing funds
*
* <p>Well designed exchange APIs will have mechanisms that make even placing orders idempotent.
* Most however cannot handle retries on this type of calls and if you do one after a socket read
* timeout for eq. then this may result in placing two identical orders instead of one. For such
* exchanged this retry configuration is recommended.
*/
public static final RetryConfig DEFAULT_NON_IDEMPOTENT_CALLS_RETRY_CONFIG =
RetryConfig.from(DEFAULT_RETRY_CONFIG)
.retryExceptions(
UnknownHostException.class, SocketException.class, ExchangeUnavailableException.class)
.build();
public static final RateLimiterConfig DEFAULT_GLOBAL_RATE_LIMITER_CONFIG =
RateLimiterConfig.custom()
.timeoutDuration(Duration.ofSeconds(30))
.limitRefreshPeriod(Duration.ofMinutes(1))
.limitForPeriod(1200)
.build();
private final RetryRegistry retryRegistry;
private final RateLimiterRegistry rateLimiterRegistry;
public ResilienceRegistries() {
this(DEFAULT_RETRY_CONFIG, DEFAULT_NON_IDEMPOTENT_CALLS_RETRY_CONFIG);
}
public ResilienceRegistries(
RetryConfig globalRetryConfig, RetryConfig nonIdempotentCallsRetryConfig) {
this(globalRetryConfig, nonIdempotentCallsRetryConfig, DEFAULT_GLOBAL_RATE_LIMITER_CONFIG);
}
public ResilienceRegistries(
RetryConfig globalRetryConfig,
RetryConfig nonIdempotentCallsRetryConfig,
RateLimiterConfig globalRateLimiterConfig) {
this(
retryRegistryOf(globalRetryConfig, nonIdempotentCallsRetryConfig),
RateLimiterRegistry.of(globalRateLimiterConfig));
}
public ResilienceRegistries(
RetryRegistry retryRegistry, RateLimiterRegistry rateLimiterRegistry) {
this.retryRegistry = retryRegistry;
this.rateLimiterRegistry = rateLimiterRegistry;
}
public RetryRegistry retries() {
return retryRegistry;
}
public RateLimiterRegistry rateLimiters() {
return rateLimiterRegistry;
}
private static RetryRegistry retryRegistryOf(
RetryConfig globalRetryConfig, RetryConfig nonIdempotentCallsRetryConfig) {<FILL_FUNCTION_BODY>}
}
|
RetryRegistry registry = RetryRegistry.of(globalRetryConfig);
registry.addConfiguration(
NON_IDEMPOTENT_CALLS_RETRY_CONFIG_NAME, nonIdempotentCallsRetryConfig);
return registry;
| 828
| 64
| 892
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-core/src/main/java/org/knowm/xchange/client/ResilienceUtils.java
|
DecorateCallableApi
|
withRetry
|
class DecorateCallableApi<T> {
private final ExchangeSpecification.ResilienceSpecification resilienceSpecification;
private CallableApi<T> callable;
private DecorateCallableApi(
ExchangeSpecification.ResilienceSpecification resilienceSpecification,
CallableApi<T> callable) {
this.resilienceSpecification = resilienceSpecification;
this.callable = callable;
}
public DecorateCallableApi<T> withRetry(Retry retryContext) {<FILL_FUNCTION_BODY>}
public DecorateCallableApi<T> withRateLimiter(RateLimiter rateLimiter) {
if (resilienceSpecification.isRateLimiterEnabled()) {
return this.withRateLimiter(rateLimiter, 1);
}
return this;
}
public DecorateCallableApi<T> withRateLimiter(RateLimiter rateLimiter, int permits) {
if (resilienceSpecification.isRateLimiterEnabled()) {
this.callable =
CallableApi.wrapCallable(
RateLimiter.decorateCallable(rateLimiter, permits, this.callable));
}
return this;
}
public T call() throws IOException {
return this.callable.call();
}
}
|
if (resilienceSpecification.isRetryEnabled()) {
this.callable =
CallableApi.wrapCallable(Retry.decorateCallable(retryContext, this.callable));
}
return this;
| 348
| 61
| 409
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-core/src/main/java/org/knowm/xchange/derivative/FuturesContract.java
|
FuturesContract
|
equals
|
class FuturesContract extends Instrument
implements Derivative, Comparable<FuturesContract>, Serializable {
private static final long serialVersionUID = 6876906648149216819L;
private static final Comparator<FuturesContract> COMPARATOR =
Comparator.comparing(FuturesContract::getCurrencyPair)
.thenComparing(FuturesContract::getPrompt);
/** The CurrencyPair the FuturesContract is based upon */
private final CurrencyPair currencyPair;
/** The Date when the FuturesContract expires, when null it is perpetual */
private final String prompt;
public FuturesContract(CurrencyPair currencyPair, String prompt) {
this.currencyPair = currencyPair;
this.prompt = prompt;
}
@JsonCreator
public FuturesContract(final String symbol) {
String[] parts = symbol.split("/");
if (parts.length < 3) {
throw new IllegalArgumentException("Could not parse futures contract from '" + symbol + "'");
}
String base = parts[0];
String counter = parts[1];
String prompt = parts[2];
this.currencyPair = new CurrencyPair(base, counter);
this.prompt = prompt;
}
@Override
public CurrencyPair getCurrencyPair() {
return currencyPair;
}
public String getPrompt() {
return prompt;
}
public boolean isPerpetual() {
return this.prompt.matches("(?i)PERP|SWAP|PERPETUAL");
}
@Override
public int compareTo(final FuturesContract that) {
return COMPARATOR.compare(this, that);
}
@Override
public boolean equals(final Object o) {<FILL_FUNCTION_BODY>}
@Override
public int hashCode() {
return Objects.hash(currencyPair, prompt);
}
@Override
public Currency getBase() {
return currencyPair.base;
}
@Override
public Currency getCounter() {
return currencyPair.counter;
}
@JsonValue
@Override
public String toString() {
return currencyPair + "/" + prompt;
}
}
|
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
final FuturesContract contract = (FuturesContract) o;
return Objects.equals(currencyPair, contract.currencyPair)
&& Objects.equals(prompt, contract.prompt);
| 588
| 82
| 670
|
<methods>public non-sealed void <init>() ,public abstract org.knowm.xchange.currency.Currency getBase() ,public abstract org.knowm.xchange.currency.Currency getCounter() <variables>private static final long serialVersionUID
|
knowm_XChange
|
XChange/xchange-core/src/main/java/org/knowm/xchange/dto/account/Fee.java
|
Fee
|
equals
|
class Fee implements Serializable {
private static final long serialVersionUID = -6235230375777573680L;
@JsonProperty("maker_fee")
private final BigDecimal makerFee;
@JsonProperty("taker_fee")
private final BigDecimal takerFee;
public Fee(BigDecimal makerFee, BigDecimal takerFee) {
this.makerFee = makerFee;
this.takerFee = takerFee;
}
public BigDecimal getMakerFee() {
return makerFee;
}
public BigDecimal getTakerFee() {
return takerFee;
}
@Override
public String toString() {
return "Fee [makerFee=" + makerFee + ", takerFee=" + takerFee + "]";
}
@Override
public boolean equals(Object obj) {<FILL_FUNCTION_BODY>}
@Override
public int hashCode() {
return makerFee.hashCode() + 31 * takerFee.hashCode();
}
}
|
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
Fee other = (Fee) obj;
return other.makerFee.equals(makerFee) && other.takerFee.equals(takerFee);
| 306
| 102
| 408
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-core/src/main/java/org/knowm/xchange/dto/account/FundingRecord.java
|
Builder
|
build
|
class Builder {
private String address;
private String addressTag;
private Date date;
private Currency currency;
private BigDecimal amount;
private String internalId;
private String blockchainTransactionHash;
private String description;
private Type type;
private Status status;
private BigDecimal balance;
private BigDecimal fee;
public static Builder from(FundingRecord record) {
return new Builder()
.setAddress(record.address)
.setAddressTag(record.addressTag)
.setBlockchainTransactionHash(record.blockchainTransactionHash)
.setDate(record.date)
.setCurrency(record.currency)
.setAmount(record.amount)
.setInternalId(record.internalId)
.setDescription(record.description)
.setType(record.type)
.setStatus(record.status)
.setBalance(record.balance)
.setFee(record.fee);
}
public Builder setAddress(String address) {
this.address = address;
return this;
}
public Builder setAddressTag(String addressTag) {
this.addressTag = addressTag;
return this;
}
public Builder setDate(Date date) {
this.date = date;
return this;
}
public Builder setCurrency(Currency currency) {
this.currency = currency;
return this;
}
public Builder setAmount(BigDecimal amount) {
this.amount = amount;
return this;
}
public Builder setInternalId(String internalId) {
this.internalId = internalId;
return this;
}
public Builder setBlockchainTransactionHash(String blockchainTransactionHash) {
this.blockchainTransactionHash = blockchainTransactionHash;
return this;
}
public Builder setDescription(String description) {
this.description = description;
return this;
}
public Builder setType(Type type) {
this.type = type;
return this;
}
public Builder setStatus(Status status) {
this.status = status;
return this;
}
public Builder setBalance(BigDecimal balance) {
this.balance = balance;
return this;
}
public Builder setFee(BigDecimal fee) {
this.fee = fee;
return this;
}
public FundingRecord build() {<FILL_FUNCTION_BODY>}
}
|
return new FundingRecord(
address,
addressTag,
date,
currency,
amount,
internalId,
blockchainTransactionHash,
type,
status,
balance,
fee,
description);
| 639
| 64
| 703
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-core/src/main/java/org/knowm/xchange/dto/meta/CurrencyMetaData.java
|
CurrencyMetaData
|
toString
|
class CurrencyMetaData implements Serializable {
private static final long serialVersionUID = -247899067657358542L;
@JsonProperty("scale")
private final Integer scale;
/** Withdrawal fee */
@JsonProperty("withdrawal_fee")
private final BigDecimal withdrawalFee;
/** Minimum withdrawal amount */
@JsonProperty("min_withdrawal_amount")
private final BigDecimal minWithdrawalAmount;
/** Wallet health */
@JsonProperty("wallet_health")
private WalletHealth walletHealth;
/**
* Constructor
*
* @param scale
* @param withdrawalFee
*/
public CurrencyMetaData(Integer scale, BigDecimal withdrawalFee) {
this(scale, withdrawalFee, null);
}
/**
* Constructor
*
* @param scale
* @param withdrawalFee
* @param minWithdrawalAmount
*/
public CurrencyMetaData(Integer scale, BigDecimal withdrawalFee, BigDecimal minWithdrawalAmount) {
this(scale, withdrawalFee, minWithdrawalAmount, WalletHealth.UNKNOWN);
}
/**
* Constructor
*
* @param scale
*/
public CurrencyMetaData(
@JsonProperty("scale") Integer scale,
@JsonProperty("withdrawal_fee") BigDecimal withdrawalFee,
@JsonProperty("min_withdrawal_amount") BigDecimal minWithdrawalAmount,
@JsonProperty("wallet_health") WalletHealth walletHealth) {
this.scale = scale;
this.withdrawalFee = withdrawalFee;
this.minWithdrawalAmount = minWithdrawalAmount;
this.walletHealth = walletHealth;
}
public Integer getScale() {
return scale;
}
public BigDecimal getWithdrawalFee() {
return withdrawalFee;
}
public BigDecimal getMinWithdrawalAmount() {
return minWithdrawalAmount;
}
public WalletHealth getWalletHealth() {
return walletHealth;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
return "CurrencyMetaData ["
+ "scale="
+ scale
+ ", withdrawalFee="
+ withdrawalFee
+ ", minWithdrawalAmount="
+ minWithdrawalAmount
+ ", walletHealth="
+ walletHealth
+ "]";
| 594
| 78
| 672
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-core/src/main/java/org/knowm/xchange/dto/meta/RateLimit.java
|
RateLimit
|
toString
|
class RateLimit implements Serializable {
private static final long serialVersionUID = 90431040086828390L;
@JsonProperty("calls")
public int calls = 1;
@JsonProperty("time_span")
public int timeSpan = 1;
@JsonProperty("time_unit")
@JsonDeserialize(using = TimeUnitDeserializer.class)
public TimeUnit timeUnit = TimeUnit.SECONDS;
/** Constructor */
public RateLimit() {}
/**
* Constructor
*
* @param calls
* @param timeSpan
* @param timeUnit
*/
public RateLimit(
@JsonProperty("calls") int calls,
@JsonProperty("time_span") int timeSpan,
@JsonProperty("time_unit") @JsonDeserialize(using = TimeUnitDeserializer.class)
TimeUnit timeUnit) {
this.calls = calls;
this.timeUnit = timeUnit;
this.timeSpan = timeSpan;
}
/**
* @return this rate limit as a number of milliseconds required between any two remote calls,
* assuming the client makes consecutive calls without any bursts or breaks for an infinite
* period of time.
*/
@JsonIgnore
public long getPollDelayMillis() {
return timeUnit.toMillis(timeSpan) / calls;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
public static class TimeUnitDeserializer extends JsonDeserializer<TimeUnit> {
@Override
public TimeUnit deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
return TimeUnit.valueOf(jp.getValueAsString().toUpperCase());
}
}
}
|
return "RateLimit [calls=" + calls + ", timeSpan=" + timeSpan + ", timeUnit=" + timeUnit + "]";
| 463
| 38
| 501
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-core/src/main/java/org/knowm/xchange/service/trade/params/MoneroWithdrawFundsParams.java
|
MoneroWithdrawFundsParams
|
toString
|
class MoneroWithdrawFundsParams extends DefaultWithdrawFundsParams {
@Nullable public final String paymentId; // optional
public MoneroWithdrawFundsParams(String address, Currency currency, BigDecimal amount) {
this(address, currency, amount, null);
}
public MoneroWithdrawFundsParams(
String address, Currency currency, BigDecimal amount, String paymentId) {
super(address, currency, amount);
this.paymentId = paymentId;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
@Nullable
public String getPaymentId() {
return paymentId;
}
}
|
return "MoneroWithdrawFundsParams{"
+ "address='"
+ getAddress()
+ '\''
+ ", paymentId='"
+ getPaymentId()
+ '\''
+ ", currency="
+ getCurrency()
+ ", amount="
+ getAmount()
+ ", commission="
+ getCommission()
+ '}';
| 179
| 102
| 281
|
<methods>public void <init>(java.lang.String, org.knowm.xchange.currency.Currency, java.math.BigDecimal) ,public void <init>(org.knowm.xchange.dto.account.AddressWithTag, org.knowm.xchange.currency.Currency, java.math.BigDecimal) ,public void <init>(java.lang.String, org.knowm.xchange.currency.Currency, java.math.BigDecimal, java.math.BigDecimal) ,public void <init>(org.knowm.xchange.dto.account.AddressWithTag, org.knowm.xchange.currency.Currency, java.math.BigDecimal, java.math.BigDecimal) ,public void <init>(java.lang.String, java.lang.String, org.knowm.xchange.currency.Currency, java.math.BigDecimal, java.math.BigDecimal) <variables>java.lang.String address,java.lang.String addressTag,java.math.BigDecimal amount,java.math.BigDecimal commission,org.knowm.xchange.currency.Currency currency
|
knowm_XChange
|
XChange/xchange-core/src/main/java/org/knowm/xchange/service/trade/params/RippleWithdrawFundsParams.java
|
RippleWithdrawFundsParams
|
toString
|
class RippleWithdrawFundsParams extends DefaultWithdrawFundsParams {
@Nullable public final String tag; // optional
public RippleWithdrawFundsParams(String address, Currency currency, BigDecimal amount) {
this(address, currency, amount, null);
}
public RippleWithdrawFundsParams(
String address, Currency currency, BigDecimal amount, String tag) {
super(address, tag, currency, amount, null);
this.tag = tag;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
@Nullable
public String getTag() {
return tag;
}
}
|
return "RippleWithdrawFundsParams{"
+ "address='"
+ getAddress()
+ '\''
+ ", tag='"
+ getTag()
+ '\''
+ ", currency="
+ getCurrency()
+ ", amount="
+ getAmount()
+ ", commission="
+ getCommission()
+ '}';
| 175
| 100
| 275
|
<methods>public void <init>(java.lang.String, org.knowm.xchange.currency.Currency, java.math.BigDecimal) ,public void <init>(org.knowm.xchange.dto.account.AddressWithTag, org.knowm.xchange.currency.Currency, java.math.BigDecimal) ,public void <init>(java.lang.String, org.knowm.xchange.currency.Currency, java.math.BigDecimal, java.math.BigDecimal) ,public void <init>(org.knowm.xchange.dto.account.AddressWithTag, org.knowm.xchange.currency.Currency, java.math.BigDecimal, java.math.BigDecimal) ,public void <init>(java.lang.String, java.lang.String, org.knowm.xchange.currency.Currency, java.math.BigDecimal, java.math.BigDecimal) <variables>java.lang.String address,java.lang.String addressTag,java.math.BigDecimal amount,java.math.BigDecimal commission,org.knowm.xchange.currency.Currency currency
|
knowm_XChange
|
XChange/xchange-core/src/main/java/org/knowm/xchange/utils/ArrayUtils.java
|
ArrayUtils
|
getElement
|
class ArrayUtils {
public static <T> T getElement(int index, Object[] array, Class<T> expectedType) {
return getElement(index, array, expectedType, null, false);
}
public static <T> T getElement(int index, Object[] array, Class<T> expectedType, T defaultValue) {
return getElement(index, array, expectedType, defaultValue, false);
}
public static <T> T getElement(
int index, Object[] array, Class<T> expectedType, boolean errorIfNull) {
return getElement(index, array, expectedType, null, errorIfNull);
}
@SuppressWarnings("unchecked")
private static <T> T getElement(
int index, Object[] array, Class<T> expectedType, T defaultValue, boolean errorIfNull) {<FILL_FUNCTION_BODY>}
}
|
T result;
if (array == null) {
array = new Object[0];
}
if (index < 0 || index > array.length - 1) {
result = null;
} else {
Object arrayElement = array[index];
if (arrayElement != null && !expectedType.isAssignableFrom(arrayElement.getClass())) {
throw new ExchangeException(
String.format(
"Array[%d] element expected type is %s but actual is %s",
index, expectedType.getName(), arrayElement.getClass().getName()));
}
result = (T) arrayElement;
}
if (result == null) {
if (defaultValue != null) {
result = defaultValue;
}
if (errorIfNull && result == null) {
throw new ExchangeException("Array[" + index + "] element is NULL");
}
}
return result;
| 223
| 236
| 459
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-core/src/main/java/org/knowm/xchange/utils/AuthUtils.java
|
AuthUtils
|
getSecretProperties
|
class AuthUtils {
/**
* Generates a BASE64 Basic Authentication String
*
* @return BASE64 Basic Authentication String
*/
public static String getBasicAuth(String user, final String pass) {
return "Basic " + java.util.Base64.getEncoder().encodeToString((user + ":" + pass).getBytes());
}
/**
* Read the API & Secret key from a resource called {@code secret.keys}. NOTE: This file MUST
* NEVER be commited to source control. It is therefore added to .gitignore.
*/
public static void setApiAndSecretKey(ExchangeSpecification exchangeSpec) {
setApiAndSecretKey(exchangeSpec, null);
}
/**
* Read the API & Secret key from a resource called {@code prefix}-{@code secret.keys}. NOTE: This
* file MUST NEVER be commited to source control. It is therefore added to .gitignore.
*/
public static void setApiAndSecretKey(ExchangeSpecification exchangeSpec, String prefix) {
Properties props = getSecretProperties(prefix);
if (props != null) {
exchangeSpec.setApiKey(props.getProperty("apiKey"));
exchangeSpec.setSecretKey(props.getProperty("secretKey"));
}
}
/**
* Read the secret properties from a resource called {@code prefix}-{@code secret.keys}. NOTE:
* This file MUST NEVER be commited to source control. It is therefore added to .gitignore.
*
* @return The properties or null
*/
public static Properties getSecretProperties(String prefix) {<FILL_FUNCTION_BODY>}
}
|
String resource = prefix != null ? prefix + "-secret.keys" : "secret.keys";
// First try to find the keys in the classpath
InputStream inStream = AuthUtils.class.getResourceAsStream("/" + resource);
// Next try to find the keys in the user's home/.ssh dir
File keyfile = new File(System.getProperty("user.home") + "/" + ".ssh", resource);
if (inStream == null && keyfile.isFile()) {
try {
inStream = new FileInputStream(keyfile);
} catch (IOException e) {
// do nothing
}
}
Properties props = null;
if (inStream != null) {
try {
props = new Properties();
props.load(inStream);
return props;
} catch (IOException e) {
// do nothing
}
}
return props;
| 426
| 229
| 655
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-core/src/main/java/org/knowm/xchange/utils/BigDecimalUtils.java
|
BigDecimalUtils
|
roundToStepSize
|
class BigDecimalUtils {
private BigDecimalUtils() {}
public static BigDecimal roundToStepSize(BigDecimal value, BigDecimal stepSize) {
return roundToStepSize(value, stepSize, RoundingMode.HALF_DOWN);
}
public static BigDecimal roundToStepSize(
BigDecimal value, BigDecimal stepSize, RoundingMode roundingMode) {<FILL_FUNCTION_BODY>}
}
|
BigDecimal divided = value.divide(stepSize, MathContext.DECIMAL64).setScale(0, roundingMode);
return divided.multiply(stepSize, MathContext.DECIMAL64).stripTrailingZeros();
| 117
| 65
| 182
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-core/src/main/java/org/knowm/xchange/utils/OrderValuesHelper.java
|
OrderValuesHelper
|
adjustPrice
|
class OrderValuesHelper {
private final InstrumentMetaData metaData;
public OrderValuesHelper(InstrumentMetaData metaData) {
this.metaData = metaData;
}
/**
* @return true if the minimum amount is specified in the currency pair and if the amount is under
* it
*/
public boolean amountUnderMinimum(BigDecimal amount) {
BigDecimal minimalAmount = metaData.getMinimumAmount();
if (minimalAmount == null) {
return false;
}
return amount.compareTo(minimalAmount) < 0;
}
/**
* Adjusts the given amount to the restrictions dictated by {@link InstrumentMetaData}.
*
* <p>This mainly does rounding based on {@link InstrumentMetaData#getVolumeScale()} and {@link
* InstrumentMetaData#getAmountStepSize()} if they are present in the metadata. It will also
* return the maximum allowed amount if {@link InstrumentMetaData#getMaximumAmount() ()} is set
* and your amount is greater.
*
* @param amount the amount your derived from your users input or your calculations
* @return amount adjusted to the restrictions dictated by {@link InstrumentMetaData}
*/
public BigDecimal adjustAmount(BigDecimal amount) {
BigDecimal maximumAmount = metaData.getMaximumAmount();
if (maximumAmount != null && amount.compareTo(maximumAmount) > 0) {
return maximumAmount;
}
BigDecimal result = amount;
BigDecimal stepSize = metaData.getAmountStepSize();
if (stepSize != null && stepSize.compareTo(BigDecimal.ZERO) != 0) {
result = BigDecimalUtils.roundToStepSize(result, stepSize, RoundingMode.FLOOR);
}
Integer baseScale = metaData.getVolumeScale();
if (baseScale != null) {
result = result.setScale(baseScale, RoundingMode.FLOOR);
}
return result;
}
/**
* Adjusts the given price to the restrictions dictated by {@link InstrumentMetaData}.
*
* <p>Convenience method that chooses the adequate rounding mode for you order type. See {@link
* #adjustPrice(java.math.BigDecimal, java.math.RoundingMode)} for more information.
*
* @see #adjustPrice(java.math.BigDecimal, java.math.RoundingMode)
*/
public BigDecimal adjustPrice(BigDecimal price, Order.OrderType orderType) {
return adjustPrice(
price,
orderType == Order.OrderType.ASK || orderType == Order.OrderType.EXIT_ASK
? RoundingMode.CEILING
: RoundingMode.FLOOR);
}
/**
* Adjusts the given price to the restrictions dictated by {@link InstrumentMetaData}.
*
* <p>This mainly does rounding based on {@link InstrumentMetaData#getPriceScale()} if it is
* present in the metadata.
*
* @param price the price your derived from your users input or your calculations
* @return price adjusted to the restrictions dictated by {@link InstrumentMetaData}
*/
public BigDecimal adjustPrice(BigDecimal price, RoundingMode roundingMode) {<FILL_FUNCTION_BODY>}
}
|
BigDecimal result = price;
Integer scale = metaData.getPriceScale();
if (scale != null) {
result = result.setScale(scale, roundingMode);
}
return result;
| 850
| 57
| 907
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-core/src/main/java/org/knowm/xchange/utils/jackson/UnixTimestampNanoSecondsDeserializer.java
|
UnixTimestampNanoSecondsDeserializer
|
deserialize
|
class UnixTimestampNanoSecondsDeserializer extends JsonDeserializer<Date> {
@Override
public Date deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {<FILL_FUNCTION_BODY>}
}
|
String value = jp.getValueAsString();
long valueWithMilliseconds =
new BigDecimal(value).multiply(BigDecimal.valueOf(1000)).longValue();
return DateUtils.fromUnixTimeWithMilliseconds(valueWithMilliseconds);
| 63
| 73
| 136
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-core/src/main/java/org/knowm/xchange/utils/nonce/TimestampIncrementingNonceFactory.java
|
TimestampIncrementingNonceFactory
|
createValue
|
class TimestampIncrementingNonceFactory implements SynchronizedValueFactory<Long> {
private static final long START_MILLIS =
1356998400000L; // Jan 1st, 2013 in milliseconds from epoch
private int lastNonce = 0;
@Override
public Long createValue() {<FILL_FUNCTION_BODY>}
}
|
lastNonce = Math.max(lastNonce + 1, (int) ((System.currentTimeMillis() - START_MILLIS) / 250L));
return (long) lastNonce;
| 106
| 55
| 161
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-cryptowatch/src/main/java/org/knowm/xchange/cryptowatch/dto/marketdata/CryptowatchOHLCs.java
|
CryptowatchOHLCsDeserializer
|
deserialize
|
class CryptowatchOHLCsDeserializer extends JsonDeserializer<CryptowatchOHLCs> {
@Override
public CryptowatchOHLCs deserialize(JsonParser jsonParser, DeserializationContext ctxt)
throws IOException {<FILL_FUNCTION_BODY>}
}
|
Map<String, List<CryptowatchOHLC>> cwOHLCs = new HashMap<>();
ObjectCodec oc = jsonParser.getCodec();
JsonNode node = oc.readTree(jsonParser);
Iterator<Map.Entry<String, JsonNode>> tradesResultIterator = node.fields();
while (tradesResultIterator.hasNext()) {
Map.Entry<String, JsonNode> entry = tradesResultIterator.next();
String key = entry.getKey();
JsonNode value = entry.getValue();
List<CryptowatchOHLC> ohlcs = new ArrayList<>();
for (JsonNode jsonSpreadNode : value) {
long time = jsonSpreadNode.path(0).asLong();
BigDecimal open = new BigDecimal(jsonSpreadNode.path(1).asText());
BigDecimal high = new BigDecimal(jsonSpreadNode.path(2).asText());
BigDecimal low = new BigDecimal(jsonSpreadNode.path(3).asText());
BigDecimal close = new BigDecimal(jsonSpreadNode.path(4).asText());
BigDecimal volume = new BigDecimal(jsonSpreadNode.path(5).asText());
BigDecimal vwap = new BigDecimal(jsonSpreadNode.path(6).asText());
long count = jsonSpreadNode.path(7).asLong();
ohlcs.add(new CryptowatchOHLC(time, open, high, low, close, vwap, volume, count));
}
cwOHLCs.put(key, ohlcs);
}
return new CryptowatchOHLCs(cwOHLCs);
| 78
| 420
| 498
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-deribit/src/main/java/org/knowm/xchange/deribit/v2/DeribitExchange.java
|
DeribitExchange
|
updateExchangeMetaData
|
class DeribitExchange extends BaseExchange implements Exchange {
@Override
public void applySpecification(ExchangeSpecification exchangeSpecification) {
super.applySpecification(exchangeSpecification);
}
@Override
protected void initServices() {
this.marketDataService = new DeribitMarketDataService(this);
this.accountService = new DeribitAccountService(this);
this.tradeService = new DeribitTradeService(this);
}
@Override
public ExchangeSpecification getDefaultExchangeSpecification() {
ExchangeSpecification exchangeSpecification = new ExchangeSpecification(this.getClass());
exchangeSpecification.setSslUri("https://www.deribit.com");
exchangeSpecification.setHost("deribit.com");
// exchangeSpecification.setPort(80);
exchangeSpecification.setExchangeName("Deribit");
exchangeSpecification.setExchangeDescription("Deribit is a Bitcoin futures exchange");
return exchangeSpecification;
}
public ExchangeSpecification getSandboxExchangeSpecification() {
ExchangeSpecification exchangeSpecification = new ExchangeSpecification(this.getClass());
exchangeSpecification.setSslUri("https://test.deribit.com/");
exchangeSpecification.setHost("test.deribit.com");
// exchangeSpecification.setPort(80);
return exchangeSpecification;
}
@Override
public void remoteInit() throws IOException {
updateExchangeMetaData();
}
public void updateExchangeMetaData() throws IOException {<FILL_FUNCTION_BODY>}
}
|
Map<Currency, CurrencyMetaData> currencies = exchangeMetaData.getCurrencies();
Map<Instrument, InstrumentMetaData> instruments = exchangeMetaData.getInstruments();
List<DeribitCurrency> activeDeribitCurrencies =
((DeribitMarketDataServiceRaw) marketDataService).getDeribitCurrencies();
currencies.clear();
instruments.clear();
for (DeribitCurrency deribitCurrency : activeDeribitCurrencies) {
currencies.put(
new Currency(deribitCurrency.getCurrency()), DeribitAdapters.adaptMeta(deribitCurrency));
List<DeribitInstrument> deribitInstruments =
((DeribitMarketDataServiceRaw) marketDataService)
.getDeribitInstruments(deribitCurrency.getCurrency(), null, null);
for (DeribitInstrument deribitInstrument : deribitInstruments) {
instruments.put(
DeribitAdapters.adaptFuturesContract(deribitInstrument),
DeribitAdapters.adaptMeta(deribitInstrument));
}
}
| 411
| 308
| 719
|
<methods>public non-sealed void <init>() ,public void applySpecification(org.knowm.xchange.ExchangeSpecification) ,public org.knowm.xchange.service.account.AccountService getAccountService() ,public List<org.knowm.xchange.instrument.Instrument> getExchangeInstruments() ,public org.knowm.xchange.dto.meta.ExchangeMetaData getExchangeMetaData() ,public org.knowm.xchange.ExchangeSpecification getExchangeSpecification() ,public org.knowm.xchange.service.marketdata.MarketDataService getMarketDataService() ,public java.lang.String getMetaDataFileName(org.knowm.xchange.ExchangeSpecification) ,public SynchronizedValueFactory<java.lang.Long> getNonceFactory() ,public org.knowm.xchange.service.trade.TradeService getTradeService() ,public void remoteInit() throws java.io.IOException, org.knowm.xchange.exceptions.ExchangeException,public java.lang.String toString() <variables>protected org.knowm.xchange.service.account.AccountService accountService,protected org.knowm.xchange.dto.meta.ExchangeMetaData exchangeMetaData,protected org.knowm.xchange.ExchangeSpecification exchangeSpecification,protected final Logger logger,protected org.knowm.xchange.service.marketdata.MarketDataService marketDataService,private final SynchronizedValueFactory<java.lang.Long> nonceFactory,protected org.knowm.xchange.service.trade.TradeService tradeService
|
knowm_XChange
|
XChange/xchange-deribit/src/main/java/org/knowm/xchange/deribit/v2/service/DeribitMarketDataService.java
|
DeribitMarketDataService
|
getOrderBook
|
class DeribitMarketDataService extends DeribitMarketDataServiceRaw
implements MarketDataService {
/**
* Constructor
*
* @param exchange
*/
public DeribitMarketDataService(DeribitExchange exchange) {
super(exchange);
}
@Override
public Ticker getTicker(Instrument instrument, Object... args) throws IOException {
String deribitInstrumentName = DeribitAdapters.adaptInstrumentName(instrument);
DeribitTicker deribitTicker;
try {
deribitTicker = super.getDeribitTicker(deribitInstrumentName);
} catch (DeribitException ex) {
throw DeribitAdapters.adapt(ex);
}
return DeribitAdapters.adaptTicker(deribitTicker);
}
@Override
public OrderBook getOrderBook(Instrument instrument, Object... args) throws IOException {<FILL_FUNCTION_BODY>}
@Override
public Trades getTrades(Instrument instrument, Object... args) throws IOException {
String deribitInstrumentName = DeribitAdapters.adaptInstrumentName(instrument);
DeribitTrades deribitTrades;
try {
deribitTrades =
super.getLastTradesByInstrument(deribitInstrumentName, null, null, null, null, null);
} catch (DeribitException ex) {
throw new ExchangeException(ex);
}
return DeribitAdapters.adaptTrades(deribitTrades, instrument);
}
}
|
String deribitInstrumentName = DeribitAdapters.adaptInstrumentName(instrument);
DeribitOrderBook deribitOrderBook;
try {
deribitOrderBook = super.getDeribitOrderBook(deribitInstrumentName, null);
} catch (DeribitException ex) {
throw new ExchangeException(ex);
}
return DeribitAdapters.adaptOrderBook(deribitOrderBook);
| 414
| 116
| 530
|
<methods>public void <init>(org.knowm.xchange.deribit.v2.DeribitExchange) ,public List<org.knowm.xchange.deribit.v2.dto.marketdata.DeribitCurrency> getDeribitCurrencies() throws java.io.IOException,public List<org.knowm.xchange.deribit.v2.dto.marketdata.DeribitInstrument> getDeribitInstruments(java.lang.String, org.knowm.xchange.deribit.v2.dto.Kind, java.lang.Boolean) throws java.io.IOException,public org.knowm.xchange.deribit.v2.dto.marketdata.DeribitOrderBook getDeribitOrderBook(java.lang.String, java.lang.Integer) throws java.io.IOException,public org.knowm.xchange.deribit.v2.dto.marketdata.DeribitTicker getDeribitTicker(java.lang.String) throws java.io.IOException,public List<List<java.math.BigDecimal>> getHistoricalVolatility(java.lang.String) throws java.io.IOException,public org.knowm.xchange.deribit.v2.dto.marketdata.DeribitTrades getLastTradesByInstrument(java.lang.String, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Boolean, java.lang.String) throws java.io.IOException,public List<org.knowm.xchange.deribit.v2.dto.marketdata.DeribitSummary> getSummaryByInstrument(java.lang.String) throws java.io.IOException<variables>
|
knowm_XChange
|
XChange/xchange-dvchain/src/main/java/org/knowm/xchange/dvchain/DVChainExchange.java
|
DVChainExchange
|
initServices
|
class DVChainExchange extends BaseExchange {
private final SynchronizedValueFactory<Long> nonceFactory =
new CurrentTimeIncrementalNonceFactory(TimeUnit.SECONDS);
/** Adjust host parameters depending on exchange specific parameters */
private static void concludeHostParams(ExchangeSpecification exchangeSpecification) {
if (exchangeSpecification.getExchangeSpecificParameters() != null) {
if (exchangeSpecification
.getExchangeSpecificParametersItem(Exchange.USE_SANDBOX)
.equals(true)) {
exchangeSpecification.setSslUri("https://sandbox.trade.dvchain.co");
exchangeSpecification.setHost("sandbox.trade.dvchain.co");
}
}
}
@Override
public ExchangeSpecification getDefaultExchangeSpecification() {
ExchangeSpecification exchangeSpecification = new ExchangeSpecification(this.getClass());
exchangeSpecification.setSslUri("https://trade.dvchain.co");
exchangeSpecification.setHost("trade.dvchain.co");
exchangeSpecification.setPort(80);
exchangeSpecification.setExchangeName("DVChain");
exchangeSpecification.setExchangeDescription(
"DVChain is an OTC provider for a variety of cryptocurrencies.");
exchangeSpecification.setExchangeSpecificParametersItem(Exchange.USE_SANDBOX, false);
return exchangeSpecification;
}
@Override
protected void initServices() {<FILL_FUNCTION_BODY>}
@Override
public void applySpecification(ExchangeSpecification exchangeSpecification) {
super.applySpecification(exchangeSpecification);
concludeHostParams(exchangeSpecification);
}
@Override
public SynchronizedValueFactory<Long> getNonceFactory() {
return nonceFactory;
}
}
|
concludeHostParams(exchangeSpecification);
DVChainMarketDataService md = new DVChainMarketDataService(this);
this.marketDataService = md;
this.tradeService = new DVChainTradeService(md, this);
| 484
| 68
| 552
|
<methods>public non-sealed void <init>() ,public void applySpecification(org.knowm.xchange.ExchangeSpecification) ,public org.knowm.xchange.service.account.AccountService getAccountService() ,public List<org.knowm.xchange.instrument.Instrument> getExchangeInstruments() ,public org.knowm.xchange.dto.meta.ExchangeMetaData getExchangeMetaData() ,public org.knowm.xchange.ExchangeSpecification getExchangeSpecification() ,public org.knowm.xchange.service.marketdata.MarketDataService getMarketDataService() ,public java.lang.String getMetaDataFileName(org.knowm.xchange.ExchangeSpecification) ,public SynchronizedValueFactory<java.lang.Long> getNonceFactory() ,public org.knowm.xchange.service.trade.TradeService getTradeService() ,public void remoteInit() throws java.io.IOException, org.knowm.xchange.exceptions.ExchangeException,public java.lang.String toString() <variables>protected org.knowm.xchange.service.account.AccountService accountService,protected org.knowm.xchange.dto.meta.ExchangeMetaData exchangeMetaData,protected org.knowm.xchange.ExchangeSpecification exchangeSpecification,protected final Logger logger,protected org.knowm.xchange.service.marketdata.MarketDataService marketDataService,private final SynchronizedValueFactory<java.lang.Long> nonceFactory,protected org.knowm.xchange.service.trade.TradeService tradeService
|
knowm_XChange
|
XChange/xchange-dvchain/src/main/java/org/knowm/xchange/dvchain/dto/account/DVChainUser.java
|
DVChainUser
|
toString
|
class DVChainUser {
private final String id;
private final String firstName;
private final String lastName;
public DVChainUser(
@JsonProperty("_id") String id,
@JsonProperty("firstName") String firstName,
@JsonProperty("lastName") String lastName) {
this.id = id;
this.firstName = firstName;
this.lastName = lastName;
}
public String getId() {
return id;
}
public String getFirstName() {
return firstName;
}
public String getLastName() {
return lastName;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
StringBuilder builder = new StringBuilder();
builder.append("DVChain User {id=");
builder.append(id);
builder.append(", firstName=");
builder.append(firstName);
builder.append(", lastName=");
builder.append(lastName);
builder.append("}");
return builder.toString();
| 191
| 90
| 281
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-dvchain/src/main/java/org/knowm/xchange/dvchain/dto/marketdata/DVChainMarketResponse.java
|
DVChainMarketResponse
|
toString
|
class DVChainMarketResponse {
private final Map<String, DVChainMarketData> marketData;
@JsonCreator
public DVChainMarketResponse(Map<String, DVChainMarketData> marketData) {
this.marketData = marketData;
}
public Map<String, DVChainMarketData> getMarketData() {
return marketData;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
StringBuilder builder = new StringBuilder();
builder.append("Response {");
marketData.forEach(
(symbol, data) -> {
builder.append("Symbol=");
builder.append(symbol);
builder.append(", data=");
builder.append(data);
});
builder.append("}");
return builder.toString();
| 129
| 92
| 221
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-dvchain/src/main/java/org/knowm/xchange/dvchain/service/DVChainMarketDataServiceRaw.java
|
DVChainMarketDataServiceRaw
|
getMarketData
|
class DVChainMarketDataServiceRaw extends DVChainBaseService {
/**
* Constructor
*
* @param exchange
*/
public DVChainMarketDataServiceRaw(Exchange exchange) {
super(exchange);
}
public DVChainMarketResponse getMarketData() throws IOException {<FILL_FUNCTION_BODY>}
}
|
try {
return dvChain.getPrices(authToken);
} catch (DVChainException e) {
throw handleException(e);
}
| 96
| 44
| 140
|
<methods><variables>protected final non-sealed java.lang.String authToken,protected final non-sealed org.knowm.xchange.dvchain.DVChain dvChain
|
knowm_XChange
|
XChange/xchange-enigma/src/main/java/org/knowm/xchange/enigma/dto/BaseResponse.java
|
BaseResponse
|
getException
|
class BaseResponse {
private static Map<Integer, ResponseException> errorCodes;
private Integer code;
private String message;
private Boolean result;
static {
errorCodes =
Arrays.stream(ResponseException.values())
.collect(toMap(ResponseException::getCode, c -> c));
}
public BaseResponse(Integer code, String message, boolean result) {
this.code = code;
this.message = message;
this.result = result;
}
public int getCode() {
return this.code;
}
public ResponseException getException() {<FILL_FUNCTION_BODY>}
public String getMessage() {
return this.message;
}
public boolean isResult() {
return this.result;
}
}
|
if (this.code == null) {
return null;
}
return errorCodes.getOrDefault(this.code, ResponseException.GENERIC);
| 208
| 44
| 252
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-enigma/src/main/java/org/knowm/xchange/enigma/service/EnigmaAccountServiceRaw.java
|
EnigmaAccountServiceRaw
|
getBalance
|
class EnigmaAccountServiceRaw extends EnigmaBaseService {
public EnigmaAccountServiceRaw(Exchange exchange) {
super(exchange);
}
public Map<String, BigDecimal> getRiskLimits() throws IOException {
return this.enigmaAuthenticated.getAccountRiskLimits(accessToken());
}
public EnigmaBalance getBalance() throws IOException {<FILL_FUNCTION_BODY>}
public List<EnigmaWithdrawal> getWithdrawals() {
return this.enigmaAuthenticated.getAllWithdrawals(accessToken());
}
public EnigmaWithdrawal withdrawal(EnigmaWithdrawalRequest withdrawalRequest) {
return this.enigmaAuthenticated.withdrawal(accessToken(), withdrawalRequest);
}
public EnigmaWithdrawal withdrawal(EnigmaWithdrawFundsRequest withdrawalRequest) {
return this.enigmaAuthenticated.withdrawal(accessToken(), withdrawalRequest);
}
public List<Object> requestDepositAddress(Currency currency) {
return this.enigmaAuthenticated.depositAddress(accessToken(), currency.getCurrencyCode());
}
}
|
return new EnigmaBalance(
this.enigmaAuthenticated.getBalance(
accessToken(),
this.exchange
.getExchangeSpecification()
.getExchangeSpecificParametersItem("infra")
.toString()));
| 299
| 65
| 364
|
<methods>public void login() throws java.io.IOException<variables>protected final non-sealed org.knowm.xchange.enigma.EnigmaAuthenticated enigmaAuthenticated,protected final non-sealed SynchronizedValueFactory<java.lang.Long> nonceFactory
|
knowm_XChange
|
XChange/xchange-enigma/src/main/java/org/knowm/xchange/enigma/service/EnigmaMarketDataService.java
|
EnigmaMarketDataService
|
getTickers
|
class EnigmaMarketDataService extends EnigmaMarketDataServiceRaw
implements MarketDataService {
public EnigmaMarketDataService(Exchange exchange) {
super(exchange);
}
@Override
public Ticker getTicker(CurrencyPair currencyPair, Object... args) throws IOException {
return EnigmaAdapters.adaptTicker(getEnigmaTicker(currencyPair), currencyPair);
}
@Override
public OrderBook getOrderBook(CurrencyPair currencyPair, Object... args)
throws IOException, EnigmaNotImplementedException {
EnigmaOrderBook enigmaOrderBook = getEnigmaOrderBook(currencyPair.toString().replace("/", "-"));
return EnigmaAdapters.adaptOrderBook(enigmaOrderBook, currencyPair);
}
@Override
public Trades getTrades(CurrencyPair currencyPair, Object... args) throws IOException {
return EnigmaAdapters.adaptTrades(getEnigmaTransactions(), currencyPair);
}
@Override
public List<Ticker> getTickers(Params params) {<FILL_FUNCTION_BODY>}
}
|
if (!(params instanceof CurrencyPairsParam)) {
throw new IllegalArgumentException("Params must be instance of CurrencyPairsParam");
}
Collection<CurrencyPair> pairs = ((CurrencyPairsParam) params).getCurrencyPairs();
return pairs.stream()
.map(
currencyPair -> {
try {
return getTicker(currencyPair, currencyPair);
} catch (IOException e) {
throw new EnigmaException("Error while fetching ticker");
}
})
.collect(Collectors.toList());
| 280
| 141
| 421
|
<methods>public void <init>(org.knowm.xchange.Exchange) ,public org.knowm.xchange.enigma.dto.marketdata.EnigmaOrderBook getEnigmaOrderBook(java.lang.String) throws java.io.IOException,public org.knowm.xchange.enigma.dto.marketdata.EnigmaTicker getEnigmaTicker(org.knowm.xchange.currency.CurrencyPair) throws java.io.IOException,public org.knowm.xchange.enigma.dto.marketdata.EnigmaTransaction[] getEnigmaTransactions() throws java.io.IOException,public org.knowm.xchange.enigma.dto.marketdata.EnigmaProductMarketData getProductMarketData(int) throws java.io.IOException,public List<org.knowm.xchange.enigma.dto.marketdata.EnigmaProduct> getProducts() throws java.io.IOException<variables>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/bankera/BankeraDemoUtils.java
|
BankeraDemoUtils
|
createExchange
|
class BankeraDemoUtils {
public static Exchange createExchange() {<FILL_FUNCTION_BODY>}
}
|
ExchangeSpecification exSpec = new ExchangeSpecification(BankeraExchange.class);
exSpec.setExchangeSpecificParametersItem("clientId", "");
exSpec.setExchangeSpecificParametersItem("clientSecret", "");
return ExchangeFactory.INSTANCE.createExchange(exSpec);
| 32
| 79
| 111
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/bibox/account/BiboxAccountDemo.java
|
BiboxAccountDemo
|
main
|
class BiboxAccountDemo {
public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>}
private static void generic(AccountService accountService) throws IOException {
System.out.println("----------GENERIC---------");
Map<Currency, Balance> balances = accountService.getAccountInfo().getWallet().getBalances();
System.out.println(balances);
}
private static void raw(BiboxAccountServiceRaw accountService) throws IOException {
System.out.println("------------RAW-----------");
List<BiboxAsset> balances = accountService.getBiboxAccountInfo();
System.out.println(balances);
}
}
|
Exchange exchange = BiboxExamplesUtils.getExchange();
AccountService accountService = exchange.getAccountService();
generic(accountService);
raw((BiboxAccountServiceRaw) accountService);
| 183
| 56
| 239
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/binance/marketdata/BinanceMarketDataDemo.java
|
BinanceMarketDataDemo
|
raw
|
class BinanceMarketDataDemo {
public static void main(String[] args) throws IOException {
Exchange exchange = BinanceDemoUtils.createExchange();
/* create a data service from the exchange */
MarketDataService marketDataService = exchange.getMarketDataService();
generic(exchange, marketDataService);
raw((BinanceExchange) exchange, (BinanceMarketDataService) marketDataService);
// rawAll((BinanceExchange) exchange, (BinanceMarketDataService) marketDataService);
}
public static void generic(Exchange exchange, MarketDataService marketDataService)
throws IOException {}
public static void raw(BinanceExchange exchange, BinanceMarketDataService marketDataService)
throws IOException {<FILL_FUNCTION_BODY>}
public static void rawAll(BinanceExchange exchange, BinanceMarketDataService marketDataService)
throws IOException {
List<BinanceTicker24h> tickers = new ArrayList<>(marketDataService.ticker24hAllProducts());
tickers.sort((t1, t2) -> t2.getPriceChangePercent().compareTo(t1.getPriceChangePercent()));
tickers.forEach(
t ->
System.out.println(
t.getSymbol() + " => " + String.format("%+.2f%%", t.getLastPrice())));
}
}
|
List<BinanceTicker24h> tickers = new ArrayList<>();
for (Instrument cp : exchange.getExchangeMetaData().getInstruments().keySet()) {
if (cp.getCounter() == Currency.USDT) {
tickers.add(marketDataService.ticker24hAllProducts(cp));
}
}
tickers.sort((t1, t2) -> t2.getPriceChangePercent().compareTo(t1.getPriceChangePercent()));
tickers.forEach(
t ->
System.out.println(
t.getSymbol() + " => " + String.format("%+.2f%%", t.getPriceChangePercent())));
System.out.println("raw out end");
| 363
| 195
| 558
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/bitbay/marketdata/BitbayTickerDemo.java
|
BitbayTickerDemo
|
main
|
class BitbayTickerDemo {
public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>}
}
|
// Use the factory to get ANX exchange API using default settings
Exchange anx = ExchangeFactory.INSTANCE.createExchange(BitbayExchange.class);
// Interested in the public market data feed (no authentication)
MarketDataService marketDataService = anx.getMarketDataService();
// Get the latest ticker data showing BTC to USD
Ticker ticker = marketDataService.getTicker(CurrencyPair.BTC_USD);
System.out.println(ticker.toString());
// Get the latest ticker data showing BTC to EUR
ticker = marketDataService.getTicker(CurrencyPair.BTC_EUR);
System.out.println(ticker.toString());
// Get the latest ticker data showing BTC to GBP
ticker = marketDataService.getTicker(CurrencyPair.BTC_PLN);
System.out.println(ticker.toString());
| 38
| 233
| 271
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/bitcoinde/marketdata/BitcoindeTradesDemo.java
|
BitcoindeTradesDemo
|
raw
|
class BitcoindeTradesDemo {
public static void main(String[] args) throws IOException {
Exchange bitcoindeExchange = ExchangeUtils.createExchangeFromJsonConfiguration();
/* create a data service from the exchange */
MarketDataService marketDataService = bitcoindeExchange.getMarketDataService();
generic(marketDataService);
raw((BitcoindeMarketDataServiceRaw) marketDataService);
}
public static void generic(MarketDataService marketDataService) throws IOException {
/* get Trades data */
Trades trades = marketDataService.getTrades(CurrencyPair.BTC_EUR);
List<Trade> allTrades = trades.getTrades();
System.out.println("Number trades received: " + allTrades.size());
for (Trade t : allTrades) {
System.out.println(t);
}
}
public static void raw(BitcoindeMarketDataServiceRaw marketDataService) throws IOException {<FILL_FUNCTION_BODY>}
}
|
/* get BitcoindeTrades data */
BitcoindeTradesWrapper bitcoindeTrades =
marketDataService.getBitcoindeTrades(CurrencyPair.ETH_EUR, 4196418);
/* print each trade object */
for (BitcoindeTrade bitcoindeTrade : bitcoindeTrades.getTrades())
System.out.println(bitcoindeTrade);
| 267
| 116
| 383
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/bitfinex/marketdata/LendDepthDemo.java
|
LendDepthDemo
|
raw
|
class LendDepthDemo {
public static void main(String[] args) throws Exception {
// Use the factory to get BFX exchange API using default settings
Exchange bfx = ExchangeFactory.INSTANCE.createExchange(BitfinexExchange.class);
// Interested in the public market data feed (no authentication)
MarketDataService marketDataService = bfx.getMarketDataService();
raw((BitfinexMarketDataServiceRaw) marketDataService);
}
private static void raw(BitfinexMarketDataServiceRaw marketDataService) throws IOException {<FILL_FUNCTION_BODY>}
}
|
// Get the latest order book data for USD swaps
BitfinexLendDepth bitfinexDepth = marketDataService.getBitfinexLendBook("USD", 50, 50);
System.out.println(
"Current Order Book size for USD: "
+ (bitfinexDepth.getAsks().length + bitfinexDepth.getBids().length));
System.out.println("First Ask: " + bitfinexDepth.getAsks()[0].toString());
System.out.println("First Bid: " + bitfinexDepth.getBids()[0].toString());
System.out.println(bitfinexDepth.toString());
| 159
| 180
| 339
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/bitflyer/BitflyerDemoUtils.java
|
BitflyerDemoUtils
|
createExchange
|
class BitflyerDemoUtils {
public static Exchange createExchange() {<FILL_FUNCTION_BODY>}
}
|
// Use the factory to get BitFlyer exchange API using default settings
Exchange exchange = ExchangeFactory.INSTANCE.createExchange(BitflyerExchange.class);
ExchangeSpecification bfxSpec = exchange.getDefaultExchangeSpecification();
bfxSpec.setApiKey("");
bfxSpec.setSecretKey("");
exchange.applySpecification(bfxSpec);
return exchange;
| 34
| 105
| 139
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/bitflyer/trade/BitflyerTradeDemo.java
|
BitflyerTradeDemo
|
main
|
class BitflyerTradeDemo {
public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>}
private static void executionsInfo(TradeService service) throws IOException {
// Get the margin information
BitflyerTradeServiceRaw serviceRaw = (BitflyerTradeServiceRaw) service;
List<BitflyerExecution> executions = serviceRaw.getExecutions();
System.out.println(executions);
executions = serviceRaw.getExecutions("BTC_JPY");
System.out.println(executions);
}
private static void positionsInfo(TradeService service) throws IOException {
// Get the margin information
BitflyerTradeServiceRaw serviceRaw = (BitflyerTradeServiceRaw) service;
List<BitflyerPosition> executions = serviceRaw.getPositions();
System.out.println(executions);
executions = serviceRaw.getPositions("BTC_JPY");
System.out.println(executions);
}
}
|
Exchange exchange = BitflyerDemoUtils.createExchange();
TradeService service = exchange.getTradeService();
executionsInfo(service);
positionsInfo(service);
| 260
| 49
| 309
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/bithumb/account/BithumbAccountDemo.java
|
BithumbAccountDemo
|
main
|
class BithumbAccountDemo {
public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>}
private static void generic(AccountService accountService) throws IOException {
System.out.println("----------GENERIC----------");
System.out.println(accountService.getAccountInfo());
System.out.println(accountService.requestDepositAddress(Currency.BTC));
}
private static void raw(BithumbAccountServiceRaw accountServiceRaw) throws IOException {
System.out.println("----------RAW----------");
System.out.println(accountServiceRaw.getBithumbAddress());
System.out.println(accountServiceRaw.getBithumbBalance());
System.out.println(accountServiceRaw.getBithumbWalletAddress(Currency.BTC));
}
}
|
final Exchange exchange = BithumbDemoUtils.createExchange();
final AccountService accountService = exchange.getAccountService();
generic(accountService);
raw((BithumbAccountServiceRaw) accountService);
| 210
| 57
| 267
|
<no_super_class>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.