本文整理汇总了Java中com.xeiam.xchange.dto.marketdata.Trades类的典型用法代码示例。如果您正苦于以下问题:Java Trades类的具体用法?Java Trades怎么用?Java Trades使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Trades类属于com.xeiam.xchange.dto.marketdata包,在下文中一共展示了Trades类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetHistory
import com.xeiam.xchange.dto.marketdata.Trades; //导入依赖的package包/类
@Test
public void testGetHistory() throws Exception {
ArrayList<UserTrade> trades = new ArrayList<UserTrade>();
trades.add(new UserTrade.Builder().build());
when(pollingTradeService.getTradeHistory(any(DefaultTradeHistoryParamsTimeSpan.class)))
.thenReturn(new UserTrades(trades, Trades.TradeSortType.SortByTimestamp));
when(timeRetrieveService.getAndSyncQueryTime())
.thenReturn(new Date());
List<UserTrade> history = simpleRecentTradesService.getHistory();
assertNotNull(history);
verify(pollingTradeService).getTradeHistory(any(DefaultTradeHistoryParamsTimeSpan.class));
verify(timeRetrieveService).getAndSyncQueryTime();
assertEquals(trades, history);
}
示例2: testGetHistory
import com.xeiam.xchange.dto.marketdata.Trades; //导入依赖的package包/类
@Test
public void testGetHistory() throws Exception {
Date queryTime = new Date();
UserTrade expectedTrade = new UserTrade.Builder()
.id("1")
.timestamp(new DateTime(queryTime).plusMinutes(1).toDate())
.build();
UserTrade notExpectedTrade = new UserTrade.Builder()
.id("2")
.timestamp(new DateTime(queryTime).minusMinutes(1).toDate())
.build();
List<UserTrade> trades = new ArrayList<UserTrade>();
trades.add(expectedTrade);
trades.add(notExpectedTrade);
ArrayList<CurrencyPair> currencyPairs = new ArrayList<CurrencyPair>();
currencyPairs.add(CurrencyPair.BTC_AUD);
currencyPairs.add(CurrencyPair.BTC_BRL);
currencyPairs.add(CurrencyPair.BTC_CHF);
when(timeRetrieveService.getAndSyncQueryTime())
.thenReturn(queryTime);
when(pollingTradeService.getExchangeSymbols())
.thenReturn(currencyPairs);
when(pollingTradeService.getTradeHistory(any(DefaultTradeHistoryParamCurrencyPair.class)))
.thenReturn(new UserTrades(trades, Trades.TradeSortType.SortByTimestamp));
List<UserTrade> history = currencyPairRecentTradeService.getHistory();
verify(timeRetrieveService).getAndSyncQueryTime();
verify(pollingTradeService).getExchangeSymbols();
verify(pollingTradeService, times(currencyPairs.size())).getTradeHistory(any(DefaultTradeHistoryParamCurrencyPair.class));
assertEquals(3, history.size());
assertTrue(history.contains(expectedTrade));
assertFalse(history.contains(notExpectedTrade));
}
示例3: generic
import com.xeiam.xchange.dto.marketdata.Trades; //导入依赖的package包/类
private static List<Trade> generic(Exchange exchange) throws IOException {
// Interested in the public polling market data feed (no authentication)
PollingMarketDataService marketDataService = exchange
.getPollingMarketDataService();
// Get the latest trade data for BTC/USD
Trades trades = marketDataService.getTrades(CurrencyPair.BTC_USD);
return trades.getTrades();
}
示例4: generic
import com.xeiam.xchange.dto.marketdata.Trades; //导入依赖的package包/类
private static void generic(Exchange exchange) throws IOException {
// Interested in the public polling market data feed (no authentication)
PollingMarketDataService marketDataService = exchange
.getPollingMarketDataService();
// Get the latest trade data for BTC/USD
Trades trades = marketDataService.getTrades(CurrencyPair.BTC_USD);
System.out.println(trades.toString());
}
示例5: dumpBitstampData
import com.xeiam.xchange.dto.marketdata.Trades; //导入依赖的package包/类
/**
* Dump Bitstamp trades.
*/
public static void dumpBitstampData() {
try
{
Trades trades = marketDataService.getTrades(Currencies.BTC, Currencies.USD);
for (Trade t : trades.getTrades()) {
System.out.println(t);
}
}
catch (IOException ex)
{
Logger.getLogger(AlgorithmComparator.class.getName()).log(Level.SEVERE, null, ex);
}
}