Itbit fixes
This commit is contained in:
parent
aaf3f5bad3
commit
e9ce03cad5
|
@ -53,13 +53,13 @@ public class BitcoinExtension implements IExtension{
|
|||
} else if ("itbit".equalsIgnoreCase(prefix)) {
|
||||
String preferredFiatCurrency = ICurrencies.USD;
|
||||
String userId = paramTokenizer.nextToken();
|
||||
String walletId = paramTokenizer.nextToken();
|
||||
String accountId = paramTokenizer.nextToken();
|
||||
String clientKey = paramTokenizer.nextToken();
|
||||
String clientSecret = paramTokenizer.nextToken();
|
||||
if (paramTokenizer.hasMoreTokens()) {
|
||||
preferredFiatCurrency = paramTokenizer.nextToken().toUpperCase();
|
||||
}
|
||||
return new ItBitExchange(userId, walletId, clientKey, clientSecret, preferredFiatCurrency);
|
||||
return new ItBitExchange(userId, accountId, clientKey, clientSecret, preferredFiatCurrency);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -32,6 +32,8 @@ import org.knowm.xchange.ExchangeSpecification;
|
|||
import org.knowm.xchange.currency.Currency;
|
||||
import org.knowm.xchange.currency.CurrencyPair;
|
||||
import org.knowm.xchange.dto.Order;
|
||||
import org.knowm.xchange.dto.account.AccountInfo;
|
||||
import org.knowm.xchange.dto.account.Wallet;
|
||||
import org.knowm.xchange.dto.marketdata.OrderBook;
|
||||
import org.knowm.xchange.dto.marketdata.Ticker;
|
||||
import org.knowm.xchange.dto.trade.LimitOrder;
|
||||
|
@ -74,7 +76,6 @@ public abstract class XChangeExchange implements IExchangeAdvanced, IRateSourceA
|
|||
private final Logger log;
|
||||
private final RateLimiter rateLimiter;
|
||||
|
||||
|
||||
public XChangeExchange(ExchangeSpecification specification, String preferredFiatCurrency) {
|
||||
exchange = ExchangeFactory.INSTANCE.createExchange(specification);
|
||||
name = exchange.getExchangeSpecification().getExchangeName();
|
||||
|
@ -159,10 +160,9 @@ public abstract class XChangeExchange implements IExchangeAdvanced, IRateSourceA
|
|||
return BigDecimal.ZERO;
|
||||
}
|
||||
try {
|
||||
BigDecimal balance = exchange.getAccountService()
|
||||
.getAccountInfo()
|
||||
.getWallet(translateCryptoCurrencySymbolToExchangeSpecificSymbol(cryptoCurrency))
|
||||
.getBalance(Currency.getInstance(cryptoCurrency)).getAvailable();
|
||||
AccountInfo accountInfo = exchange.getAccountService().getAccountInfo();
|
||||
Wallet wallet = getWallet(accountInfo, cryptoCurrency);
|
||||
BigDecimal balance = wallet.getBalance(Currency.getInstance(cryptoCurrency)).getAvailable();
|
||||
log.debug("{} exchange balance request: {} = {}", name, cryptoCurrency, balance);
|
||||
return balance;
|
||||
} catch (IOException e) {
|
||||
|
@ -178,10 +178,9 @@ public abstract class XChangeExchange implements IExchangeAdvanced, IRateSourceA
|
|||
return BigDecimal.ZERO;
|
||||
}
|
||||
try {
|
||||
BigDecimal balance = exchange.getAccountService()
|
||||
.getAccountInfo()
|
||||
.getWallet(fiatCurrency)
|
||||
.getBalance(Currency.getInstance(fiatCurrency)).getAvailable();
|
||||
AccountInfo accountInfo = exchange.getAccountService().getAccountInfo();
|
||||
Wallet wallet = getWallet(accountInfo, fiatCurrency);
|
||||
BigDecimal balance = wallet.getBalance(Currency.getInstance(fiatCurrency)).getAvailable();
|
||||
log.debug("{} exchange balance request: {} = {}", name, fiatCurrency, balance);
|
||||
return balance;
|
||||
} catch (IOException e) {
|
||||
|
@ -191,6 +190,10 @@ public abstract class XChangeExchange implements IExchangeAdvanced, IRateSourceA
|
|||
return null;
|
||||
}
|
||||
|
||||
public Wallet getWallet(AccountInfo accountInfo, String currency) {
|
||||
return accountInfo.getWallet(translateCryptoCurrencySymbolToExchangeSpecificSymbol(currency));
|
||||
}
|
||||
|
||||
public final String sendCoins(String destinationAddress, BigDecimal amount, String cryptoCurrency, String description) {
|
||||
if (!isCryptoCurrencySupported(cryptoCurrency)){
|
||||
return null;
|
||||
|
@ -280,7 +283,7 @@ public abstract class XChangeExchange implements IExchangeAdvanced, IRateSourceA
|
|||
return orderId;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error(String.format("{} exchange purchase coins failed", name), e);
|
||||
log.error(String.format("%s exchange purchase coins failed", name), e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -23,18 +23,23 @@ package com.generalbytes.batm.server.extensions.extra.bitcoin.exchanges.itbit;
|
|||
import com.generalbytes.batm.server.extensions.ICurrencies;
|
||||
import com.generalbytes.batm.server.extensions.extra.bitcoin.exchanges.XChangeExchange;
|
||||
import org.knowm.xchange.ExchangeSpecification;
|
||||
import org.knowm.xchange.dto.account.AccountInfo;
|
||||
import org.knowm.xchange.dto.account.Wallet;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class ItBitExchange extends XChangeExchange {
|
||||
|
||||
private String accountId;
|
||||
|
||||
public ItBitExchange(String preferredFiatCurrency) {
|
||||
super(getDefaultSpecification(), preferredFiatCurrency);
|
||||
}
|
||||
|
||||
public ItBitExchange(String userId, String walletId, String clientKey, String clientSecret, String preferredFiatCurrency) {
|
||||
super(getSpecification(userId, walletId, clientKey, clientSecret), preferredFiatCurrency);
|
||||
public ItBitExchange(String userId, String accountId, String clientKey, String clientSecret, String preferredFiatCurrency) {
|
||||
super(getSpecification(userId, accountId, clientKey, clientSecret), preferredFiatCurrency);
|
||||
this.accountId = accountId;
|
||||
}
|
||||
|
||||
|
||||
|
@ -42,10 +47,10 @@ public class ItBitExchange extends XChangeExchange {
|
|||
return new org.knowm.xchange.itbit.v1.ItBitExchange().getDefaultExchangeSpecification();
|
||||
}
|
||||
|
||||
private static ExchangeSpecification getSpecification(String userId, String walletId, String clientKey, String clientSecret) {
|
||||
private static ExchangeSpecification getSpecification(String userId, String accountId, String clientKey, String clientSecret) {
|
||||
ExchangeSpecification spec = getDefaultSpecification();
|
||||
spec.setExchangeSpecificParametersItem("userId", userId);
|
||||
spec.setExchangeSpecificParametersItem("walletId", walletId);
|
||||
spec.setExchangeSpecificParametersItem("walletId", accountId);
|
||||
spec.setApiKey(clientKey);
|
||||
spec.setSecretKey(clientSecret);
|
||||
return spec;
|
||||
|
@ -53,14 +58,14 @@ public class ItBitExchange extends XChangeExchange {
|
|||
|
||||
@Override
|
||||
public Set<String> getCryptoCurrencies() {
|
||||
Set<String> cryptoCurrencies = new HashSet<String>();
|
||||
Set<String> cryptoCurrencies = new HashSet<>();
|
||||
cryptoCurrencies.add(ICurrencies.BTC);
|
||||
return cryptoCurrencies;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getFiatCurrencies() {
|
||||
Set<String> fiatCurrencies = new HashSet<String>();
|
||||
Set<String> fiatCurrencies = new HashSet<>();
|
||||
fiatCurrencies.add(ICurrencies.USD);
|
||||
fiatCurrencies.add(ICurrencies.EUR);
|
||||
fiatCurrencies.add(ICurrencies.SGD);
|
||||
|
@ -77,6 +82,11 @@ public class ItBitExchange extends XChangeExchange {
|
|||
return 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Wallet getWallet(AccountInfo accountInfo, String fiatCurrency) {
|
||||
return accountInfo.getWallet(accountId);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String translateCryptoCurrencySymbolToExchangeSpecificSymbol(String from) {
|
||||
if (ICurrencies.BTC.equalsIgnoreCase(from)) {
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
</exchange>
|
||||
<exchange prefix="itbit" name="itBit.com Exchange">
|
||||
<param name="userId" />
|
||||
<param name="walletId" />
|
||||
<param name="accountId" />
|
||||
<param name="apikey" />
|
||||
<param name="apisecret" />
|
||||
<param name="fiatcurrency" />
|
||||
|
@ -289,23 +289,6 @@
|
|||
</ratesource>
|
||||
<cryptologo cryptocurrency="NXT" file="nxt.png"/>
|
||||
</extension>
|
||||
<extension class="com.generalbytes.batm.server.extensions.extra.potcoin.PotcoinExtension" >
|
||||
<wallet prefix="potwallet" name="PotCoin">
|
||||
<param name="publicKey" />
|
||||
<param name="privateKey" />
|
||||
<param name="walletId" />
|
||||
<cryptocurrency>POT</cryptocurrency>
|
||||
</wallet>
|
||||
<ratesource prefix="potfix" name ="Fix Price" >
|
||||
<param name="price" />
|
||||
<cryptocurrency>POT</cryptocurrency>
|
||||
</ratesource>
|
||||
<ratesource prefix="coinmarketcap" name ="coinmarketcap.com" >
|
||||
<param name="fiatcurrency" />
|
||||
<cryptocurrency>POT</cryptocurrency>
|
||||
</ratesource>
|
||||
<cryptologo cryptocurrency="POT" file="pot.png"/>
|
||||
</extension>
|
||||
<extension class="com.generalbytes.batm.server.extensions.extra.dexacoin.DexCoinSupport">
|
||||
<ratesource prefix="dex_fix" name ="Fix Price" >
|
||||
<param name="price" />
|
||||
|
|
Loading…
Reference in New Issue