proj_name
stringclasses 131
values | relative_path
stringlengths 30
228
| class_name
stringlengths 1
68
| func_name
stringlengths 1
48
| masked_class
stringlengths 78
9.82k
| func_body
stringlengths 46
9.61k
| len_input
int64 29
2.01k
| len_output
int64 14
1.94k
| total
int64 55
2.05k
| relevant_context
stringlengths 0
38.4k
|
|---|---|---|---|---|---|---|---|---|---|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/bithumb/marketdata/BithumbMarketDataDemo.java
|
BithumbMarketDataDemo
|
main
|
class BithumbMarketDataDemo {
private static final CurrencyPair BTC_KRW = CurrencyPair.BTC_KRW;
public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>}
private static void generic(MarketDataService marketDataService) throws IOException {
System.out.println("----------GENERIC----------");
System.out.println(marketDataService.getTicker(BTC_KRW));
System.out.println(marketDataService.getTickers(null));
System.out.println(marketDataService.getOrderBook(BTC_KRW));
System.out.println(marketDataService.getTrades(BTC_KRW));
}
private static void raw(BithumbMarketDataServiceRaw marketDataServiceRaw) throws IOException {
System.out.println("----------RAW----------");
System.out.println(marketDataServiceRaw.getBithumbTicker(BTC_KRW));
System.out.println(marketDataServiceRaw.getBithumbTickers());
System.out.println(marketDataServiceRaw.getBithumbOrderBook(BTC_KRW));
System.out.println(marketDataServiceRaw.getBithumbTrades(BTC_KRW));
}
}
|
Exchange exchange = BithumbDemoUtils.createExchange();
MarketDataService marketDataService = exchange.getMarketDataService();
generic(marketDataService);
raw((BithumbMarketDataServiceRaw) marketDataService);
| 335
| 63
| 398
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/bitmex/dto/marketdata/BitmexMarketdataDemo.java
|
BitmexMarketdataDemo
|
ticker
|
class BitmexMarketdataDemo {
public static void main(String[] args) throws IOException {
Exchange exchange = BitmexDemoUtils.createExchange();
MarketDataService service = exchange.getMarketDataService();
ticker(service);
}
private static void ticker(MarketDataService service) throws IOException {<FILL_FUNCTION_BODY>}
}
|
// Get the ticker/markets information
BitmexMarketDataServiceRaw serviceRaw = (BitmexMarketDataServiceRaw) service;
List<BitmexTicker> tickers = serviceRaw.getActiveTickers();
System.out.println(tickers);
tickers = serviceRaw.getTicker("Xbt");
System.out.println(tickers);
List<BitmexTicker> ticker = serviceRaw.getTicker("XBt");
System.out.println(ticker);
| 101
| 138
| 239
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/bitso/marketdata/BitsoMarketDataDemo.java
|
BitsoMarketDataDemo
|
main
|
class BitsoMarketDataDemo {
public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>}
private static void generic(MarketDataService marketDataService) throws IOException {
CurrencyPair cp = new CurrencyPair(Currency.BTC, Currency.MXN);
Ticker ticker = marketDataService.getTicker(cp);
System.out.println("Ticker: " + ticker);
// Get the latest order book data for BTCMXN
OrderBook orderBook = marketDataService.getOrderBook(cp);
System.out.println(
"Current Order Book size for BTC / MXN: "
+ (orderBook.getAsks().size() + orderBook.getBids().size()));
System.out.println("First Ask: " + orderBook.getAsks().get(0).toString());
System.out.println(
"Last Ask: " + orderBook.getAsks().get(orderBook.getAsks().size() - 1).toString());
System.out.println("First Bid: " + orderBook.getBids().get(0).toString());
System.out.println(
"Last Bid: " + orderBook.getBids().get(orderBook.getBids().size() - 1).toString());
System.out.println(orderBook.toString());
// Get trades within the last hour
Object[] args = {"hour"};
List<Trade> trades = marketDataService.getTrades(cp, args).getTrades();
System.out.println("Number Trades within last hour: " + trades.size());
for (Trade t : trades) {
System.out.println(" " + t);
}
}
private static void raw(BitsoMarketDataServiceRaw marketDataService) throws IOException {
BitsoTicker ticker = marketDataService.getBitsoTicker(CurrencyPair.BTC_MXN);
System.out.println("Ticker: " + ticker);
// Get the latest order book data for BTCMXN
BitsoOrderBook orderBook = marketDataService.getBitsoOrderBook(CurrencyPair.BTC_MXN);
System.out.println(
"Current Order Book size for BTC / MXN: "
+ (orderBook.getAsks().size() + orderBook.getBids().size()));
System.out.println("First Ask: " + orderBook.getAsks().get(0).toString());
System.out.println("First Bid: " + orderBook.getBids().get(0).toString());
System.out.println(orderBook.toString());
}
}
|
// Use the factory to get Bitso exchange API using default settings
Exchange bitso = ExchangeFactory.INSTANCE.createExchange(BitsoExchange.class);
// Interested in the public market data feed (no authentication)
MarketDataService marketDataService = bitso.getMarketDataService();
generic(marketDataService);
raw((BitsoMarketDataServiceRaw) marketDataService);
| 675
| 101
| 776
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/bitso/trade/BitsoTradeDemo.java
|
BitsoTradeDemo
|
generic
|
class BitsoTradeDemo {
public static void main(String[] args) throws IOException {
Exchange bitso = BitsoDemoUtils.createExchange();
TradeService tradeService = bitso.getTradeService();
generic(tradeService);
raw((BitsoTradeServiceRaw) tradeService);
}
private static void generic(TradeService tradeService) throws IOException {<FILL_FUNCTION_BODY>}
private static void printOpenOrders(TradeService tradeService) throws IOException {
OpenOrders openOrders = tradeService.getOpenOrders();
System.out.println("Open Orders: " + openOrders.toString());
}
private static void raw(BitsoTradeServiceRaw tradeService) throws IOException {
printRawOpenOrders(tradeService);
// place a limit buy order
BitsoOrder order =
tradeService.sellBitsoOrder(new BigDecimal("0.01"), new BigDecimal("5000.00"));
System.out.println("BitsoOrder return value: " + order);
printRawOpenOrders(tradeService);
// Cancel the added order
boolean cancelResult = tradeService.cancelBitsoOrder(order.getId());
System.out.println("Canceling returned " + cancelResult);
printRawOpenOrders(tradeService);
}
private static void printRawOpenOrders(BitsoTradeServiceRaw tradeService) throws IOException {
BitsoOrder[] openOrders = tradeService.getBitsoOpenOrders();
System.out.println("Open Orders: " + openOrders.length);
for (BitsoOrder order : openOrders) {
System.out.println(order.toString());
}
}
}
|
printOpenOrders(tradeService);
// place a limit buy order
LimitOrder limitOrder =
new LimitOrder(
(OrderType.ASK),
new BigDecimal("0.01"),
new CurrencyPair(Currency.BTC, Currency.MXN),
"",
null,
new BigDecimal("5000.00"));
String limitOrderReturnValue = tradeService.placeLimitOrder(limitOrder);
System.out.println("Limit Order return value: " + limitOrderReturnValue);
printOpenOrders(tradeService);
// Cancel the added order
boolean cancelResult = tradeService.cancelOrder(limitOrderReturnValue);
System.out.println("Canceling returned " + cancelResult);
printOpenOrders(tradeService);
| 445
| 206
| 651
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/bitstamp/account/BitstampSepaWithdrawal.java
|
BitstampSepaWithdrawal
|
raw
|
class BitstampSepaWithdrawal {
public static void main(String[] args) throws IOException {
Exchange bitstamp = BitstampDemoUtils.createExchange();
AccountService accountService = bitstamp.getAccountService();
raw((BitstampAccountServiceRaw) accountService);
}
private static void raw(BitstampAccountServiceRaw accountService) throws IOException {<FILL_FUNCTION_BODY>}
}
|
// Get the account information
BitstampBalance bitstampBalance = accountService.getBitstampBalance();
System.out.println("BitstampBalance: " + bitstampBalance);
BitstampDepositAddress depositAddress = accountService.getBitstampBitcoinDepositAddress();
System.out.println("BitstampDepositAddress address: " + depositAddress);
accountService.withdrawSepa(
new BigDecimal("150"),
"Kovin Kostner",
"BY13NBRB3600900000002Z00AB00",
"DABAIE2D",
"Minsk, Belarus, Main street 2",
"197372",
"Minsk",
Country.Belarus.alpha2);
| 112
| 220
| 332
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/bitstamp/marketdata/DepthChartDemo.java
|
DepthChartDemo
|
main
|
class DepthChartDemo {
public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>}
}
|
// Use the factory to get the version 1 Bitstamp exchange API using default settings
Exchange bitstampExchange = ExchangeFactory.INSTANCE.createExchange(BitstampExchange.class);
// Interested in the public market data feed (no authentication)
MarketDataService marketDataService = bitstampExchange.getMarketDataService();
System.out.println("fetching data...");
// Get the current orderbook
OrderBook orderBook = marketDataService.getOrderBook(CurrencyPair.BTC_USD);
System.out.println("orderBook = " + orderBook);
System.out.println("received data.");
System.out.println("plotting...");
// Create Chart
XYChart chart =
new XYChartBuilder()
.width(800)
.height(600)
.title("Bitstamp Order Book")
.xAxisTitle("BTC")
.yAxisTitle("USD")
.build();
// Customize Chart
chart.getStyler().setDefaultSeriesRenderStyle(XYSeriesRenderStyle.Area);
// BIDS
List<Number> xData = new ArrayList<>();
List<Number> yData = new ArrayList<>();
BigDecimal accumulatedBidUnits = new BigDecimal("0");
for (LimitOrder limitOrder : orderBook.getBids()) {
if (limitOrder.getLimitPrice().doubleValue() > 5000) {
xData.add(limitOrder.getLimitPrice());
accumulatedBidUnits = accumulatedBidUnits.add(limitOrder.getOriginalAmount());
yData.add(accumulatedBidUnits);
}
}
Collections.reverse(xData);
Collections.reverse(yData);
// Bids Series
XYSeries series = chart.addSeries("bids", xData, yData);
series.setMarker(SeriesMarkers.NONE);
// ASKS
xData = new ArrayList<>();
yData = new ArrayList<>();
BigDecimal accumulatedAskUnits = new BigDecimal("0");
for (LimitOrder limitOrder : orderBook.getAsks()) {
if (limitOrder.getLimitPrice().doubleValue() < 20000) {
xData.add(limitOrder.getLimitPrice());
accumulatedAskUnits = accumulatedAskUnits.add(limitOrder.getOriginalAmount());
yData.add(accumulatedAskUnits);
}
}
// Asks Series
series = chart.addSeries("asks", xData, yData);
series.setMarker(SeriesMarkers.NONE);
new SwingWrapper(chart).displayChart();
| 37
| 687
| 724
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/bitstamp/marketdata/TradesDemo.java
|
TradesDemo
|
generic
|
class TradesDemo {
public static void main(String[] args) throws IOException {
// Use the factory to get Bitstamp exchange API using default settings
Exchange bitstamp = ExchangeFactory.INSTANCE.createExchange(BitstampExchange.class);
// Interested in the public market data feed (no authentication)
MarketDataService marketDataService = bitstamp.getMarketDataService();
generic(marketDataService);
raw((BitstampMarketDataServiceRaw) marketDataService);
}
private static void generic(MarketDataService marketDataService) throws IOException {<FILL_FUNCTION_BODY>}
private static void raw(BitstampMarketDataServiceRaw marketDataService) throws IOException {
// Get the latest trade data for BTC/USD
BitstampTransaction[] trades = marketDataService.getTransactions(CurrencyPair.BTC_USD, null);
System.out.println("Trades, default. Size= " + trades.length);
trades =
marketDataService.getTransactions(
CurrencyPair.BTC_USD, BitstampMarketDataServiceRaw.BitstampTime.HOUR);
System.out.println("Trades, hour= " + trades.length);
trades =
marketDataService.getTransactions(
CurrencyPair.BTC_USD, BitstampMarketDataServiceRaw.BitstampTime.MINUTE);
System.out.println("Trades, minute= " + trades.length);
System.out.println(Arrays.toString(trades));
}
}
|
// Get the latest trade data for BTC/USD
Trades trades = marketDataService.getTrades(CurrencyPair.BTC_USD);
System.out.println("Trades, default. Size= " + trades.getTrades().size());
trades =
marketDataService.getTrades(
CurrencyPair.BTC_USD, BitstampMarketDataServiceRaw.BitstampTime.HOUR);
System.out.println("Trades, hour= " + trades.getTrades().size());
trades =
marketDataService.getTrades(
CurrencyPair.BTC_USD, BitstampMarketDataServiceRaw.BitstampTime.MINUTE);
System.out.println("Trades, minute= " + trades.getTrades().size());
System.out.println(trades.toString());
| 394
| 214
| 608
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/bitstamp/trade/BitstampUserTradeHistoryDemo.java
|
BitstampUserTradeHistoryDemo
|
main
|
class BitstampUserTradeHistoryDemo {
public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>}
private static void generic(TradeService tradeService) throws IOException {
Trades trades = tradeService.getTradeHistory(tradeService.createTradeHistoryParams());
System.out.println(trades);
// Warning: using a limit here can be misleading. The underlying call
// retrieves trades, withdrawals, and deposits. So the example here will
// limit the result to 17 of those types and from those 17 only trades are
// returned. It is recommended to use the raw service demonstrated below
// if you want to use this feature.
BitstampTradeHistoryParams params =
(BitstampTradeHistoryParams) tradeService.createTradeHistoryParams();
params.setPageLength(17);
params.setCurrencyPair(CurrencyPair.BTC_USD);
Trades tradesLimitedTo17 = tradeService.getTradeHistory(params);
System.out.println(tradesLimitedTo17);
}
private static void raw(BitstampTradeServiceRaw tradeService) throws IOException {
BitstampUserTransaction[] tradesLimitedTo17 =
tradeService.getBitstampUserTransactions(17L, CurrencyPair.BTC_USD);
for (BitstampUserTransaction trade : tradesLimitedTo17) {
System.out.println(trade);
}
}
}
|
Exchange bitstamp = BitstampDemoUtils.createExchange();
TradeService tradeService = bitstamp.getTradeService();
generic(tradeService);
raw((BitstampTradeServiceRaw) tradeService);
| 385
| 62
| 447
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/bitz/BitZTickerDemo.java
|
BitZTickerDemo
|
main
|
class BitZTickerDemo {
public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>}
}
|
// Create Default BitZ Instance
Exchange bitZ = ExchangeFactory.INSTANCE.createExchange(BitZExchange.class);
// Get The Public Market Data Service
MarketDataService marketDataService = bitZ.getMarketDataService();
BitZMarketDataServiceRaw rawMarketDataService = (BitZMarketDataServiceRaw) marketDataService;
// Currency Pair To Get Ticker Of
CurrencyPair pair = CurrencyPair.LTC_BTC;
// Print The Generic and Raw Ticker
System.out.println(marketDataService.getTicker(pair));
System.out.println(rawMarketDataService.getBitZTicker(BitZUtils.toPairString(pair)));
| 38
| 182
| 220
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/blockchain/marketdata/BlockchainMarketDataDemo.java
|
BlockchainMarketDataDemo
|
marketDataServiceDemo
|
class BlockchainMarketDataDemo {
private static final Exchange BLOCKCHAIN_EXCHANGE = BlockchainDemoUtils.createExchange();
private static final ObjectMapper OBJECT_MAPPER =
new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT);
public static void main(String[] args) throws IOException, InterruptedException {
System.out.println("===== MARKETDATA SERVICE =====");
marketDataServiceDemo();
}
private static void marketDataServiceDemo() throws IOException {<FILL_FUNCTION_BODY>}
}
|
MarketDataService marketDataService = BLOCKCHAIN_EXCHANGE.getMarketDataService();
System.out.println("===== ORDERBOOK FOR BTC/USD =====");
Instrument instrument = CurrencyPair.BTC_USD;
OrderBook orders = marketDataService.getOrderBook(instrument);
System.out.println(OBJECT_MAPPER.writeValueAsString(orders));
| 145
| 104
| 249
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/btcmarkets/BTCMarketsAccountDemo.java
|
BTCMarketsAccountDemo
|
generic
|
class BTCMarketsAccountDemo {
public static void main(String[] args) throws IOException {
Exchange btcMarketsExchange = BTCMarketsExampleUtils.createTestExchange();
generic(btcMarketsExchange);
raw(btcMarketsExchange);
}
private static void generic(Exchange btcMarketsExchange) throws IOException {<FILL_FUNCTION_BODY>}
private static void raw(Exchange btcMarketsExchange) throws IOException {
BTCMarketsAccountServiceRaw rawBTCMarketsAcctService =
(BTCMarketsAccountServiceRaw) btcMarketsExchange.getAccountService();
System.out.println("Balance Info: " + rawBTCMarketsAcctService.getBTCMarketsBalance());
}
}
|
AccountInfo accountInfo = btcMarketsExchange.getAccountService().getAccountInfo();
System.out.println("Account Info: " + accountInfo);
| 201
| 41
| 242
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/btcmarkets/BTCMarketsTradeDemo.java
|
BTCMarketsTradeDemo
|
main
|
class BTCMarketsTradeDemo {
public static void main(String[] args) throws Exception {<FILL_FUNCTION_BODY>}
}
|
Exchange btcMarketsExchange = BTCMarketsExampleUtils.createTestExchange();
TradeService tradeService = btcMarketsExchange.getTradeService();
final OpenOrdersParamCurrencyPair openOrdersParams =
(OpenOrdersParamCurrencyPair) tradeService.createOpenOrdersParams();
openOrdersParams.setCurrencyPair(CurrencyPair.BTC_AUD);
System.out.println("Open Orders: " + tradeService.getOpenOrders(openOrdersParams));
// Place a limit sell order at a high price
LimitOrder sellOrder =
new LimitOrder(
(OrderType.ASK),
new BigDecimal("0.003"),
CurrencyPair.BTC_AUD,
null,
null,
new BigDecimal("2000"));
String limitOrderReturnValue = tradeService.placeLimitOrder(sellOrder);
System.out.println("Limit Order return value: " + limitOrderReturnValue);
System.out.println("Waiting a while for the order to get registered...");
Thread.sleep(2000);
System.out.println("Open Orders: " + tradeService.getOpenOrders(openOrdersParams));
openOrdersParams.setCurrencyPair(CurrencyPair.LTC_BTC);
System.out.println("Open Orders for LTC/BTC: " + tradeService.getOpenOrders(openOrdersParams));
// Cancel the added order.
boolean cancelResult = tradeService.cancelOrder(limitOrderReturnValue);
System.out.println("Canceling returned " + cancelResult);
System.out.println("Open Orders: " + tradeService.getOpenOrders(openOrdersParams));
// An example of a sell market order
MarketOrder sellMarketOrder =
new MarketOrder((OrderType.ASK), new BigDecimal("0.003"), CurrencyPair.BTC_AUD, null, null);
String marketSellOrderId = tradeService.placeMarketOrder(sellMarketOrder);
System.out.println("Market Order return value: " + marketSellOrderId);
// An example of a buy limit order.
LimitOrder buyOrder =
new LimitOrder(
(OrderType.BID),
new BigDecimal("0.002"),
CurrencyPair.BTC_AUD,
null,
null,
new BigDecimal("240"));
String buyLimiOrderId = tradeService.placeLimitOrder(buyOrder);
System.out.println("Limit Order return value: " + buyLimiOrderId);
// An example of a buy market order
MarketOrder buyMarketOrder =
new MarketOrder((OrderType.BID), new BigDecimal("0.004"), CurrencyPair.BTC_AUD, null, null);
String buyMarketOrderId = tradeService.placeMarketOrder(buyMarketOrder);
System.out.println("Market Order return value: " + buyMarketOrderId);
// Get history of executed trades.
BTCMarketsTradeService.HistoryParams params =
(BTCMarketsTradeService.HistoryParams) tradeService.createTradeHistoryParams();
params.setPageLength(10);
params.setCurrencyPair(CurrencyPair.BTC_AUD);
final UserTrades tradeHistory = tradeService.getTradeHistory(params);
System.out.println("Trade history: " + tradeHistory);
| 40
| 875
| 915
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/btcturk/account/BTCTurkAccountDemo.java
|
BTCTurkAccountDemo
|
main
|
class BTCTurkAccountDemo {
public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>}
private static void generic(AccountService accountService) throws IOException {
Map<Currency, Balance> balances = accountService.getAccountInfo().getWallet().getBalances();
System.out.println(balances.toString());
System.out.println(accountService.requestDepositAddress(Currency.BTC));
}
private static void raw(BTCTurkAccountServiceRaw accountService) throws IOException {
BTCTurkAccountBalance responseBalances = accountService.getBTCTurkBalance();
System.out.println(responseBalances.toString());
System.out.println(responseBalances.getBtc_balance().toString());
}
}
|
// Use the factory to get BTCTurk exchange API using default settings
Exchange exchange = BTCTurkDemoUtils.createExchange();
AccountService accountService = exchange.getAccountService();
generic(accountService);
raw((BTCTurkAccountServiceRaw) accountService);
| 207
| 75
| 282
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/ccex/CCEXExamplesUtils.java
|
CCEXExamplesUtils
|
getExchange
|
class CCEXExamplesUtils {
public static Exchange getExchange() {<FILL_FUNCTION_BODY>}
}
|
ExchangeSpecification exSpec = new ExchangeSpecification(CCEXExchange.class);
exSpec.setApiKey("");
exSpec.setSecretKey("");
return ExchangeFactory.INSTANCE.createExchange(exSpec);
| 33
| 62
| 95
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/ccex/marketdata/OrderBookDemo.java
|
OrderBookDemo
|
main
|
class OrderBookDemo {
public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>}
}
|
Exchange ccexExchange = ExchangeFactory.INSTANCE.createExchange(CCEXExchange.class);
// Interested in the public market data feed (no authentication)
MarketDataService marketDataService = ccexExchange.getMarketDataService();
System.out.println("fetching data...");
// Get the current orderbook
OrderBook orderBook = marketDataService.getOrderBook(CurrencyPair.XAUR_BTC);
System.out.println("received data.");
for (LimitOrder limitOrder : orderBook.getBids()) {
System.out.println(
limitOrder.getType()
+ " "
+ limitOrder.getCurrencyPair()
+ " Limit price: "
+ limitOrder.getLimitPrice()
+ " Amount: "
+ limitOrder.getOriginalAmount());
}
for (LimitOrder limitOrder : orderBook.getAsks()) {
System.out.println(
limitOrder.getType()
+ " "
+ limitOrder.getCurrencyPair()
+ " Limit price: "
+ limitOrder.getLimitPrice()
+ " Amount: "
+ limitOrder.getOriginalAmount());
}
| 36
| 309
| 345
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/ccex/marketdata/TickerDemo.java
|
TickerDemo
|
main
|
class TickerDemo {
public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>}
}
|
Exchange ccexExchange = ExchangeFactory.INSTANCE.createExchange(CCEXExchange.class);
// Interested in the public market data feed (no authentication)
MarketDataService marketDataService = ccexExchange.getMarketDataService();
System.out.println("fetching data...");
// Get the current orderbook
Ticker ticker = marketDataService.getTicker(CurrencyPair.XAUR_BTC);
System.out.println("received data.");
System.out.println(ticker);
| 36
| 141
| 177
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/cexio/CexIODemoUtils.java
|
CexIODemoUtils
|
createExchange
|
class CexIODemoUtils {
public static Exchange createExchange() {<FILL_FUNCTION_BODY>}
}
|
ExchangeSpecification exSpec = new ExchangeSpecification(CexIOExchange.class);
exSpec.setUserName("");
exSpec.setSecretKey("");
exSpec.setApiKey("");
exSpec.setSslUri("https://cex.io");
return ExchangeFactory.INSTANCE.createExchange(exSpec);
| 35
| 88
| 123
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/cexio/account/AccountInfoDemo.java
|
AccountInfoDemo
|
main
|
class AccountInfoDemo {
public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>}
}
|
Exchange exchange = CexIODemoUtils.createExchange();
AccountService accountService = exchange.getAccountService();
// Get the account information
AccountInfo accountInfo = accountService.getAccountInfo();
System.out.println("AccountInfo as String: " + accountInfo.toString());
| 36
| 76
| 112
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/cexio/marketdata/TickerDemo.java
|
TickerDemo
|
main
|
class TickerDemo {
public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>}
}
|
// Use the factory to get Cex.IO exchange API using default settings
Exchange exchange = ExchangeFactory.INSTANCE.createExchange(CexIOExchange.class);
// Interested in the public market data feed (no authentication)
MarketDataService marketDataService = exchange.getMarketDataService();
// Get the latest ticker data showing BTC to USD
Ticker ticker = marketDataService.getTicker(new CurrencyPair(Currency.BTC, Currency.USD));
System.out.println("Pair: " + ticker.getCurrencyPair());
System.out.println("Last: " + ticker.getLast());
System.out.println("Volume: " + ticker.getVolume());
System.out.println("High: " + ticker.getHigh());
System.out.println("Low: " + ticker.getLow());
System.out.println("Bid: " + ticker.getBid());
System.out.println("Ask: " + ticker.getAsk());
System.out.println("Timestamp: " + ticker.getTimestamp());
| 36
| 275
| 311
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/cexio/marketdata/TradesDemo.java
|
TradesDemo
|
main
|
class TradesDemo {
public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>}
}
|
// Use the factory to get Cex.IO exchange API using default settings
Exchange exchange = ExchangeFactory.INSTANCE.createExchange(CexIOExchange.class);
// Interested in the public market data feed (no authentication)
MarketDataService marketDataService = exchange.getMarketDataService();
// Get the latest trade data for GHs/BTC since tid=5635556
Trades trades =
marketDataService.getTrades(new CurrencyPair(Currency.GHs, Currency.BTC), 5909107);
System.out.println("Trades Size= " + trades.getTrades().size());
System.out.println(trades.toString());
| 36
| 181
| 217
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/cexio/trade/TradeDemo.java
|
TradeDemo
|
generic
|
class TradeDemo {
public static void main(String[] args) throws IOException {
Exchange exchange = CexIODemoUtils.createExchange();
TradeService tradeService = exchange.getTradeService();
generic(tradeService);
raw((CexIOTradeServiceRaw) tradeService);
}
private static void generic(TradeService tradeService)
throws NotAvailableFromExchangeException, NotYetImplementedForExchangeException, IOException {<FILL_FUNCTION_BODY>}
private static void raw(CexIOTradeServiceRaw tradeService) throws IOException {
List<CexIOOrder> openOrders = tradeService.getCexIOOpenOrders(new CurrencyPair("NMC", "BTC"));
System.out.println(openOrders);
}
private static void printOpenOrders(TradeService tradeService) throws IOException {
OpenOrders openOrders = tradeService.getOpenOrders();
System.out.println(openOrders.toString());
}
}
|
printOpenOrders(tradeService);
// place a limit buy order
LimitOrder limitOrder =
new LimitOrder(
Order.OrderType.BID,
BigDecimal.ONE,
new CurrencyPair(Currency.GHs, Currency.BTC),
"",
null,
new BigDecimal("0.00015600"));
System.out.println("Trying to place: " + limitOrder);
String orderId = "0";
try {
orderId = tradeService.placeLimitOrder(limitOrder);
System.out.println("New Limit Order ID: " + orderId);
} catch (ExchangeException e) {
System.out.println(e);
}
printOpenOrders(tradeService);
// Cancel the added order
boolean cancelResult = tradeService.cancelOrder(orderId);
System.out.println("Canceling order id=" + orderId + " returned " + cancelResult);
printOpenOrders(tradeService);
| 258
| 263
| 521
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/coinbase/account/CoinbaseAccountDemo.java
|
CoinbaseAccountDemo
|
demoTransactions
|
class CoinbaseAccountDemo {
public static void main(String[] args) throws IOException {
Exchange coinbase = CoinbaseDemoUtils.createExchange();
AccountService accountService = coinbase.getAccountService();
generic(accountService);
raw((CoinbaseAccountService) accountService);
}
private static void generic(AccountService accountService) throws IOException {
AccountInfo accountInfo = accountService.getAccountInfo();
System.out.println("Account Info: " + accountInfo);
String depositAddress = accountService.requestDepositAddress(Currency.BTC);
System.out.println("Deposit Address: " + depositAddress);
// String transactionHash = accountService.withdrawFunds(new BigDecimal(".01"), "XXX");
// System.out.println("Bitcoin blockchain transaction hash: " + transactionHash);
}
public static void raw(CoinbaseAccountService accountService) throws IOException {
CoinbaseMoney balance = accountService.getCoinbaseBalance();
System.out.println(balance);
demoUsers(accountService);
demoAddresses(accountService);
demoTransactions(accountService);
CoinbaseAccountChanges accountChanges = accountService.getCoinbaseAccountChanges();
System.out.println(accountChanges);
CoinbaseContacts contacts = accountService.getCoinbaseContacts();
System.out.println(contacts);
demoTokens(accountService);
demoRecurringPayments(accountService);
}
private static void demoRecurringPayments(CoinbaseAccountService accountService)
throws IOException {
CoinbaseRecurringPayments recurringPayments = accountService.getCoinbaseRecurringPayments();
System.out.println(recurringPayments);
List<CoinbaseRecurringPayment> recurringPaymentsList = recurringPayments.getRecurringPayments();
if (!recurringPaymentsList.isEmpty()) {
CoinbaseRecurringPayment recurringPayment = recurringPaymentsList.get(0);
recurringPayment = accountService.getCoinbaseRecurringPayment(recurringPayment.getId());
System.out.println(recurringPayment);
}
}
private static void demoUsers(CoinbaseAccountService accountService) throws IOException {
CoinbaseUsers users = accountService.getCoinbaseUsers();
System.out.println("Current User: " + users);
CoinbaseUser user = users.getUsers().get(0);
user.updateTimeZone("Tijuana").updateNativeCurrency("MXN");
user = accountService.updateCoinbaseUser(user);
System.out.println("Updated User: " + user);
CoinbaseUser newUser =
CoinbaseUser.createCoinbaseNewUserWithReferrerId(
"demo@demo.com", "pass1234", "527d2a1ffedcb8b73b000028");
String oauthClientId = ""; // optional
CoinbaseUser createdUser = accountService.createCoinbaseUser(newUser, oauthClientId);
System.out.println("Newly created user: " + createdUser);
}
private static void demoTokens(CoinbaseAccountService accountService) throws IOException {
CoinbaseToken token = accountService.createCoinbaseToken();
System.out.println(token);
boolean isAccepted = accountService.redeemCoinbaseToken(token.getTokenId());
System.out.println(isAccepted);
}
private static void demoAddresses(CoinbaseAccountService accountService) throws IOException {
CoinbaseAddress receiveAddress = accountService.getCoinbaseReceiveAddress();
System.out.println(receiveAddress);
CoinbaseAddress generatedReceiveAddress =
accountService.generateCoinbaseReceiveAddress("http://www.example.com/callback", "test");
System.out.println(generatedReceiveAddress);
CoinbaseAddresses addresses = accountService.getCoinbaseAddresses();
System.out.println(addresses);
}
private static void demoTransactions(CoinbaseAccountService accountService) throws IOException {<FILL_FUNCTION_BODY>}
}
|
CoinbaseRequestMoneyRequest moneyRequest =
CoinbaseTransaction.createMoneyRequest("xchange@demo.com", "BTC", new BigDecimal(".001"))
.withNotes("test");
CoinbaseTransaction pendingTransaction =
accountService.requestMoneyCoinbaseRequest(moneyRequest);
System.out.println(pendingTransaction);
CoinbaseBaseResponse resendResponse =
accountService.resendCoinbaseRequest(pendingTransaction.getId());
System.out.println(resendResponse);
CoinbaseBaseResponse cancelResponse =
accountService.cancelCoinbaseRequest(pendingTransaction.getId());
System.out.println(cancelResponse);
// CoinbaseSendMoneyRequest sendMoneyRequest = CoinbaseTransaction
// .createSendMoneyRequest("XXX", MoneyUtils.parse("BTC .01"))
// .withNotes("Demo Money!").withInstantBuy(false).withUserFee("0.0");
// CoinbaseTransaction sendTransaction = accountService.sendMoney(sendMoneyRequest);
// System.out.println(sendTransaction);
// CoinbaseTransaction completedTransaction =
// accountService.completeRequest("530010d62b342891e2000083");
// System.out.println(completedTransaction);
CoinbaseTransactions transactions = accountService.getCoinbaseTransactions();
System.out.println(transactions);
if (transactions.getTotalCount() > 0) {
CoinbaseTransaction transaction =
accountService.getCoinbaseTransaction(transactions.getTransactions().get(0).getId());
System.out.println(transaction);
}
| 1,093
| 428
| 1,521
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/coinbase/v2/account/CoinbaseAccountDemo.java
|
CoinbaseAccountDemo
|
raw
|
class CoinbaseAccountDemo {
public static void main(String[] args) throws IOException {
Exchange exchange = CoinbaseDemoUtils.createExchange();
AccountService accountService = exchange.getAccountService();
// [TODO] generic(accountService);
raw((CoinbaseAccountService) accountService);
}
private static void generic(AccountService accountService) throws IOException {
AccountInfo accountInfo = accountService.getAccountInfo();
System.out.println("Account Info: " + accountInfo);
String depositAddress = accountService.requestDepositAddress(Currency.BTC);
System.out.println("Deposit Address: " + depositAddress);
// String transactionHash = accountService.withdrawFunds(new BigDecimal(".01"), "???");
// System.out.println("Bitcoin blockchain transaction hash: " + transactionHash);
}
public static void raw(CoinbaseAccountService accountService) throws IOException {<FILL_FUNCTION_BODY>}
private static void demoAccounts(CoinbaseAccountService accountService) throws IOException {
List<CoinbaseAccount> accounts = accountService.getCoinbaseAccounts();
for (CoinbaseAccount aux : accounts) {
System.out.println(aux);
}
}
private static void demoPaymentMethods(CoinbaseAccountService accountService) throws IOException {
List<CoinbasePaymentMethod> methods = accountService.getCoinbasePaymentMethods();
for (CoinbasePaymentMethod aux : methods) {
System.out.println(aux);
}
}
}
|
demoAccounts(accountService);
demoPaymentMethods(accountService);
// [TODO] CoinbaseMoney balance = accountService.getCoinbaseBalance();
// System.out.println(balance);
// [TODO] demoUsers(accountService);
// [TODO] demoAddresses(accountService);
// [TODO] demoTransactions(accountService);
// [TODO] CoinbaseAccountChanges accountChanges = accountService.getCoinbaseAccountChanges();
// [TODO] System.out.println(accountChanges);
// [TODO] CoinbaseContacts contacts = accountService.getCoinbaseContacts();
// [TODO] System.out.println(contacts);
// [TODO] demoTokens(accountService);
// [TODO] demoRecurringPayments(accountService);
| 406
| 224
| 630
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/coinbase/v2/marketdata/CoinbaseMarketDataDemo.java
|
CoinbaseMarketDataDemo
|
main
|
class CoinbaseMarketDataDemo {
public static void main(String[] args) throws IOException, ParseException {<FILL_FUNCTION_BODY>}
}
|
Exchange coinbaseExchange = ExchangeFactory.INSTANCE.createExchange(CoinbaseExchange.class);
CoinbaseMarketDataService marketDataService =
(CoinbaseMarketDataService) coinbaseExchange.getMarketDataService();
List<CoinbaseCurrency> currencies = marketDataService.getCoinbaseCurrencies();
System.out.println("Currencies: " + currencies);
Map<String, BigDecimal> exchangeRates = marketDataService.getCoinbaseExchangeRates();
System.out.println("Exchange Rates: " + exchangeRates);
CoinbasePrice buyPrice = marketDataService.getCoinbaseBuyPrice(Currency.BTC, Currency.USD);
System.out.println("Buy Price for one BTC: " + buyPrice);
CoinbasePrice sellPrice = marketDataService.getCoinbaseSellPrice(Currency.BTC, Currency.USD);
System.out.println("Sell Price: " + sellPrice);
CoinbasePrice spotRate = marketDataService.getCoinbaseSpotRate(Currency.BTC, Currency.USD);
System.out.println("Spot Rate: " + spotRate);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
CoinbasePrice historicalSpotRate =
marketDataService.getCoinbaseHistoricalSpotRate(
Currency.BTC, Currency.USD, format.parse("2016-12-01"));
System.out.println("Historical Spot Rate 2016-12-01: " + historicalSpotRate);
| 44
| 419
| 463
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/coinbasepro/CoinbaseProHistoricalCandlesDemo.java
|
CoinbaseProHistoricalCandlesDemo
|
main
|
class CoinbaseProHistoricalCandlesDemo {
public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>}
}
|
Exchange coinbasePro = ExchangeFactory.INSTANCE.createExchange(CoinbaseProExchange.class);
CoinbaseProMarketDataService mds =
(CoinbaseProMarketDataService) coinbasePro.getMarketDataService();
CoinbaseProCandle[] candles =
mds.getCoinbaseProHistoricalCandles(
CurrencyPair.BTC_USD, "2018-02-01T00:00:00Z", "2018-02-01T00:10:00Z", "60");
System.out.println(Arrays.toString(candles));
| 43
| 170
| 213
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/coincheck/marketdata/CoincheckTradesDemo.java
|
CoincheckTradesDemo
|
raw
|
class CoincheckTradesDemo {
public static void main(String[] args) throws IOException {
// Use the factory to get Coincheck exchange API using default settings
Exchange coincheck = ExchangeFactory.INSTANCE.createExchange(CoincheckExchange.class);
// Get the market data service.
MarketDataService marketDataService = coincheck.getMarketDataService();
generic(marketDataService);
raw((CoincheckMarketDataServiceRaw) marketDataService);
}
private static void generic(MarketDataService marketDataService) throws IOException {
// Get the latest trade data.
Trades defaultTrades = marketDataService.getTrades(CurrencyPair.BTC_JPY);
System.out.println(
String.format(
"Coincheck returned %s trades by default.", defaultTrades.getTrades().size()));
// Get a specific number of trades.
CoincheckPagination pagination = CoincheckPagination.builder().limit(100).build();
Trades limitedTrades = marketDataService.getTrades(CurrencyPair.BTC_JPY, pagination);
System.out.println(
String.format(
"When requesting 100 trades, Coincheck returned %s.",
limitedTrades.getTrades().size()));
System.out.println(limitedTrades.getTrades().get(0).toString());
}
private static void raw(CoincheckMarketDataServiceRaw marketDataService) throws IOException {<FILL_FUNCTION_BODY>}
}
|
// Get the latest trade data.
CoincheckTradesContainer defaultTrades =
marketDataService.getCoincheckTrades(new CoincheckPair(CurrencyPair.BTC_JPY), null);
System.out.println(
String.format(
"Coincheck raw returned %s trades by default.", defaultTrades.getData().size()));
// Get a specific number of trades.
CoincheckPagination pagination = CoincheckPagination.builder().limit(100).build();
CoincheckTradesContainer limitedTrades =
marketDataService.getCoincheckTrades(new CoincheckPair(CurrencyPair.BTC_JPY), pagination);
System.out.println(
String.format(
"When requesting 100 trades, Coincheck raw returned %s.",
limitedTrades.getData().size()));
System.out.println(limitedTrades.getData().get(0).toString());
| 400
| 252
| 652
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/coinegg/CoinEggTickerDemo.java
|
CoinEggTickerDemo
|
main
|
class CoinEggTickerDemo {
public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>}
}
|
// Create Default BitZ Instance
Exchange coinEgg = ExchangeFactory.INSTANCE.createExchange(CoinEggExchange.class);
// Get The Public Market Data Service
MarketDataService marketDataService = coinEgg.getMarketDataService();
// Currency Pair To Get Ticker Of
CurrencyPair pair = CurrencyPair.ETH_BTC;
// Print The Generic and Raw Ticker
System.out.println(marketDataService.getTicker(pair));
| 40
| 127
| 167
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/coingi/marketdata/CoingiPublicOrderBookDemo.java
|
CoingiPublicOrderBookDemo
|
main
|
class CoingiPublicOrderBookDemo {
public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>}
}
|
Exchange coingi = CoingiDemoUtils.createExchange();
MarketDataService marketDataService = coingi.getMarketDataService();
OrderBook orderBook = marketDataService.getOrderBook(CurrencyPair.BTC_EUR);
// The following example limits max asks to 10, max bids to 10, and market depth to 32
// OrderBook orderBook = marketDataService.getOrderBook(CurrencyPair.BTC_EUR, 10, 10, 32);
List<LimitOrder> asks = orderBook.getAsks();
List<LimitOrder> bids = orderBook.getBids();
asks.forEach(System.out::println);
bids.forEach(System.out::println);
System.out.printf(
"Received an order book with the latest %d asks and %d bids.\n", asks.size(), bids.size());
| 39
| 234
| 273
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/coinone/CoinoneDemoUtils.java
|
CoinoneDemoUtils
|
createExchange
|
class CoinoneDemoUtils {
public static Exchange createExchange() {<FILL_FUNCTION_BODY>}
}
|
ExchangeSpecification exSpec = new CoinoneExchange().getDefaultExchangeSpecification();
exSpec.setApiKey("PublicKeyGeneratedUopnLogin");
exSpec.setSecretKey("SecretKeyGeneratedUopnLogin");
return ExchangeFactory.INSTANCE.createExchange(exSpec);
| 33
| 76
| 109
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/coinone/account/CoinoneAccountInfoDemo.java
|
CoinoneAccountInfoDemo
|
raw
|
class CoinoneAccountInfoDemo {
public static void main(String[] args) throws IOException {
Exchange coinone = CoinoneDemoUtils.createExchange();
AccountService accountService = coinone.getAccountService();
generic(accountService);
raw((CoinoneAccountServiceRaw) accountService);
}
private static void generic(AccountService accountService) throws IOException {
AccountInfo accountInfo = accountService.getAccountInfo();
System.out.println("Wallet: " + accountInfo);
System.out.println(
"ETH balance: " + accountInfo.getWallet().getBalance(Currency.ETH).getAvailable());
}
private static void raw(CoinoneAccountServiceRaw accountService) throws IOException {<FILL_FUNCTION_BODY>}
}
|
CoinoneBalancesResponse coinoneBalancesResponse = accountService.getWallet();
System.out.println("Coinone Avail Balance: " + coinoneBalancesResponse.getEth().getAvail());
System.out.println("Coinone total Balance: " + coinoneBalancesResponse.getEth().getBalance());
| 197
| 86
| 283
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/dvchain/DVChainMarketDataDemo.java
|
DVChainMarketDataDemo
|
generic
|
class DVChainMarketDataDemo {
public static void main(String[] args) throws IOException {
// Use the factory to get DVChain exchange API using default settings
Exchange exchange = ExchangeFactory.INSTANCE.createExchange(DVChainExchange.class);
// Interested in the public market data feed (no authentication)
MarketDataService marketDataService = exchange.getMarketDataService();
generic(marketDataService);
raw((DVChainMarketDataServiceRaw) marketDataService);
}
private static void generic(MarketDataService marketDataService) throws IOException {<FILL_FUNCTION_BODY>}
private static void raw(DVChainMarketDataServiceRaw marketDataService) throws IOException {
// Get the latest order book data for BTC/CAD
DVChainMarketResponse orderBook = marketDataService.getMarketData();
DVChainMarketData btcMarketData = orderBook.getMarketData().get("BTC");
System.out.println(
"Current Order Book size for BTC / USD: " + (btcMarketData.getLevels().size()));
System.out.println("First Ask: " + btcMarketData.getLevels().get(0).getBuyPrice().toString());
System.out.println("First Bid: " + btcMarketData.getLevels().get(0).getSellPrice().toString());
System.out.println(orderBook.toString());
}
}
|
// Get the latest order book data for BTC/USD
OrderBook orderBook = marketDataService.getOrderBook(CurrencyPair.BTC_USD, 3);
System.out.println(
"Current Order Book size for BTC / USD: "
+ (orderBook.getAsks().size() + orderBook.getBids().size()));
System.out.println("First Ask: " + orderBook.getAsks().get(0).toString());
System.out.println(
"Last Ask: " + orderBook.getAsks().get(orderBook.getAsks().size() - 1).toString());
System.out.println("First Bid: " + orderBook.getBids().get(0).toString());
System.out.println(
"Last Bid: " + orderBook.getBids().get(orderBook.getBids().size() - 1).toString());
System.out.println(orderBook.toString());
| 371
| 243
| 614
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/dvchain/DVChainNewLimitOrderDemo.java
|
DVChainNewLimitOrderDemo
|
main
|
class DVChainNewLimitOrderDemo {
public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>}
private static void generic(TradeService tradeService) throws IOException {
// Send out a limit order
LimitOrder order =
new LimitOrder(
Order.OrderType.BID,
new BigDecimal(1),
CurrencyPair.BTC_USD,
"",
null,
new BigDecimal("1000"));
System.out.println("Placing limit order 1@1000 for BTC / USD: ");
String orderResponse = tradeService.placeLimitOrder(order);
System.out.println("Received response: " + orderResponse);
}
private static void raw(DVChainTradeServiceRaw tradeServiceRaw) throws IOException {
// Send out a limit order
DVChainNewLimitOrder order =
new DVChainNewLimitOrder("Buy", new BigDecimal("1000"), new BigDecimal("1"), "USD");
System.out.println("Placing limit order 1@1000 for BTC / USD: ");
DVChainTrade orderResponse = tradeServiceRaw.newDVChainLimitOrder(order);
System.out.println("Received response: " + orderResponse.toString());
}
}
|
// Use the factory to get DVChain exchange API using default settings
Exchange exchange = ExchangeFactory.INSTANCE.createExchange(DVChainExchange.class);
// Interested in the public market data feed (no authentication)
TradeService tradeService = exchange.getTradeService();
generic(tradeService);
raw((DVChainTradeServiceRaw) tradeService);
| 339
| 97
| 436
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/enigma/EnigmaDemoUtils.java
|
EnigmaDemoUtils
|
createExchange
|
class EnigmaDemoUtils {
private static String username = "iSemyonova";
private static String password = "irinaEnigmaSecuritiesRestApi123!";
private static String infra = "dev";
public static Exchange createExchange() {<FILL_FUNCTION_BODY>}
}
|
EnigmaExchange enigmaExchange = new EnigmaExchange();
ExchangeSpecification exchangeSpec = enigmaExchange.getDefaultExchangeSpecification();
exchangeSpec.setExchangeSpecificParametersItem("infra", infra);
exchangeSpec.setUserName(username);
exchangeSpec.setPassword(password);
enigmaExchange.applySpecification(exchangeSpec);
try {
((EnigmaAccountService) enigmaExchange.getAccountService()).login();
} catch (IOException e) {
throw new RuntimeException("Login exception", e);
}
return enigmaExchange;
| 80
| 150
| 230
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/gateio/account/GateioAccountDemo.java
|
GateioAccountDemo
|
main
|
class GateioAccountDemo {
public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>}
private static void generic(AccountService accountService) throws IOException {
AccountInfo accountInfo = accountService.getAccountInfo();
System.out.println(accountInfo);
}
private static void raw(GateioAccountServiceRaw accountService) throws IOException {
GateioFunds accountFunds = accountService.getGateioAccountInfo();
System.out.println(accountFunds);
}
}
|
Exchange exchange = GateioDemoUtils.createExchange();
AccountService accountService = exchange.getAccountService();
generic(accountService);
raw((GateioAccountServiceRaw) accountService);
| 141
| 54
| 195
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/gateio/marketdata/GateioMetaDataDemo.java
|
GateioMetaDataDemo
|
main
|
class GateioMetaDataDemo {
public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>}
}
|
ExchangeSpecification exSpec = new GateioExchange().getDefaultExchangeSpecification();
exSpec.setShouldLoadRemoteMetaData(true);
Exchange exchange = ExchangeFactory.INSTANCE.createExchange(exSpec);
System.out.println(exchange.getExchangeSpecification().isShouldLoadRemoteMetaData());
System.out.println(exchange.getExchangeMetaData().toString());
System.out.println(exchange.getExchangeInstruments());
| 38
| 119
| 157
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/gateio/trade/GateioTradeDemo.java
|
GateioTradeDemo
|
raw
|
class GateioTradeDemo {
public static void main(String[] args) throws IOException, InterruptedException {
Exchange exchange = GateioDemoUtils.createExchange();
TradeService tradeService = exchange.getTradeService();
generic(tradeService);
raw((GateioTradeServiceRaw) tradeService);
}
private static void generic(TradeService tradeService) throws IOException, InterruptedException {
LimitOrder limitOrder =
new LimitOrder(
OrderType.ASK,
new BigDecimal("0.384"),
CurrencyPair.LTC_BTC,
"",
null,
new BigDecimal("0.0265"));
String orderId = tradeService.placeLimitOrder(limitOrder);
System.out.println(
orderId); // Returned order id is currently broken for Gateio, rely on open orders instead//
// for demo :(
Thread.sleep(2000); // wait for Gateio's back-end to propagate the order
OpenOrders openOrders = tradeService.getOpenOrders();
System.out.println(openOrders);
List<LimitOrder> openOrdersList = openOrders.getOpenOrders();
if (!openOrdersList.isEmpty()) {
String existingOrderId = openOrdersList.get(0).getId();
boolean isCancelled = tradeService.cancelOrder(existingOrderId);
System.out.println(isCancelled);
}
Thread.sleep(2000); // wait for Gateio's back-end to propagate the cancelled order
openOrders = tradeService.getOpenOrders();
System.out.println(openOrders);
Thread.sleep(2000);
Trades tradeHistory =
tradeService.getTradeHistory(
new DefaultTradeHistoryParamCurrencyPair(CurrencyPair.LTC_BTC));
System.out.println(tradeHistory);
}
private static void raw(GateioTradeServiceRaw tradeService)
throws IOException, InterruptedException {<FILL_FUNCTION_BODY>}
}
|
String placedOrderId =
tradeService.placeGateioLimitOrder(
CurrencyPair.LTC_BTC,
GateioOrderType.SELL,
new BigDecimal("0.0265"),
new BigDecimal("0.384"));
System.out.println(placedOrderId);
Thread.sleep(2000); // wait for Gateio's back-end to propagate the order
GateioOpenOrders openOrders = tradeService.getGateioOpenOrders();
System.out.println(openOrders);
List<GateioOpenOrder> openOrdersList = openOrders.getOrders();
if (!openOrdersList.isEmpty()) {
String existingOrderId = openOrdersList.get(0).getId();
GateioOrderStatus orderStatus =
tradeService.getGateioOrderStatus(existingOrderId, CurrencyPair.LTC_BTC);
System.out.println(orderStatus);
boolean isCancelled =
tradeService.cancelOrder(
existingOrderId,
CurrencyPairDeserializer.getCurrencyPairFromString(
openOrdersList.get(0).getCurrencyPair()));
System.out.println(isCancelled);
}
Thread.sleep(2000); // wait for Gateio's back-end to propagate the cancelled order
openOrders = tradeService.getGateioOpenOrders();
System.out.println(openOrders);
List<GateioTrade> tradeHistory =
tradeService.getGateioTradeHistory(CurrencyPair.LTC_BTC).getTrades();
System.out.println(tradeHistory);
| 538
| 430
| 968
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/independentreserve/marketdata/DepthDemo.java
|
DepthDemo
|
generic
|
class DepthDemo {
public static void main(String[] args) throws IOException {
// Use the factory to get IndependentReserve exchange API using default settings
Exchange independentReserve =
ExchangeFactory.INSTANCE.createExchange(IndependentReserveExchange.class);
// Interested in the public market data feed (no authentication)
MarketDataService marketDataService = independentReserve.getMarketDataService();
generic(marketDataService);
raw((IndependentReserveMarketDataServiceRaw) marketDataService);
}
private static void generic(MarketDataService marketDataService) throws IOException {<FILL_FUNCTION_BODY>}
private static void raw(IndependentReserveMarketDataServiceRaw marketDataService)
throws IOException {
// Get the latest order book data for BTC/USD
IndependentReserveOrderBook orderBook =
marketDataService.getIndependentReserveOrderBook(
Currency.BTC.getCurrencyCode(), Currency.USD.getCurrencyCode());
System.out.println(
"Current Order Book size for BTC / USD: "
+ (orderBook.getSellOrders().size() + orderBook.getBuyOrders().size()));
System.out.println("First Ask: " + orderBook.getSellOrders().get(0).toString());
System.out.println("First Bid: " + orderBook.getBuyOrders().get(0).toString());
System.out.println(orderBook.toString());
}
}
|
// Get the latest order book data for BTC/USD
OrderBook orderBook = marketDataService.getOrderBook(CurrencyPair.BTC_USD);
System.out.println(
"Current Order Book size for BTC / USD: "
+ (orderBook.getAsks().size() + orderBook.getBids().size()));
System.out.println("First Ask: " + orderBook.getAsks().get(0).toString());
System.out.println(
"Last Ask: " + orderBook.getAsks().get(orderBook.getAsks().size() - 1).toString());
System.out.println("First Bid: " + orderBook.getBids().get(0).toString());
System.out.println(
"Last Bid: " + orderBook.getBids().get(orderBook.getBids().size() - 1).toString());
System.out.println(orderBook.toString());
| 378
| 240
| 618
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/independentreserve/trade/IndependentReserveTradeDemo.java
|
IndependentReserveTradeDemo
|
printOpenOrders
|
class IndependentReserveTradeDemo {
public static void main(String[] args) throws IOException, InterruptedException {
Exchange independentReserve = IndependentReserveDemoUtils.createExchange();
TradeService tradeService = independentReserve.getTradeService();
generic(tradeService);
}
private static void generic(TradeService tradeService) throws IOException, InterruptedException {
printOpenOrders(tradeService);
// place a limit buy order
LimitOrder limitOrder =
new LimitOrder(
(Order.OrderType.ASK),
new BigDecimal(".01"),
CurrencyPair.BTC_USD,
"",
null,
new BigDecimal("500.00"));
String limitOrderReturnValue = tradeService.placeLimitOrder(limitOrder);
System.out.println("Limit Order return value: " + limitOrderReturnValue);
printOpenOrders(tradeService);
// Cancel the added order
boolean cancelResult = tradeService.cancelOrder(limitOrderReturnValue);
System.out.println("Canceling returned " + cancelResult);
printOpenOrders(tradeService);
UserTrades tradeHistory = tradeService.getTradeHistory(tradeService.createTradeHistoryParams());
System.out.println("Trade history: " + tradeHistory.toString());
}
static void printOpenOrders(TradeService tradeService) throws IOException, InterruptedException {<FILL_FUNCTION_BODY>}
}
|
// IR API caches data for some time, so we can get the same set of orders as we saw before
TimeUnit.SECONDS.sleep(1);
final OpenOrdersParamCurrencyPair params =
(OpenOrdersParamCurrencyPair) tradeService.createOpenOrdersParams();
OpenOrders openOrders = tradeService.getOpenOrders(params);
System.out.printf("All open Orders: %s%n", openOrders);
params.setCurrencyPair(CurrencyPair.BTC_USD);
openOrders = tradeService.getOpenOrders(params);
System.out.printf("Open Orders for %s: %s%n: ", params, openOrders);
params.setCurrencyPair(CurrencyPair.ETH_NZD);
openOrders = tradeService.getOpenOrders(params);
System.out.printf("Open Orders for %s: %s%n: ", params, openOrders);
| 375
| 240
| 615
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/itbit/market/ItBitOrderBookDemo.java
|
ItBitOrderBookDemo
|
generic
|
class ItBitOrderBookDemo {
public static void main(String[] args) throws IOException {
Exchange xchange = ExchangeFactory.INSTANCE.createExchange(ItBitExchange.class);
MarketDataService marketDataService = xchange.getMarketDataService();
generic(marketDataService);
raw((ItBitMarketDataServiceRaw) marketDataService);
}
private static void generic(MarketDataService marketDataService) throws IOException {<FILL_FUNCTION_BODY>}
private static void raw(ItBitMarketDataServiceRaw marketDataService) throws IOException {
ItBitDepth orderBook = marketDataService.getItBitDepth(CurrencyPair.BTC_USD);
System.out.println(orderBook.toString());
}
}
|
OrderBook orderBook = marketDataService.getOrderBook(CurrencyPair.BTC_USD);
System.out.println(orderBook.toString());
OrderBook orderBookAsXBT =
marketDataService.getOrderBook(new CurrencyPair(Currency.XBT, Currency.USD));
System.out.println(orderBookAsXBT.toString());
| 192
| 96
| 288
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/itbit/market/ItBitTickerDemo.java
|
ItBitTickerDemo
|
main
|
class ItBitTickerDemo {
public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>}
private static void generic(MarketDataService marketDataService) throws IOException {
Ticker ticker = marketDataService.getTicker(CurrencyPair.BTC_USD);
System.out.println(ticker.toString());
}
private static void raw(ItBitMarketDataServiceRaw marketDataService) throws IOException {
ItBitTicker ticker = marketDataService.getItBitTicker(CurrencyPair.BTC_USD);
System.out.println(ticker.toString());
}
}
|
Exchange exchange = ExchangeFactory.INSTANCE.createExchange(ItBitExchange.class);
MarketDataService marketDataService = exchange.getMarketDataService();
generic(marketDataService);
raw((ItBitMarketDataServiceRaw) marketDataService);
| 168
| 69
| 237
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/itbit/trade/ItBitTradesDemo.java
|
ItBitTradesDemo
|
printOrderStatus
|
class ItBitTradesDemo {
public static void main(String[] args) throws Exception {
Exchange itbit = ItBitDemoUtils.createExchange();
AccountService account = itbit.getAccountService();
TradeService tradeService = itbit.getTradeService();
AccountInfo accountInfo = account.getAccountInfo();
System.out.println("Account Info: " + accountInfo);
printOpenOrders(tradeService);
String placeLimitOrderXBT =
tradeService.placeLimitOrder(
new LimitOrder(
OrderType.BID,
BigDecimal.valueOf(0.001),
new CurrencyPair("XBT", "USD"),
"0",
new Date(),
BigDecimal.valueOf(300)));
String placeLimitOrderBTC =
tradeService.placeLimitOrder(
new LimitOrder(
OrderType.BID,
BigDecimal.valueOf(0.001),
new CurrencyPair("BTC", "USD"),
"0",
new Date(),
BigDecimal.valueOf(360)));
System.out.println("limit order id " + placeLimitOrderXBT);
System.out.println("limit order id " + placeLimitOrderBTC);
printOrderStatus(tradeService, placeLimitOrderXBT);
printOrderStatus(tradeService, placeLimitOrderBTC);
printOpenOrders(tradeService);
System.out.println("Cancelling " + placeLimitOrderXBT);
tradeService.cancelOrder(placeLimitOrderXBT);
printOrderStatus(tradeService, placeLimitOrderXBT);
printOpenOrders(tradeService);
System.out.println("Cancelling " + placeLimitOrderBTC);
tradeService.cancelOrder(placeLimitOrderBTC);
printOrderStatus(tradeService, placeLimitOrderBTC);
printOpenOrders(tradeService);
Trades tradeHistory = tradeService.getTradeHistory(tradeService.createTradeHistoryParams());
System.out.println("Trade history: " + tradeHistory);
printOrderStatus(tradeService, placeLimitOrderXBT);
printOrderStatus(tradeService, placeLimitOrderBTC);
printOpenOrders(tradeService);
}
private static void printOpenOrders(TradeService tradeService) throws IOException {
OpenOrders openOrders = tradeService.getOpenOrders();
System.out.println("Open Orders: " + openOrders.toString());
}
private static void printOrderStatus(TradeService tradeService, String orderId)
throws IOException {<FILL_FUNCTION_BODY>}
}
|
final ItBitTradeServiceRaw tradeServiceRaw = (ItBitTradeServiceRaw) tradeService;
final ItBitOrder response = tradeServiceRaw.getItBitOrder(orderId);
System.out.println("Order Status: " + response.toString());
| 677
| 65
| 742
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/kraken/account/KrakenAccountDemo.java
|
KrakenAccountDemo
|
fundingHistory
|
class KrakenAccountDemo {
public static void main(String[] args) throws IOException {
Exchange krakenExchange = KrakenExampleUtils.createTestExchange();
generic(krakenExchange);
raw(krakenExchange);
}
private static void generic(Exchange krakenExchange) throws IOException {
AccountInfo accountInfo = krakenExchange.getAccountService().getAccountInfo();
System.out.println("Account Info: " + accountInfo.toString());
fundingHistory(krakenExchange.getAccountService());
}
private static void raw(Exchange krakenExchange) throws IOException {
KrakenAccountServiceRaw rawKrakenAcctService =
(KrakenAccountServiceRaw) krakenExchange.getAccountService();
System.out.println("Balance Info: " + rawKrakenAcctService.getKrakenBalance());
}
private static void fundingHistory(AccountService accountService) throws IOException {<FILL_FUNCTION_BODY>}
}
|
// Get the funds information
TradeHistoryParams params = accountService.createFundingHistoryParams();
if (params instanceof TradeHistoryParamsTimeSpan) {
final TradeHistoryParamsTimeSpan timeSpanParam = (TradeHistoryParamsTimeSpan) params;
timeSpanParam.setStartTime(
new Date(System.currentTimeMillis() - (1 * 12 * 30 * 24 * 60 * 60 * 1000L)));
}
if (params instanceof HistoryParamsFundingType) {
((HistoryParamsFundingType) params).setType(FundingRecord.Type.DEPOSIT);
}
if (params instanceof TradeHistoryParamCurrencies) {
final TradeHistoryParamCurrencies currenciesParam = (TradeHistoryParamCurrencies) params;
currenciesParam.setCurrencies(new Currency[] {Currency.BTC, Currency.USD});
}
List<FundingRecord> fundingRecords = accountService.getFundingHistory(params);
AccountServiceTestUtil.printFundingHistory(fundingRecords);
| 266
| 277
| 543
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/kraken/marketdata/KrakenDepthDemo.java
|
KrakenDepthDemo
|
raw
|
class KrakenDepthDemo {
public static void main(String[] args) throws IOException {
// Use the factory to get Kraken exchange API using default settings
Exchange krakenExchange = ExchangeFactory.INSTANCE.createExchange(KrakenExchange.class);
generic(krakenExchange);
raw(krakenExchange);
}
private static void generic(Exchange krakenExchange) throws IOException {
// Interested in the public market data feed (no authentication)
MarketDataService krakenMarketDataService = krakenExchange.getMarketDataService();
// Get the latest full order book data for NMC/XRP
OrderBook orderBook = krakenMarketDataService.getOrderBook(CurrencyPair.BTC_EUR);
System.out.println(orderBook.toString());
System.out.println(
"full orderbook size: " + (orderBook.getAsks().size() + orderBook.getBids().size()));
// Get the latest partial size order book data for NMC/XRP
orderBook = krakenMarketDataService.getOrderBook(CurrencyPair.BTC_EUR, 3L);
System.out.println(orderBook.toString());
System.out.println(
"partial orderbook size: " + (orderBook.getAsks().size() + orderBook.getBids().size()));
}
private static void raw(Exchange krakenExchange) throws IOException {<FILL_FUNCTION_BODY>}
}
|
// Interested in the public market data feed (no authentication)
KrakenMarketDataServiceRaw krakenMarketDataService =
(KrakenMarketDataServiceRaw) krakenExchange.getMarketDataService();
// Get the latest full order book data
KrakenDepth depth =
krakenMarketDataService.getKrakenDepth(CurrencyPair.BTC_EUR, Long.MAX_VALUE);
System.out.println(depth.toString());
System.out.println("size: " + (depth.getAsks().size() + depth.getBids().size()));
// Get the latest partial size order book data
depth = krakenMarketDataService.getKrakenDepth(CurrencyPair.BTC_EUR, 3L);
System.out.println(depth.toString());
System.out.println("size: " + (depth.getAsks().size() + depth.getBids().size()));
| 387
| 240
| 627
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/kraken/marketdata/KrakenTradesDemo.java
|
KrakenTradesDemo
|
generic
|
class KrakenTradesDemo {
public static void main(String[] args) throws IOException {
// Use the factory to get Kraken exchange API using default settings
Exchange krakenExchange = ExchangeFactory.INSTANCE.createExchange(KrakenExchange.class);
generic(krakenExchange);
// raw(krakenExchange);
}
private static void generic(Exchange krakenExchange) throws IOException {<FILL_FUNCTION_BODY>}
private static void raw(Exchange krakenExchange) throws IOException {
// Interested in the public market data feed (no authentication)
KrakenMarketDataServiceRaw krakenMarketDataService =
(KrakenMarketDataServiceRaw) krakenExchange.getMarketDataService();
// Get the latest trade data for BTC_USD
KrakenPublicTrades krakenPublicTrades =
krakenMarketDataService.getKrakenTrades(CurrencyPair.BTC_USD);
long last = krakenPublicTrades.getLast();
System.out.println(krakenPublicTrades.getTrades());
System.out.println("Trades size: " + krakenPublicTrades.getTrades().size());
System.out.println("Trades(0): " + krakenPublicTrades.getTrades().get(0).toString());
System.out.println("Last: " + last);
// Poll for any new trades since last id
krakenPublicTrades = krakenMarketDataService.getKrakenTrades(CurrencyPair.LTC_USD, last);
System.out.println(krakenPublicTrades.getTrades());
System.out.println("Trades size: " + krakenPublicTrades.getTrades().size());
}
}
|
// Interested in the public market data feed (no authentication)
MarketDataService marketDataService = krakenExchange.getMarketDataService();
// Get the latest trade data for BTC_USD
Trades trades = marketDataService.getTrades(CurrencyPair.BTC_USD);
System.out.println(trades);
System.out.println("Trades(0): " + trades.getTrades().get(0).toString());
System.out.println("Trades size: " + trades.getTrades().size());
// Get the latest trade data for BTC_USD for the past 12 hours (note:
// doesn't account for time zone differences, should use UTC instead)
// trades = marketDataService.getTrades(CurrencyPair.BTC_USD, (long) (System.nanoTime() - (12
// * 60 * 60 * Math.pow(10, 9))));
// System.out.println(trades);
// System.out.println("Trades size: " + trades.getTrades().size());
| 469
| 279
| 748
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/kraken/trade/KrakenLimitOrderDemo.java
|
KrakenLimitOrderDemo
|
raw
|
class KrakenLimitOrderDemo {
public static void main(String[] args) throws IOException {
Exchange krakenExchange = KrakenExampleUtils.createTestExchange();
generic(krakenExchange);
raw(krakenExchange);
}
private static void generic(Exchange krakenExchange) throws IOException {
TradeService tradeService = krakenExchange.getTradeService();
OrderType orderType = (OrderType.ASK);
BigDecimal tradeableAmount = new BigDecimal("0.01");
BigDecimal price = new BigDecimal("65.25");
LimitOrder limitOrder =
new LimitOrder(orderType, tradeableAmount, CurrencyPair.BTC_LTC, "", null, price);
String orderID = tradeService.placeLimitOrder(limitOrder);
System.out.println("Limit Order ID: " + orderID);
}
private static void raw(Exchange krakenExchange) throws IOException {<FILL_FUNCTION_BODY>}
}
|
KrakenTradeServiceRaw tradeService = (KrakenTradeServiceRaw) krakenExchange.getTradeService();
OrderType orderType = (OrderType.ASK);
BigDecimal tradeableAmount = new BigDecimal("0.01");
BigDecimal price = new BigDecimal("65.25");
LimitOrder limitOrder =
new LimitOrder(orderType, tradeableAmount, CurrencyPair.BTC_LTC, "", null, price);
KrakenOrderResponse orderResponse = tradeService.placeKrakenLimitOrder(limitOrder);
System.out.println("Limit Order response: " + orderResponse);
| 267
| 166
| 433
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/kucoin/KucoinExamplesUtils.java
|
KucoinExamplesUtils
|
getExchange
|
class KucoinExamplesUtils {
public static Exchange getExchange() {<FILL_FUNCTION_BODY>}
}
|
if (System.getProperty("kucoin-api-key") == null) {
throw new IllegalArgumentException(
"To run the examples, call using:\n"
+ " -Dkucoin-api-key=YOURAPIKEY -Dkucoin-api-secret=YOURSECRET \n"
+ " -Dkucoin-api-passphrase=YOURPASSPHRASE -Dkucoin-sandbox=true");
}
ExchangeSpecification exSpec = new ExchangeSpecification(KucoinExchange.class);
exSpec.setApiKey(System.getProperty("kucoin-api-key"));
exSpec.setSecretKey(System.getProperty("kucoin-api-secret"));
exSpec.setExchangeSpecificParametersItem(
"passphrase", System.getProperty("kucoin-api-passphrase"));
exSpec.setExchangeSpecificParametersItem(
Exchange.USE_SANDBOX, Boolean.valueOf(System.getProperty("kucoin-sandbox")));
return ExchangeFactory.INSTANCE.createExchange(exSpec);
| 34
| 279
| 313
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/kucoin/trade/KucoinTradeHistoryDemo.java
|
KucoinTradeHistoryDemo
|
getRecentTrades
|
class KucoinTradeHistoryDemo {
public static void main(String[] args) throws Exception {
Exchange exchange = KucoinExamplesUtils.getExchange();
TradeService tradeService = exchange.getTradeService();
getRecentTrades(tradeService);
// getHistoricalTrades(tradeService); // historical trades API endpoint not supported on
// Sandbox
getPagedTrades(tradeService);
}
private static void getRecentTrades(TradeService tradeService) throws IOException {<FILL_FUNCTION_BODY>}
private static void getHistoricalTrades(TradeService tradeService) throws IOException {
System.out.println(
"Requesting trades from the old API (before 18 Feb 2019 UTC+8, no time span limitation)...");
KucoinTradeHistoryParams tradeHistoryParams =
(KucoinTradeHistoryParams) tradeService.createTradeHistoryParams();
Date aWhileBack =
Date.from(
LocalDate.of(2019, 2, 1).atStartOfDay().atZone(ZoneId.systemDefault()).toInstant());
tradeHistoryParams.setEndTime(aWhileBack);
UserTrades tradeHistory = tradeService.getTradeHistory(tradeHistoryParams);
tradeHistory.getUserTrades().forEach(System.out::println);
}
private static void getPagedTrades(TradeService tradeService) throws IOException {
System.out.println("Requesting trades from the last 3 days...");
KucoinTradeHistoryParams tradeHistoryParams =
(KucoinTradeHistoryParams) tradeService.createTradeHistoryParams();
Date threeDaysAgo =
Date.from(
LocalDate.now().minusDays(3).atStartOfDay().atZone(ZoneId.systemDefault()).toInstant());
tradeHistoryParams.setStartTime(threeDaysAgo);
// end time could be set here if desired
tradeHistoryParams.setCurrencyPair(CurrencyPair.ETH_BTC);
UserTrades tradeHistory = tradeService.getTradeHistory(tradeHistoryParams);
tradeHistory.getUserTrades().forEach(System.out::println);
while (tradeHistory.getNextPageCursor() != null) {
tradeHistoryParams.setNextPageCursor(tradeHistory.getNextPageCursor());
tradeHistory = tradeService.getTradeHistory(tradeHistoryParams);
tradeHistory.getUserTrades().forEach(System.out::println);
}
}
}
|
System.out.println("Requesting trades from the last 8 days (API allows up to 8 days)...");
KucoinTradeHistoryParams tradeHistoryParams =
(KucoinTradeHistoryParams) tradeService.createTradeHistoryParams();
UserTrades tradeHistory = tradeService.getTradeHistory(tradeHistoryParams);
tradeHistory.getUserTrades().forEach(System.out::println);
| 634
| 103
| 737
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/livecoin/marketdata/TradeDemo.java
|
TradeDemo
|
main
|
class TradeDemo {
public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>}
}
|
Exchange livecoinExchange = ExchangeFactory.INSTANCE.createExchange(LivecoinExchange.class);
// Interested in the public market data feed (no authentication)
MarketDataService marketDataService = livecoinExchange.getMarketDataService();
System.out.println("fetching data...");
Trades trades = marketDataService.getTrades(CurrencyPair.BTC_USD);
System.out.println("received data.");
for (Trade trade : trades.getTrades()) {
System.out.println(
trade.getType()
+ " "
+ trade.getCurrencyPair()
+ " Price: "
+ trade.getPrice()
+ " Amount: "
+ trade.getOriginalAmount());
}
| 35
| 197
| 232
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/mercadobitcoin/account/MercadoBitcoinAccountDemo.java
|
MercadoBitcoinAccountDemo
|
generic
|
class MercadoBitcoinAccountDemo {
public static void main(String[] args) throws IOException {
Exchange mercadoBitcoin = InteractiveAuthenticatedExchange.createInstanceFromDefaultInput();
AccountService accountService = mercadoBitcoin.getAccountService();
generic(accountService);
raw((MercadoBitcoinAccountServiceRaw) accountService);
}
private static void generic(AccountService accountService) throws IOException {<FILL_FUNCTION_BODY>}
private static void raw(MercadoBitcoinAccountServiceRaw accountService) throws IOException {
// Get the account information
MercadoBitcoinBaseTradeApiResult<MercadoBitcoinAccountInfo> mercadoBitcoinAccountInfo =
accountService.getMercadoBitcoinAccountInfo();
System.out.println(
"MercadoBitcoinBaseTradeApiResult<MercadoBitcoinAccountInfo> as String: "
+ mercadoBitcoinAccountInfo.toString());
}
}
|
// Get the account information
AccountInfo accountInfo = accountService.getAccountInfo();
System.out.println("AccountInfo as String: " + accountInfo.toString());
| 241
| 45
| 286
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/mercadobitcoin/marketdata/btc/TickerDemo.java
|
TickerDemo
|
main
|
class TickerDemo {
public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>}
private static void generic(MarketDataService marketDataService) throws IOException {
Ticker ticker = marketDataService.getTicker(CurrencyPair.BTC_BRL);
System.out.println(ticker.toString());
}
private static void raw(MercadoBitcoinMarketDataServiceRaw marketDataService) throws IOException {
MercadoBitcoinTicker mercadoBitcoinTicker =
marketDataService.getMercadoBitcoinTicker(CurrencyPair.BTC_BRL);
System.out.println(mercadoBitcoinTicker.toString());
}
}
|
// Use the factory to get Mercado Bitcoin exchange API using default settings
Exchange mercadoBitcoin = ExchangeFactory.INSTANCE.createExchange(MercadoBitcoinExchange.class);
// Interested in the public market data feed (no authentication)
MarketDataService marketDataService = mercadoBitcoin.getMarketDataService();
generic(marketDataService);
raw((MercadoBitcoinMarketDataServiceRaw) marketDataService);
| 186
| 112
| 298
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/mercadobitcoin/marketdata/ltc/DepthDemo.java
|
DepthDemo
|
generic
|
class DepthDemo {
public static void main(String[] args) throws IOException {
// Use the factory to get Mercado Bitcoin exchange API using default settings
Exchange mercadoBitcoin = ExchangeFactory.INSTANCE.createExchange(MercadoBitcoinExchange.class);
// Interested in the public market data feed (no authentication)
MarketDataService marketDataService = mercadoBitcoin.getMarketDataService();
generic(marketDataService);
raw((MercadoBitcoinMarketDataServiceRaw) marketDataService);
}
private static void generic(MarketDataService marketDataService) throws IOException {<FILL_FUNCTION_BODY>}
private static void raw(MercadoBitcoinMarketDataServiceRaw marketDataService) throws IOException {
// Get the latest order book data for LTC/BRL
MercadoBitcoinOrderBook orderBook =
marketDataService.getMercadoBitcoinOrderBook(new CurrencyPair(Currency.LTC, Currency.BRL));
System.out.println(
"Current Order Book size for LTC / BRL: "
+ (orderBook.getAsks().size() + orderBook.getBids().size()));
System.out.println("First Ask: " + orderBook.getAsks().get(0).toString());
System.out.println("First Bid: " + orderBook.getBids().get(0).toString());
System.out.println(orderBook.toString());
}
}
|
// Get the latest order book data for LTC/BRL
OrderBook orderBook =
marketDataService.getOrderBook(new CurrencyPair(Currency.LTC, Currency.BRL));
System.out.println(
"Current Order Book size for LTC / BRL: "
+ (orderBook.getAsks().size() + orderBook.getBids().size()));
System.out.println("First Ask: " + orderBook.getAsks().get(0).toString());
System.out.println(
"Last Ask: " + orderBook.getAsks().get(orderBook.getAsks().size() - 1).toString());
System.out.println("First Bid: " + orderBook.getBids().get(0).toString());
System.out.println(
"Last Bid: " + orderBook.getBids().get(orderBook.getBids().size() - 1).toString());
System.out.println(orderBook.toString());
| 370
| 250
| 620
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/mercadobitcoin/marketdata/ltc/TradesDemo.java
|
TradesDemo
|
raw
|
class TradesDemo {
public static void main(String[] args) throws IOException {
// Use the factory to get Mercado Bitcoin exchange API using default settings
Exchange mercadoBitcoin = ExchangeFactory.INSTANCE.createExchange(MercadoBitcoinExchange.class);
// Interested in the public market data feed (no authentication)
MarketDataService marketDataService = mercadoBitcoin.getMarketDataService();
Long now = new Date().getTime();
generic(now, marketDataService);
raw(now, (MercadoBitcoinMarketDataServiceRaw) marketDataService);
}
private static void generic(Long now, MarketDataService marketDataService) throws IOException {
// Get the latest trade data for LTC/BRL
Trades trades = marketDataService.getTrades(new CurrencyPair(Currency.LTC, Currency.BRL));
System.out.println("Trades, default. Size= " + trades.getTrades().size());
trades =
marketDataService.getTrades(
new CurrencyPair(Currency.LTC, Currency.BRL), now - (24L * 60L * 60L * 1000L));
System.out.println("Trades, last 24h= " + trades.getTrades().size());
trades =
marketDataService.getTrades(
new CurrencyPair(Currency.LTC, Currency.BRL), 1406851200000L, 1409529600000L);
System.out.println("Trades, since Aug 2014 to Sep 2014= " + trades.getTrades().size());
System.out.println(trades.toString());
}
private static void raw(Long now, MercadoBitcoinMarketDataServiceRaw marketDataService)
throws IOException {<FILL_FUNCTION_BODY>}
}
|
// Get the latest trade data for LTC/BRL
MercadoBitcoinTransaction[] trades =
marketDataService.getMercadoBitcoinTransactions(
new CurrencyPair(Currency.LTC, Currency.BRL));
System.out.println("Trades, default. Size= " + trades.length);
trades =
marketDataService.getMercadoBitcoinTransactions(
new CurrencyPair(Currency.LTC, Currency.BRL), now - (24L * 60L * 60L * 1000L));
System.out.println("Trades, last 24h= " + trades.length);
trades =
marketDataService.getMercadoBitcoinTransactions(
new CurrencyPair(Currency.LTC, Currency.BRL), 1406851200000L, 1409529600000L);
System.out.println("Trades, since Aug 2014 to Sep 2014= " + trades.length);
System.out.println(Arrays.toString(trades));
| 489
| 288
| 777
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/okcoin/marketdata/OkCoinDepthDemo.java
|
OkCoinDepthDemo
|
raw
|
class OkCoinDepthDemo {
public static void main(String[] args) throws IOException {
ExchangeSpecification exSpec = new ExchangeSpecification(OkCoinExchange.class);
// flag to set Use_Intl (USD) or China (default)
exSpec.setExchangeSpecificParametersItem("Use_Intl", true);
Exchange okcoinExchange = ExchangeFactory.INSTANCE.createExchange(exSpec);
generic(okcoinExchange);
raw(okcoinExchange);
}
private static void generic(Exchange okcoinExchange) throws IOException {
// Interested in the public market data feed (no authentication)
MarketDataService marketDataService = okcoinExchange.getMarketDataService();
// Get the latest full order book data for NMC/XRP
OrderBook orderBook = marketDataService.getOrderBook(CurrencyPair.BTC_CNY);
System.out.println(orderBook.toString());
System.out.println(
"full orderbook size: " + (orderBook.getAsks().size() + orderBook.getBids().size()));
}
private static void raw(Exchange okcoinExchange) throws IOException {<FILL_FUNCTION_BODY>}
}
|
// Interested in the public market data feed (no authentication)
OkCoinMarketDataServiceRaw okCoinMarketDataServiceRaw =
(OkCoinMarketDataServiceRaw) okcoinExchange.getMarketDataService();
// Get the latest full order book data
OkCoinDepth depth = okCoinMarketDataServiceRaw.getDepth(CurrencyPair.BTC_CNY);
System.out.println(depth.toString());
System.out.println("size: " + (depth.getAsks().length + depth.getBids().length));
| 312
| 143
| 455
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/okex/v5/marketdata/OkexTradesDemo.java
|
OkexTradesDemo
|
generic
|
class OkexTradesDemo {
public static void main(String[] args) throws IOException {
ExchangeSpecification exSpec = new ExchangeSpecification(OkexExchange.class);
Exchange okexExchange = ExchangeFactory.INSTANCE.createExchange(exSpec);
generic(okexExchange);
}
private static void generic(Exchange okexExchange) throws IOException {<FILL_FUNCTION_BODY>}
}
|
// Interested in the public market data feed (no authentication)
MarketDataService marketDataService = okexExchange.getMarketDataService();
FuturesContract contract = new FuturesContract(CurrencyPair.BTC_USDT, "210924");
// Get the latest trades data for BTC_UST Sept 24th Contact
Trades trades = marketDataService.getTrades(contract);
System.out.println(trades);
System.out.println("Trades(0): " + trades.getTrades().get(0).toString());
System.out.println("Trades size: " + trades.getTrades().size());
| 116
| 169
| 285
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/paribu/marketdata/ParibuTickerDemo.java
|
ParibuTickerDemo
|
main
|
class ParibuTickerDemo {
public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>}
private static void generic(MarketDataService marketDataService) throws IOException {
Ticker ticker = marketDataService.getTicker(CurrencyPair.BTC_TRY);
System.out.println(ticker.toString());
}
private static void raw(ParibuMarketDataService marketDataService) throws IOException {
ParibuTicker paribuTicker = marketDataService.getParibuTicker();
System.out.println(paribuTicker.toString());
}
}
|
// Use the factory to get Paribu exchange API using default settings
Exchange paribu = ParibuDemoUtils.createExchange();
// Interested in the public market data feed (no authentication)
MarketDataService marketDataService = paribu.getMarketDataService();
generic(marketDataService);
raw((ParibuMarketDataService) marketDataService);
| 157
| 93
| 250
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/poloniex/account/PoloniexAccountDemo.java
|
PoloniexAccountDemo
|
generic
|
class PoloniexAccountDemo {
public static void main(String[] args) throws Exception {
CertHelper.trustAllCerts();
Exchange poloniex = PoloniexExamplesUtils.getExchange();
AccountService accountService = poloniex.getAccountService();
generic(accountService);
raw((PoloniexAccountServiceRaw) accountService);
}
private static void generic(AccountService accountService) throws IOException {<FILL_FUNCTION_BODY>}
private static void raw(PoloniexAccountServiceRaw accountService) throws IOException {
System.out.println("------------RAW------------");
System.out.println(accountService.getDepositAddress("BTC"));
System.out.println(accountService.getWallets());
}
}
|
System.out.println("----------GENERIC----------");
System.out.println(accountService.requestDepositAddress(Currency.BTC));
System.out.println(accountService.getAccountInfo());
System.out.println(accountService.withdrawFunds(Currency.BTC, new BigDecimal("0.03"), "XXX"));
final TradeHistoryParams params = accountService.createFundingHistoryParams();
((TradeHistoryParamsTimeSpan) params)
.setStartTime(new Date(System.currentTimeMillis() - 7L * 24 * 60 * 60 * 1000));
final List<FundingRecord> fundingHistory = accountService.getFundingHistory(params);
for (FundingRecord fundingRecord : fundingHistory) {
System.out.println(fundingRecord);
}
| 202
| 220
| 422
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/quoine/QuoineExamplesUtils.java
|
QuoineExamplesUtils
|
createExchange
|
class QuoineExamplesUtils {
public static Exchange createExchange() {<FILL_FUNCTION_BODY>}
}
|
ExchangeSpecification exSpec = new ExchangeSpecification(QuoineExchange.class);
// enter your specific API access info here
exSpec.setApiKey("KEY_TOKEN_ID");
exSpec.setSecretKey("KEY_USER_SECRET");
return ExchangeFactory.INSTANCE.createExchange(exSpec);
| 34
| 87
| 121
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/quoine/trade/QuoineOrdersListDemo.java
|
QuoineOrdersListDemo
|
main
|
class QuoineOrdersListDemo {
public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>}
private static void raw(QuoineTradeServiceRaw tradeServiceRaw) throws IOException {
// list orders
QuoineOrdersList quoineOrdersList = tradeServiceRaw.listQuoineOrders();
System.out.println(quoineOrdersList.toString());
}
}
|
Exchange exchange = QuoineExamplesUtils.createExchange();
TradeService tradeService = exchange.getTradeService();
raw((QuoineTradeServiceRaw) tradeService);
| 113
| 50
| 163
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/ripple/marketdata/RippleOrderBookDemo.java
|
RippleOrderBookDemo
|
main
|
class RippleOrderBookDemo {
public static void main(final String[] args) throws IOException {<FILL_FUNCTION_BODY>}
private static void generic(final MarketDataService marketDataService) throws IOException {
final RippleMarketDataParams params = new RippleMarketDataParams();
// rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B is Bitstamp's account
params.setAddress("rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B");
// Base symbol is BTC, this requires a counterparty
params.setBaseCounterparty("rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B");
// Counter symbol is XRP, this is the native currency so does not need counterparty
// params.setCounterCounterparty("");
// Set number of orders on each bid/ask side to return
params.setLimit(10);
// Fetch order book for Bitstamp issued BTC vs XRP
final OrderBook orderBook = marketDataService.getOrderBook(CurrencyPair.BTC_XRP, params);
System.out.println(orderBook.toString());
}
private static void raw(final RippleMarketDataServiceRaw marketDataService) throws IOException {
final RippleMarketDataParams params = new RippleMarketDataParams();
// rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q is SnapSwap's address
params.setAddress("rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q");
// Base symbol is BTC, this requires a counterparty
params.setBaseCounterparty("rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q");
// Counter symbol is USD, this requires a counterparty
params.setCounterCounterparty("rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q");
// Set number of orders on each bid/ask side to return
params.setLimit(10);
// fetch SnapSwap's EUR/USD order book
final RippleOrderBook orderBook =
marketDataService.getRippleOrderBook(CurrencyPair.EUR_USD, params);
System.out.println(orderBook.toString());
}
}
|
// Use the factory to get Riiple exchange API using default settings
final Exchange ripple = ExchangeFactory.INSTANCE.createExchange(RippleExchange.class);
// Interested in the public market data feed (no authentication)
final MarketDataService marketDataService = ripple.getMarketDataService();
// Ripple specific objects
raw((RippleMarketDataServiceRaw) marketDataService);
// Xchange objects
generic(marketDataService);
| 643
| 119
| 762
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/upbit/UpbitDemoUtils.java
|
UpbitDemoUtils
|
createExchange
|
class UpbitDemoUtils {
public static Exchange createExchange() {<FILL_FUNCTION_BODY>}
}
|
ExchangeSpecification exSpec = new UpbitExchange().getDefaultExchangeSpecification();
exSpec.setApiKey("PublicKeyGeneratedUopnLogin");
exSpec.setSecretKey("SecretKeyGeneratedUopnLogin");
return ExchangeFactory.INSTANCE.createExchange(exSpec);
| 32
| 74
| 106
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/upbit/account/UpbitAccountInfoDemo.java
|
UpbitAccountInfoDemo
|
raw
|
class UpbitAccountInfoDemo {
public static void main(String[] args) throws IOException {
Exchange upbit = UpbitDemoUtils.createExchange();
AccountService accountService = upbit.getAccountService();
generic(accountService);
raw((UpbitAccountServiceRaw) accountService);
}
private static void generic(AccountService accountService) throws IOException {
AccountInfo accountInfo = accountService.getAccountInfo();
System.out.println("Wallet: " + accountInfo);
System.out.println(
"ETH balance: " + accountInfo.getWallet().getBalance(Currency.ETH).getAvailable());
}
private static void raw(UpbitAccountServiceRaw accountService) throws IOException {<FILL_FUNCTION_BODY>}
}
|
UpbitBalance[] upbitBalance = accountService.getWallet().getBalances();
Arrays.stream(upbitBalance)
.forEach(
balance -> {
System.out.println(
"UPBIT Currency : "
+ balance.getCurrency()
+ " balance :"
+ balance.getBalance());
});
| 193
| 93
| 286
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/util/AccountServiceTestUtil.java
|
AccountServiceTestUtil
|
printFundingHistory
|
class AccountServiceTestUtil {
public static void printFundingHistory(List<FundingRecord> fundingRecords) throws IOException {<FILL_FUNCTION_BODY>}
}
|
if (fundingRecords != null) {
for (final FundingRecord fundingRecord : fundingRecords) {
System.out.println(fundingRecord);
}
} else {
System.out.println("No Funding History Found.");
}
| 46
| 70
| 116
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/yobit/YoBitExchangeDemo.java
|
YoBitExchangeDemo
|
main
|
class YoBitExchangeDemo {
public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>}
}
|
Exchange exchange = ExchangeFactory.INSTANCE.createExchange(YoBitExchange.class);
System.out.println("ExchangeMetaData toString(): " + exchange.getExchangeMetaData().toString());
System.out.println(
"ExchangeMetaData toJSONString(): " + exchange.getExchangeMetaData().toJSONString());
System.out.println("Currency Pairs: " + exchange.getExchangeInstruments());
| 39
| 112
| 151
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/yobit/marketdata/YoBitBookDemo.java
|
YoBitBookDemo
|
main
|
class YoBitBookDemo {
public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>}
}
|
Exchange yoBitExchange = ExchangeFactory.INSTANCE.createExchange(YoBitExchange.class);
// Interested in the public market data feed (no authentication)
MarketDataService marketDataService = yoBitExchange.getMarketDataService();
System.out.println("fetching data...");
// Get the current orderbook
OrderBook orderBook = marketDataService.getOrderBook(CurrencyPair.ETH_BTC);
System.out.println("received data.");
for (LimitOrder limitOrder : orderBook.getBids()) {
System.out.println(
limitOrder.getType()
+ " "
+ limitOrder.getCurrencyPair()
+ " Limit price: "
+ limitOrder.getLimitPrice()
+ " Amount: "
+ limitOrder.getOriginalAmount());
}
for (LimitOrder limitOrder : orderBook.getAsks()) {
System.out.println(
limitOrder.getType()
+ " "
+ limitOrder.getCurrencyPair()
+ " Limit price: "
+ limitOrder.getLimitPrice()
+ " Amount: "
+ limitOrder.getOriginalAmount());
}
| 38
| 305
| 343
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-examples/src/main/java/org/knowm/xchange/examples/yobit/marketdata/YoBitTradeDemo.java
|
YoBitTradeDemo
|
main
|
class YoBitTradeDemo {
public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>}
}
|
Exchange yoBitExchange = ExchangeFactory.INSTANCE.createExchange(YoBitExchange.class);
// Interested in the public market data feed (no authentication)
MarketDataService marketDataService = yoBitExchange.getMarketDataService();
System.out.println("fetching data...");
Trades trades = marketDataService.getTrades(CurrencyPair.BTC_USD);
System.out.println("received data.");
for (Trade trade : trades.getTrades()) {
System.out.println(
trade.getType()
+ " "
+ trade.getCurrencyPair()
+ " Price: "
+ trade.getPrice()
+ " Amount: "
+ trade.getOriginalAmount());
}
| 39
| 198
| 237
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-exmo/src/main/java/org/knowm/xchange/exmo/ExmoDigest.java
|
ExmoDigest
|
digestParams
|
class ExmoDigest extends BaseParamsDigest {
private ExmoDigest(String secretKeyBase64) {
super(secretKeyBase64, HMAC_SHA_512);
}
public static ExmoDigest createInstance(String secretKeyBase64) {
return secretKeyBase64 == null ? null : new ExmoDigest(secretKeyBase64);
}
@Override
public String digestParams(RestInvocation restInvocation) {<FILL_FUNCTION_BODY>}
}
|
Mac mac = getMac();
String requestBody = restInvocation.getRequestBody();
if (requestBody != null && !requestBody.isEmpty()) {
mac.update(requestBody.getBytes());
}
return String.format("%0128x", new BigInteger(1, mac.doFinal()));
| 133
| 84
| 217
|
<methods>public javax.crypto.Mac getMac() <variables>public static final java.lang.String HMAC_MD5,public static final java.lang.String HMAC_SHA_1,public static final java.lang.String HMAC_SHA_256,public static final java.lang.String HMAC_SHA_384,public static final java.lang.String HMAC_SHA_512,private final non-sealed javax.crypto.Mac mac
|
knowm_XChange
|
XChange/xchange-ftx/src/main/java/org/knowm/xchange/ftx/FtxExchange.java
|
FtxExchange
|
initServices
|
class FtxExchange extends BaseExchange implements Exchange {
private FtxLendingServiceRaw lendingService;
private FtxBorrowingServiceRaw borrowingService;
@Override
protected void initServices() {<FILL_FUNCTION_BODY>}
@Override
public ExchangeSpecification getDefaultExchangeSpecification() {
ExchangeSpecification exchangeSpecification = new ExchangeSpecification(this.getClass());
exchangeSpecification.setSslUri("https://ftx.com");
exchangeSpecification.setHost("ftx.com");
exchangeSpecification.setPort(80);
exchangeSpecification.setExchangeName("Ftx");
exchangeSpecification.setExchangeDescription("Ftx is a spot and derivatives exchange.");
return exchangeSpecification;
}
@Override
public void remoteInit() throws IOException, ExchangeException {
FtxMarketsDto marketsDto =
((FtxMarketDataServiceRaw) marketDataService).getFtxMarkets().getResult();
exchangeMetaData = FtxAdapters.adaptExchangeMetaData(marketsDto);
}
@Override
public MarketDataService getMarketDataService() {
return this.marketDataService;
}
@Override
public AccountService getAccountService() {
return this.accountService;
}
@Override
public TradeService getTradeService() {
return this.tradeService;
}
public FtxLendingServiceRaw getLendingService() {
return lendingService;
}
public FtxBorrowingServiceRaw getBorrowingService() {
return borrowingService;
}
}
|
this.marketDataService = new FtxMarketDataService(this);
this.accountService = new FtxAccountService(this);
this.tradeService = new FtxTradeService(this);
this.lendingService = new FtxLendingServiceRaw(this);
this.borrowingService = new FtxBorrowingServiceRaw(this);
| 415
| 91
| 506
|
<methods>public non-sealed void <init>() ,public void applySpecification(org.knowm.xchange.ExchangeSpecification) ,public org.knowm.xchange.service.account.AccountService getAccountService() ,public List<org.knowm.xchange.instrument.Instrument> getExchangeInstruments() ,public org.knowm.xchange.dto.meta.ExchangeMetaData getExchangeMetaData() ,public org.knowm.xchange.ExchangeSpecification getExchangeSpecification() ,public org.knowm.xchange.service.marketdata.MarketDataService getMarketDataService() ,public java.lang.String getMetaDataFileName(org.knowm.xchange.ExchangeSpecification) ,public SynchronizedValueFactory<java.lang.Long> getNonceFactory() ,public org.knowm.xchange.service.trade.TradeService getTradeService() ,public void remoteInit() throws java.io.IOException, org.knowm.xchange.exceptions.ExchangeException,public java.lang.String toString() <variables>protected org.knowm.xchange.service.account.AccountService accountService,protected org.knowm.xchange.dto.meta.ExchangeMetaData exchangeMetaData,protected org.knowm.xchange.ExchangeSpecification exchangeSpecification,protected final Logger logger,protected org.knowm.xchange.service.marketdata.MarketDataService marketDataService,private final SynchronizedValueFactory<java.lang.Long> nonceFactory,protected org.knowm.xchange.service.trade.TradeService tradeService
|
knowm_XChange
|
XChange/xchange-ftx/src/main/java/org/knowm/xchange/ftx/dto/FtxResponse.java
|
FtxResponse
|
toString
|
class FtxResponse<V> {
private final boolean success;
private final V result;
@JsonIgnore private final boolean hasMoreData;
public FtxResponse(
@JsonProperty("success") boolean success,
@JsonProperty("result") V result,
@JsonProperty("hasMoreData") boolean hasMoreData) {
this.success = success;
this.result = result;
this.hasMoreData = hasMoreData;
}
public boolean isSuccess() {
return success;
}
public V getResult() {
return result;
}
public boolean isHasMoreData() {
return hasMoreData;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
return "FtxResponse{"
+ "success="
+ success
+ ", result="
+ result
+ ", hasMoreData="
+ hasMoreData
+ '}';
| 196
| 54
| 250
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-ftx/src/main/java/org/knowm/xchange/ftx/dto/account/FtxAccountDto.java
|
FtxAccountDto
|
toString
|
class FtxAccountDto {
@JsonProperty("backstopProvider")
private final boolean backstopProvider;
@JsonProperty("collateral")
private final BigDecimal collateral;
@JsonProperty("freeCollateral")
private final BigDecimal freeCollateral;
@JsonProperty("initialMarginRequirement")
private final BigDecimal initialMarginRequirement;
@JsonProperty("leverage")
private final BigDecimal leverage;
@JsonProperty("liquidating")
private final boolean liquidating;
@JsonProperty("maintenanceMarginRequirement")
private final BigDecimal maintenanceMarginRequirement;
@JsonProperty("makerFee")
private final BigDecimal makerFee;
@JsonProperty("marginFraction")
private final BigDecimal marginFraction;
@JsonProperty("openMarginFraction")
private final BigDecimal openMarginFraction;
@JsonProperty("takerFee")
private final BigDecimal takerFee;
@JsonProperty("totalAccountValue")
private final BigDecimal totalAccountValue;
@JsonProperty("totalPositionSize")
private final BigDecimal totalPositionSize;
@JsonProperty("username")
private final String username;
@JsonProperty("positions")
private final List<FtxPositionDto> positions;
public FtxAccountDto(
@JsonProperty("backstopProvider") boolean backstopProvider,
@JsonProperty("collateral") BigDecimal collateral,
@JsonProperty("freeCollateral") BigDecimal freeCollateral,
@JsonProperty("initialMarginRequirement") BigDecimal initialMarginRequirement,
@JsonProperty("leverage") BigDecimal leverage,
@JsonProperty("liquidating") boolean liquidating,
@JsonProperty("maintenanceMarginRequirement") BigDecimal maintenanceMarginRequirement,
@JsonProperty("makerFee") BigDecimal makerFee,
@JsonProperty("marginFraction") BigDecimal marginFraction,
@JsonProperty("openMarginFraction") BigDecimal openMarginFraction,
@JsonProperty("takerFee") BigDecimal takerFee,
@JsonProperty("totalAccountValue") BigDecimal totalAccountValue,
@JsonProperty("totalPositionSize") BigDecimal totalPositionSize,
@JsonProperty("username") String username,
@JsonProperty("positions") List<FtxPositionDto> positions) {
this.backstopProvider = backstopProvider;
this.collateral = collateral;
this.freeCollateral = freeCollateral;
this.initialMarginRequirement = initialMarginRequirement;
this.leverage = leverage;
this.liquidating = liquidating;
this.maintenanceMarginRequirement = maintenanceMarginRequirement;
this.makerFee = makerFee;
this.marginFraction = marginFraction;
this.openMarginFraction = openMarginFraction;
this.takerFee = takerFee;
this.totalAccountValue = totalAccountValue;
this.totalPositionSize = totalPositionSize;
this.username = username;
this.positions = positions;
}
public boolean getBackstopProvider() {
return backstopProvider;
}
public BigDecimal getCollateral() {
return collateral;
}
public BigDecimal getFreeCollateral() {
return freeCollateral;
}
public BigDecimal getInitialMarginRequirement() {
return initialMarginRequirement;
}
public BigDecimal getLeverage() {
return leverage;
}
public boolean getLiquidating() {
return liquidating;
}
public BigDecimal getMaintenanceMarginRequirement() {
return maintenanceMarginRequirement;
}
public BigDecimal getMakerFee() {
return makerFee;
}
public BigDecimal getMarginFraction() {
return marginFraction;
}
public BigDecimal getOpenMarginFraction() {
return openMarginFraction;
}
public BigDecimal getTakerFee() {
return takerFee;
}
public BigDecimal getTotalAccountValue() {
return totalAccountValue;
}
public BigDecimal getTotalPositionSize() {
return totalPositionSize;
}
public String getUsername() {
return username;
}
public List<FtxPositionDto> getPositions() {
return positions;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
return "FtxAccountDto{"
+ "backstopProvider="
+ backstopProvider
+ ", collateral="
+ collateral
+ ", freeCollateral="
+ freeCollateral
+ ", initialMarginRequirement="
+ initialMarginRequirement
+ ", leverage="
+ leverage
+ ", liquidating="
+ liquidating
+ ", maintenanceMarginRequirement="
+ maintenanceMarginRequirement
+ ", makerFee="
+ makerFee
+ ", marginFraction="
+ marginFraction
+ ", openMarginFraction="
+ openMarginFraction
+ ", takerFee="
+ takerFee
+ ", totalAccountValue="
+ totalAccountValue
+ ", totalPositionSize="
+ totalPositionSize
+ ", username='"
+ username
+ '\''
+ ", positions="
+ positions
+ '}';
| 1,181
| 249
| 1,430
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-ftx/src/main/java/org/knowm/xchange/ftx/dto/account/FtxBorrowingRatesDto.java
|
FtxBorrowingRatesDto
|
toString
|
class FtxBorrowingRatesDto {
@JsonProperty("coin")
private final String coin;
@JsonProperty("previous")
private final double previous;
@JsonProperty("estimate")
private final double estimate;
@JsonCreator
public FtxBorrowingRatesDto(
@JsonProperty("coin") String coin,
@JsonProperty("previous") double previous,
@JsonProperty("estimate") double estimate) {
this.coin = coin;
this.previous = previous;
this.estimate = estimate;
}
public String getCoin() {
return coin;
}
public double getPrevious() {
return previous;
}
public double getEstimate() {
return estimate;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
return "FtxBorrowingRatesDto{"
+ "coin='"
+ coin
+ '\''
+ ", previous="
+ previous
+ ", estimate="
+ estimate
+ '}';
| 224
| 61
| 285
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-ftx/src/main/java/org/knowm/xchange/ftx/dto/account/FtxConvertDto.java
|
FtxConvertDto
|
toString
|
class FtxConvertDto {
@JsonProperty("baseCoin")
private final String baseCoin;
@JsonProperty("cost")
private final double cost;
@JsonProperty("expired")
private final boolean expired;
// @JsonProperty("expiry")
// private final Date expiry;
@JsonProperty("filled")
private final boolean filled;
@JsonProperty("fromCoin")
private final String fromCoin;
@JsonProperty("id")
private final int id;
@JsonProperty("price")
private final double price;
@JsonProperty("proceeds")
private final double proceeds;
@JsonProperty("quoteCoin")
private final String quoteCoin;
@JsonProperty("side")
private final String side;
@JsonProperty("toCoin")
private final String toCoin;
@JsonCreator
public FtxConvertDto(
@JsonProperty(value = "baseCoin", required = false) String baseCoin,
@JsonProperty(value = "cost", required = false) double cost,
@JsonProperty(value = "expired", required = false) boolean expired,
@JsonProperty(value = "filled", required = false) boolean filled,
@JsonProperty(value = "fromCoin", required = false) String fromCoin,
@JsonProperty(value = "id", required = false) int id,
@JsonProperty(value = "price", required = false) double price,
@JsonProperty(value = "proceeds", required = false) double proceeds,
@JsonProperty(value = "quoteCoin", required = false) String quoteCoin,
@JsonProperty(value = "side", required = false) String side,
@JsonProperty(value = "toCoin", required = false) String toCoin) {
this.baseCoin = baseCoin;
this.cost = cost;
this.expired = expired;
this.filled = filled;
this.fromCoin = fromCoin;
this.id = id;
this.price = price;
this.proceeds = proceeds;
this.quoteCoin = quoteCoin;
this.side = side;
this.toCoin = toCoin;
}
public String getBaseCoin() {
return baseCoin;
}
public double getCost() {
return cost;
}
public boolean isExpired() {
return expired;
}
public boolean isFilled() {
return filled;
}
public String getFromCoin() {
return fromCoin;
}
public int getId() {
return id;
}
public double getPrice() {
return price;
}
public double getProceeds() {
return proceeds;
}
public String getQuoteCoin() {
return quoteCoin;
}
public String getSide() {
return side;
}
public String getToCoin() {
return toCoin;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
return "FtxConvertDto [baseCoin="
+ baseCoin
+ ", cost="
+ cost
+ ", expired="
+ expired
+ ", filled="
+ filled
+ ", fromCoin="
+ fromCoin
+ ", id="
+ id
+ ", price="
+ price
+ ", proceeds="
+ proceeds
+ ", quoteCoin="
+ quoteCoin
+ ", side="
+ side
+ ", toCoin="
+ toCoin
+ "]";
| 806
| 154
| 960
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-ftx/src/main/java/org/knowm/xchange/ftx/dto/account/FtxLendDataDto.java
|
FtxLendDataDto
|
toString
|
class FtxLendDataDto {
@JsonProperty("coin")
private final String coin;
@JsonProperty("locked")
private final double locked;
@JsonProperty("currentOffered")
private final double currentOffered;
@JsonProperty("newOffered")
private final double newOffered;
@JsonProperty("rate")
private final double rate;
public FtxLendDataDto(
@JsonProperty("coin") String coin,
@JsonProperty("locked") double locked,
@JsonProperty("currentOffered") double currentOffered,
@JsonProperty("newOffered") double newOffered,
@JsonProperty("rate") double rate) {
this.coin = coin;
this.locked = locked;
this.currentOffered = currentOffered;
this.newOffered = newOffered;
this.rate = rate;
}
public String getCoin() {
return coin;
}
public double getLocked() {
return locked;
}
public double getCurrentOffered() {
return currentOffered;
}
public double getNewOffered() {
return newOffered;
}
public double getRate() {
return rate;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
return "FtxLendDataDto{"
+ "coin='"
+ coin
+ '\''
+ ", locked="
+ locked
+ ", currentOffered="
+ currentOffered
+ ", newOffered="
+ newOffered
+ ", rate="
+ rate
+ '}';
| 350
| 89
| 439
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-ftx/src/main/java/org/knowm/xchange/ftx/dto/account/FtxLendingRatesDto.java
|
FtxLendingRatesDto
|
toString
|
class FtxLendingRatesDto {
@JsonProperty("coin")
private final String coin;
@JsonProperty("previous")
private final double previous;
@JsonProperty("estimate")
private final double estimate;
@JsonCreator
public FtxLendingRatesDto(
@JsonProperty("coin") String coin,
@JsonProperty("previous") double previous,
@JsonProperty("estimate") double estimate) {
this.coin = coin;
this.previous = previous;
this.estimate = estimate;
}
public String getCoin() {
return coin;
}
public double getPrevious() {
return previous;
}
public double getEstimate() {
return estimate;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
return "FtxLendingRatesDto{"
+ "coin='"
+ coin
+ '\''
+ ", previous="
+ previous
+ ", estimate="
+ estimate
+ '}';
| 222
| 60
| 282
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-ftx/src/main/java/org/knowm/xchange/ftx/dto/account/FtxPositionDto.java
|
FtxPositionDto
|
toString
|
class FtxPositionDto {
@JsonProperty("cost")
private final BigDecimal cost;
@JsonProperty("entryPrice")
private final BigDecimal entryPrice;
@JsonProperty("estimatedLiquidationPrice")
private final BigDecimal estimatedLiquidationPrice;
@JsonProperty("future")
private final String future;
@JsonProperty("initialMarginRequirement")
private final BigDecimal initialMarginRequirement;
@JsonProperty("longOrderSize")
private final BigDecimal longOrderSize;
@JsonProperty("maintenanceMarginRequirement")
private final BigDecimal maintenanceMarginRequirement;
@JsonProperty("netSize")
private final BigDecimal netSize;
@JsonProperty("openSize")
private final BigDecimal openSize;
@JsonProperty("realizedPnl")
private final BigDecimal realizedPnl;
@JsonProperty("shortOrderSize")
private final BigDecimal shortOrderSize;
@JsonProperty("side")
private final FtxOrderSide side;
@JsonProperty("size")
private final BigDecimal size;
@JsonProperty("unrealizedPnl")
private final BigDecimal unrealizedPnl;
@JsonProperty("collateralUsed")
private final BigDecimal collateralUsed;
@JsonProperty("recentBreakEvenPrice")
private final BigDecimal recentBreakEvenPrice;
@JsonProperty("recentAverageOpenPrice")
private final BigDecimal recentAverageOpenPrice;
@JsonProperty("recentPnl")
private final BigDecimal recentPnl;
@JsonProperty("cumulativeBuySize")
private final BigDecimal cumulativeBuySize;
@JsonProperty("cumulativeSellSize")
private final BigDecimal cumulativeSellSize;
public FtxPositionDto(
@JsonProperty("cost") BigDecimal cost,
@JsonProperty("entryPrice") BigDecimal entryPrice,
@JsonProperty("estimatedLiquidationPrice") BigDecimal estimatedLiquidationPrice,
@JsonProperty("future") String future,
@JsonProperty("initialMarginRequirement") BigDecimal initialMarginRequirement,
@JsonProperty("longOrderSize") BigDecimal longOrderSize,
@JsonProperty("maintenanceMarginRequirement") BigDecimal maintenanceMarginRequirement,
@JsonProperty("netSize") BigDecimal netSize,
@JsonProperty("openSize") BigDecimal openSize,
@JsonProperty("realizedPnl") BigDecimal realizedPnl,
@JsonProperty("shortOrderSize") BigDecimal shortOrderSize,
@JsonProperty("side") FtxOrderSide side,
@JsonProperty("size") BigDecimal size,
@JsonProperty("unrealizedPnl") BigDecimal unrealizedPnl,
@JsonProperty("collateralUsed") BigDecimal collateralUsed,
@JsonProperty("recentBreakEvenPrice") BigDecimal recentBreakEvenPrice,
@JsonProperty("recentAverageOpenPrice") BigDecimal recentAverageOpenPrice,
@JsonProperty("recentPnl") BigDecimal recentPnl,
@JsonProperty("cumulativeBuySize") BigDecimal cumulativeBuySize,
@JsonProperty("cumulativeSellSize") BigDecimal cumulativeSellSize) {
this.cost = cost;
this.entryPrice = entryPrice;
this.estimatedLiquidationPrice = estimatedLiquidationPrice;
this.future = future;
this.initialMarginRequirement = initialMarginRequirement;
this.longOrderSize = longOrderSize;
this.maintenanceMarginRequirement = maintenanceMarginRequirement;
this.netSize = netSize;
this.openSize = openSize;
this.realizedPnl = realizedPnl;
this.shortOrderSize = shortOrderSize;
this.side = side;
this.size = size;
this.unrealizedPnl = unrealizedPnl;
this.collateralUsed = collateralUsed;
this.recentBreakEvenPrice = recentBreakEvenPrice;
this.recentAverageOpenPrice = recentAverageOpenPrice;
this.recentPnl = recentPnl;
this.cumulativeBuySize = cumulativeBuySize;
this.cumulativeSellSize = cumulativeSellSize;
}
public BigDecimal getCost() {
return cost;
}
public BigDecimal getEntryPrice() {
return entryPrice;
}
public BigDecimal getEstimatedLiquidationPrice() {
return estimatedLiquidationPrice;
}
public String getFuture() {
return future;
}
public BigDecimal getInitialMarginRequirement() {
return initialMarginRequirement;
}
public BigDecimal getLongOrderSize() {
return longOrderSize;
}
public BigDecimal getMaintenanceMarginRequirement() {
return maintenanceMarginRequirement;
}
public BigDecimal getNetSize() {
return netSize;
}
public BigDecimal getOpenSize() {
return openSize;
}
public BigDecimal getRealizedPnl() {
return realizedPnl;
}
public BigDecimal getShortOrderSize() {
return shortOrderSize;
}
public FtxOrderSide getSide() {
return side;
}
public BigDecimal getSize() {
return size;
}
public BigDecimal getUnrealizedPnl() {
return unrealizedPnl;
}
public BigDecimal getCollateralUsed() {
return collateralUsed;
}
public BigDecimal getRecentBreakEvenPrice() {
return recentBreakEvenPrice;
}
public BigDecimal getRecentAverageOpenPrice() {
return recentAverageOpenPrice;
}
public BigDecimal getRecentPnl() {
return recentPnl;
}
public BigDecimal getCumulativeBuySize() {
return cumulativeBuySize;
}
public BigDecimal getCumulativeSellSize() {
return cumulativeSellSize;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
return "FtxPositionDto{"
+ "cost="
+ cost
+ ", entryPrice="
+ entryPrice
+ ", estimatedLiquidationPrice="
+ estimatedLiquidationPrice
+ ", future='"
+ future
+ '\''
+ ", initialMarginRequirement="
+ initialMarginRequirement
+ ", longOrderSize="
+ longOrderSize
+ ", maintenanceMarginRequirement="
+ maintenanceMarginRequirement
+ ", netSize="
+ netSize
+ ", openSize="
+ openSize
+ ", realizedPnl="
+ realizedPnl
+ ", shortOrderSize="
+ shortOrderSize
+ ", side="
+ side
+ ", size="
+ size
+ ", unrealizedPnl="
+ unrealizedPnl
+ ", collateralUsed="
+ collateralUsed
+ ", recentBreakEvenPrice="
+ recentBreakEvenPrice
+ ", recentAverageOpenPrice="
+ recentAverageOpenPrice
+ ", recentPnl="
+ recentPnl
+ ", cumulativeBuySize="
+ cumulativeBuySize
+ ", cumulativeSellSize="
+ cumulativeSellSize
+ '}';
| 1,591
| 332
| 1,923
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-ftx/src/main/java/org/knowm/xchange/ftx/dto/account/FtxSubAccountTransferPOJO.java
|
FtxSubAccountTransferPOJO
|
toString
|
class FtxSubAccountTransferPOJO {
private String coin;
private BigDecimal size;
private String source;
private String destination;
public FtxSubAccountTransferPOJO(
String coin, BigDecimal size, String source, String destination) {
this.coin = coin;
this.size = size;
this.source = source;
this.destination = destination;
}
public String getCoin() {
return coin;
}
public void setCoin(String coin) {
this.coin = coin;
}
public BigDecimal getSize() {
return size;
}
public void setSize(BigDecimal size) {
this.size = size;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
public String getDestination() {
return destination;
}
public void setDestination(String destination) {
this.destination = destination;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
return "FtxSubAccountTransferPOJO{"
+ "coin='"
+ coin
+ '\''
+ ", size="
+ size
+ ", source='"
+ source
+ '\''
+ ", destination='"
+ destination
+ '\''
+ '}';
| 303
| 81
| 384
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-ftx/src/main/java/org/knowm/xchange/ftx/dto/marketdata/FtxPublicOrder.java
|
FtxOrderDeserializer
|
deserialize
|
class FtxOrderDeserializer extends JsonDeserializer<FtxPublicOrder> {
@Override
public FtxPublicOrder deserialize(JsonParser jsonParser, DeserializationContext ctxt)
throws IOException, JsonProcessingException {<FILL_FUNCTION_BODY>}
}
|
ObjectCodec oc = jsonParser.getCodec();
JsonNode node = oc.readTree(jsonParser);
if (node.isArray()) {
BigDecimal price = new BigDecimal(node.path(0).asText());
BigDecimal volume = new BigDecimal(node.path(1).asText());
return new FtxPublicOrder(price, volume);
}
return null;
| 73
| 107
| 180
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-ftx/src/main/java/org/knowm/xchange/ftx/dto/trade/FtxConditionalOrderRequestPayload.java
|
FtxConditionalOrderRequestPayload
|
toString
|
class FtxConditionalOrderRequestPayload {
private String market;
private FtxOrderSide side;
private BigDecimal size;
private FtxConditionalOrderType type;
private boolean reduceOnly;
private boolean retryUntilFilled;
private BigDecimal orderPrice;
private BigDecimal triggerPrice;
private BigDecimal trailValue;
public FtxConditionalOrderRequestPayload(
String market,
FtxOrderSide side,
BigDecimal size,
FtxConditionalOrderType type,
boolean reduceOnly,
boolean retryUntilFilled,
BigDecimal orderPrice,
BigDecimal triggerPrice,
BigDecimal trailValue) {
this.market = market;
this.side = side;
this.size = size;
this.type = type;
this.reduceOnly = reduceOnly;
this.retryUntilFilled = retryUntilFilled;
this.orderPrice = orderPrice;
this.triggerPrice = triggerPrice;
this.trailValue = trailValue;
}
public String getMarket() {
return market;
}
public void setMarket(String market) {
this.market = market;
}
public FtxOrderSide getSide() {
return side;
}
public void setSide(FtxOrderSide side) {
this.side = side;
}
public BigDecimal getSize() {
return size;
}
public void setSize(BigDecimal size) {
this.size = size;
}
public FtxConditionalOrderType getType() {
return type;
}
public void setType(FtxConditionalOrderType type) {
this.type = type;
}
public boolean isReduceOnly() {
return reduceOnly;
}
public void setReduceOnly(boolean reduceOnly) {
this.reduceOnly = reduceOnly;
}
public boolean isRetryUntilFilled() {
return retryUntilFilled;
}
public void setRetryUntilFilled(boolean retryUntilFilled) {
this.retryUntilFilled = retryUntilFilled;
}
public BigDecimal getOrderPrice() {
return orderPrice;
}
public void setOrderPrice(BigDecimal orderPrice) {
this.orderPrice = orderPrice;
}
public BigDecimal getTriggerPrice() {
return triggerPrice;
}
public void setTriggerPrice(BigDecimal triggerPrice) {
this.triggerPrice = triggerPrice;
}
public BigDecimal getTrailValue() {
return trailValue;
}
public void setTrailValue(BigDecimal trailValue) {
this.trailValue = trailValue;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
return "FtxConditionalOrderRequestPayload{"
+ "market='"
+ market
+ '\''
+ ", side="
+ side
+ ", size="
+ size
+ ", type="
+ type
+ ", reduceOnly="
+ reduceOnly
+ ", retryUntilFilled="
+ retryUntilFilled
+ ", orderPrice="
+ orderPrice
+ ", triggerPrice="
+ triggerPrice
+ ", trailValue="
+ trailValue
+ '}';
| 743
| 142
| 885
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-ftx/src/main/java/org/knowm/xchange/ftx/dto/trade/FtxFillDto.java
|
FtxFillDto
|
toString
|
class FtxFillDto {
private final Date time;
private final String id;
private final String market;
private final BigDecimal price;
private final FtxOrderSide side;
private final BigDecimal size;
private final String orderId;
private final String tradeId;
private final BigDecimal fee;
private final String feeCurrency;
private final BigDecimal feeRate;
@JsonCreator
public FtxFillDto(
@JsonProperty("time") Date time,
@JsonProperty("id") String id,
@JsonProperty("market") String market,
@JsonProperty("price") BigDecimal price,
@JsonProperty("side") FtxOrderSide side,
@JsonProperty("size") BigDecimal size,
@JsonProperty("orderId") String orderId,
@JsonProperty("tradeId") String tradeId,
@JsonProperty("fee") BigDecimal fee,
@JsonProperty("feeCurrency") String feeCurrency,
@JsonProperty("feeRate") BigDecimal feeRate) {
this.time = time;
this.id = id;
this.market = market;
this.price = price;
this.side = side;
this.size = size;
this.orderId = orderId;
this.tradeId = tradeId;
this.fee = fee;
this.feeCurrency = feeCurrency;
this.feeRate = feeRate;
}
public Date getTime() {
return time;
}
public String getId() {
return id;
}
public String getMarket() {
return market;
}
public BigDecimal getPrice() {
return price;
}
public FtxOrderSide getSide() {
return side;
}
public BigDecimal getSize() {
return size;
}
public String getOrderId() {
return orderId;
}
public String getTradeId() {
return tradeId;
}
public BigDecimal getFee() {
return fee;
}
public String getFeeCurrency() {
return feeCurrency;
}
public BigDecimal getFeeRate() {
return feeRate;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
return "FtxFillDto{"
+ "time="
+ time
+ ", id='"
+ id
+ '\''
+ ", market='"
+ market
+ '\''
+ ", price="
+ price
+ ", side="
+ side
+ ", size="
+ size
+ ", orderId='"
+ orderId
+ '\''
+ ", tradeId='"
+ tradeId
+ '\''
+ ", fee="
+ fee
+ ", feeCurrency='"
+ feeCurrency
+ '\''
+ ", feeRate="
+ feeRate
+ '}';
| 620
| 175
| 795
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-ftx/src/main/java/org/knowm/xchange/ftx/dto/trade/FtxModifyOrderRequestPayload.java
|
FtxModifyOrderRequestPayload
|
toString
|
class FtxModifyOrderRequestPayload {
private final BigDecimal price;
private final BigDecimal size;
private final String clientId;
public FtxModifyOrderRequestPayload(
@JsonProperty("price") BigDecimal price,
@JsonProperty("size") BigDecimal size,
@JsonProperty("clientId") String clientId) {
this.price = price;
this.size = size;
this.clientId = clientId;
}
public BigDecimal getPrice() {
return price;
}
public BigDecimal getSize() {
return size;
}
public String getClientId() {
return clientId;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
return "FtxModifyOrderRequestPayload{"
+ "price="
+ price
+ ", size="
+ size
+ ", clientId='"
+ clientId
+ '\''
+ '}';
| 206
| 62
| 268
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-ftx/src/main/java/org/knowm/xchange/ftx/service/FtxAccountServiceRaw.java
|
FtxAccountServiceRaw
|
createFtxSubAccount
|
class FtxAccountServiceRaw extends FtxBaseService {
public FtxAccountServiceRaw(Exchange exchange) {
super(exchange);
}
public FtxResponse<FtxAccountDto> getFtxAccountInformation(String subaccount)
throws FtxException, IOException {
try {
return ftx.getAccountInformation(
exchange.getExchangeSpecification().getApiKey(),
exchange.getNonceFactory().createValue(),
signatureCreator,
subaccount);
} catch (FtxException e) {
throw new FtxException(e.getMessage());
}
}
public FtxResponse<List<FtxWalletBalanceDto>> getFtxWalletBalances(String subaccount)
throws FtxException, IOException {
try {
return ftx.getWalletBalances(
exchange.getExchangeSpecification().getApiKey(),
exchange.getNonceFactory().createValue(),
signatureCreator,
subaccount);
} catch (FtxException e) {
throw new FtxException(e.getMessage());
}
}
public FtxResponse<FtxSubAccountBalanceDto> getFtxSubAccountBalances(String nickname)
throws FtxException, IOException {
try {
return ftx.getSubAccountBalances(
exchange.getExchangeSpecification().getApiKey(),
exchange.getNonceFactory().createValue(),
signatureCreator,
null,
nickname);
} catch (FtxException e) {
throw new FtxException(e.getMessage());
}
}
public FtxResponse<FtxSubAccountBalanceDto> changeFtxSubAccountName(
String nickname, String newNickname) throws FtxException, IOException {
try {
return ftx.changeSubAccountName(
exchange.getExchangeSpecification().getApiKey(),
exchange.getNonceFactory().createValue(),
signatureCreator,
new FtxChangeSubAccountNamePOJO(nickname, newNickname));
} catch (FtxException e) {
throw new FtxException(e.getMessage());
}
}
public FtxResponse<List<FtxSubAccountDto>> getFtxAllSubAccounts()
throws FtxException, IOException {
try {
return ftx.getAllSubAccounts(
exchange.getExchangeSpecification().getApiKey(),
exchange.getNonceFactory().createValue(),
signatureCreator);
} catch (FtxException e) {
throw new FtxException(e.getMessage());
}
}
public FtxResponse deleteFtxAllSubAccounts(String nickname) throws FtxException, IOException {
try {
return ftx.deleteSubAccounts(
exchange.getExchangeSpecification().getApiKey(),
exchange.getNonceFactory().createValue(),
signatureCreator,
new FtxSubAccountRequestPOJO(nickname));
} catch (FtxException e) {
throw new FtxException(e.getMessage());
}
}
public FtxResponse<FtxSubAccountDto> createFtxSubAccount(String nickname)
throws FtxException, IOException {<FILL_FUNCTION_BODY>}
public FtxResponse<FtxSubAccountTranferDto> transferBetweenFtxSubAccount(
FtxSubAccountTransferPOJO payload) throws FtxException, IOException {
try {
return ftx.transferBetweenSubAccounts(
exchange.getExchangeSpecification().getApiKey(),
exchange.getNonceFactory().createValue(),
signatureCreator,
null,
payload);
} catch (FtxException e) {
throw new FtxException(e.getMessage());
}
}
public FtxResponse<FtxLeverageDto> changeLeverage(int leverage) throws FtxException, IOException {
return changeLeverage(null, leverage);
}
public FtxResponse<FtxLeverageDto> changeLeverage(String subaccount, int leverage)
throws FtxException, IOException {
try {
return ftx.changeLeverage(
exchange.getExchangeSpecification().getApiKey(),
exchange.getNonceFactory().createValue(),
signatureCreator,
subaccount,
new FtxLeverageDto(leverage));
} catch (FtxException e) {
throw new FtxException(e.getMessage());
}
}
public FtxResponse<List<FtxFundingPaymentsDto>> getFtxFundingPayments(
String subaccount, Long startTime, Long endTime, String future)
throws FtxException, IOException {
try {
return ftx.getFundingPayments(
exchange.getExchangeSpecification().getApiKey(),
exchange.getNonceFactory().createValue(),
signatureCreator,
subaccount,
startTime,
endTime,
future);
} catch (FtxException e) {
throw new FtxException(e.getMessage());
}
}
public FtxResponse<FtxConvertSimulatetDto> simulateFtxConvert(
String subaccount, String fromCoin, String toCoin, double size)
throws FtxException, IOException {
try {
return ftx.simulateConvert(
exchange.getExchangeSpecification().getApiKey(),
exchange.getNonceFactory().createValue(),
signatureCreator,
subaccount,
new FtxConvertSimulatePayloadRequestDto(fromCoin, toCoin, size));
} catch (FtxException e) {
throw new FtxException(e.getMessage());
}
}
public FtxResponse<FtxConvertDto> getFtxConvertStatus(String subaccount, Integer quoteId)
throws FtxException, IOException {
try {
return ftx.getConvertStatus(
exchange.getExchangeSpecification().getApiKey(),
exchange.getNonceFactory().createValue(),
signatureCreator,
subaccount,
quoteId.toString());
} catch (FtxException e) {
e.printStackTrace();
throw new FtxException(e.getMessage());
}
}
public FtxResponse<FtxConvertAcceptRequestDto> acceptFtxConvert(
String subaccount, Integer quoteId) throws FtxException, IOException {
try {
return ftx.acceptConvert(
exchange.getExchangeSpecification().getApiKey(),
exchange.getNonceFactory().createValue(),
signatureCreator,
subaccount,
quoteId.toString(),
new FtxConvertAcceptPayloadRequestDto(quoteId));
} catch (FtxException e) {
throw new FtxException(e.getMessage());
}
}
}
|
try {
return ftx.createSubAccount(
exchange.getExchangeSpecification().getApiKey(),
exchange.getNonceFactory().createValue(),
signatureCreator,
null,
new FtxSubAccountRequestPOJO(nickname));
} catch (FtxException e) {
throw new FtxException(e.getMessage());
}
| 1,702
| 94
| 1,796
|
<methods>public void <init>(org.knowm.xchange.Exchange) <variables>protected final non-sealed org.knowm.xchange.ftx.FtxAuthenticated ftx,protected final non-sealed ParamsDigest signatureCreator
|
knowm_XChange
|
XChange/xchange-ftx/src/main/java/org/knowm/xchange/ftx/service/FtxLendingServiceRaw.java
|
FtxLendingServiceRaw
|
lend
|
class FtxLendingServiceRaw extends FtxBaseService {
public FtxLendingServiceRaw(FtxExchange exchange) {
super(exchange);
}
public FtxLendDataDto stopLending(String subaccount, String coin) {
return lend(subaccount, coin, 0, 0);
}
public List<FtxLendDataDto> stopLending(String subaccount, List<String> coins) {
return coins.stream().map(coin -> stopLending(subaccount, coin)).collect(Collectors.toList());
}
public FtxLendDataDto lend(String subaccount, String coin, double size, double rate) {<FILL_FUNCTION_BODY>}
public List<FtxLendingHistoryDto> histories(String subaccount) {
try {
return ftx.getlendingHistories(
exchange.getExchangeSpecification().getApiKey(),
exchange.getNonceFactory().createValue(),
signatureCreator,
subaccount)
.getResult();
} catch (IOException e) {
throw new FtxLendingServiceException("Can't get lending infos subAccount: " + subaccount, e);
}
}
public List<FtxLendingHistoryDto> histories(String subaccount, List<String> coins) {
Objects.requireNonNull(coins);
return histories(subaccount).stream()
.filter(lendingHistory -> coins.contains(lendingHistory.getCoin()))
.collect(Collectors.toList());
}
public FtxLendingHistoryDto history(String subaccount, String coin) {
Objects.requireNonNull(coin);
if (StringUtils.isNotBlank(coin))
throw new FtxLendingServiceException("Coin are blank or empty");
return histories(subaccount).stream()
.filter(lendingHistory -> lendingHistory.getCoin().equalsIgnoreCase(coin))
.findFirst()
.orElse(null);
}
public List<FtxLendingInfoDto> infos(String subaccount) {
try {
return ftx.getLendingInfos(
exchange.getExchangeSpecification().getApiKey(),
exchange.getNonceFactory().createValue(),
signatureCreator,
subaccount)
.getResult();
} catch (IOException e) {
throw new FtxLendingServiceException("Can't get lending infos subAccount: " + subaccount, e);
}
}
public List<FtxLendingInfoDto> infos(String subaccount, List<String> coins) {
Objects.requireNonNull(coins);
return infos(subaccount).stream()
.filter(lendingInfo -> coins.contains(lendingInfo.getCoin()))
.collect(Collectors.toList());
}
public FtxLendingInfoDto info(String subaccount, String coin) {
Objects.requireNonNull(coin);
if (StringUtils.isNotBlank(coin))
throw new FtxLendingServiceException("Coin are blank or empty");
return infos(subaccount).stream()
.filter(lendingInfo -> lendingInfo.getCoin().equalsIgnoreCase(coin))
.findFirst()
.orElse(null);
}
public List<FtxLendingRatesDto> rates() {
try {
return ftx.getLendingRates(
exchange.getExchangeSpecification().getApiKey(),
exchange.getNonceFactory().createValue(),
signatureCreator)
.getResult();
} catch (IOException e) {
throw new FtxLendingServiceException("Can't get lending rates", e);
}
}
public List<FtxLendingRatesDto> rates(List<String> coins) {
Objects.requireNonNull(coins);
return rates().stream()
.filter(lendingRates -> coins.contains(lendingRates.getCoin()))
.collect(Collectors.toList());
}
public FtxLendingRatesDto rate(String coin) {
Objects.requireNonNull(coin);
if (StringUtils.isNotBlank(coin))
throw new FtxLendingServiceException("Coin are blank or empty");
try {
return ftx
.getLendingRates(
exchange.getExchangeSpecification().getApiKey(),
exchange.getNonceFactory().createValue(),
signatureCreator)
.getResult()
.stream()
.filter(lendingRates -> lendingRates.getCoin().equalsIgnoreCase(coin))
.findFirst()
.orElse(null);
} catch (IOException e) {
throw new FtxLendingServiceException("Can't get lending rate coin: " + coin, e);
}
}
public static class FtxLendingServiceException extends RuntimeException {
public FtxLendingServiceException(String message, Throwable cause) {
super(message, cause);
}
public FtxLendingServiceException(String message) {
super(message);
}
}
}
|
Objects.requireNonNull(coin);
if (StringUtils.isNotBlank(coin))
throw new FtxLendingServiceException("Coin are blank or empty");
if (rate < 0)
throw new FtxLendingServiceException(
"Rate must to be >= 0, subaccount: " + subaccount + ", coin: " + coin);
if (size < 0)
throw new FtxLendingServiceException(
"Size must to be >= 0, subaccount: "
+ subaccount
+ ", coin: "
+ coin
+ ", rate: "
+ rate);
try {
FtxLendingInfoDto info = info(subaccount, coin);
double sizeToLend = FtxAdapters.lendingRounding(BigDecimal.valueOf(size)).doubleValue();
if (Double.compare(sizeToLend, info.getLendable()) == 1) {
throw new FtxLendingServiceException(
"Can't lend sizeToLend > to lendable, subaccount: "
+ subaccount
+ ", coin: "
+ coin
+ ", size: "
+ size
+ ", sizeToLend: "
+ sizeToLend
+ ", rate: "
+ rate);
}
ftx.submitLendingOffer(
exchange.getExchangeSpecification().getApiKey(),
exchange.getNonceFactory().createValue(),
signatureCreator,
subaccount,
new FtxSubmitLendingOfferParams(
coin, FtxAdapters.lendingRounding(new BigDecimal(sizeToLend)).doubleValue(), rate));
return new FtxLendDataDto(coin, info.getLocked(), info.getOffered(), sizeToLend, rate);
} catch (IOException e) {
throw new FtxLendingServiceException(
"Can't lend subaccount: "
+ subaccount
+ ", coin: "
+ coin
+ ", size: "
+ size
+ ", rate: "
+ rate,
e);
}
| 1,312
| 524
| 1,836
|
<methods>public void <init>(org.knowm.xchange.Exchange) <variables>protected final non-sealed org.knowm.xchange.ftx.FtxAuthenticated ftx,protected final non-sealed ParamsDigest signatureCreator
|
knowm_XChange
|
XChange/xchange-ftx/src/main/java/org/knowm/xchange/ftx/service/FtxMarketDataServiceRaw.java
|
FtxMarketDataServiceRaw
|
getFtxTrades
|
class FtxMarketDataServiceRaw extends FtxBaseService {
public FtxMarketDataServiceRaw(Exchange exchange) {
super(exchange);
}
public FtxResponse<FtxMarketDto> getFtxMarket(String market) throws FtxException, IOException {
try {
return ftx.getMarket(market);
} catch (FtxException e) {
throw new FtxException(e.getMessage());
}
}
public FtxResponse<List<FtxCandleDto>> getFtxCandles(
String market, String resolution, String starTime, String endTime, Integer limit)
throws FtxException, IOException {
try {
return ftx.getCandles(market, resolution, starTime, endTime, limit);
} catch (FtxException e) {
throw new FtxException(e.getMessage());
}
}
public FtxResponse<FtxMarketsDto> getFtxMarkets() throws FtxException, IOException {
try {
return ftx.getMarkets();
} catch (FtxException e) {
throw new FtxException(e.getMessage());
}
}
public FtxResponse<List<FtxTradeDto>> getFtxTrades(String market)
throws FtxException, IOException {<FILL_FUNCTION_BODY>}
public FtxResponse<FtxOrderbookDto> getFtxOrderbook(String market)
throws FtxException, IOException {
try {
return ftx.getOrderbook(market, 20);
} catch (FtxException e) {
throw new FtxException(e.getMessage());
}
}
}
|
try {
return ftx.getTrades(market, 30);
} catch (FtxException e) {
throw new FtxException(e.getMessage());
}
| 429
| 49
| 478
|
<methods>public void <init>(org.knowm.xchange.Exchange) <variables>protected final non-sealed org.knowm.xchange.ftx.FtxAuthenticated ftx,protected final non-sealed ParamsDigest signatureCreator
|
knowm_XChange
|
XChange/xchange-ftx/src/main/java/org/knowm/xchange/ftx/service/FtxTradeService.java
|
FtxTradeService
|
changeOrder
|
class FtxTradeService extends FtxTradeServiceRaw implements TradeService {
public FtxTradeService(Exchange exchange) {
super(exchange);
}
@Override
public String placeMarketOrder(MarketOrder marketOrder) throws IOException {
return placeMarketOrderForSubaccount(
exchange.getExchangeSpecification().getUserName(), marketOrder);
}
@Override
public String placeLimitOrder(LimitOrder limitOrder) throws IOException {
return placeLimitOrderForSubaccount(
exchange.getExchangeSpecification().getUserName(), limitOrder);
}
@Override
public String placeStopOrder(StopOrder stopOrder) throws IOException {
return placeStopOrderForSubAccount(
exchange.getExchangeSpecification().getUserName(), stopOrder);
}
@Override
public UserTrades getTradeHistory(TradeHistoryParams params) throws IOException {
return getTradeHistoryForSubaccount(exchange.getExchangeSpecification().getUserName(), params);
}
@Override
public Collection<String> cancelAllOrders(CancelAllOrders orderParams) throws IOException {
if (orderParams instanceof CancelAllFtxOrdersParams) {
cancelAllFtxOrders(
exchange.getExchangeSpecification().getUserName(),
(CancelAllFtxOrdersParams) orderParams);
return Collections.singletonList("");
} else {
throw new IOException(
"Cancel all orders supports only " + CancelAllFtxOrdersParams.class.getSimpleName());
}
}
@Override
public boolean cancelOrder(String orderId) throws IOException {
return cancelOrderForSubaccount(exchange.getExchangeSpecification().getUserName(), orderId);
}
@Override
public boolean cancelOrder(CancelOrderParams orderParams) throws IOException {
return cancelOrderForSubaccount(exchange.getExchangeSpecification().getUserName(), orderParams);
}
@Override
public Class[] getRequiredCancelOrderParamClasses() {
return new Class[] {CancelOrderByCurrencyPair.class, CancelOrderByUserReferenceParams.class};
}
@Override
public Collection<Order> getOrder(String... orderIds) throws IOException {
return getOrderFromSubaccount(exchange.getExchangeSpecification().getUserName(), orderIds);
}
@Override
public Collection<Order> getOrder(OrderQueryParams... orderQueryParams) throws IOException {
return getOrderFromSubaccount(
exchange.getExchangeSpecification().getUserName(),
TradeService.toOrderIds(orderQueryParams));
}
@Override
public OpenOrders getOpenOrders(OpenOrdersParams params) throws IOException {
return getOpenOrdersForSubaccount(exchange.getExchangeSpecification().getUserName(), params);
}
@Override
public OpenOrders getOpenOrders() throws IOException {
return getOpenOrdersForSubaccount(exchange.getExchangeSpecification().getUserName());
}
@Override
public OpenPositions getOpenPositions() throws IOException {
return getOpenPositionsForSubaccount(exchange.getExchangeSpecification().getUserName());
}
@Override
public String changeOrder(LimitOrder limitOrder) throws IOException {<FILL_FUNCTION_BODY>}
}
|
if (limitOrder.getUserReference() != null) {
return modifyFtxOrderByClientId(
exchange.getExchangeSpecification().getUserName(),
limitOrder.getId(),
FtxAdapters.adaptModifyOrderToFtxOrderPayload(limitOrder))
.getResult()
.getClientId();
} else {
return modifyFtxOrder(
exchange.getExchangeSpecification().getUserName(),
limitOrder.getId(),
FtxAdapters.adaptModifyOrderToFtxOrderPayload(limitOrder))
.getResult()
.getId();
}
| 826
| 156
| 982
|
<methods>public void <init>(org.knowm.xchange.Exchange) ,public boolean cancelAllFtxOrders(java.lang.String, org.knowm.xchange.ftx.dto.trade.CancelAllFtxOrdersParams) throws java.io.IOException,public boolean cancelFtxByClientId(java.lang.String, java.lang.String) throws java.io.IOException,public boolean cancelFtxConditionalOrderForSubAccount(java.lang.String, java.lang.String) throws java.io.IOException,public boolean cancelFtxOrder(java.lang.String, java.lang.String) throws java.io.IOException,public boolean cancelOrderForSubaccount(java.lang.String, java.lang.String) throws java.io.IOException,public boolean cancelOrderForSubaccount(java.lang.String, org.knowm.xchange.service.trade.params.CancelOrderParams) throws java.io.IOException,public boolean cancelStopOrder(java.lang.String) throws java.io.IOException,public java.lang.String changeStopOrder(org.knowm.xchange.dto.trade.StopOrder) throws java.io.IOException,public FtxResponse<List<org.knowm.xchange.ftx.dto.trade.FtxOrderDto>> getFtxAllOpenOrdersForSubaccount(java.lang.String) throws java.io.IOException,public FtxResponse<List<org.knowm.xchange.ftx.dto.trade.FtxConditionalOrderDto>> getFtxConditionalOrderHistory(java.lang.String, java.lang.String) throws java.io.IOException,public FtxResponse<List<org.knowm.xchange.ftx.dto.trade.FtxFillDto>> getFtxFills(java.lang.String, java.lang.String, java.lang.Long, java.lang.Long) throws java.io.IOException,public FtxResponse<List<org.knowm.xchange.ftx.dto.trade.FtxConditionalOrderDto>> getFtxOpenConditionalOrdersForSubAccount(java.lang.String, java.lang.String) throws java.io.IOException,public FtxResponse<List<org.knowm.xchange.ftx.dto.trade.FtxOrderDto>> getFtxOpenOrders(java.lang.String, java.lang.String) throws java.io.IOException,public FtxResponse<List<org.knowm.xchange.ftx.dto.trade.FtxOrderDto>> getFtxOrderHistory(java.lang.String, java.lang.String, java.lang.Long, java.lang.Long) throws java.io.IOException,public FtxResponse<org.knowm.xchange.ftx.dto.trade.FtxOrderDto> getFtxOrderStatus(java.lang.String, java.lang.String) throws java.io.IOException,public FtxResponse<List<org.knowm.xchange.ftx.dto.account.FtxPositionDto>> getFtxPositions(java.lang.String) throws java.io.IOException,public List<org.knowm.xchange.ftx.dto.trade.FtxTriggerDto> getFtxTriggers(java.lang.String) throws java.io.IOException,public FtxResponse<List<org.knowm.xchange.ftx.dto.trade.FtxTriggerDto>> getFtxTriggersForSubAccount(java.lang.String, java.lang.String) throws java.io.IOException,public org.knowm.xchange.dto.trade.OpenOrders getOpenOrdersForSubaccount(java.lang.String) throws java.io.IOException,public org.knowm.xchange.dto.trade.OpenOrders getOpenOrdersForSubaccount(java.lang.String, org.knowm.xchange.service.trade.params.orders.OpenOrdersParams) throws java.io.IOException,public org.knowm.xchange.dto.account.OpenPositions getOpenPositionsForSubaccount(java.lang.String) throws java.io.IOException,public transient Collection<org.knowm.xchange.dto.Order> getOrderFromSubaccount(java.lang.String, java.lang.String[]) throws java.io.IOException,public org.knowm.xchange.dto.trade.OpenOrders getOrderHistoryForSubaccount(java.lang.String, org.knowm.xchange.service.trade.params.TradeHistoryParams) throws java.io.IOException,public org.knowm.xchange.dto.trade.UserTrades getTradeHistoryForSubaccount(java.lang.String, org.knowm.xchange.service.trade.params.TradeHistoryParams) throws java.io.IOException,public FtxResponse<org.knowm.xchange.ftx.dto.trade.FtxConditionalOrderDto> modifyFtxConditionalOrderForSubAccount(java.lang.String, java.lang.String, org.knowm.xchange.ftx.dto.trade.FtxModifyConditionalOrderRequestPayload) throws java.io.IOException,public FtxResponse<org.knowm.xchange.ftx.dto.trade.FtxOrderDto> modifyFtxOrder(java.lang.String, java.lang.String, org.knowm.xchange.ftx.dto.trade.FtxModifyOrderRequestPayload) throws java.io.IOException,public FtxResponse<org.knowm.xchange.ftx.dto.trade.FtxOrderDto> modifyFtxOrderByClientId(java.lang.String, java.lang.String, org.knowm.xchange.ftx.dto.trade.FtxModifyOrderRequestPayload) throws java.io.IOException,public java.lang.String placeLimitOrderForSubaccount(java.lang.String, org.knowm.xchange.dto.trade.LimitOrder) throws java.io.IOException,public java.lang.String placeMarketOrderForSubaccount(java.lang.String, org.knowm.xchange.dto.trade.MarketOrder) throws java.io.IOException,public FtxResponse<org.knowm.xchange.ftx.dto.trade.FtxConditionalOrderDto> placeNewFtxConditionalOrderForSubAccount(java.lang.String, org.knowm.xchange.ftx.dto.trade.FtxConditionalOrderRequestPayload) throws java.io.IOException,public FtxResponse<org.knowm.xchange.ftx.dto.trade.FtxOrderDto> placeNewFtxOrder(java.lang.String, org.knowm.xchange.ftx.dto.trade.FtxOrderRequestPayload) throws java.io.IOException,public java.lang.String placeStopOrderForSubAccount(java.lang.String, org.knowm.xchange.dto.trade.StopOrder) throws java.io.IOException<variables>
|
knowm_XChange
|
XChange/xchange-gateio-v4/src/main/java/org/knowm/xchange/gateio/GateioAdapters.java
|
GateioAdapters
|
toString
|
class GateioAdapters {
public String toString(Instrument instrument) {
if (instrument == null) {
return null;
}
else {
return String.format("%s_%s",
instrument.getBase().getCurrencyCode(),
instrument.getCounter().getCurrencyCode())
.toUpperCase(Locale.ROOT);
}
}
public OrderBook toOrderBook(GateioOrderBook gateioOrderBook, Instrument instrument) {
List<LimitOrder> asks = gateioOrderBook.getAsks().stream()
.map(priceSizeEntry -> new LimitOrder(OrderType.ASK, priceSizeEntry.getSize(), instrument, null, null, priceSizeEntry.getPrice()))
.collect(Collectors.toList());
List<LimitOrder> bids = gateioOrderBook.getBids().stream()
.map(priceSizeEntry -> new LimitOrder(OrderType.BID, priceSizeEntry.getSize(), instrument, null, null, priceSizeEntry.getPrice()))
.collect(Collectors.toList());
return new OrderBook(Date.from(gateioOrderBook.getGeneratedAt()), asks, bids);
}
public InstrumentMetaData toInstrumentMetaData(GateioCurrencyPairDetails gateioCurrencyPairDetails) {
return new InstrumentMetaData.Builder()
.tradingFee(gateioCurrencyPairDetails.getFee())
.minimumAmount(gateioCurrencyPairDetails.getMinAssetAmount())
.counterMinimumAmount(gateioCurrencyPairDetails.getMinQuoteAmount())
.volumeScale(gateioCurrencyPairDetails.getAssetScale())
.priceScale(gateioCurrencyPairDetails.getQuoteScale())
.build();
}
public String toString(OrderStatus orderStatus) {<FILL_FUNCTION_BODY>}
public OrderStatus toOrderStatus(String gateioOrderStatus) {
switch (gateioOrderStatus) {
case "open":
return OrderStatus.OPEN;
case "filled":
case "closed":
return OrderStatus.FILLED;
case "cancelled":
case "stp":
return OrderStatus.CANCELED;
default:
throw new IllegalArgumentException("Can't map " + gateioOrderStatus);
}
}
public GateioOrder toGateioOrder(MarketOrder marketOrder) {
return GateioOrder.builder()
.currencyPair((CurrencyPair) marketOrder.getInstrument())
.side(marketOrder.getType())
.clientOrderId(marketOrder.getUserReference())
.account("spot")
.type("market")
.timeInForce("ioc")
.amount(marketOrder.getOriginalAmount())
.build();
}
public GateioOrder toGateioOrder(LimitOrder limitOrder) {
return GateioOrder.builder()
.currencyPair((CurrencyPair) limitOrder.getInstrument())
.side(limitOrder.getType())
.clientOrderId(limitOrder.getUserReference())
.account("spot")
.type("limit")
.timeInForce("gtc")
.price(limitOrder.getLimitPrice())
.amount(limitOrder.getOriginalAmount())
.build();
}
public Order toOrder(GateioOrder gateioOrder) {
Order.Builder builder;
Instrument instrument = gateioOrder.getCurrencyPair();
OrderType orderType = gateioOrder.getSide();
switch (gateioOrder.getType()) {
case "market":
builder = new MarketOrder.Builder(orderType, instrument);
break;
case "limit":
builder = new LimitOrder.Builder(orderType, instrument)
.limitPrice(gateioOrder.getPrice());
break;
default:
throw new IllegalArgumentException("Can't map " + gateioOrder.getType());
}
if (orderType == OrderType.BID) {
builder.cumulativeAmount(gateioOrder.getFilledTotalQuote());
}
else if (orderType == OrderType.ASK) {
BigDecimal filledAssetAmount = gateioOrder.getFilledTotalQuote().divide(gateioOrder.getAvgDealPrice(), MathContext.DECIMAL32);
builder.cumulativeAmount(filledAssetAmount);
}
else {
throw new IllegalArgumentException("Can't map " + orderType);
}
return builder
.id(gateioOrder.getId())
.originalAmount(gateioOrder.getAmount())
.userReference(gateioOrder.getClientOrderId())
.timestamp(Date.from(gateioOrder.getCreatedAt()))
.orderStatus(toOrderStatus(gateioOrder.getStatus()))
.averagePrice(gateioOrder.getAvgDealPrice())
.fee(gateioOrder.getFee())
.build();
}
public UserTrade toUserTrade(GateioUserTradeRaw gateioUserTradeRaw) {
return new GateioUserTrade(gateioUserTradeRaw.getSide(), gateioUserTradeRaw.getAmount(), gateioUserTradeRaw.getCurrencyPair(),
gateioUserTradeRaw.getPrice(), Date.from(gateioUserTradeRaw.getTimeMs()), String.valueOf(
gateioUserTradeRaw.getId()),
String.valueOf(gateioUserTradeRaw.getOrderId()), gateioUserTradeRaw.getFee(), gateioUserTradeRaw.getFeeCurrency(),
gateioUserTradeRaw.getRemark(), gateioUserTradeRaw.getRole());
}
public GateioWithdrawalRequest toGateioWithdrawalRequest(GateioWithdrawFundsParams p) {
return GateioWithdrawalRequest.builder()
.clientRecordId(p.getClientRecordId())
.address(p.getAddress())
.tag(p.getAddressTag())
.chain(p.getChain())
.amount(p.getAmount())
.currency(p.getCurrency())
.build();
}
public Ticker toTicker(GateioTicker gateioTicker) {
return new Ticker.Builder()
.instrument(gateioTicker.getCurrencyPair())
.last(gateioTicker.getLastPrice())
.bid(gateioTicker.getHighestBid())
.ask(gateioTicker.getLowestAsk())
.high(gateioTicker.getMaxPrice24h())
.low(gateioTicker.getMinPrice24h())
.volume(gateioTicker.getAssetVolume())
.quoteVolume(gateioTicker.getQuoteVolume())
.percentageChange(gateioTicker.getChangePercentage24h())
.build();
}
public FundingRecord toFundingRecords(GateioAccountBookRecord gateioAccountBookRecord) {
return new FundingRecord.Builder()
.setInternalId(gateioAccountBookRecord.getId())
.setDate(Date.from(gateioAccountBookRecord.getTimestamp()))
.setCurrency(gateioAccountBookRecord.getCurrency())
.setBalance(gateioAccountBookRecord.getBalance())
.setType(gateioAccountBookRecord.getType())
.setAmount(gateioAccountBookRecord.getChange().abs())
.setDescription(gateioAccountBookRecord.getTypeDescription())
.build();
}
}
|
switch (orderStatus) {
case OPEN:
return "open";
case CLOSED:
return "finished";
default:
throw new IllegalArgumentException("Can't map " + orderStatus);
}
| 1,897
| 59
| 1,956
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-gateio-v4/src/main/java/org/knowm/xchange/gateio/config/GateioJacksonObjectMapperFactory.java
|
GateioJacksonObjectMapperFactory
|
configureObjectMapper
|
class GateioJacksonObjectMapperFactory extends DefaultJacksonObjectMapperFactory {
@Override
public void configureObjectMapper(ObjectMapper objectMapper) {<FILL_FUNCTION_BODY>}
}
|
super.configureObjectMapper(objectMapper);
// by default read timetamps as milliseconds
objectMapper.configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, false);
// enable parsing to Instant
objectMapper.registerModule(new JavaTimeModule());
| 50
| 83
| 133
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-gateio-v4/src/main/java/org/knowm/xchange/gateio/config/converter/StringToOrderTypeConverter.java
|
StringToOrderTypeConverter
|
convert
|
class StringToOrderTypeConverter extends StdConverter<String, OrderType> {
@Override
public OrderType convert(String value) {<FILL_FUNCTION_BODY>}
}
|
switch (value) {
case "buy":
return OrderType.BID;
case "sell":
return OrderType.ASK;
default:
throw new IllegalArgumentException("Can't map " + value);
}
| 48
| 63
| 111
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-gateio-v4/src/main/java/org/knowm/xchange/gateio/service/GateioTradeService.java
|
GateioTradeService
|
cancelOrder
|
class GateioTradeService extends GateioTradeServiceRaw implements TradeService {
public GateioTradeService(GateioExchange exchange) {
super(exchange);
}
@Override
public String placeMarketOrder(MarketOrder marketOrder) throws IOException {
try {
GateioOrder order = createOrder(GateioAdapters.toGateioOrder(marketOrder));
return order.getId();
}
catch (GateioException e) {
throw GateioErrorAdapter.adapt(e);
}
}
@Override
public String placeLimitOrder(LimitOrder limitOrder) throws IOException {
try {
GateioOrder order = createOrder(GateioAdapters.toGateioOrder(limitOrder));
return order.getId();
}
catch (GateioException e) {
throw GateioErrorAdapter.adapt(e);
}
}
@Override
public Collection<Order> getOrder(OrderQueryParams... orderQueryParams) throws IOException {
// todo: implement getting of several orders
Validate.validState(orderQueryParams.length == 1);
Validate.isInstanceOf(OrderQueryParamInstrument.class, orderQueryParams[0]);
OrderQueryParamInstrument params = (OrderQueryParamInstrument) orderQueryParams[0];
try {
GateioOrder gateioOrder = getOrder(params.getOrderId(), params.getInstrument());
return Collections.singletonList(GateioAdapters.toOrder(gateioOrder));
}
catch (GateioException e) {
throw GateioErrorAdapter.adapt(e);
}
}
public Order cancelOrder(String orderId, Instrument instrument) throws IOException {<FILL_FUNCTION_BODY>}
@Override
public boolean cancelOrder(CancelOrderParams orderParams) throws IOException {
Validate.isInstanceOf(DefaultCancelOrderByInstrumentAndIdParams.class, orderParams);
DefaultCancelOrderByInstrumentAndIdParams params = (DefaultCancelOrderByInstrumentAndIdParams) orderParams;
try {
Order order = cancelOrder(params.getOrderId(), params.getInstrument());
return order.getStatus() == OrderStatus.CANCELED;
}
catch (GateioException e) {
throw GateioErrorAdapter.adapt(e);
}
}
@Override
public UserTrades getTradeHistory(TradeHistoryParams params) throws IOException {
try {
List<UserTrade> userTradeList = getGateioUserTrades(params).stream()
.map(GateioAdapters::toUserTrade)
.collect(Collectors.toList());
return new UserTrades(userTradeList, TradeSortType.SortByID);
}
catch (GateioException e) {
throw GateioErrorAdapter.adapt(e);
}
}
@Override
public Class[] getRequiredCancelOrderParamClasses() {
return new Class[] {DefaultCancelOrderByInstrumentAndIdParams.class};
}
@Override
public TradeHistoryParams createTradeHistoryParams() {
return GateioTradeHistoryParams.builder().build();
}
}
|
try {
GateioOrder gateioOrder = cancelOrderRaw(orderId, instrument);
return GateioAdapters.toOrder(gateioOrder);
}
catch (GateioException e) {
throw GateioErrorAdapter.adapt(e);
}
| 807
| 70
| 877
|
<methods>public void <init>(org.knowm.xchange.gateio.GateioExchange) ,public org.knowm.xchange.gateio.dto.account.GateioOrder cancelOrderRaw(java.lang.String, org.knowm.xchange.instrument.Instrument) throws java.io.IOException,public org.knowm.xchange.gateio.dto.account.GateioOrder createOrder(org.knowm.xchange.gateio.dto.account.GateioOrder) throws java.io.IOException,public List<org.knowm.xchange.gateio.dto.trade.GateioUserTradeRaw> getGateioUserTrades(org.knowm.xchange.service.trade.params.TradeHistoryParams) throws java.io.IOException,public org.knowm.xchange.gateio.dto.account.GateioOrder getOrder(java.lang.String, org.knowm.xchange.instrument.Instrument) throws java.io.IOException,public List<org.knowm.xchange.gateio.dto.account.GateioOrder> listOrders(org.knowm.xchange.instrument.Instrument, org.knowm.xchange.dto.Order.OrderStatus) throws java.io.IOException<variables>
|
knowm_XChange
|
XChange/xchange-gateio/src/main/java/org/knowm/xchange/gateio/GateioUtils.java
|
GateioUtils
|
toPairString
|
class GateioUtils {
public static String toPairString(CurrencyPair currencyPair) {<FILL_FUNCTION_BODY>}
}
|
String baseSymbol = currencyPair.base.getCurrencyCode().toLowerCase();
String counterSymbol = currencyPair.counter.getCurrencyCode().toLowerCase();
String pair = baseSymbol + "_" + counterSymbol;
return pair;
| 37
| 64
| 101
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-gateio/src/main/java/org/knowm/xchange/gateio/dto/account/GateioDepositsWithdrawals.java
|
GateioDepositsWithdrawals
|
toString
|
class GateioDepositsWithdrawals extends GateioBaseResponse {
private final List<GateioDeposit> deposits;
private final List<GateioWithdrawal> withdraws;
public GateioDepositsWithdrawals(
@JsonProperty("result") boolean result,
@JsonProperty("deposits") List<GateioDeposit> deposits,
@JsonProperty("withdraws") List<GateioWithdrawal> withdraws,
@JsonProperty("message") final String message) {
super(result, message);
this.deposits = deposits;
this.withdraws = withdraws;
}
public List<GateioDeposit> getDeposits() {
return deposits;
}
public List<GateioWithdrawal> getWithdraws() {
return withdraws;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
return "GateioDepositsWithdrawals [deposits=" + deposits + ", withdraws=" + withdraws + "]";
| 246
| 38
| 284
|
<methods>public java.lang.String getMessage() ,public boolean isResult() ,public java.lang.String toString() <variables>private final non-sealed java.lang.String message,private final non-sealed boolean result
|
knowm_XChange
|
XChange/xchange-gateio/src/main/java/org/knowm/xchange/gateio/dto/marketdata/GateioCandlestickHistory.java
|
GateioCandlestickHistory
|
toString
|
class GateioCandlestickHistory extends GateioBaseResponse {
private final List<List<String>> candlesticks;
private final String elapsed;
private GateioCandlestickHistory(
@JsonProperty("data") List<List<String>> candlesticks,
@JsonProperty("result") boolean result,
@JsonProperty("elapsed") String elapsed) {
super(result, null);
this.candlesticks = candlesticks;
this.elapsed = elapsed;
}
public List<List<String>> getCandlesticks() {
return candlesticks;
}
public String getElapsed() {
return elapsed;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
return "BTERPublicTrades [candlesticks=" + candlesticks + ", elapsed=" + elapsed + "]";
| 201
| 36
| 237
|
<methods>public java.lang.String getMessage() ,public boolean isResult() ,public java.lang.String toString() <variables>private final non-sealed java.lang.String message,private final non-sealed boolean result
|
knowm_XChange
|
XChange/xchange-gateio/src/main/java/org/knowm/xchange/gateio/dto/marketdata/GateioCoin.java
|
GateioCoin
|
toString
|
class GateioCoin {
boolean delisted;
boolean withdrawDisabled;
boolean withdrawDelayed;
boolean depositDisabled;
boolean tradeDisabled;
public GateioCoin(
boolean delisted,
boolean withdrawDisabled,
boolean withdrawDelayed,
boolean depositDisabled,
boolean tradeDisabled) {
this.delisted = delisted;
this.withdrawDisabled = withdrawDisabled;
this.withdrawDelayed = withdrawDelayed;
this.depositDisabled = depositDisabled;
this.tradeDisabled = tradeDisabled;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
public boolean isDelisted() {
return delisted;
}
public boolean isWithdrawDisabled() {
return withdrawDisabled;
}
public boolean isWithdrawDelayed() {
return withdrawDelayed;
}
public boolean isDepositDisabled() {
return depositDisabled;
}
public boolean isTradeDisabled() {
return tradeDisabled;
}
}
|
return "GateioCoin{"
+ "delisted="
+ delisted
+ ", withdrawDisabled="
+ withdrawDisabled
+ ", withdrawDelayed="
+ withdrawDelayed
+ ", depositDisabled="
+ depositDisabled
+ ", tradeDisabled="
+ tradeDisabled
+ '}';
| 287
| 92
| 379
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-gateio/src/main/java/org/knowm/xchange/gateio/dto/marketdata/GateioKline.java
|
GateioKline
|
toString
|
class GateioKline {
private final long id;
private final BigDecimal open;
private final BigDecimal close;
private final BigDecimal low;
private final BigDecimal high;
private final BigDecimal vol;
public GateioKline(
long id, BigDecimal vol, BigDecimal close, BigDecimal high, BigDecimal low, BigDecimal open) {
this.id = id;
this.open = open;
this.close = close;
this.low = low;
this.high = high;
this.vol = vol;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
public long getId() {
return id;
}
public BigDecimal getOpen() {
return open;
}
public BigDecimal getClose() {
return close;
}
public BigDecimal getLow() {
return low;
}
public BigDecimal getHigh() {
return high;
}
public BigDecimal getVol() {
return vol;
}
}
|
return String.format(
"[id = %d, open = %f, close = %f, low = %f, high = %f, vol = %f]",
getId(), getOpen(), getClose(), getLow(), getHigh(), getVol());
| 290
| 64
| 354
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-gateio/src/main/java/org/knowm/xchange/gateio/dto/marketdata/GateioPublicOrder.java
|
GateioPublicOrderDeserializer
|
deserialize
|
class GateioPublicOrderDeserializer extends JsonDeserializer<GateioPublicOrder> {
@Override
public GateioPublicOrder deserialize(JsonParser jp, DeserializationContext ctxt)
throws IOException, JsonProcessingException {<FILL_FUNCTION_BODY>}
}
|
final ObjectCodec oc = jp.getCodec();
final JsonNode tickerNode = oc.readTree(jp);
final BigDecimal price = new BigDecimal(tickerNode.path(0).asText());
final BigDecimal amount = new BigDecimal(tickerNode.path(1).asText());
return new GateioPublicOrder(price, amount);
| 75
| 99
| 174
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-gateio/src/main/java/org/knowm/xchange/gateio/dto/marketdata/GateioTradeHistory.java
|
GateioPublicTrade
|
toString
|
class GateioPublicTrade {
private final long date;
private final BigDecimal price;
private final BigDecimal amount;
private final String tradeId;
private final GateioOrderType type;
private GateioPublicTrade(
@JsonProperty("date") String date,
@JsonProperty("rate") BigDecimal price,
@JsonProperty("amount") BigDecimal amount,
@JsonProperty("tradeID") String tradeId,
@JsonProperty("timestamp") long timestamp,
@JsonProperty("type") GateioOrderType type) {
this.date = timestamp;
this.price = price;
this.amount = amount;
this.tradeId = tradeId;
this.type = type;
}
public long getDate() {
return date;
}
public BigDecimal getPrice() {
return price;
}
public BigDecimal getAmount() {
return amount;
}
public String getTradeId() {
return tradeId;
}
public GateioOrderType getType() {
return type;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
return "BTERPublicTrade [date="
+ date
+ ", price="
+ price
+ ", amount="
+ amount
+ ", tradeId="
+ tradeId
+ ", type="
+ type
+ "]";
| 314
| 73
| 387
|
<methods>public java.lang.String getMessage() ,public boolean isResult() ,public java.lang.String toString() <variables>private final non-sealed java.lang.String message,private final non-sealed boolean result
|
knowm_XChange
|
XChange/xchange-gateio/src/main/java/org/knowm/xchange/gateio/service/GateioBaseService.java
|
GateioBaseService
|
handleResponse
|
class GateioBaseService extends BaseExchangeService<GateioExchange> implements BaseService {
protected final String apiKey;
protected final Gateio gateio;
protected final GateioAuthenticated gateioAuthenticated;
protected final ParamsDigest signatureCreator;
/**
* Constructor
*
* @param exchange
*/
public GateioBaseService(GateioExchange exchange) {
super(exchange);
gateio =
ExchangeRestProxyBuilder.forInterface(Gateio.class, exchange.getExchangeSpecification())
.build();
gateioAuthenticated =
ExchangeRestProxyBuilder.forInterface(
GateioAuthenticated.class, exchange.getExchangeSpecification())
.build();
apiKey = exchange.getExchangeSpecification().getApiKey();
signatureCreator =
GateioHmacPostBodyDigest.createInstance(exchange.getExchangeSpecification().getSecretKey());
}
protected <R extends GateioBaseResponse> R handleResponse(R response) {<FILL_FUNCTION_BODY>}
public String getApiKey() {
return apiKey;
}
}
|
if (!response.isResult()) {
throw new ExchangeException(response.getMessage());
}
return response;
| 294
| 34
| 328
|
<methods>public void verifyOrder(org.knowm.xchange.dto.trade.LimitOrder) ,public void verifyOrder(org.knowm.xchange.dto.trade.MarketOrder) <variables>protected final non-sealed org.knowm.xchange.gateio.GateioExchange exchange
|
knowm_XChange
|
XChange/xchange-gateio/src/main/java/org/knowm/xchange/gateio/service/GateioTradeServiceRaw.java
|
GateioTradeServiceRaw
|
cancelOrder
|
class GateioTradeServiceRaw extends GateioBaseService {
/**
* Constructor
*
* @param exchange
*/
public GateioTradeServiceRaw(GateioExchange exchange) {
super(exchange);
}
/**
* Submits a Limit Order to be executed on the Gateio Exchange for the desired market defined by
* {@code CurrencyPair}. WARNING - Gateio will return true regardless of whether or not an order
* actually gets created. The reason for this is that orders are simply submitted to a queue in
* their back-end. One example for why an order might not get created is because there are
* insufficient funds. The best attempt you can make to confirm that the order was created is to
* poll {@link #getGateioOpenOrders}. However if the order is created and executed before it is
* caught in its open state from calling {@link #getGateioOpenOrders} then the only way to confirm
* would be confirm the expected difference in funds available for your account.
*
* @param limitOrder
* @return String order id of submitted request.
* @throws IOException
*/
public String placeGateioLimitOrder(LimitOrder limitOrder) throws IOException {
GateioOrderType type =
(limitOrder.getType() == Order.OrderType.BID) ? GateioOrderType.BUY : GateioOrderType.SELL;
return placeGateioLimitOrder(
limitOrder.getCurrencyPair(),
type,
limitOrder.getLimitPrice(),
limitOrder.getOriginalAmount());
}
/**
* Submits a Limit Order to be executed on the Gateio Exchange for the desired market defined by
* {@code currencyPair}. WARNING - Gateio will return true regardless of whether or not an order
* actually gets created. The reason for this is that orders are simply submitted to a queue in
* their back-end. One example for why an order might not get created is because there are
* insufficient funds. The best attempt you can make to confirm that the order was created is to
* poll {@link #getGateioOpenOrders}. However if the order is created and executed before it is
* caught in its open state from calling {@link #getGateioOpenOrders} then the only way to confirm
* would be confirm the expected difference in funds available for your account.
*
* @param currencyPair
* @param orderType
* @param rate
* @param amount
* @return String order id of submitted request.
* @throws IOException
*/
public String placeGateioLimitOrder(
CurrencyPair currencyPair, GateioOrderType orderType, BigDecimal rate, BigDecimal amount)
throws IOException {
String pair = formatCurrencyPair(currencyPair);
GateioPlaceOrderReturn orderId;
if (orderType.equals(GateioOrderType.BUY)) {
orderId = gateioAuthenticated.buy(pair, rate, amount, apiKey, signatureCreator);
} else {
orderId = gateioAuthenticated.sell(pair, rate, amount, apiKey, signatureCreator);
}
return handleResponse(orderId).getOrderId();
}
public boolean cancelOrder(String orderId, CurrencyPair currencyPair) throws IOException {<FILL_FUNCTION_BODY>}
/**
* Cancels all orders. See https://gate.io/api2.
*
* @param type order type(0:sell,1:buy,-1:all)
* @param currencyPair currency pair
* @return
* @throws IOException
*/
public boolean cancelAllOrders(String type, CurrencyPair currencyPair) throws IOException {
GateioBaseResponse cancelAllOrdersResult =
gateioAuthenticated.cancelAllOrders(
type, formatCurrencyPair(currencyPair), apiKey, signatureCreator);
return handleResponse(cancelAllOrdersResult).isResult();
}
public GateioOpenOrders getGateioOpenOrders() throws IOException {
GateioOpenOrders gateioOpenOrdersReturn =
gateioAuthenticated.getOpenOrders(apiKey, signatureCreator);
return handleResponse(gateioOpenOrdersReturn);
}
public GateioOrderStatus getGateioOrderStatus(String orderId, CurrencyPair currencyPair)
throws IOException {
GateioOrderStatus orderStatus =
gateioAuthenticated.getOrderStatus(
orderId, GateioUtils.toPairString(currencyPair), apiKey, signatureCreator);
return handleResponse(orderStatus);
}
public GateioTradeHistoryReturn getGateioTradeHistory(CurrencyPair currencyPair)
throws IOException {
GateioTradeHistoryReturn gateioTradeHistoryReturn =
gateioAuthenticated.getUserTradeHistory(
apiKey, signatureCreator, GateioUtils.toPairString(currencyPair));
return handleResponse(gateioTradeHistoryReturn);
}
private String formatCurrencyPair(CurrencyPair currencyPair) {
return String.format(
"%s_%s", currencyPair.base.getCurrencyCode(), currencyPair.counter.getCurrencyCode())
.toLowerCase();
}
public static class GateioCancelOrderParams
implements CancelOrderByIdParams, CancelOrderByCurrencyPair {
public final CurrencyPair currencyPair;
public final String orderId;
public GateioCancelOrderParams(CurrencyPair currencyPair, String orderId) {
this.currencyPair = currencyPair;
this.orderId = orderId;
}
@Override
public String getOrderId() {
return orderId;
}
@Override
public CurrencyPair getCurrencyPair() {
return currencyPair;
}
}
}
|
GateioBaseResponse cancelOrderResult =
gateioAuthenticated.cancelOrder(
orderId, GateioUtils.toPairString(currencyPair), apiKey, signatureCreator);
return handleResponse(cancelOrderResult).isResult();
| 1,439
| 62
| 1,501
|
<methods>public void <init>(org.knowm.xchange.gateio.GateioExchange) <variables>protected final non-sealed java.lang.String apiKey,protected final non-sealed org.knowm.xchange.gateio.Gateio gateio,protected final non-sealed org.knowm.xchange.gateio.GateioV4Authenticated gateioV4Authenticated,protected final non-sealed ParamsDigest gateioV4ParamsDigest
|
knowm_XChange
|
XChange/xchange-gemini/src/main/java/org/knowm/xchange/gemini/v1/GeminiExchange.java
|
GeminiExchange
|
getDefaultExchangeSpecification
|
class GeminiExchange extends BaseExchange {
@Override
protected void initServices() {
concludeHostParams(exchangeSpecification);
this.marketDataService = new GeminiMarketDataService(this);
this.accountService = new GeminiAccountService(this);
this.tradeService = new GeminiTradeService(this);
}
@Override
public void applySpecification(ExchangeSpecification exchangeSpecification) {
super.applySpecification(exchangeSpecification);
concludeHostParams(exchangeSpecification);
}
/** Adjust host parameters depending on exchange specific parameters */
private static void concludeHostParams(ExchangeSpecification exchangeSpecification) {
if (exchangeSpecification.getExchangeSpecificParameters() != null) {
if (exchangeSpecification
.getExchangeSpecificParametersItem(Exchange.USE_SANDBOX)
.equals(true)) {
exchangeSpecification.setSslUri("https://api.sandbox.gemini.com");
exchangeSpecification.setHost("api.sandbox.gemini.com");
}
}
}
@Override
public ExchangeSpecification getDefaultExchangeSpecification() {<FILL_FUNCTION_BODY>}
@Override
public void remoteInit() throws IOException, ExchangeException {
GeminiMarketDataServiceRaw dataService = (GeminiMarketDataServiceRaw) this.marketDataService;
List<CurrencyPair> currencyPairs = dataService.getExchangeSymbols();
exchangeMetaData = GeminiAdapters.adaptMetaData(currencyPairs, exchangeMetaData);
}
@Override
public ExchangeSpecification getExchangeSpecification() {
return super.getExchangeSpecification();
}
}
|
ExchangeSpecification exchangeSpecification = new ExchangeSpecification(this.getClass());
exchangeSpecification.setSslUri("https://api.Gemini.com/");
exchangeSpecification.setHost("api.Gemini.com");
exchangeSpecification.setPort(80);
exchangeSpecification.setExchangeName("Gemini");
exchangeSpecification.setExchangeDescription("Gemini is a bitcoin exchange.");
exchangeSpecification.setExchangeSpecificParametersItem(Exchange.USE_SANDBOX, false);
return exchangeSpecification;
| 450
| 145
| 595
|
<methods>public non-sealed void <init>() ,public void applySpecification(org.knowm.xchange.ExchangeSpecification) ,public org.knowm.xchange.service.account.AccountService getAccountService() ,public List<org.knowm.xchange.instrument.Instrument> getExchangeInstruments() ,public org.knowm.xchange.dto.meta.ExchangeMetaData getExchangeMetaData() ,public org.knowm.xchange.ExchangeSpecification getExchangeSpecification() ,public org.knowm.xchange.service.marketdata.MarketDataService getMarketDataService() ,public java.lang.String getMetaDataFileName(org.knowm.xchange.ExchangeSpecification) ,public SynchronizedValueFactory<java.lang.Long> getNonceFactory() ,public org.knowm.xchange.service.trade.TradeService getTradeService() ,public void remoteInit() throws java.io.IOException, org.knowm.xchange.exceptions.ExchangeException,public java.lang.String toString() <variables>protected org.knowm.xchange.service.account.AccountService accountService,protected org.knowm.xchange.dto.meta.ExchangeMetaData exchangeMetaData,protected org.knowm.xchange.ExchangeSpecification exchangeSpecification,protected final Logger logger,protected org.knowm.xchange.service.marketdata.MarketDataService marketDataService,private final SynchronizedValueFactory<java.lang.Long> nonceFactory,protected org.knowm.xchange.service.trade.TradeService tradeService
|
knowm_XChange
|
XChange/xchange-gemini/src/main/java/org/knowm/xchange/gemini/v1/dto/account/GeminiBalancesResponse.java
|
GeminiBalancesResponse
|
toString
|
class GeminiBalancesResponse {
private final String type;
private final String currency;
private final BigDecimal amount;
private final BigDecimal available;
/**
* Constructor
*
* @param type
* @param currency
* @param amount
* @param available
*/
public GeminiBalancesResponse(
@JsonProperty("type") String type,
@JsonProperty("currency") String currency,
@JsonProperty("amount") BigDecimal amount,
@JsonProperty("available") BigDecimal available) {
this.type = type;
this.currency = currency;
this.amount = amount;
this.available = available;
}
public BigDecimal getAmount() {
return amount;
}
public BigDecimal getAvailable() {
return available;
}
public String getCurrency() {
return currency;
}
public String getType() {
return type;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
StringBuilder builder = new StringBuilder();
builder.append("GeminiBalancesResponse [type=");
builder.append(type);
builder.append(", currency=");
builder.append(currency);
builder.append(", amount=");
builder.append(amount);
builder.append(", available=");
builder.append(available);
builder.append("]");
return builder.toString();
| 280
| 107
| 387
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-gemini/src/main/java/org/knowm/xchange/gemini/v1/dto/marketdata/GeminiDepth.java
|
GeminiDepth
|
toString
|
class GeminiDepth {
private final GeminiLevel[] asks;
private final GeminiLevel[] bids;
/**
* Constructor
*
* @param asks
* @param bids
*/
public GeminiDepth(
@JsonProperty("asks") GeminiLevel[] asks, @JsonProperty("bids") GeminiLevel[] bids) {
this.asks = asks;
this.bids = bids;
}
public GeminiLevel[] getAsks() {
return asks;
}
public GeminiLevel[] getBids() {
return bids;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
return "GeminiDepth [asks=" + Arrays.toString(asks) + ", bids=" + Arrays.toString(bids) + "]";
| 194
| 43
| 237
|
<no_super_class>
|
knowm_XChange
|
XChange/xchange-gemini/src/main/java/org/knowm/xchange/gemini/v1/dto/marketdata/GeminiLend.java
|
GeminiLend
|
toString
|
class GeminiLend {
private final BigDecimal rate;
private final BigDecimal amountLent;
private final long timestamp;
/**
* Constructor
*
* @param rate
* @param amountLent
* @param timestamp
*/
public GeminiLend(
@JsonProperty("rate") BigDecimal rate,
@JsonProperty("amount_lent") BigDecimal amountLent,
@JsonProperty("timestamp") long timestamp) {
this.rate = rate;
this.amountLent = amountLent;
this.timestamp = timestamp;
}
public BigDecimal getRate() {
return rate;
}
public BigDecimal getAmountLent() {
return amountLent;
}
public long getTimestamp() {
return timestamp;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
return "GeminiLend [rate="
+ rate
+ ", amountLent="
+ amountLent
+ ", timestamp="
+ timestamp
+ "]";
| 244
| 53
| 297
|
<no_super_class>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.