how to get book market data
weichafe opened this issue · comments
weichafe commented
I am trying to get the market data but I only get the message "HubConnection - Processing message"
`@Slf4j
public class MarketDataBT {
public MarketDataBT(Properties prop) throws IOException {
try (BittrexExchange bittrexExchange = new BittrexExchange(prop.getProperty("key.bittrex"), prop.getProperty("clave.bittrex"))) {
bittrexExchange.onUpdateSummaryState(exchangeSummaryState -> {
if (exchangeSummaryState.getDeltas().length > 0) {
Arrays.stream(exchangeSummaryState.getDeltas())
.filter(marketSummary -> marketSummary.getMarketName().equals("BTC-BCC") || marketSummary.getMarketName().equals("BTC-ETH"))
.forEach(marketSummary -> System.out.println(
String.format("24 hour volume for market %s: %s",
marketSummary.getMarketName(),
marketSummary.getVolume().toString())));
}
});
bittrexExchange.onUpdateExchangeState(updateExchangeState -> {
double volume = Arrays.stream(updateExchangeState.getFills())
.mapToDouble(Fill::getQuantity)
.sum();
if(updateExchangeState.getFills().length > 0) {
System.out.println(String.format("N: %d, %02f volume across %d fill(s) for %s", updateExchangeState.getNounce(),
volume, updateExchangeState.getFills().length, updateExchangeState.getMarketName()));
}
});
bittrexExchange.onOrderStateChange(orderDelta -> {
if(orderDelta.getType() == OrderType.Open || orderDelta.getType() == OrderType.Partial){
System.out.println(String.format("%s order open with id %s, remaining %.04f", orderDelta.getOrder().getExchange(),
orderDelta.getOrder().getOrderUuid(),orderDelta.getOrder().getQuantityRemaining()));
}else if(orderDelta.getType() == OrderType.Filled ){
System.out.println(String.format("%s order with id %s filled, qty %.04f", orderDelta.getOrder().getExchange(),
orderDelta.getOrder().getOrderUuid(),orderDelta.getOrder().getQuantity()));
}else if(orderDelta.getType() == OrderType.Cancelled){
System.out.println(String.format("%s order with id %s cancelled", orderDelta.getOrder().getExchange(),
orderDelta.getOrder().getOrderUuid()));
}
});
bittrexExchange.onBalanceStateChange(balanceDelta -> {
System.out.println(String.format("%s wallet balance updated, available: %s, pending: %s", balanceDelta.getBalance().getCurrency(),
balanceDelta.getBalance().getAvailable(),balanceDelta.getBalance().getPending()));
});
bittrexExchange.connectToWebSocket(() -> {
bittrexExchange.subscribeToExchangeDeltas("BTC-ETH", res -> {
System.out.println("subscribed deltas1 " + res);
});
bittrexExchange.subscribeToMarketSummaries(res -> {
System.out.println("subscribed summaries" + res);
});
});
}
}
}`
can you help me please
thank a lot
stale commented
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.