OnixS C++ CME iLink 3 Binary Order Entry Handler  1.18.0
API Documentation
Getting Started Sample

This sample shows how to connect to the CME iLink 3 Gateway or the local Gateway emulator.

When the session is established, the NewSingleOrder SBE message is sent to the counterparty.

Source code

#include "../Common/Helpers.h"
#include "../Common/Listener.h"
#include "../Settings/Defaults.h"
using namespace Samples;
Session* createSession(const SessionSettings settings, std::string segment, SessionListener* listener)
{
std::transform(segment.begin(), segment.end(), segment.begin(), ::toupper);
if(segment == "CGW")
return new CgwSession(settings, listener);
return new Session(settings, atoi(segment.c_str()), listener);
}
int main(int argc, char * argv[])
{
clog << "CME iLink 3 GettingStarted Sample." << endl << endl;
std::string marketSegmentId = "99";
string host = "127.0.0.1";
Port port = 49152;
bool useEmulator = false;
if (argc < 4)
{
#if defined(ONIXS_ILINK3_HAS_GATEWAY_EMULATOR)
useEmulator = true;
#else
std::cerr << "usage: [MarketSegmentId|'CGW'] [Host] [Port] (SecurityId) (PriceMantissa)" << std::endl;
return 1;
#endif
}
else
{
marketSegmentId = argv[1];
host = argv[2];
port = atoi(argv[3]);
}
const int securityId = argc > 4 ? atoi(argv[4]) : DefaultSecurityId;
const Int64 priceMantissa = argc > 5 ? fromStr<Int64>(argv[5]) : DefaultPriceMantissa;
try
{
SignalHelper::manageLinuxSignals();
const SessionSettings settings = fillSettings(useEmulator);
#if defined(ONIXS_ILINK3_HAS_GATEWAY_EMULATOR)
std::unique_ptr<GatewayEmulatorThread> gateway;
if (useEmulator)
gateway.reset(new GatewayEmulatorThread(settings.licenseStores(), host, port));
#endif
Listener listener;
ScopedPtr<Session> session(createSession(settings, marketSegmentId, &listener));
NewOrderSingle order;
Helper::setOrderFields(order, PartyDetailsListReqID, securityId, priceMantissa);
if(session->negotiated())
session->reset(true);
session
->connect(host, port)
.send(order);
clog << "\nThe order was sent." << endl;
Helper::waitUntilEnterKey("disconnect the session and terminate the application");
session->disconnect();
}
catch(const std::exception & ex)
{
cerr << "\nEXCEPTION: " << ex.what() << endl;
return 1;
}
return 0;
}

Output

