idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
9,300 | public static BitstampGenericOrder adaptOrder ( String orderId , BitstampOrderStatusResponse bitstampOrderStatusResponse ) { BitstampOrderTransaction [ ] bitstampTransactions = bitstampOrderStatusResponse . getTransactions ( ) ; CurrencyPair currencyPair = adaptCurrencyPair ( bitstampTransactions [ 0 ] ) ; Date date = bitstampTransactions [ 0 ] . getDatetime ( ) ; BigDecimal averagePrice = Arrays . stream ( bitstampTransactions ) . map ( t -> t . getPrice ( ) ) . reduce ( ( x , y ) -> x . add ( y ) ) . get ( ) . divide ( BigDecimal . valueOf ( bitstampTransactions . length ) , 2 ) ; BigDecimal cumulativeAmount = Arrays . stream ( bitstampTransactions ) . map ( t -> getBaseCurrencyAmountFromBitstampTransaction ( t ) ) . reduce ( ( x , y ) -> x . add ( y ) ) . get ( ) ; BigDecimal totalFee = Arrays . stream ( bitstampTransactions ) . map ( t -> t . getFee ( ) ) . reduce ( ( x , y ) -> x . add ( y ) ) . get ( ) ; Order . OrderStatus orderStatus = adaptOrderStatus ( bitstampOrderStatusResponse . getStatus ( ) ) ; BitstampGenericOrder bitstampGenericOrder = new BitstampGenericOrder ( null , null , currencyPair , orderId , date , averagePrice , cumulativeAmount , totalFee , orderStatus ) ; return bitstampGenericOrder ; } | There is no method to discern market versus limit order type - so this returns a generic BitstampGenericOrder as a status |
9,301 | public static OrderBook adaptOrderbook ( BitcoiniumOrderbook bitcoiniumOrderbook , CurrencyPair currencyPair ) { List < LimitOrder > asks = createOrders ( currencyPair , Order . OrderType . ASK , bitcoiniumOrderbook . getAsks ( ) ) ; List < LimitOrder > bids = createOrders ( currencyPair , Order . OrderType . BID , bitcoiniumOrderbook . getBids ( ) ) ; Date date = new Date ( bitcoiniumOrderbook . getBitcoiniumTicker ( ) . getTimestamp ( ) ) ; return new OrderBook ( date , asks , bids ) ; } | Adapts a BitcoiniumOrderbook to a OrderBook Object |
9,302 | public static Ticker adaptTicker ( BTCTurkTicker btcTurkTicker ) { CurrencyPair pair = btcTurkTicker . getPair ( ) ; BigDecimal high = btcTurkTicker . getHigh ( ) ; BigDecimal last = btcTurkTicker . getLast ( ) ; Date timestamp = new Date ( btcTurkTicker . getTimestamp ( ) ) ; BigDecimal bid = btcTurkTicker . getBid ( ) ; BigDecimal volume = btcTurkTicker . getVolume ( ) ; BigDecimal low = btcTurkTicker . getLow ( ) ; BigDecimal ask = btcTurkTicker . getAsk ( ) ; BigDecimal open = btcTurkTicker . getOpen ( ) ; BigDecimal average = btcTurkTicker . getAverage ( ) ; return new Ticker . Builder ( ) . currencyPair ( pair != null ? pair : null ) . last ( last ) . bid ( bid ) . ask ( ask ) . high ( high ) . low ( low ) . vwap ( average ) . open ( open ) . volume ( volume ) . timestamp ( timestamp ) . build ( ) ; } | Adapts a BTCTurkTicker to a Ticker Object |
9,303 | public static Trade adaptTrade ( BTCTurkTrades btcTurkTrade , CurrencyPair currencyPair ) { return new Trade ( null , btcTurkTrade . getAmount ( ) , currencyPair , btcTurkTrade . getPrice ( ) , btcTurkTrade . getDate ( ) , btcTurkTrade . getTid ( ) . toString ( ) ) ; } | Adapts a BTCTurkTrade to a Trade Object |
9,304 | public static OrderBook adaptOrderBook ( BTCTurkOrderBook btcTurkOrderBook , CurrencyPair currencyPair ) { List < LimitOrder > asks = createOrders ( currencyPair , Order . OrderType . ASK , btcTurkOrderBook . getAsks ( ) ) ; List < LimitOrder > bids = createOrders ( currencyPair , Order . OrderType . BID , btcTurkOrderBook . getBids ( ) ) ; return new OrderBook ( btcTurkOrderBook . getTimestamp ( ) , asks , bids ) ; } | Adapts org . knowm . xchange . btcturk . dto . marketdata . BTCTurkOrderBook to a OrderBook Object |
9,305 | private static LimitOrder withAmount ( LimitOrder limitOrder , BigDecimal tradeableAmount ) { OrderType type = limitOrder . getType ( ) ; CurrencyPair currencyPair = limitOrder . getCurrencyPair ( ) ; String id = limitOrder . getId ( ) ; Date date = limitOrder . getTimestamp ( ) ; BigDecimal limit = limitOrder . getLimitPrice ( ) ; return new LimitOrder ( type , tradeableAmount , currencyPair , id , date , limit ) ; } | Returns a copy of limitOrder with tradeableAmount replaced . |
9,306 | public void update ( LimitOrder limitOrder ) { update ( getOrders ( limitOrder . getType ( ) ) , limitOrder ) ; updateDate ( limitOrder . getTimestamp ( ) ) ; } | Given a new LimitOrder it will replace a matching limit order in the orderbook if one is found or add the new LimitOrder if one is not . timeStamp will be updated if the new timestamp is non - null and in the future . |
9,307 | private void update ( List < LimitOrder > asks , LimitOrder limitOrder ) { int idx = Collections . binarySearch ( asks , limitOrder ) ; if ( idx >= 0 ) { asks . remove ( idx ) ; asks . add ( idx , limitOrder ) ; } else { asks . add ( - idx - 1 , limitOrder ) ; } } | Replace the amount for limitOrder s price in the provided list . |
9,308 | public void update ( OrderBookUpdate orderBookUpdate ) { LimitOrder limitOrder = orderBookUpdate . getLimitOrder ( ) ; List < LimitOrder > limitOrders = getOrders ( limitOrder . getType ( ) ) ; int idx = Collections . binarySearch ( limitOrders , limitOrder ) ; if ( idx >= 0 ) { limitOrders . remove ( idx ) ; } else { idx = - idx - 1 ; } if ( orderBookUpdate . getTotalVolume ( ) . compareTo ( BigDecimal . ZERO ) != 0 ) { LimitOrder updatedOrder = withAmount ( limitOrder , orderBookUpdate . getTotalVolume ( ) ) ; limitOrders . add ( idx , updatedOrder ) ; } updateDate ( limitOrder . getTimestamp ( ) ) ; } | Given an OrderBookUpdate it will replace a matching limit order in the orderbook if one is found or add a new if one is not . timeStamp will be updated if the new timestamp is non - null and in the future . |
9,309 | public static Wallet adaptWallet ( GatecoinBalance [ ] gatecoinBalances ) { ArrayList < Balance > balances = new ArrayList < > ( ) ; for ( GatecoinBalance balance : gatecoinBalances ) { Currency ccy = Currency . getInstance ( balance . getCurrency ( ) ) ; balances . add ( new Balance . Builder ( ) . currency ( ccy ) . total ( balance . getBalance ( ) ) . available ( balance . getAvailableBalance ( ) ) . frozen ( balance . getOpenOrder ( ) . negate ( ) ) . withdrawing ( balance . getPendingOutgoing ( ) . negate ( ) ) . depositing ( balance . getPendingIncoming ( ) . negate ( ) ) . build ( ) ) ; } return new Wallet ( balances ) ; } | Adapts a GatecoinBalance to a Wallet |
9,310 | public String withdraw ( String asset , String address , BigDecimal amount ) throws IOException , BinanceException { String name = address . length ( ) <= 10 ? address : address . substring ( 0 , 10 ) ; return withdraw ( asset , address , amount , name , null , getTimestamp ( ) ) ; } | lack of current documentation |
9,311 | public Ticker getTicker ( CurrencyPair currencyPair , Object ... args ) throws IOException { return BitZAdapters . adaptTicker ( getBitZTicker ( BitZUtils . toPairString ( currencyPair ) ) , currencyPair ) ; } | X - Change Generic Services |
9,312 | public Map < Long , WexTradeHistoryResult > getBTCETradeHistory ( Long from , Long count , Long fromId , Long endId , WexAuthenticated . SortOrder order , Long since , Long end , String pair ) throws IOException { WexTradeHistoryReturn btceTradeHistory = btce . TradeHistory ( apiKey , signatureCreator , exchange . getNonceFactory ( ) , from , count , fromId , endId , order , since , end , pair ) ; String error = btceTradeHistory . getError ( ) ; if ( MSG_NO_TRADES . equals ( error ) ) { return Collections . emptyMap ( ) ; } checkResult ( btceTradeHistory ) ; return btceTradeHistory . getReturnValue ( ) ; } | All parameters are nullable |
9,313 | public Map < Long , WexTransHistoryResult > getBTCETransHistory ( Long from , Long count , Long fromId , Long endId , WexAuthenticated . SortOrder order , Long since , Long end ) throws IOException { WexTransHistoryReturn btceTransHistory = btce . TransHistory ( apiKey , signatureCreator , exchange . getNonceFactory ( ) , from , count , fromId , endId , order , since , end ) ; String error = btceTransHistory . getError ( ) ; if ( MSG_NO_TRADES . equals ( error ) ) { return Collections . emptyMap ( ) ; } checkResult ( btceTransHistory ) ; return btceTransHistory . getReturnValue ( ) ; } | Get Map of transaction history from Wex exchange . All parameters are nullable |
9,314 | public WexOrderInfoResult getBTCEOrderInfo ( Long orderId ) throws IOException { WexOrderInfoReturn btceOrderInfo = btce . OrderInfo ( apiKey , signatureCreator , exchange . getNonceFactory ( ) , orderId ) ; checkResult ( btceOrderInfo ) ; return btceOrderInfo . getReturnValue ( ) . values ( ) . iterator ( ) . next ( ) ; } | Get order info from Wex exchange . |
9,315 | public static AccountInfo adaptAccountInfo ( CoingiBalances coingiBalances , String userName ) { List < Balance > balances = new ArrayList < > ( ) ; for ( CoingiBalance coingiBalance : coingiBalances . getList ( ) ) { BigDecimal total = coingiBalance . getAvailable ( ) . add ( coingiBalance . getBlocked ( ) ) . add ( coingiBalance . getWithdrawing ( ) ) . add ( coingiBalance . getDeposited ( ) ) ; Balance xchangeBalance = new Balance ( Currency . getInstance ( coingiBalance . getCurrency ( ) . getName ( ) . toUpperCase ( ) ) , total , coingiBalance . getAvailable ( ) , coingiBalance . getBlocked ( ) , BigDecimal . ZERO , BigDecimal . ZERO , coingiBalance . getWithdrawing ( ) , coingiBalance . getDeposited ( ) ) ; balances . add ( xchangeBalance ) ; } return new AccountInfo ( userName , new Wallet ( balances ) ) ; } | Adapts a CoingiBalances to an AccountInfo |
9,316 | public Ticker getTicker ( CurrencyPair currencyPair , Object ... args ) throws IOException { String marketName = DSXAdapters . currencyPairToMarketName ( currencyPair ) ; String accountType = null ; try { if ( args != null ) { accountType = ( String ) args [ 0 ] ; } } catch ( ArrayIndexOutOfBoundsException e ) { } DSXTickerWrapper dsxTickerWrapper = getDSXTicker ( marketName , accountType ) ; return DSXAdapters . adaptTicker ( dsxTickerWrapper . getTicker ( marketName ) , currencyPair ) ; } | Get ticker from exchange |
9,317 | public CoinbasePrice getCoinbaseBuyPrice ( Currency base , Currency counter ) throws IOException { return coinbase . getBuyPrice ( Coinbase . CB_VERSION_VALUE , base + "-" + counter ) . getData ( ) ; } | Unauthenticated resource that tells you the price to buy one unit . |
9,318 | public CoinbasePrice getCoinbaseSellPrice ( Currency base , Currency counter ) throws IOException { return coinbase . getSellPrice ( Coinbase . CB_VERSION_VALUE , base + "-" + counter ) . getData ( ) ; } | Unauthenticated resource that tells you the amount you can get if you sell one unit . |
9,319 | public BitZKline getKline ( CurrencyPair currencyPair , BitZKlineResolution resolution , Integer size , String microsecond ) throws IOException { return bitz . getKline ( BitZUtils . toPairString ( currencyPair ) , resolution . code ( ) , size , microsecond ) . getData ( ) ; } | Get Kline data |
9,320 | public BitZTicker getTicker ( CurrencyPair currencyPair ) throws IOException { BitZTickerResult result = bitz . getTicker ( BitZUtils . toPairString ( currencyPair ) ) ; return result . getData ( ) ; } | Get the Ticker data |
9,321 | public BitZTickerAll getTickerAll ( CurrencyPair ... currencyPairs ) throws IOException { List < String > symbolList = new ArrayList < > ( currencyPairs . length ) ; Arrays . stream ( currencyPairs ) . forEach ( currencyPair -> symbolList . add ( BitZUtils . toPairString ( currencyPair ) ) ) ; String symbols = symbolList . stream ( ) . collect ( Collectors . joining ( "," ) ) ; BitZTickerAllResult result = bitz . getTickerAll ( symbols ) ; return result . getData ( ) ; } | Get the price of all symbol |
9,322 | public BitZOrders getDepth ( CurrencyPair currencyPair ) throws IOException { BitZOrdersResult result = bitz . getDepth ( BitZUtils . toPairString ( currencyPair ) ) ; return result . getData ( ) ; } | Get depth data |
9,323 | public BitZTrades getOrder ( CurrencyPair currencyPair ) throws IOException { BitZTradesResult result = bitz . getOrder ( BitZUtils . toPairString ( currencyPair ) ) ; return result . getData ( ) ; } | Get the order |
9,324 | protected JsonNode formAndSignRequestJson ( Map < String , String > params ) { CoinbeneUtils . signParams ( params ) ; return toJson ( params ) ; } | Sign request JSON . |
9,325 | protected Map < String , String > getCommonParams ( ) { Map < String , String > params = new TreeMap < > ( ) ; params . put ( "apiid" , apiKey ) ; params . put ( "secret" , secretKey ) ; params . put ( "timestamp" , String . valueOf ( exchange . getNonceFactory ( ) . createValue ( ) ) ) ; return params ; } | Return private API common params . |
9,326 | public static void adapt ( HttpStatusIOException httpStatusException ) { String msg = "HTTP Status: " + httpStatusException . getHttpStatusCode ( ) ; if ( isNotEmpty ( httpStatusException . getHttpBody ( ) ) ) { ObjectMapper mapper = new ObjectMapper ( ) ; CmcResult result ; try { result = mapper . readValue ( httpStatusException . getHttpBody ( ) , CmcResult . class ) ; } catch ( Exception e ) { throw new ExchangeException ( msg , httpStatusException ) ; } if ( result . getStatus ( ) != null && isNotEmpty ( result . getStatus ( ) . getErrorMessage ( ) ) && ! result . isSuccess ( ) ) { String error = result . getStatus ( ) . getErrorMessage ( ) ; if ( result . getStatus ( ) . getErrorCode ( ) == 401 ) { throw new ExchangeSecurityException ( error ) ; } if ( result . getStatus ( ) . getErrorCode ( ) == 402 ) { throw new FundsExceededException ( error ) ; } if ( result . getStatus ( ) . getErrorCode ( ) == 429 ) { throw new FrequencyLimitExceededException ( error ) ; } msg = error + " - ErrorCode: " + result . getStatus ( ) . getErrorCode ( ) ; throw new ExchangeException ( msg ) ; } } throw new ExchangeException ( msg , httpStatusException ) ; } | Parse errors from HTTP exceptions |
9,327 | public AccountInfo getAccountInfo ( ) throws IOException { final RippleAccountBalances account = getRippleAccountBalances ( ) ; final String username = exchange . getExchangeSpecification ( ) . getApiKey ( ) ; return RippleAdapters . adaptAccountInfo ( account , username ) ; } | A wallet s currency will be prefixed with the issuing counterparty address for all currencies other than XRP . |
9,328 | public Map < String , KrakenLedger > getKrakenLedgerInfo ( ) throws IOException { return getKrakenLedgerInfo ( null , null , null , null ) ; } | Retrieves the full account Ledger which represents all account asset activity . |
9,329 | public static void signParams ( Map < String , String > params ) { String requestString = params . entrySet ( ) . stream ( ) . sorted ( Comparator . comparing ( Map . Entry :: getKey ) ) . map ( e -> e . getKey ( ) + "=" + e . getValue ( ) ) . map ( String :: toUpperCase ) . collect ( Collectors . joining ( "&" ) ) ; String sign = md5 ( requestString ) . toLowerCase ( ) ; params . put ( "sign" , sign ) ; params . remove ( "secret" ) ; } | Sign Coinbene private API request parameters . |
9,330 | public static AccountInfo adaptAccountInfo ( CryptonitBalance cryptonitBalance , String userName ) { List < Balance > balances = new ArrayList < > ( ) ; for ( CryptonitBalance . Balance b : cryptonitBalance . getBalances ( ) ) { Balance xchangeBalance = new Balance ( Currency . getInstance ( b . getCurrency ( ) . toUpperCase ( ) ) , b . getBalance ( ) , b . getAvailable ( ) , b . getReserved ( ) , ZERO , ZERO , b . getBalance ( ) . subtract ( b . getAvailable ( ) ) . subtract ( b . getReserved ( ) ) , ZERO ) ; balances . add ( xchangeBalance ) ; } return new AccountInfo ( userName , cryptonitBalance . getFee ( ) , new Wallet ( balances ) ) ; } | Adapts a CryptonitBalance to an AccountInfo |
9,331 | public static OrderBook adaptOrderBook ( CryptonitOrderBook cryptonitOrderBook , CurrencyPair currencyPair ) { List < LimitOrder > asks = createOrders ( currencyPair , OrderType . ASK , cryptonitOrderBook . getAsks ( ) ) ; List < LimitOrder > bids = createOrders ( currencyPair , OrderType . BID , cryptonitOrderBook . getBids ( ) ) ; return new OrderBook ( cryptonitOrderBook . getTimestamp ( ) , asks , bids ) ; } | Adapts a org . knowm . xchange . cryptonit2 . api . model . OrderBook to a OrderBook Object |
9,332 | public static Ticker adaptTicker ( CryptonitTicker cryptonitTicker , CurrencyPair currencyPair ) { BigDecimal open = cryptonitTicker . getOpen ( ) ; BigDecimal last = cryptonitTicker . getLast ( ) ; BigDecimal bid = cryptonitTicker . getBid ( ) ; BigDecimal ask = cryptonitTicker . getAsk ( ) ; BigDecimal high = cryptonitTicker . getHigh ( ) ; BigDecimal low = cryptonitTicker . getLow ( ) ; BigDecimal vwap = cryptonitTicker . getVwap ( ) ; BigDecimal volume = cryptonitTicker . getVolume ( ) ; Date timestamp = new Date ( cryptonitTicker . getTimestamp ( ) * 1000L ) ; return new Ticker . Builder ( ) . currencyPair ( currencyPair ) . open ( open ) . last ( last ) . bid ( bid ) . ask ( ask ) . high ( high ) . low ( low ) . vwap ( vwap ) . volume ( volume ) . timestamp ( timestamp ) . build ( ) ; } | Adapts a CryptonitTicker to a Ticker Object |
9,333 | public static CryptonitGenericOrder adaptOrder ( String orderId , CryptonitOrderStatusResponse cryptonitOrderStatusResponse ) { CryptonitOrderTransaction [ ] cryptonitTransactions = cryptonitOrderStatusResponse . getTransactions ( ) ; CurrencyPair currencyPair = null ; Date date = null ; BigDecimal averagePrice = null ; BigDecimal cumulativeAmount = null ; BigDecimal totalFee = null ; if ( cryptonitTransactions . length > 0 ) { currencyPair = adaptCurrencyPair ( cryptonitTransactions [ 0 ] ) ; date = cryptonitTransactions [ 0 ] . getDatetime ( ) ; averagePrice = Arrays . stream ( cryptonitTransactions ) . map ( t -> t . getPrice ( ) ) . reduce ( ( x , y ) -> x . add ( y ) ) . get ( ) . divide ( BigDecimal . valueOf ( cryptonitTransactions . length ) , 2 ) ; cumulativeAmount = Arrays . stream ( cryptonitTransactions ) . map ( t -> getBaseCurrencyAmountFromCryptonitTransaction ( t ) ) . reduce ( ( x , y ) -> x . add ( y ) ) . get ( ) ; totalFee = Arrays . stream ( cryptonitTransactions ) . map ( t -> t . getFee ( ) ) . reduce ( ( x , y ) -> x . add ( y ) ) . get ( ) ; } OrderStatus orderStatus = adaptOrderStatus ( cryptonitOrderStatusResponse . getStatus ( ) , cryptonitTransactions . length ) ; CryptonitGenericOrder cryptonitGenericOrder = new CryptonitGenericOrder ( null , null , currencyPair , orderId , date , averagePrice , cumulativeAmount , totalFee , orderStatus ) ; return cryptonitGenericOrder ; } | There is no method to discern market versus limit order type - so this returns a generic CryptonitGenericOrder as a status |
9,334 | public static OrderBook adaptOrderBook ( CCEXGetorderbook ccexOrderBook , CurrencyPair currencyPair ) { List < LimitOrder > asks = createOrders ( currencyPair , Order . OrderType . ASK , ccexOrderBook . getAsks ( ) ) ; List < LimitOrder > bids = createOrders ( currencyPair , Order . OrderType . BID , ccexOrderBook . getBids ( ) ) ; Date date = new Date ( ) ; return new OrderBook ( date , asks , bids ) ; } | Adapts a org . knowm . xchange . ccex . api . model . OrderBook to a OrderBook Object |
9,335 | public static Ticker adaptTicker ( CoinmateTicker coinmateTicker , CurrencyPair currencyPair ) { BigDecimal last = coinmateTicker . getData ( ) . getLast ( ) ; BigDecimal bid = coinmateTicker . getData ( ) . getBid ( ) ; BigDecimal ask = coinmateTicker . getData ( ) . getAsk ( ) ; BigDecimal high = coinmateTicker . getData ( ) . getHigh ( ) ; BigDecimal low = coinmateTicker . getData ( ) . getLow ( ) ; BigDecimal volume = coinmateTicker . getData ( ) . getAmount ( ) ; Date timestamp = new Date ( coinmateTicker . getData ( ) . getTimestamp ( ) * 1000L ) ; return new Ticker . Builder ( ) . currencyPair ( currencyPair ) . last ( last ) . bid ( bid ) . ask ( ask ) . high ( high ) . low ( low ) . volume ( volume ) . timestamp ( timestamp ) . build ( ) ; } | Adapts a CoinmateTicker to a Ticker Object |
9,336 | public static String getBasicAuth ( String user , final String pass ) { return "Basic " + java . util . Base64 . getEncoder ( ) . encodeToString ( ( user + ":" + pass ) . getBytes ( ) ) ; } | Generates a BASE64 Basic Authentication String |
9,337 | public String requestDepositAddress ( Currency currency , String ... arguments ) throws IOException { GeminiDepositAddressResponse response = super . requestDepositAddressRaw ( currency ) ; return response . getAddress ( ) ; } | This will result in a new address being created each time and is severely rate - limited |
9,338 | public static OrderBook adaptOrderBook ( CryptopiaOrderBook cryptopiaOrderBook , CurrencyPair currencyPair ) { List < LimitOrder > asks = createOrders ( currencyPair , Order . OrderType . ASK , cryptopiaOrderBook . getAsks ( ) ) ; List < LimitOrder > bids = createOrders ( currencyPair , Order . OrderType . BID , cryptopiaOrderBook . getBids ( ) ) ; return new OrderBook ( new Date ( ) , asks , bids ) ; } | Adapts a CryptopiaOrderBook to an OrderBook Object |
9,339 | public static Ticker adaptTicker ( CryptopiaTicker cryptopiaTicker , CurrencyPair currencyPair ) { return new Ticker . Builder ( ) . currencyPair ( currencyPair ) . last ( cryptopiaTicker . getLast ( ) ) . bid ( cryptopiaTicker . getBid ( ) ) . ask ( cryptopiaTicker . getAsk ( ) ) . high ( cryptopiaTicker . getHigh ( ) ) . low ( cryptopiaTicker . getLow ( ) ) . volume ( cryptopiaTicker . getVolume ( ) ) . timestamp ( new Date ( ) ) . build ( ) ; } | Adapts a CryptopiaTicker to a Ticker Object |
9,340 | public CoinbasePrice getCoinbaseBuyPrice ( BigDecimal quantity , String currency ) throws IOException { return coinbase . getBuyPrice ( quantity , currency ) ; } | Unauthenticated resource that tells you the total price to buy some quantity of Bitcoin . |
9,341 | public CoinbasePrice getCoinbaseSellPrice ( BigDecimal quantity , String currency ) throws IOException { return coinbase . getSellPrice ( quantity , currency ) ; } | Unauthenticated resource that tells you the total amount you can get if you sell some quantity Bitcoin . |
9,342 | public CoinbaseSpotPriceHistory getCoinbaseHistoricalSpotRates ( Integer page ) throws IOException { return CoinbaseSpotPriceHistory . fromRawString ( coinbase . getHistoricalSpotRates ( page ) ) ; } | Unauthenticated resource that displays historical spot rates for Bitcoin in USD . |
9,343 | public static OrderBook adaptOrders ( CampBXOrderBook orderBook , CurrencyPair currencyPair ) { List < LimitOrder > asks = createOrders ( currencyPair , Order . OrderType . ASK , orderBook . getAsks ( ) ) ; List < LimitOrder > bids = createOrders ( currencyPair , Order . OrderType . BID , orderBook . getBids ( ) ) ; return new OrderBook ( null , asks , bids ) ; } | CampBXOrderBook to a OrderBook Object |
9,344 | public static Ticker adaptTicker ( CampBXTicker campbxTicker , CurrencyPair currencyPair ) { BigDecimal last = campbxTicker . getLast ( ) ; BigDecimal bid = campbxTicker . getBid ( ) ; BigDecimal ask = campbxTicker . getAsk ( ) ; return new Ticker . Builder ( ) . currencyPair ( currencyPair ) . last ( last ) . bid ( bid ) . ask ( ask ) . build ( ) ; } | Adapts a CampBXTicker to a Ticker Object |
9,345 | private static int futuresLeverageOfConfig ( ExchangeSpecification exchangeSpecification ) { if ( exchangeSpecification . getExchangeSpecificParameters ( ) . containsKey ( "Futures_Leverage" ) ) { return Integer . valueOf ( ( String ) exchangeSpecification . getExchangeSpecificParameters ( ) . get ( "Futures_Leverage" ) ) ; } else { return 10 ; } } | Extract futures leverage used by spec |
9,346 | public static FuturesContract futuresContractOfConfig ( ExchangeSpecification exchangeSpecification ) { FuturesContract contract ; if ( exchangeSpecification . getExchangeSpecificParameters ( ) . containsKey ( "Futures_Contract" ) ) { contract = ( FuturesContract ) exchangeSpecification . getExchangeSpecificParameters ( ) . get ( "Futures_Contract" ) ; } else if ( exchangeSpecification . getExchangeSpecificParameters ( ) . containsKey ( "Futures_Contract_String" ) ) { contract = FuturesContract . valueOfIgnoreCase ( FuturesContract . class , ( String ) exchangeSpecification . getExchangeSpecificParameters ( ) . get ( "Futures_Contract_String" ) ) ; } else { throw new RuntimeException ( "`Futures_Contract` or `Futures_Contract_String` not defined in exchange specific parameters." ) ; } return contract ; } | Extract contract used by spec |
9,347 | public static OrderBook adaptOrderBook ( BitcoindeOrderbookWrapper bitcoindeOrderbookWrapper , CurrencyPair currencyPair ) { List < LimitOrder > asks = createOrders ( currencyPair , Order . OrderType . ASK , bitcoindeOrderbookWrapper . getBitcoindeOrders ( ) . getAsks ( ) ) ; List < LimitOrder > bids = createOrders ( currencyPair , Order . OrderType . BID , bitcoindeOrderbookWrapper . getBitcoindeOrders ( ) . getBids ( ) ) ; Collections . sort ( bids , BID_COMPARATOR ) ; Collections . sort ( asks , ASK_COMPARATOR ) ; return new OrderBook ( null , asks , bids ) ; } | Adapt a org . knowm . xchange . bitcoinde . dto . marketdata . BitcoindeOrderBook object to an OrderBook object . |
9,348 | public static AccountInfo adaptAccountInfo ( BitcoindeAccountWrapper bitcoindeAccount ) { BitcoindeBalance btc = bitcoindeAccount . getData ( ) . getBalances ( ) . getBtc ( ) ; BitcoindeBalance eth = bitcoindeAccount . getData ( ) . getBalances ( ) . getEth ( ) ; BigDecimal eur = bitcoindeAccount . getData ( ) . getFidorReservation ( ) . getAvailableAmount ( ) ; Balance btcBalance = new Balance ( Currency . BTC , btc . getAvailableAmount ( ) ) ; Balance ethBalance = new Balance ( Currency . ETH , eth . getAvailableAmount ( ) ) ; Balance eurBalance = new Balance ( Currency . EUR , eur ) ; Wallet wallet = new Wallet ( btcBalance , ethBalance , eurBalance ) ; return new AccountInfo ( wallet ) ; } | Adapt a org . knowm . xchange . bitcoinde . dto . marketdata . BitcoindeAccount object to an AccountInfo object . |
9,349 | public static List < LimitOrder > createOrders ( CurrencyPair currencyPair , Order . OrderType orderType , BitcoindeOrder [ ] orders ) { List < LimitOrder > limitOrders = new ArrayList < > ( ) ; for ( BitcoindeOrder order : orders ) { limitOrders . add ( createOrder ( currencyPair , order , orderType , null , null ) ) ; } return limitOrders ; } | Create a list of orders from a list of asks or bids . |
9,350 | public static LimitOrder createOrder ( CurrencyPair currencyPair , BitcoindeOrder bitcoindeOrder , Order . OrderType orderType , String orderId , Date timeStamp ) { return new LimitOrder ( orderType , bitcoindeOrder . getAmount ( ) , currencyPair , orderId , timeStamp , bitcoindeOrder . getPrice ( ) ) ; } | Create an individual order . |
9,351 | public ItBitOrder [ ] getItBitOrders ( String status , String instrument ) throws IOException { ItBitOrder [ ] orders = itBitAuthenticated . getOrders ( signatureCreator , new Date ( ) . getTime ( ) , exchange . getNonceFactory ( ) , instrument , "1" , "1000" , status , walletId ) ; return orders ; } | Retrieves the set of orders with the given status . |
9,352 | public static String toUTCString ( Date date ) { SimpleDateFormat sd = new SimpleDateFormat ( "yyyy-MM-dd HH:mm:ss z" ) ; sd . setTimeZone ( TimeZone . getTimeZone ( "GMT" ) ) ; return sd . format ( date ) ; } | Converts a date to a UTC String representation |
9,353 | public static String formatDate ( Date d ) { return d == null ? null : DATE_FORMAT . format ( d ) ; } | Format a date String for IR |
9,354 | public static Date parseDate ( String dateString ) { try { return DATE_FORMAT . parse ( dateString ) ; } catch ( ParseException e ) { throw new ExchangeException ( "Illegal date/time format" , e ) ; } } | Format a date String for QuadrigaCx |
9,355 | public BigDecimal getTransferFeeRate ( ) { if ( transferRate == 0 ) { return BigDecimal . ZERO ; } else { return BigDecimal . valueOf ( transferRate ) . divide ( TRANSFER_RATE_DENOMINATOR ) . subtract ( BigDecimal . ONE ) ; } } | The raw transfer rate is represented as an integer the amount that must be sent in order for 1 billion units to arrive . For example a 20% transfer fee is represented as the value 120000000 . The value cannot be less than 1000000000 . Less than that would indicate giving away money for sending transactions which is exploitable . You can specify 0 as a shortcut for 1000000000 meaning no fee . |
9,356 | public boolean cancelOrder ( String orderId ) throws IOException { CurrencyPair cp = ( CurrencyPair ) exchange . getExchangeSpecification ( ) . getExchangeSpecificParameters ( ) . get ( TheRockExchange . CURRENCY_PAIR ) ; if ( cp == null ) { throw new ExchangeException ( "Provide TheRockCancelOrderParams with orderId and currencyPair" ) ; } return cancelOrder ( cp , orderId ) ; } | Not available from exchange since TheRock needs currency pair in order to cancel an order |
9,357 | public static AccountInfo adaptAccountInfo ( ANXAccountInfo anxAccountInfo ) { AccountInfo accountInfo = new AccountInfo ( anxAccountInfo . getLogin ( ) , percentToFactor ( anxAccountInfo . getTradeFee ( ) ) , ANXAdapters . adaptWallet ( anxAccountInfo . getWallets ( ) ) ) ; return accountInfo ; } | Adapts a ANXAccountInfo to an AccountInfo |
9,358 | public static LimitOrder adaptOrder ( BigDecimal originalAmount , BigDecimal price , String tradedCurrency , String transactionCurrency , String orderTypeString , String id , Date timestamp ) { OrderType orderType = adaptSide ( orderTypeString ) ; CurrencyPair currencyPair = adaptCurrencyPair ( tradedCurrency , transactionCurrency ) ; LimitOrder limitOrder = new LimitOrder ( orderType , originalAmount , currencyPair , id , timestamp , price ) ; return limitOrder ; } | Adapts a ANXOrder to a LimitOrder |
9,359 | public static List < LimitOrder > adaptOrders ( List < ANXOrder > anxOrders , String tradedCurrency , String currency , String orderType , String id ) { List < LimitOrder > limitOrders = new ArrayList < > ( ) ; for ( ANXOrder anxOrder : anxOrders ) { limitOrders . add ( adaptOrder ( anxOrder . getAmount ( ) , anxOrder . getPrice ( ) , tradedCurrency , currency , orderType , id , new Date ( anxOrder . getStamp ( ) ) ) ) ; } return limitOrders ; } | Adapts a List of ANXOrders to a List of LimitOrders |
9,360 | public static Balance adaptBalance ( ANXWallet anxWallet ) { if ( anxWallet == null ) { return null ; } else { return new Balance ( Currency . getInstance ( anxWallet . getBalance ( ) . getCurrency ( ) ) , anxWallet . getBalance ( ) . getValue ( ) , anxWallet . getAvailableBalance ( ) . getValue ( ) ) ; } } | Adapts a ANX Wallet to a XChange Balance |
9,361 | public static Wallet adaptWallet ( Map < String , ANXWallet > anxWallets ) { List < Balance > balances = new ArrayList < > ( ) ; for ( ANXWallet anxWallet : anxWallets . values ( ) ) { Balance balance = adaptBalance ( anxWallet ) ; if ( balance != null ) { balances . add ( balance ) ; } } return new Wallet ( balances ) ; } | Adapts a List of ANX Wallets to an XChange Wallet |
9,362 | public static Trades adaptTrades ( List < ANXTrade > anxTrades ) { List < Trade > tradesList = new ArrayList < > ( ) ; long latestTid = 0 ; for ( ANXTrade anxTrade : anxTrades ) { long tid = anxTrade . getTid ( ) ; if ( tid > latestTid ) { latestTid = tid ; } tradesList . add ( adaptTrade ( anxTrade ) ) ; } return new Trades ( tradesList , latestTid , TradeSortType . SortByID ) ; } | Adapts ANXTrade s to a Trades Object |
9,363 | public static Trade adaptTrade ( ANXTrade anxTrade ) { OrderType orderType = adaptSide ( anxTrade . getTradeType ( ) ) ; BigDecimal amount = anxTrade . getAmount ( ) ; BigDecimal price = anxTrade . getPrice ( ) ; CurrencyPair currencyPair = adaptCurrencyPair ( anxTrade . getItem ( ) , anxTrade . getPriceCurrency ( ) ) ; Date dateTime = DateUtils . fromMillisUtc ( anxTrade . getTid ( ) ) ; final String tradeId = String . valueOf ( anxTrade . getTid ( ) ) ; return new Trade ( orderType , amount , currencyPair , price , dateTime , tradeId ) ; } | Adapts a ANXTrade to a Trade Object |
9,364 | @ SuppressWarnings ( "unchecked" ) private OpenOrders filterOrders ( OpenOrders rawOpenOrders , OpenOrdersParams params ) { if ( params == null ) { return rawOpenOrders ; } List < LimitOrder > openOrdersList = rawOpenOrders . getOpenOrders ( ) ; openOrdersList . removeIf ( openOrder -> ! params . accept ( openOrder ) ) ; return new OpenOrders ( openOrdersList , ( List < Order > ) rawOpenOrders . getHiddenOrders ( ) ) ; } | Bitfinex API does not provide filtering option . So we should filter orders ourselves |
9,365 | public String abucoinsPaymentMethodForCurrency ( String currency ) throws IOException { String method = null ; AbucoinsPaymentMethod [ ] paymentMethods = getPaymentMethods ( ) ; for ( AbucoinsPaymentMethod apm : paymentMethods ) { if ( apm . getCurrency ( ) . equals ( currency ) ) { method = apm . getType ( ) ; break ; } } if ( method == null ) logger . warn ( "Unable to determine the payment method suitable for " + currency + " this will likely lead to an error" ) ; return method ; } | Helper method that obtains the payment method for a given currency based on the payment - method information returned from abucoins . |
9,366 | public static AccountInfo adaptAccountInfo ( LakeBTCAccount lakeBTCAccount ) { LakeBTCProfile profile = lakeBTCAccount . getProfile ( ) ; LakeBTCBalance balance = lakeBTCAccount . getBalance ( ) ; Balance usdBalance = new Balance ( Currency . USD , balance . getUSD ( ) ) ; Balance cnyWBalance = new Balance ( Currency . CNY , balance . getCNY ( ) ) ; Balance btcBalance = new Balance ( Currency . BTC , balance . getBTC ( ) ) ; return new AccountInfo ( profile . getId ( ) , new Wallet ( usdBalance , btcBalance , cnyWBalance ) ) ; } | Adapts a LakeBTCAccount to an AccountInfo |
9,367 | public static String adaptCurrencyPair ( CurrencyPair currencyPair ) { return currencyPair . base . getCurrencyCode ( ) . toLowerCase ( ) + currencyPair . counter . getCurrencyCode ( ) . toLowerCase ( ) ; } | Adapts a currency pair to the keys returned by the tickers map . |
9,368 | public static Wallet adaptWallet ( BitMarketBalance balance ) { List < Balance > balances = new ArrayList < > ( balance . getAvailable ( ) . size ( ) ) ; for ( Map . Entry < String , BigDecimal > entry : balance . getAvailable ( ) . entrySet ( ) ) { Currency currency = Currency . getInstance ( entry . getKey ( ) ) ; BigDecimal frozen = balance . getBlocked ( ) . containsKey ( entry . getKey ( ) ) ? balance . getBlocked ( ) . get ( entry . getKey ( ) ) : new BigDecimal ( "0" ) ; BigDecimal available = entry . getValue ( ) ; balances . add ( new Balance ( currency , available . add ( frozen ) , available , frozen ) ) ; } return new Wallet ( balances ) ; } | Adapts BitMarketBalance to Wallet |
9,369 | public static Ticker adaptTicker ( BitMarketTicker bitMarketTicker , CurrencyPair currencyPair ) { BigDecimal bid = bitMarketTicker . getBid ( ) ; BigDecimal ask = bitMarketTicker . getAsk ( ) ; BigDecimal high = bitMarketTicker . getHigh ( ) ; BigDecimal low = bitMarketTicker . getLow ( ) ; BigDecimal volume = bitMarketTicker . getVolume ( ) ; BigDecimal vwap = bitMarketTicker . getVwap ( ) ; BigDecimal last = bitMarketTicker . getLast ( ) ; return new Ticker . Builder ( ) . currencyPair ( currencyPair ) . last ( last ) . bid ( bid ) . ask ( ask ) . high ( high ) . low ( low ) . volume ( volume ) . vwap ( vwap ) . build ( ) ; } | Adapts BitMarket ticker to Ticker . |
9,370 | public Wallet getWallet ( ) { if ( wallets . size ( ) != 1 ) { throw new UnsupportedOperationException ( wallets . size ( ) + " wallets in account" ) ; } return getWallet ( wallets . keySet ( ) . iterator ( ) . next ( ) ) ; } | Gets wallet for accounts which don t use multiple wallets with ids |
9,371 | public static Ticker adaptTicker ( KoineksTicker koineksTicker , CurrencyPair currencyPair ) { switch ( currencyPair . base . getCurrencyCode ( ) ) { case KoineksCurrency . BTC : return getTickerOf ( koineksTicker . getKoineksBTCTicker ( ) , currencyPair . base ) ; case KoineksCurrency . ETH : return getTickerOf ( koineksTicker . getKoineksETHTicker ( ) , currencyPair . base ) ; case KoineksCurrency . LTC : return getTickerOf ( koineksTicker . getKoineksLTCTicker ( ) , currencyPair . base ) ; case KoineksCurrency . DASH : return getTickerOf ( koineksTicker . getKoineksDASHTicker ( ) , currencyPair . base ) ; case KoineksCurrency . DOGE : return getTickerOf ( koineksTicker . getKoineksDOGETicker ( ) , currencyPair . base ) ; default : throw new NotAvailableFromExchangeException ( ) ; } } | Adapts a KoineksTicker to a Ticker Object |
9,372 | public String placeLimitOrder ( LimitOrder placeOrder ) { OrderType type = placeOrder . getType ( ) ; Currency baseCurrency = placeOrder . getCurrencyPair ( ) . base ; Currency counterCurrency = placeOrder . getCurrencyPair ( ) . counter ; BigDecimal originalAmount = placeOrder . getOriginalAmount ( ) ; BigDecimal limitPrice = placeOrder . getLimitPrice ( ) ; OrderReq orderReq = createNormalizedLimitOrderReq ( baseCurrency , counterCurrency , type , limitPrice , originalAmount , null , null , null ) ; try { orderApi . order ( orderReq ) . getOrderHash ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } return null ; } | returns OrderHash so you can fetch it and cancel it ... but there is a OrderNumber that you can intercept if you need to . |
9,373 | public static Ticker adaptTicker ( ParibuTicker paribuTicker , CurrencyPair currencyPair ) { if ( ! currencyPair . equals ( new CurrencyPair ( BTC , TRY ) ) ) { throw new NotAvailableFromExchangeException ( ) ; } BTC_TL btcTL = paribuTicker . getBtcTL ( ) ; if ( btcTL != null ) { BigDecimal last = btcTL . getLast ( ) ; BigDecimal lowestAsk = btcTL . getLowestAsk ( ) ; BigDecimal highestBid = btcTL . getHighestBid ( ) ; BigDecimal volume = btcTL . getVolume ( ) ; BigDecimal high24hr = btcTL . getHigh24hr ( ) ; BigDecimal low24hr = btcTL . getLow24hr ( ) ; return new Ticker . Builder ( ) . currencyPair ( new CurrencyPair ( BTC , Currency . TRY ) ) . last ( last ) . bid ( highestBid ) . ask ( lowestAsk ) . high ( high24hr ) . low ( low24hr ) . volume ( volume ) . build ( ) ; } return null ; } | Adapts a ParibuTicker to a Ticker Object |
9,374 | public String requestDepositAddress ( Currency currency , String ... arguments ) throws IOException { try { CoingiDepositWalletRequest request = new CoingiDepositWalletRequest ( ) . setCurrency ( currency . getCurrencyCode ( ) . toUpperCase ( ) ) ; return depositWallet ( request ) . getAddress ( ) ; } catch ( CoingiException e ) { throw CoingiErrorAdapter . adapt ( e ) ; } } | This returns the current deposit address . It does not generate a new one! Repeated calls will return the same . |
9,375 | public static CoinsuperGenericOrder adaptOrder ( String orderId , OrderList orderList ) { BigDecimal averagePrice = new BigDecimal ( orderList . getPriceLimit ( ) ) ; BigDecimal cumulativeAmount = new BigDecimal ( orderList . getQuantity ( ) ) ; BigDecimal totalFee = new BigDecimal ( orderList . getFee ( ) ) ; BigDecimal amount = new BigDecimal ( orderList . getQuantity ( ) ) ; OrderType action = OrderType . ASK ; if ( orderList . getAction ( ) . equals ( "Buy" ) ) { action = OrderType . BID ; } OrderStatus orderStatus = OrderStatus . PENDING_NEW ; if ( orderList . getState ( ) . equals ( "UNDEAL" ) ) { orderStatus = OrderStatus . PENDING_NEW ; } else if ( orderList . getState ( ) . equals ( "Canceled" ) ) { orderStatus = OrderStatus . CANCELED ; } CoinsuperGenericOrder coinsuperGenericOrder = new CoinsuperGenericOrder ( action , amount , new CurrencyPair ( orderList . getSymbol ( ) ) , orderId , CommonUtil . timeStampToDate ( orderList . getUtcCreate ( ) ) , averagePrice , cumulativeAmount , totalFee , orderStatus ) ; return coinsuperGenericOrder ; } | There is no method to discern market versus limit order type - so this returns a generic GenericOrder as a status |
9,376 | public static AccountInfo adaptAccountInfo ( final RippleAccountBalances account , final String username ) { final Map < String , List < Balance > > balances = new HashMap < > ( ) ; for ( final RippleBalance balance : account . getBalances ( ) ) { final String walletId ; if ( balance . getCurrency ( ) . equals ( "XRP" ) ) { walletId = null ; } else { walletId = balance . getCounterparty ( ) ; } if ( ! balances . containsKey ( walletId ) ) { balances . put ( walletId , new LinkedList < Balance > ( ) ) ; } balances . get ( walletId ) . add ( new Balance ( Currency . getInstance ( balance . getCurrency ( ) ) , balance . getValue ( ) ) ) ; } final List < Wallet > accountInfo = new ArrayList < > ( balances . size ( ) ) ; for ( final Map . Entry < String , List < Balance > > wallet : balances . entrySet ( ) ) { accountInfo . add ( new Wallet ( wallet . getKey ( ) , wallet . getValue ( ) ) ) ; } return new AccountInfo ( username , BigDecimal . ZERO , accountInfo ) ; } | Adapts a Ripple Account to an XChange Wallet object . |
9,377 | public static OrderBook adaptOrderBook ( final RippleOrderBook rippleOrderBook , final RippleMarketDataParams params , final CurrencyPair currencyPair ) { final String orderBook = rippleOrderBook . getOrderBook ( ) ; final String [ ] splitPair = orderBook . split ( "/" ) ; final String [ ] baseSplit = splitPair [ 0 ] . split ( "\\+" ) ; final String baseSymbol = baseSplit [ 0 ] ; if ( baseSymbol . equals ( currencyPair . base . getCurrencyCode ( ) ) == false ) { throw new IllegalStateException ( String . format ( "base symbol in Ripple order book %s does not match requested base %s" , orderBook , currencyPair ) ) ; } final String baseCounterparty ; if ( baseSymbol . equals ( "XRP" ) ) { baseCounterparty = "" ; } else { baseCounterparty = baseSplit [ 1 ] ; } if ( baseCounterparty . equals ( params . getBaseCounterparty ( ) ) == false ) { throw new IllegalStateException ( String . format ( "base counterparty in Ripple order book %s does not match requested counterparty %s" , orderBook , params . getBaseCounterparty ( ) ) ) ; } final String [ ] counterSplit = splitPair [ 1 ] . split ( "\\+" ) ; final String counterSymbol = counterSplit [ 0 ] ; if ( counterSymbol . equals ( currencyPair . counter . getCurrencyCode ( ) ) == false ) { throw new IllegalStateException ( String . format ( "counter symbol in Ripple order book %s does not match requested base %s" , orderBook , currencyPair ) ) ; } final String counterCounterparty ; if ( counterSymbol . equals ( "XRP" ) ) { counterCounterparty = "" ; } else { counterCounterparty = counterSplit [ 1 ] ; } if ( counterCounterparty . equals ( params . getCounterCounterparty ( ) ) == false ) { throw new IllegalStateException ( String . format ( "counter counterparty in Ripple order book %s does not match requested counterparty %s" , orderBook , params . getCounterCounterparty ( ) ) ) ; } final List < LimitOrder > bids = createOrders ( currencyPair , OrderType . BID , rippleOrderBook . getBids ( ) , baseCounterparty , counterCounterparty ) ; final List < LimitOrder > asks = createOrders ( currencyPair , OrderType . ASK , rippleOrderBook . getAsks ( ) , baseCounterparty , counterCounterparty ) ; return new OrderBook ( null , asks , bids ) ; } | Adapts a Ripple OrderBook to an XChange OrderBook object . Counterparties are not mapped since the application calling this should know and keep track of the counterparties it is using in the polling thread . |
9,378 | public static OpenOrders adaptOpenOrders ( final RippleAccountOrders rippleOrders , final int scale ) { final List < LimitOrder > list = new ArrayList < > ( rippleOrders . getOrders ( ) . size ( ) ) ; for ( final RippleAccountOrdersBody order : rippleOrders . getOrders ( ) ) { final OrderType orderType ; final RippleAmount baseAmount ; final RippleAmount counterAmount ; if ( order . getType ( ) . equals ( "buy" ) ) { counterAmount = order . getTakerGets ( ) ; baseAmount = order . getTakerPays ( ) ; orderType = OrderType . BID ; } else { baseAmount = order . getTakerGets ( ) ; counterAmount = order . getTakerPays ( ) ; orderType = OrderType . ASK ; } final String baseSymbol = baseAmount . getCurrency ( ) ; final String counterSymbol = counterAmount . getCurrency ( ) ; final BigDecimal price = counterAmount . getValue ( ) . divide ( baseAmount . getValue ( ) , scale , RoundingMode . HALF_UP ) . stripTrailingZeros ( ) ; final CurrencyPair pair = new CurrencyPair ( baseSymbol , counterSymbol ) ; final RippleLimitOrder xchangeOrder = ( RippleLimitOrder ) new RippleLimitOrder . Builder ( orderType , pair ) . baseCounterparty ( baseAmount . getCounterparty ( ) ) . counterCounterparty ( counterAmount . getCounterparty ( ) ) . id ( Long . toString ( order . getSequence ( ) ) ) . limitPrice ( price ) . timestamp ( null ) . originalAmount ( baseAmount . getValue ( ) ) . build ( ) ; list . add ( xchangeOrder ) ; } return new OpenOrders ( list ) ; } | Adapts a Ripple Account Orders object to an XChange OpenOrders object Counterparties set in additional data since there is no other way of the application receiving this information . |
9,379 | public static boolean findLimitOrder ( List < LimitOrder > orders , LimitOrder order , String id ) { boolean found = false ; for ( LimitOrder openOrder : orders ) { if ( openOrder . getId ( ) . equalsIgnoreCase ( id ) ) { if ( order . getCurrencyPair ( ) . equals ( openOrder . getCurrencyPair ( ) ) && ( order . getOriginalAmount ( ) . compareTo ( openOrder . getOriginalAmount ( ) ) == 0 ) && ( order . getLimitPrice ( ) . compareTo ( openOrder . getLimitPrice ( ) ) == 0 ) ) { found = true ; } } } return found ; } | Find and match an order with id in orders |
9,380 | public static Ticker adaptTicker ( BitcoinAverageTicker bitcoinAverageTicker , CurrencyPair currencyPair ) { BigDecimal last = bitcoinAverageTicker . getLast ( ) ; BigDecimal bid = bitcoinAverageTicker . getBid ( ) ; BigDecimal ask = bitcoinAverageTicker . getAsk ( ) ; Date timestamp = bitcoinAverageTicker . getTimestamp ( ) ; BigDecimal volume = bitcoinAverageTicker . getVolume ( ) ; return new Ticker . Builder ( ) . currencyPair ( currencyPair ) . last ( last ) . bid ( bid ) . ask ( ask ) . volume ( volume ) . timestamp ( timestamp ) . build ( ) ; } | Adapts a BitcoinAverageTicker to a Ticker Object |
9,381 | public static Wallet adaptAccountInfo ( List < BitflyerBalance > balances ) { List < Balance > adaptedBalances = new ArrayList < > ( balances . size ( ) ) ; for ( BitflyerBalance balance : balances ) { adaptedBalances . add ( new Balance ( Currency . getInstance ( balance . getCurrencyCode ( ) ) , balance . getAmount ( ) , balance . getAvailable ( ) ) ) ; } return new Wallet ( adaptedBalances ) ; } | Adapts a list of BitflyerBalance objects to Wallet . |
9,382 | public static Ticker adaptTicker ( BitflyerTicker ticker , CurrencyPair currencyPair ) { BigDecimal bid = ticker . getBestBid ( ) ; BigDecimal ask = ticker . getBestAsk ( ) ; BigDecimal volume = ticker . getVolume ( ) ; BigDecimal last = ticker . getLtp ( ) ; Date timestamp = ticker . getTimestamp ( ) != null ? BitflyerUtils . parseDate ( ticker . getTimestamp ( ) ) : null ; return new Ticker . Builder ( ) . currencyPair ( currencyPair ) . bid ( bid ) . ask ( ask ) . last ( ask ) . volume ( volume ) . timestamp ( timestamp ) . build ( ) ; } | Adapts a BitflyerTicker to a Ticker Object |
9,383 | public static OrderBook adaptOrderBook ( MercadoBitcoinOrderBook mercadoBitcoinOrderBook , CurrencyPair currencyPair ) { List < LimitOrder > asks = createOrders ( currencyPair , OrderType . ASK , mercadoBitcoinOrderBook . getAsks ( ) ) ; List < LimitOrder > bids = createOrders ( currencyPair , OrderType . BID , mercadoBitcoinOrderBook . getBids ( ) ) ; return new OrderBook ( null , asks , bids ) ; } | Adapts a org . knowm . xchange . mercadobitcoin . dto . marketdata . OrderBook to a OrderBook Object |
9,384 | public static Ticker adaptTicker ( MercadoBitcoinTicker mercadoBitcoinTicker , CurrencyPair currencyPair ) { BigDecimal last = mercadoBitcoinTicker . getTicker ( ) . getLast ( ) ; BigDecimal bid = mercadoBitcoinTicker . getTicker ( ) . getBuy ( ) ; BigDecimal ask = mercadoBitcoinTicker . getTicker ( ) . getSell ( ) ; BigDecimal high = mercadoBitcoinTicker . getTicker ( ) . getHigh ( ) ; BigDecimal low = mercadoBitcoinTicker . getTicker ( ) . getLow ( ) ; BigDecimal volume = mercadoBitcoinTicker . getTicker ( ) . getVol ( ) ; Date timestamp = new Date ( mercadoBitcoinTicker . getTicker ( ) . getDate ( ) * 1000L ) ; return new Ticker . Builder ( ) . currencyPair ( currencyPair ) . last ( last ) . bid ( bid ) . ask ( ask ) . high ( high ) . low ( low ) . volume ( volume ) . timestamp ( timestamp ) . build ( ) ; } | Adapts a MercadoBitcoinTicker to a Ticker Object |
9,385 | private void setOReturn ( Object oReturn ) { if ( oReturn != null ) { if ( oReturn instanceof String ) { this . oReturnAsString = ( String ) oReturn ; } else if ( oReturn instanceof List ) { this . oReturn = new ArrayList < > ( ) ; for ( Object obj : ( List ) oReturn ) { if ( obj instanceof LinkedHashMap ) { addNewBitcointoyouOrderInfo ( ( Map < String , String > ) obj ) ; } else if ( obj instanceof BitcointoyouOrderInfo ) { this . oReturn . add ( ( BitcointoyouOrderInfo ) obj ) ; } } } else if ( oReturn instanceof Map ) { this . oReturn = new ArrayList < > ( ) ; addNewBitcointoyouOrderInfo ( ( Map < String , String > ) oReturn ) ; } } } | This complete messy it s because the oReturn JSON field can be either an Object or a String or an Array of Objects . |
9,386 | public static void hasLength ( String input , int length , String message ) { notNull ( input , message ) ; if ( input . trim ( ) . length ( ) != length ) { throw new IllegalArgumentException ( message ) ; } } | Asserts that a String is not null and of a certain length |
9,387 | public static void hasSize ( Collection < ? > input , int length , String message ) { notNull ( input , message ) ; if ( input . size ( ) != length ) { throw new IllegalArgumentException ( message ) ; } } | Asserts that a Collection is not null and of a certain size |
9,388 | public static LimitOrder adaptOrder ( BigDecimal amount , BigDecimal price , CurrencyPair currencyPair , OrderType orderType , String id ) { return new LimitOrder ( orderType , amount , currencyPair , id , null , price ) ; } | Adapts a WexOrder to a LimitOrder |
9,389 | public static Trade adaptTrade ( WexTrade bTCETrade , CurrencyPair currencyPair ) { OrderType orderType = bTCETrade . getTradeType ( ) . equalsIgnoreCase ( "bid" ) ? OrderType . BID : OrderType . ASK ; BigDecimal amount = bTCETrade . getAmount ( ) ; BigDecimal price = bTCETrade . getPrice ( ) ; Date date = DateUtils . fromMillisUtc ( bTCETrade . getDate ( ) * 1000L ) ; final String tradeId = String . valueOf ( bTCETrade . getTid ( ) ) ; return new Trade ( orderType , amount , currencyPair , price , date , tradeId ) ; } | Adapts a BTCETradeV3 to a Trade Object |
9,390 | public static Ticker adaptTicker ( WexTicker bTCETicker , CurrencyPair currencyPair ) { BigDecimal last = bTCETicker . getLast ( ) ; BigDecimal bid = bTCETicker . getSell ( ) ; BigDecimal ask = bTCETicker . getBuy ( ) ; BigDecimal high = bTCETicker . getHigh ( ) ; BigDecimal low = bTCETicker . getLow ( ) ; BigDecimal avg = bTCETicker . getAvg ( ) ; BigDecimal volume = bTCETicker . getVolCur ( ) ; Date timestamp = DateUtils . fromMillisUtc ( bTCETicker . getUpdated ( ) * 1000L ) ; return new Ticker . Builder ( ) . currencyPair ( currencyPair ) . last ( last ) . bid ( bid ) . ask ( ask ) . high ( high ) . low ( low ) . vwap ( avg ) . volume ( volume ) . timestamp ( timestamp ) . build ( ) ; } | Adapts a WexTicker to a Ticker Object |
9,391 | public static LimitOrder adaptOrderInfo ( String orderId , WexOrderInfoResult orderInfo ) { OrderType orderType = orderInfo . getType ( ) == WexOrderInfoResult . Type . buy ? OrderType . BID : OrderType . ASK ; BigDecimal price = orderInfo . getRate ( ) ; Date timestamp = DateUtils . fromMillisUtc ( orderInfo . getTimestampCreated ( ) * 1000L ) ; CurrencyPair currencyPair = adaptCurrencyPair ( orderInfo . getPair ( ) ) ; OrderStatus orderStatus = null ; switch ( orderInfo . getStatus ( ) ) { case 0 : if ( orderInfo . getAmount ( ) . compareTo ( orderInfo . getStartAmount ( ) ) == 0 ) { orderStatus = OrderStatus . NEW ; } else { orderStatus = OrderStatus . PARTIALLY_FILLED ; } break ; case 1 : orderStatus = OrderStatus . FILLED ; break ; case 2 : case 3 : orderStatus = OrderStatus . CANCELED ; break ; } return new LimitOrder ( orderType , orderInfo . getStartAmount ( ) , currencyPair , orderId , timestamp , price , price , orderInfo . getStartAmount ( ) . subtract ( orderInfo . getAmount ( ) ) , null , orderStatus ) ; } | Adapts a WexOrderInfoResult to a LimitOrder |
9,392 | private static Order . OrderStatus convertOrderStatus ( String status ) { switch ( status ) { case "new" : return Order . OrderStatus . NEW ; case "suspended" : return Order . OrderStatus . STOPPED ; case "partiallyFilled" : return Order . OrderStatus . PARTIALLY_FILLED ; case "filled" : return Order . OrderStatus . FILLED ; case "canceled" : return Order . OrderStatus . CANCELED ; case "expired" : return Order . OrderStatus . EXPIRED ; default : throw new RuntimeException ( "Unknown HitBTC transaction status: " + status ) ; } } | Decodes HitBTC Order status . |
9,393 | public OkCoinPriceLimit getPriceLimits ( CurrencyPair currencyPair , Object ... args ) throws IOException { if ( args != null && args . length > 0 ) return getFuturesPriceLimits ( currencyPair , ( FuturesContract ) args [ 0 ] ) ; else return getFuturesPriceLimits ( currencyPair , futuresContract ) ; } | Retrieves the max price from the okex imposed by the price limits |
9,394 | public static Ticker adaptTicker ( IndependentReserveTicker independentReserveTicker , CurrencyPair currencyPair ) { BigDecimal last = independentReserveTicker . getLast ( ) ; BigDecimal bid = independentReserveTicker . getBid ( ) ; BigDecimal ask = independentReserveTicker . getAsk ( ) ; BigDecimal high = independentReserveTicker . getHigh ( ) ; BigDecimal low = independentReserveTicker . getLow ( ) ; BigDecimal vwap = independentReserveTicker . getVwap ( ) ; BigDecimal volume = independentReserveTicker . getVolume ( ) ; Date timestamp = independentReserveTicker . getTimestamp ( ) ; return new Ticker . Builder ( ) . currencyPair ( currencyPair ) . last ( last ) . bid ( bid ) . ask ( ask ) . high ( high ) . low ( low ) . vwap ( vwap ) . volume ( volume ) . timestamp ( timestamp ) . build ( ) ; } | Adapts a IndependentReserveTicker to a Ticker Object |
9,395 | 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 |
9,396 | public static Balance zero ( Currency currency ) { return new Balance ( currency , BigDecimal . ZERO , BigDecimal . ZERO , BigDecimal . ZERO , BigDecimal . ZERO , BigDecimal . ZERO , BigDecimal . ZERO , BigDecimal . ZERO ) ; } | Returns a zero balance . |
9,397 | protected static String utcNow ( ) { Calendar calendar = Calendar . getInstance ( ) ; SimpleDateFormat dateFormat = new SimpleDateFormat ( "EEE, dd MMM yyyy HH:mm:ss z" , Locale . US ) ; dateFormat . setTimeZone ( TimeZone . getTimeZone ( "GMT" ) ) ; return dateFormat . format ( calendar . getTime ( ) ) ; } | current date in utc as http header |
9,398 | public static Ticker adaptTicker ( HuobiTicker huobiTicker , CurrencyPair currencyPair ) { Ticker . Builder builder = new Ticker . Builder ( ) ; builder . open ( huobiTicker . getOpen ( ) ) ; builder . ask ( huobiTicker . getAsk ( ) . getPrice ( ) ) ; builder . bid ( huobiTicker . getBid ( ) . getPrice ( ) ) ; builder . last ( huobiTicker . getClose ( ) ) ; builder . high ( huobiTicker . getHigh ( ) ) ; builder . low ( huobiTicker . getLow ( ) ) ; builder . volume ( huobiTicker . getVol ( ) ) ; builder . timestamp ( huobiTicker . getTs ( ) ) ; builder . currencyPair ( currencyPair ) ; return builder . build ( ) ; } | Trading fee at Huobi is 0 . 2 % |
9,399 | public TheRockWithdrawalResponse withdrawDefault ( Currency currency , BigDecimal amount , String destinationAddress ) throws TheRockException , IOException { final TheRockWithdrawal withdrawal = TheRockWithdrawal . createDefaultWithdrawal ( currency . getCurrencyCode ( ) , amount , destinationAddress ) ; return theRockAuthenticated . withdraw ( apiKey , signatureCreator , exchange . getNonceFactory ( ) , withdrawal ) ; } | Withdraw using the default method |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.