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 pathMainProgram.cs
More file actions
Latest commit
49 lines (49 loc) · 2.51 KB
/
Copy pathMainProgram.cs
File metadata and controls
49 lines (49 loc) · 2.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
39
40
41
42
43
44
45
46
47
48
49
classMainProgram{
classMyEventHandler:ccapi.EventHandler{
publicoverridevoidProcessEvent(ccapi.Eventevent_,ccapi.Sessionsession){
if(event_.GetType_()==ccapi.Event.Type.AUTHORIZATION_STATUS){
System.Console.WriteLine(string.Format("Received an event of type AUTHORIZATION_STATUS:\n{0}",event_.ToStringPretty(2,2)));
varmessage=event_.GetMessageList()[0];
if(message.GetType_()==ccapi.Message.Type.AUTHORIZATION_SUCCESS){
varrequest=newccapi.Request(ccapi.Request.Operation.FIX,"coinbase","","same correlation id for subscription and request");
varparam=newccapi.VectorPairIntString();
param.Add(newccapi.PairIntString(35,"D"));
param.Add(newccapi.PairIntString(11,"6d4eb0fb-2229-469f-873e-557dd78ac11e"));
param.Add(newccapi.PairIntString(55,"BTC-USD"));
param.Add(newccapi.PairIntString(54,"1"));
param.Add(newccapi.PairIntString(44,"20000"));
param.Add(newccapi.PairIntString(38,"0.001"));
param.Add(newccapi.PairIntString(40,"2"));
param.Add(newccapi.PairIntString(59,"1"));
request.AppendParamFix(param);
session.SendRequestByFix(request);
}
}elseif(event_.GetType_()==ccapi.Event.Type.FIX){
System.Console.WriteLine(string.Format("Received an event of type FIX:\n{0}",event_.ToStringPretty(2,2)));
}
}
}
staticvoidMain(string[]args){
if(System.Environment.GetEnvironmentVariable("COINBASE_API_KEY")isnull){
System.Console.Error.WriteLine("Please set environment variable COINBASE_API_KEY");
return;
}
if(System.Environment.GetEnvironmentVariable("COINBASE_API_SECRET")isnull){
System.Console.Error.WriteLine("Please set environment variable COINBASE_API_SECRET");
return;
}
if(System.Environment.GetEnvironmentVariable("COINBASE_API_PASSPHRASE")isnull){
System.Console.Error.WriteLine("Please set environment variable COINBASE_API_PASSPHRASE");
return;
}
vareventHandler=newMyEventHandler();
varoption=newccapi.SessionOptions();
varconfig=newccapi.SessionConfigs();
varsession=newccapi.Session(option,config,eventHandler);
varsubscription=newccapi.Subscription("coinbase","","FIX","","same correlation id for subscription and request");
session.SubscribeByFix(subscription);
System.Threading.Thread.Sleep(10000);
session.Stop();
System.Console.WriteLine("Bye");
}
}