1 CME iLink 3 GettingStarted Sample.
2 
3 Session's state is changed, prevState=Disconnected, newState=AwaitNegotiationResponse
4 
5 Outbound message:
6 Negotiate500 [CustomerFlow(39000)=IDEMPOTENT,HMACVersion(39003)=CME-1-SHA-256,HMACSignature(39005)=33-F9-95-40-AA-3E-21-9A-09-09-9B-E6-06-6E-87-3D-86-60-F9-2A-5D-DF-16-20-DA-93-E2-A1-2E-BF-C4-EF,AccessKeyID(39004)=dGVzdHRlc3R0ZXN0dA==,UUID(39001)=1681728478628755,RequestTimestamp(39002)=1681728478629312547,Session(39006)=XXX,Firm(39007)=001,Credentials(39008)='']
7 
8 Received:
9 NegotiationResponse501 [ServerFlow(39009)=RECOVERABLE,UUID(39001)=1681728478628755,RequestTimestamp(39002)=1681728478629312547,SecretKeySecureIDExpiration(39022)=0,FaultToleranceIndicator(39010)=Primary,SplitMsg(9553)=SplitMessageDelayed,PreviousSeqNo(39021)=0,PreviousUUID(39015)=0,Credentials(39008)='']
10 
11 Session's state is changed, prevState=AwaitNegotiationResponse, newState=AwaitEstablishmentAck
12 
13 Outbound message:
14 Establish503 [HMACVersion(39003)=CME-1-SHA-256,HMACSignature(39005)=5B-86-46-C9-82-48-94-5B-10-27-E7-88-FE-D1-3B-0A-5E-95-79-47-28-49-2A-BA-3B-C5-F5-17-12-A3-17-82,AccessKeyID(39004)=dGVzdHRlc3R0ZXN0dA==,TradingSystemName(1603)=OnixS 1,TradingSystemVersion(1604)=1.0.0,TradingSystemVendor(1605)=OnixS,UUID(39001)=1681728478628755,RequestTimestamp(39002)=1681728478630410836,NextSeqNo(39013)=1,Session(39006)=XXX,Firm(39007)=001,KeepAliveInterval(39014)=5000,Credentials(39008)='']
15 
16 Received:
17 EstablishmentAck504 [UUID(39001)=1681728478628755,RequestTimestamp(39002)=1681728478630410836,NextSeqNo(39013)=1,PreviousSeqNo(39021)=0,PreviousUUID(39015)=0,KeepAliveInterval(39014)=5000,SecretKeySecureIDExpiration(39022)=0,FaultToleranceIndicator(39010)=Primary,SplitMsg(9553)=SplitMessageDelayed]
18 
19 Session's state is changed, prevState=AwaitEstablishmentAck, newState=Established
20 
21 Outbound message:
22 NewOrderSingle514 [Price(44)=-46100,OrderQty(38)=1,SecurityID(48)=5502,Side(54)=Buy,SeqNum(9726)=1,SenderID(5392)=GFP,ClOrdID(11)=OrderId,PartyDetailsListReqID(1505)=1,OrderRequestID(2422)=1,SendingTimeEpoch(5297)=1681728478628797265,StopPx(99)=[],Location(9537)=GB,MinQty(110)=[],DisplayQty(1138)=[],ExpireDate(432)=[],OrdType(40)=Limit,TimeInForce(59)=Day,ManualOrderIndicator(1028)=Automated,ExecInst(18)=[],ExecutionMode(5906)=Aggressive,LiquidityFlag(9373)=[],ManagedOrder(6881)=[],ShortSaleType(5409)=[],DiscretionPrice(845)=[],ReservationPrice(9562)=[]]
23 
24 The order was sent.
25 
26 Press the ENTER key to disconnect the session and terminate the application..
27 
28 Received:
29 ExecutionReportNew522 [SeqNum(9726)=1,UUID(39001)=1681728478628755,ExecID(17)=0,SenderID(5392)=GFP,ClOrdID(11)=OrderId,PartyDetailsListReqID(1505)=1,OrderID(37)=0,Price(44)=-46100,StopPx(99)=[],TransactTime(60)=1681728478630559109,SendingTimeEpoch(5297)=1681728478630559109,OrderRequestID(2422)=1,CrossID(548)=[],HostCrossID(961)=[],Location(9537)=GB,SecurityID(48)=5502,OrderQty(38)=1,MinQty(110)=[],DisplayQty(1138)=[],ExpireDate(432)=[],DelayDuration(5904)=[],OrdStatus(39)=0,ExecType(150)=0,OrdType(40)=Limit,Side(54)=Buy,TimeInForce(59)=Day,ManualOrderIndicator(1028)=Automated,PossRetransFlag(9765)=False,SplitMsg(9553)=[],CrossType(549)=[],ExecInst(18)=[],ExecutionMode(5906)=[],LiquidityFlag(9373)=[],ManagedOrder(6881)=[],ShortSaleType(5409)=[],DelayToTime(7552)=[],DiscretionPrice(845)=[],ReservationPrice(9562)=[],PriorityIndicator(638)=[]]
30 
31 Outbound message:
32 Sequence506 [UUID(39001)=1681728478628755,NextSeqNo(39013)=2,FaultToleranceIndicator(39010)=[],KeepAliveIntervalLapsed(39016)=NotLapsed]
33 
34 Received:
35 Sequence506 [UUID(39001)=1681728478628755,NextSeqNo(39013)=2,FaultToleranceIndicator(39010)=Primary,KeepAliveIntervalLapsed(39016)=NotLapsed]
36 
37 
38 Outbound message:
39 Terminate507 [Reason(39011)=[],UUID(39001)=1681728478628755,RequestTimestamp(39002)=1681728484422757499,ErrorCodes(39012)=0,SplitMsg(9553)=[]]
40 
41 Session's state is changed, prevState=Established, newState=AwaitConfirmingTerminate
42 
43 Received:
44 Terminate507 [Reason(39011)=Confirm Terminate,UUID(39001)=1681728478628755,RequestTimestamp(39002)=1681728484422757499,ErrorCodes(39012)=0,SplitMsg(9553)=[]]
45 
46 Session's state is changed, prevState=AwaitConfirmingTerminate, newState=Disconnected