Java Code Examples for org.knowm.xchange.currency.Currency#getInstance()
The following examples show how to use
org.knowm.xchange.currency.Currency#getInstance() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BitmexUtils.java From zheshiyigeniubidexiangmu with MIT License | 6 votes |
public static void setBitmexAssetPairs(List<BitmexTicker> tickers) { for (BitmexTicker ticker : tickers) { String quote = ticker.getQuoteCurrency(); String base = ticker.getRootSymbol(); Currency baseCurrencyCode = Currency.getInstance(base); Currency quoteCurrencyCode = Currency.getInstance(quote); CurrencyPair pair = new CurrencyPair(base, quote); if (!assetPairMap.containsKey(ticker.getSymbol()) && !assetPairMap.containsValue(pair)) assetPairMap.put(ticker.getSymbol(), pair); if (!assetsMap.containsKey(quote) && !assetsMap.containsValue(quoteCurrencyCode)) assetsMap.put(quote, quoteCurrencyCode); if (!assetsMap.containsKey(base) && !assetsMap.containsValue(baseCurrencyCode)) assetsMap.put(base, baseCurrencyCode); } }
Example 2
Source File: CoinbaseAccountService.java From zheshiyigeniubidexiangmu with MIT License | 6 votes |
@Override public AccountInfo getAccountInfo() throws IOException { List<Wallet> wallets = new ArrayList<>(); List<CoinbaseAccountData.CoinbaseAccount> coinbaseAccounts = getCoinbaseAccounts(); for (CoinbaseAccountData.CoinbaseAccount coinbaseAccount : coinbaseAccounts) { CoinbaseAmount balance = coinbaseAccount.getBalance(); Wallet wallet = new Wallet( coinbaseAccount.getId(), new Balance(Currency.getInstance(balance.getCurrency()), balance.getAmount())); wallets.add(wallet); } return new AccountInfo(wallets); }
Example 3
Source File: CoinbaseAdapters.java From zheshiyigeniubidexiangmu with MIT License | 6 votes |
public static UserTrade adaptTrade(CoinbaseTransfer transfer) { final OrderType orderType = adaptOrderType(transfer.getType()); final CoinbaseMoney btcAmount = transfer.getBtcAmount(); final BigDecimal originalAmount = btcAmount.getAmount(); final String tradableIdentifier = btcAmount.getCurrency(); final CoinbaseMoney subTotal = transfer.getSubtotal(); final String transactionCurrency = subTotal.getCurrency(); final BigDecimal price = subTotal.getAmount().divide(originalAmount, RoundingMode.HALF_EVEN); final Date timestamp = transfer.getCreatedAt(); final String id = transfer.getTransactionId(); final String transferId = transfer.getId(); final BigDecimal feeAmount = transfer.getCoinbaseFee().getAmount(); final String feeCurrency = transfer.getCoinbaseFee().getCurrency(); return new UserTrade( orderType, originalAmount, new CurrencyPair(tradableIdentifier, transactionCurrency), price, timestamp, id, transferId, feeAmount, Currency.getInstance(feeCurrency)); }
Example 4
Source File: BinanceBalance.java From zheshiyigeniubidexiangmu with MIT License | 5 votes |
public BinanceBalance( @JsonProperty("asset") String asset, @JsonProperty("free") BigDecimal free, @JsonProperty("locked") BigDecimal locked) { this.currency = Currency.getInstance(asset); this.locked = locked; this.free = free; }
Example 5
Source File: BiboxAdapters.java From zheshiyigeniubidexiangmu with MIT License | 5 votes |
public static FundingRecord adaptDeposit(BiboxDeposit d) { return new FundingRecord( d.to, d.getCreatedAt(), Currency.getInstance(d.coinSymbol), d.amount, null, null, Type.DEPOSIT, convertStatus(d.status), null, null, null); }
Example 6
Source File: BiboxAdapters.java From zheshiyigeniubidexiangmu with MIT License | 5 votes |
public static FundingRecord adaptDeposit(BiboxWithdrawal w) { return new FundingRecord( w.toAddress, w.getCreatedAt(), Currency.getInstance(w.coinSymbol), w.amountReal, null, null, Type.WITHDRAWAL, convertStatus(w.status), null, null, null); }
Example 7
Source File: HuobiAdapters.java From zheshiyigeniubidexiangmu with MIT License | 5 votes |
public static FundingRecord adaptFundingRecord(HuobiFundingRecord r) { return new FundingRecord( r.getAddress(), r.getCreatedAt(), Currency.getInstance(r.getCurrency()), r.getAmount(), Long.toString(r.getId()), r.getTxhash(), r.getType(), adaptFundingStatus(r), null, r.getFee(), null); }
Example 8
Source File: OkCoinAdapters.java From zheshiyigeniubidexiangmu with MIT License | 5 votes |
public static UserTrades adaptTradeHistory( OkCoinFuturesTradeHistoryResult[] okCoinFuturesTradeHistoryResult) { List<UserTrade> trades = new ArrayList<>(); long lastTradeId = 0; for (OkCoinFuturesTradeHistoryResult okCoinFuturesTrade : okCoinFuturesTradeHistoryResult) { // if (okCoinFuturesTrade.getType().equals(OkCoinFuturesTradeHistoryResult.TransactionType.)) // { // skip account deposits and withdrawals. OrderType orderType = okCoinFuturesTrade.getType().equals(TransactionType.sell) ? OrderType.ASK : OrderType.BID; BigDecimal originalAmount = BigDecimal.valueOf(okCoinFuturesTrade.getAmount()); BigDecimal price = okCoinFuturesTrade.getPrice(); Date timestamp = new Date(okCoinFuturesTrade.getTimestamp()); long transactionId = okCoinFuturesTrade.getId(); if (transactionId > lastTradeId) { lastTradeId = transactionId; } final String tradeId = String.valueOf(transactionId); final String orderId = String.valueOf(okCoinFuturesTrade.getId()); final CurrencyPair currencyPair = CurrencyPair.BTC_USD; BigDecimal feeAmont = BigDecimal.ZERO; UserTrade trade = new UserTrade( orderType, originalAmount, currencyPair, price, timestamp, tradeId, orderId, feeAmont, Currency.getInstance(currencyPair.counter.getCurrencyCode())); trades.add(trade); } return new UserTrades(trades, lastTradeId, TradeSortType.SortByID); }
Example 9
Source File: CoinbaseAdapters.java From zheshiyigeniubidexiangmu with MIT License | 5 votes |
public static AccountInfo adaptAccountInfo(CoinbaseUser user) { final String username = user.getEmail(); final CoinbaseMoney money = user.getBalance(); final Balance balance = new Balance(Currency.getInstance(money.getCurrency()), money.getAmount()); final AccountInfo accountInfoTemporaryName = new AccountInfo(username, new Wallet(balance)); return accountInfoTemporaryName; }
Example 10
Source File: BitfinexAdapters.java From zheshiyigeniubidexiangmu with MIT License | 4 votes |
public static List<FundingRecord> adaptFundingHistory( BitfinexDepositWithdrawalHistoryResponse[] bitfinexDepositWithdrawalHistoryResponses) { final List<FundingRecord> fundingRecords = new ArrayList<>(); for (BitfinexDepositWithdrawalHistoryResponse responseEntry : bitfinexDepositWithdrawalHistoryResponses) { String address = responseEntry.getAddress(); String description = responseEntry.getDescription(); Currency currency = Currency.getInstance(responseEntry.getCurrency()); FundingRecord.Status status = FundingRecord.Status.resolveStatus(responseEntry.getStatus()); if (status == null && responseEntry .getStatus() .equalsIgnoreCase("CANCELED")) // there's a spelling mistake in the protocol status = FundingRecord.Status.CANCELLED; String txnId = null; if (status == null || !status.equals(FundingRecord.Status.CANCELLED)) { /* sometimes the description looks like this (with the txn hash in it): "description":"a9d387cf5d9df58ff2ac4a338e0f050fd3857cf78d1dbca4f33619dc4ccdac82","address":"1Enx... and sometimes like this (with the address in it as well as the txn hash): "description":"3AXVnDapuRiAn73pjKe7gukLSx5813oFyn, txid: aa4057486d5f73747167beb9949a0dfe17b5fc630499a66af075abdaf4986987","address":"3AX... and sometimes when cancelled "description":"3LFVTLFZoDDzLCcLGDDQ7MNkk4YPe26Yva, expired","address":"3LFV... */ String cleanedDescription = description.replace(",", "").replace("txid:", "").trim().toLowerCase(); // Address will only be present for crypto payments. It will be null for all fiat payments if (address != null) { cleanedDescription = cleanedDescription.replace(address.toLowerCase(), ""); } // check its just some hex characters, and if so lets assume its the txn hash if (cleanedDescription.matches("^(0x)?[0-9a-f]+$")) { txnId = cleanedDescription; } } FundingRecord fundingRecordEntry = new FundingRecord( address, responseEntry.getTimestamp(), currency, responseEntry.getAmount(), String.valueOf(responseEntry.getId()), txnId, responseEntry.getType(), status, null, null, description); fundingRecords.add(fundingRecordEntry); } return fundingRecords; }
Example 11
Source File: OkCoinAdapters.java From zheshiyigeniubidexiangmu with MIT License | 4 votes |
public static List<FundingRecord> adaptFundingHistory( final OkCoinAccountRecords okCoinAccountRecordsList, FundingRecord.Type type) { final List<FundingRecord> fundingRecords = new ArrayList<>(); if (okCoinAccountRecordsList != null) { final Currency c = Currency.getInstance(okCoinAccountRecordsList.getSymbol()); for (OkCoinRecords okCoinRecordEntry : okCoinAccountRecordsList.getRecords()) { FundingRecord.Status status = null; if (okCoinRecordEntry.getStatus() != null) { if (type == Type.DEPOSIT) { final OkCoinRecords.RechargeStatus rechargeStatus = OkCoinRecords.RechargeStatus.fromInt(okCoinRecordEntry.getStatus()); if (rechargeStatus != null) { status = FundingRecord.Status.resolveStatus(rechargeStatus.getStatus()); } } else { // WITHDRAWAL final OkCoinRecords.WithdrawalStatus withdrawalStatus = OkCoinRecords.WithdrawalStatus.fromInt(okCoinRecordEntry.getStatus()); if (withdrawalStatus != null) { status = FundingRecord.Status.resolveStatus(withdrawalStatus.getStatus()); } } } fundingRecords.add( new FundingRecord( okCoinRecordEntry.getAddress(), adaptDate(okCoinRecordEntry.getDate()), c, okCoinRecordEntry.getAmount(), null, null, type, status, null, okCoinRecordEntry.getFee(), null)); } } return fundingRecords; }
Example 12
Source File: CoinbasePrice.java From zheshiyigeniubidexiangmu with MIT License | 4 votes |
@JsonCreator public CoinbasePrice( @JsonProperty("amount") BigDecimal amount, @JsonProperty("currency") String currency) { this(amount, Currency.getInstance(currency)); }