Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 236
Expand file tree
/
Copy pathMain.java
More file actions
Latest commit
46 lines (45 loc) · 1.81 KB
/
Copy pathMain.java
File metadata and controls
46 lines (45 loc) · 1.81 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
39
40
41
42
43
44
45
46
importcom.cryptochassis.ccapi.Event;
importcom.cryptochassis.ccapi.EventHandler;
importcom.cryptochassis.ccapi.Session;
importcom.cryptochassis.ccapi.SessionConfigs;
importcom.cryptochassis.ccapi.SessionOptions;
importcom.cryptochassis.ccapi.Subscription;
importcom.cryptochassis.ccapi.SubscriptionList;
publicclassMain {
staticclassMyEventHandlerextendsEventHandler {
@Override
publicvoidprocessEvent(Eventevent, Sessionsession) {
if (event.getType() == Event.Type.SUBSCRIPTION_STATUS) {
System.out.println(String.format("Received an event of type SUBSCRIPTION_STATUS:\n%s", event.toPrettyString(2, 2)));
} elseif (event.getType() == Event.Type.SUBSCRIPTION_DATA) {
for (varmessage : event.getMessageList()) {
System.out.println(String.format("Best bid and ask at %s are:", message.getTimeISO()));
for (varelement : message.getElementList()) {
varelementNameValueMap = element.getNameValueMap();
for (varentry : elementNameValueMap.entrySet()) {
varname = entry.getKey();
varvalue = entry.getValue();
System.out.println(String.format(" %s = %s", name, value));
}
}
}
}
}
}
publicstaticvoidmain(String[] args) {
System.loadLibrary("ccapi_binding_java");
vareventHandler = newMyEventHandler();
varoption = newSessionOptions();
varconfig = newSessionConfigs();
varsession = newSession(option, config, eventHandler);
varsubscriptionList = newSubscriptionList();
subscriptionList.add(newSubscription("okx", "BTC-USDT", "MARKET_DEPTH"));
session.subscribe(subscriptionList);
try {
Thread.sleep(10000);
} catch (InterruptedExceptione) {
}
session.stop();
System.out.println("Bye");
}
}