use of org.knowm.xchange.currency.CurrencyPair in project XChange by knowm.
the class TradeServiceIntegration method sampleTakeProfitLimitOrder.
private StopOrder sampleTakeProfitLimitOrder() throws IOException {
final CurrencyPair currencyPair = CurrencyPair.BTC_USDT;
final BigDecimal amount = BigDecimal.ONE;
final BigDecimal limitPrice = limitPriceForCurrencyPair(currencyPair);
final BigDecimal takeProfitPrice = limitPrice.multiply(new BigDecimal("1.1")).setScale(2, RoundingMode.HALF_UP);
return new StopOrder.Builder(BID, currencyPair).originalAmount(amount).stopPrice(takeProfitPrice).limitPrice(limitPrice).intention(StopOrder.Intention.TAKE_PROFIT).flag(TimeInForce.GTC).build();
}
use of org.knowm.xchange.currency.CurrencyPair in project XChange by knowm.
the class TradeServiceIntegration method sampleLimitOrder.
private LimitOrder sampleLimitOrder() throws IOException {
final CurrencyPair currencyPair = CurrencyPair.BTC_USDT;
final BigDecimal amount = BigDecimal.ONE;
final BigDecimal limitPrice = limitPriceForCurrencyPair(currencyPair);
return new LimitOrder.Builder(BID, currencyPair).originalAmount(amount).limitPrice(limitPrice).flag(TimeInForce.GTC).build();
}
use of org.knowm.xchange.currency.CurrencyPair in project XChange by knowm.
the class TradeServiceIntegration method sampleStopLimitOrder.
private StopOrder sampleStopLimitOrder() throws IOException {
final CurrencyPair currencyPair = CurrencyPair.BTC_USDT;
final BigDecimal amount = BigDecimal.ONE;
final BigDecimal limitPrice = limitPriceForCurrencyPair(currencyPair);
final BigDecimal stopPrice = limitPrice.multiply(new BigDecimal("0.9")).setScale(2, RoundingMode.HALF_UP);
return new StopOrder.Builder(BID, currencyPair).originalAmount(amount).limitPrice(limitPrice).stopPrice(stopPrice).intention(StopOrder.Intention.STOP_LOSS).flag(TimeInForce.GTC).build();
}
use of org.knowm.xchange.currency.CurrencyPair in project XChange by knowm.
the class BitbayAdapters method createUserTrade.
private static UserTrade createUserTrade(BitbayOrder bitbayOrder) {
CurrencyPair currencyPair = new CurrencyPair(bitbayOrder.getCurrency(), bitbayOrder.getPaymentCurrency());
OrderType type = "ask".equals(bitbayOrder.getType()) ? OrderType.ASK : OrderType.BID;
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date;
try {
date = formatter.parse(bitbayOrder.getDate());
} catch (ParseException e) {
throw new IllegalArgumentException(e);
}
return new UserTrade.Builder().type(type).originalAmount(bitbayOrder.getAmount()).currencyPair(currencyPair).price(bitbayOrder.getCurrentPrice().divide(bitbayOrder.getStartAmount())).timestamp(date).id(String.valueOf(bitbayOrder.getId())).orderId(String.valueOf(bitbayOrder.getId())).build();
}
use of org.knowm.xchange.currency.CurrencyPair in project XChange by knowm.
the class BitbayTradeService method getTradeHistory.
@Override
public UserTrades getTradeHistory(TradeHistoryParams params) throws IOException {
final BitbayUserTradesQuery query = new BitbayUserTradesQuery();
if (params instanceof TradeHistoryParamNextPageCursor) {
query.setNextPageCursor(((TradeHistoryParamNextPageCursor) params).getNextPageCursor());
}
if (params instanceof TradeHistoryParamLimit) {
Integer limit = ((TradeHistoryParamLimit) params).getLimit();
query.setLimit(limit != null ? limit.toString() : null);
}
if (params instanceof TradeHistoryParamMultiCurrencyPair) {
final Collection<CurrencyPair> currencyPairs = ((TradeHistoryParamMultiCurrencyPair) params).getCurrencyPairs();
query.setMarkets(currencyPairs.stream().map(BitbayAdapters::adaptCurrencyPair).collect(Collectors.toList()));
}
final BitbayUserTrades response = getBitbayTransactions(query);
return BitbayAdapters.adaptUserTrades(response);
}
Aggregations