Search in sources :

Example 1 with BTCTurkUserTransactions

use of org.knowm.xchange.btcturk.dto.account.BTCTurkUserTransactions in project XChange by knowm.

the class TradeDataFetchIntegration method Tests.

@Test
public void Tests() throws IOException, InterruptedException {
    if (!BTCTurkDemoUtilsTest.BTCTURK_APIKEY.isEmpty()) {
        // PlaceOrderAndOpenOrders Test
        Thread.sleep(1000);
        List<BTCTurkOpenOrders> openOrders = btcTurkTradeService.getBTCTurkOpenOrders(CurrencyPair.ETH_TRY);
        Boolean result = false;
        if (openOrders.isEmpty()) {
            Thread.sleep(1000);
            BTCTurkExchangeResult exchangeResult = btcTurkTradeService.placeLimitOrder(new BigDecimal("0.01"), new BigDecimal(713), CurrencyPair.ETH_TRY, BTCTurkOrderTypes.Sell);
            Thread.sleep(1000);
            result = btcTurkTradeService.cancelOrder(exchangeResult.getId());
        } else {
            result = btcTurkTradeService.cancelOrder(openOrders.get(0).getId());
        }
        assertThat(result).isEqualTo(true);
        // UserTransactions Test
        Thread.sleep(1000);
        List<BTCTurkUserTransactions> userTransactions = btcTurkTradeService.getBTCTurkUserTransactions();
        assertThat(userTransactions.size()).isEqualTo(25);
    } else
        assertThat(tradeService).isNotEqualTo(null);
}
Also used : BTCTurkOpenOrders(org.knowm.xchange.btcturk.dto.trade.BTCTurkOpenOrders) BTCTurkUserTransactions(org.knowm.xchange.btcturk.dto.account.BTCTurkUserTransactions) BTCTurkExchangeResult(org.knowm.xchange.btcturk.dto.trade.BTCTurkExchangeResult) BigDecimal(java.math.BigDecimal) Test(org.junit.Test) BTCTurkDemoUtilsTest(org.knowm.xchange.btcturk.service.BTCTurkDemoUtilsTest)

Example 2 with BTCTurkUserTransactions

use of org.knowm.xchange.btcturk.dto.account.BTCTurkUserTransactions in project XChange by knowm.

the class BTCTurkTradeService method getTradeHistory.

@Override
public UserTrades getTradeHistory(TradeHistoryParams params) throws IOException {
    List<UserTrade> trades = new ArrayList<UserTrade>();
    List<BTCTurkUserTransactions> transactions = super.getBTCTurkUserTransactions();
    for (BTCTurkUserTransactions transaction : transactions) {
        if (transaction.getOperation().equals(BTCTurkOperations.trade))
            trades.add(new UserTrade.Builder().type(((transaction.getAmount().compareTo(BigDecimal.ZERO) > 0) ? OrderType.ASK : OrderType.BID)).originalAmount(transaction.getAmount()).price(transaction.getPrice()).timestamp(transaction.getDate()).id(transaction.getId()).feeAmount(transaction.getFee()).feeCurrency(transaction.getCurrency()).build());
    }
    long lastId = transactions.stream().map(t -> Long.parseLong(t.getId())).max(Long::compareTo).orElse(0L);
    return new UserTrades(trades, lastId, TradeSortType.SortByTimestamp);
}
Also used : UserTrades(org.knowm.xchange.dto.trade.UserTrades) ArrayList(java.util.ArrayList) UserTrade(org.knowm.xchange.dto.trade.UserTrade) BTCTurkUserTransactions(org.knowm.xchange.btcturk.dto.account.BTCTurkUserTransactions)

Example 3 with BTCTurkUserTransactions

use of org.knowm.xchange.btcturk.dto.account.BTCTurkUserTransactions in project XChange by knowm.

the class BTCTurkAccountService method getFundingHistory.

@Override
public List<FundingRecord> getFundingHistory(TradeHistoryParams params) throws IOException {
    List<FundingRecord> records = new ArrayList<>();
    List<BTCTurkUserTransactions> transactions = super.getBTCTurkUserTransactions();
    for (BTCTurkUserTransactions transaction : transactions) {
        if (!transaction.getOperation().equals(BTCTurkOperations.trade))
            records.add(BTCTurkAdapters.adaptTransaction(transaction));
    }
    return records;
}
Also used : FundingRecord(org.knowm.xchange.dto.account.FundingRecord) ArrayList(java.util.ArrayList) BTCTurkUserTransactions(org.knowm.xchange.btcturk.dto.account.BTCTurkUserTransactions)

Aggregations

BTCTurkUserTransactions (org.knowm.xchange.btcturk.dto.account.BTCTurkUserTransactions)3 ArrayList (java.util.ArrayList)2 BigDecimal (java.math.BigDecimal)1 Test (org.junit.Test)1 BTCTurkExchangeResult (org.knowm.xchange.btcturk.dto.trade.BTCTurkExchangeResult)1 BTCTurkOpenOrders (org.knowm.xchange.btcturk.dto.trade.BTCTurkOpenOrders)1 BTCTurkDemoUtilsTest (org.knowm.xchange.btcturk.service.BTCTurkDemoUtilsTest)1 FundingRecord (org.knowm.xchange.dto.account.FundingRecord)1 UserTrade (org.knowm.xchange.dto.trade.UserTrade)1 UserTrades (org.knowm.xchange.dto.trade.UserTrades)1