use of org.knowm.xchange.currency.CurrencyPair in project XChange by knowm.
the class BitstampAdapters method adaptMetaData.
public static ExchangeMetaData adaptMetaData(List<BitstampPairInfo> rawSymbols, ExchangeMetaData metaData) {
Map<CurrencyPair, CurrencyPairMetaData> currencyPairs = adaptCurrencyPairs(rawSymbols);
Map<CurrencyPair, CurrencyPairMetaData> pairsMap = metaData.getCurrencyPairs();
Map<Currency, CurrencyMetaData> currenciesMap = metaData.getCurrencies();
for (Map.Entry<CurrencyPair, CurrencyPairMetaData> entry : currencyPairs.entrySet()) {
CurrencyPair c = entry.getKey();
CurrencyPairMetaData cmeta = entry.getValue();
if (!pairsMap.containsKey(c)) {
pairsMap.put(c, cmeta);
} else {
pairsMap.replace(c, cmeta);
}
if (!currenciesMap.containsKey(c.base)) {
currenciesMap.put(c.base, null);
}
if (!currenciesMap.containsKey(c.counter)) {
currenciesMap.put(c.counter, null);
}
}
return metaData;
}
use of org.knowm.xchange.currency.CurrencyPair in project XChange by knowm.
the class CoingiAdapters method adaptTradeHistory.
public static UserTrades adaptTradeHistory(CoingiOrdersList ordersList) {
List<UserTrade> trades = new ArrayList<>();
for (CoingiOrder o : ordersList.getList()) {
final OrderType orderType = o.getType() == 0 ? OrderType.BID : OrderType.ASK;
final CurrencyPair pair = new CurrencyPair(o.getCurrencyPair().get("base").toUpperCase(), o.getCurrencyPair().get("counter").toUpperCase());
UserTrade trade = new UserTrade.Builder().type(orderType).originalAmount(o.getOriginalBaseAmount()).currencyPair(pair).price(o.getPrice()).timestamp(new Date(o.getTimestamp())).id(o.getId()).orderId(o.getId()).feeAmount(BigDecimal.ZERO).build();
trades.add(trade);
}
return new UserTrades(trades, TradeSortType.SortByID);
}
use of org.knowm.xchange.currency.CurrencyPair in project XChange by knowm.
the class CoingiTradeService method getOrder.
@Override
public Collection<Order> getOrder(String... orderIds) throws IOException {
try {
Collection<Order> orders = new ArrayList<>();
for (String orderId : orderIds) {
CoingiGetOrderRequest request = new CoingiGetOrderRequest().setOrderId(orderId);
CoingiOrder coingiOrder;
coingiOrder = getCoingiOrder(request);
CurrencyPair currencyPair = CoingiAdapters.adaptCurrency(coingiOrder.getCurrencyPair());
Date date = new Date(coingiOrder.getTimestamp() * 1000);
Order order = new LimitOrder(coingiOrder.getType() == 0 ? Order.OrderType.BID : Order.OrderType.ASK, coingiOrder.getOriginalBaseAmount(), currencyPair, coingiOrder.getId(), date, coingiOrder.getPrice());
order.setOrderStatus(CoingiAdapters.adaptOrderStatus(coingiOrder.getStatus()));
orders.add(order);
}
return orders;
} catch (CoingiException e) {
throw CoingiErrorAdapter.adapt(e);
}
}
use of org.knowm.xchange.currency.CurrencyPair in project XChange by knowm.
the class CmcAdapter method adaptTickerList.
public static List<Ticker> adaptTickerList(List<CmcTicker> cmcTickerList) {
List<Ticker> tickerList = new ArrayList<>();
cmcTickerList.forEach(cmcTicker -> {
cmcTicker.getQuote().forEach((currencySymbol, quote) -> {
CurrencyPair pair = new CurrencyPair(cmcTicker.getSymbol(), currencySymbol);
tickerList.add(adaptTicker(cmcTicker, pair));
});
});
return tickerList;
}
use of org.knowm.xchange.currency.CurrencyPair in project XChange by knowm.
the class CoinMarketCapExchange method getExchangeSymbols.
@Override
public List<CurrencyPair> getExchangeSymbols() {
List<Currency> currencies = marketDataService.getCurrencies();
List<CurrencyPair> pairs = new ArrayList<>();
for (Currency currency : currencies) {
pairs.add(new CurrencyPair(currency, Currency.USD));
pairs.add(new CurrencyPair(currency, Currency.BTC));
}
return pairs;
}
Aggregations