forked from binance-exchange/binance-java-api
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGeneralEndpointsExampleAsync.java
More file actions
executable file
·38 lines (30 loc) · 1.51 KB
/
GeneralEndpointsExampleAsync.java
File metadata and controls
executable file
·38 lines (30 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.binance.api.examples;
import com.binance.api.client.api.async.BinanceApiSpotAsyncRestClient;
import com.binance.api.client.domain.general.FilterType;
import com.binance.api.client.domain.general.SymbolFilter;
import com.binance.api.client.domain.general.SymbolInfo;
import com.binance.api.client.factory.BinanceSpotApiClientFactory;
/**
* Examples on how to use the general endpoints.
*/
public class GeneralEndpointsExampleAsync {
public static void main(String[] args) throws InterruptedException {
BinanceSpotApiClientFactory factory = BinanceSpotApiClientFactory.newInstance();
BinanceApiSpotAsyncRestClient client = factory.newAsyncRestClient();
// Test connectivity
client.ping(response -> System.out.println("Ping succeeded."));
// Check server time
client.getServerTime(response -> System.out.println(response.getServerTime()));
// Exchange info
client.getExchangeInfo(exchangeInfo -> {
System.out.println(exchangeInfo.getTimezone());
System.out.println(exchangeInfo.getSymbols());
// Obtain symbol information
SymbolInfo symbolInfo = exchangeInfo.getSymbolInfo("ETHBTC");
System.out.println(symbolInfo.getStatus());
SymbolFilter priceFilter = symbolInfo.getSymbolFilter(FilterType.PRICE_FILTER);
System.out.println(priceFilter.getMinPrice());
System.out.println(priceFilter.getTickSize());
});
}
}