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
66 lines (65 loc) · 2.83 KB
/
Copy pathMain.java
File metadata and controls
66 lines (65 loc) · 2.83 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
importcom.cryptochassis.ccapi.Event;
importcom.cryptochassis.ccapi.EventHandler;
importcom.cryptochassis.ccapi.Message;
importcom.cryptochassis.ccapi.PairIntString;
importcom.cryptochassis.ccapi.Request;
importcom.cryptochassis.ccapi.Session;
importcom.cryptochassis.ccapi.SessionConfigs;
importcom.cryptochassis.ccapi.SessionOptions;
importcom.cryptochassis.ccapi.Subscription;
importcom.cryptochassis.ccapi.SubscriptionList;
importcom.cryptochassis.ccapi.VectorPairIntString;
publicclassMain {
staticclassMyEventHandlerextendsEventHandler {
@Override
publicvoidprocessEvent(Eventevent, Sessionsession) {
if (event.getType() == Event.Type.AUTHORIZATION_STATUS) {
System.out.println(String.format("Received an event of type AUTHORIZATION_STATUS:\n%s", event.toPrettyString(2, 2)));
varmessage = event.getMessageList().get(0);
if (message.getType() == Message.Type.AUTHORIZATION_SUCCESS) {
varrequest = newRequest(Request.Operation.FIX, "coinbase", "", "same correlation id for subscription and request");
varparam = newVectorPairIntString();
param.add(newPairIntString(35, "D"));
param.add(newPairIntString(11, "6d4eb0fb-2229-469f-873e-557dd78ac11e"));
param.add(newPairIntString(55, "BTC-USD"));
param.add(newPairIntString(54, "1"));
param.add(newPairIntString(44, "20000"));
param.add(newPairIntString(38, "0.001"));
param.add(newPairIntString(40, "2"));
param.add(newPairIntString(59, "1"));
request.appendFixParam(param);
session.sendRequestByFix(request);
}
} elseif (event.getType() == Event.Type.FIX) {
System.out.println(String.format("Received an event of type FIX:\n%s", event.toPrettyString(2, 2)));
}
}
}
publicstaticvoidmain(String[] args) {
if (System.getenv("COINBASE_API_KEY") == null) {
System.err.println("Please set environment variable COINBASE_API_KEY");
return;
}
if (System.getenv("COINBASE_API_SECRET") == null) {
System.err.println("Please set environment variable COINBASE_API_SECRET");
return;
}
if (System.getenv("COINBASE_API_PASSPHRASE") == null) {
System.err.println("Please set environment variable COINBASE_API_PASSPHRASE");
return;
}
System.loadLibrary("ccapi_binding_java");
vareventHandler = newMyEventHandler();
varoption = newSessionOptions();
varconfig = newSessionConfigs();
varsession = newSession(option, config, eventHandler);
varsubscription = newSubscription("coinbase", "", "FIX", "", "same correlation id for subscription and request");
session.subscribe(subscription);
try {
Thread.sleep(10000);
} catch (InterruptedExceptione) {
}
session.stop();
System.out.println("Bye");
}
}