@ Override public Trades getTrades ( CurrencyPair currencyPair , Object ... args ) throws IOException , RateLimitExceededException { if ( args . length == 0 ) { return CoinbaseProAdapters . adaptTrades ( getCoinbaseProTrades ( currencyPair ) , currencyPair ) ; } else if ( ( args . length == 2 ) && ( args [ 0 ] instanceof Long ) && ( args [ 1 ] instanceof Long ) ) { Long fromTradeId = ( Long ) args [ 0 ] ; Long toTradeId = ( Long ) args [ 1 ] ; log . debug ( "fromTradeId: {}, toTradeId: {}" , fromTradeId , toTradeId ) ; Long latestTradeId = toTradeId ; CoinbaseProTrades CoinbaseProTrades = new CoinbaseProTrades ( ) ; for ( ; ; ) { CoinbaseProTrades CoinbaseProTradesNew = getCoinbaseProTradesExtended ( currencyPair , latestTradeId , 100 ) ; CoinbaseProTrades . addAll ( CoinbaseProTradesNew ) ; log . debug ( "latestTradeId: {}, earliest-latest: {}-{}, trades: {}" , latestTradeId , CoinbaseProTrades . getEarliestTradeId ( ) , CoinbaseProTrades . getLatestTradeId ( ) , CoinbaseProTrades ) ; latestTradeId = CoinbaseProTrades . getEarliestTradeId ( ) ; if ( CoinbaseProTradesNew . getEarliestTradeId ( ) == null ) { break ; } if ( CoinbaseProTrades . getEarliestTradeId ( ) <= fromTradeId ) { break ; } } log . debug ( "earliest-latest: {}-{}" , CoinbaseProTrades . getEarliestTradeId ( ) , CoinbaseProTrades . getLatestTradeId ( ) ) ; if ( log . isDebugEnabled ( ) ) { CoinbaseProTrades . stream ( ) . forEach ( System . out :: println ) ; } return CoinbaseProAdapters . adaptTrades ( CoinbaseProTrades , currencyPair ) ; } throw new IllegalArgumentException ( "Invalid arguments passed to getTrades" ) ; }
Get trades data for a specific currency pair