OnixS C++ ICE Binary Order Entry Handler 1.1.1
API Documentation
Loading...
Searching...
No Matches
Main.cpp
Go to the documentation of this file.
1/*
2 * Copyright Onix Solutions Limited [OnixS]. All rights reserved.
3 *
4 * This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
5 * and international copyright treaties.
6 *
7 * Access to and use of the software is governed by the terms of the applicable ONIXS Software
8 * Services Agreement (the Agreement) and Customer end user license agreements granting
9 * a non-assignable, non-transferable and non-exclusive license to use the software
10 * for it's own data processing purposes under the terms defined in the Agreement.
11 *
12 * Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
13 * of this source code or associated reference material to any other location for further reproduction
14 * or redistribution, and any amendments to this copyright notice, are expressly prohibited.
15 *
16 * Any reproduction or redistribution for sale or hiring of the Software not in accordance with
17 * the terms of the Agreement is a violation of copyright law.
18 */
19
20#include <Common/Helpers.h>
21#include <Common/Settings.h>
22#include <Common/Signal.h>
23
24#include "Settings.h"
25#include "TradingClient.h"
26
27using namespace Samples;
28
29int main(int argc, char * argv[])
30{
31 try
32 {
33 // `--help` to show options.
34 const AppConfiguration<SettingsConfiguration> cfg{"TradingClient", argc, argv};
35
36 const Settings settings{cfg.settingsFile()};
37 TradingClient client{settings};
38
39 const auto connectBus = [&client]{ client.connectBus(); };
40 const auto requestBgwCredentials = [&client]{ client.requestBgwCredentials(); };
41 const auto connectBgw = [&client]{ client.connectBgw(); };
42 const auto traderLogon = [&client]{ client.traderLogon(); };
43
44 CUI::Menu menu{
45 {"Print this message", "Printing available options", [&menu]{ menu.outputItems(); }},
46
47 {"Connect BUS session", "Connecting a BUS session", connectBus},
48 {"Request BGW credentials", "Requesting BGW credentials", requestBgwCredentials},
49 {"Request instruments", "Requesting SecurityDefinition data", [&client]{ client.requestInstruments(); }},
50 {"List known instruments", "Listing instruments", [&client]{ client.listInstruments(); }},
51 {"Show instrument by provided symbol", "Looking up the instrument",[&client]{ client.lookupInstruments(); }},
52
53 {"Connect BGW session", "Connecting a BGW session", connectBgw},
54 {"Trader log on", "Logging trader on", traderLogon},
55 {"Trader log out", "Logging trader out", [&client]{ client.traderLogout(); }},
56
57 {"Send order", "Sending order", [&client]{ client.sendOrder(); }},
58 {"Send cross order", "Sending cross order", [&client]{ client.sendOrderCross(); }},
59 {"Cancel order", "Cancelling order", [&client]{ client.cancelOrder(); }},
60 {"Replace order", "Replacing order", [&client]{ client.replaceOrder(); }},
61 {"Mass cancel", "Cancelling matching working orders", [&client]{ client.sendMassCancel(); }},
62
63 {"Show orders", "Viewing orders and status", [&client]{ client.showOrders(); }},
64 {"Show active orders", "Viewing active orders", [&client]{ client.showActiveOrders(); }},
65
66
67 {"Send RFQ", "Sending quote", [&client]{ client.sendQuote(); }},
68 {"Send mass quote", "Sending mass quote", [&client]{ client.sendMassQuote(); }},
69 {"Cancel quote", "Sending quote cancel", [&client]{ client.sendQuoteCancelRequest(); }},
70
71 {"Create strategy", "Creating strategy", [&client]{ client.createStrategy(); }},
72 {"Create flex", "Creating flexible instrument", [&client]{ client.createFlex(); }},
73
74
75 {"*Get ready BGW session (shortcut)", "Preparing BGW session", {connectBus, requestBgwCredentials, connectBgw, traderLogon}},
76 {"Exit", "Closing connections and exiting", [&menu]{ menu.stopRequest(); }}
77 };
78
79 menu.processRequests();
80 }
81 catch (const std::exception& ex)
82 {
83 std::cerr << std::endl << "Error: " << ex.what() << "." << std::endl;
84 return 1;
85 }
86
87 return 0;
88}
int main(int argc, char *argv[])
Definition Main.cpp:29
Abstraction of the main menu for the application.
Definition CUI.h:375
void stopRequest() noexcept
Requests stop.
Definition CUI.h:400
void outputItems() const
Outputs items' names onto the screen.
Definition CUI.h:393
void processRequests() const
Processes user requests until any command terminates the execution.
Definition CUI.h:385
void createStrategy()
Creates a strategy.
void traderLogout()
Logs the trader out from the BGW session.
void listInstruments()
Prints the list of instruments currently known to the client.
void requestBgwCredentials()
Requests BGW credentials (IpRequest) over the active BUS session.
void connectBus()
Commands.
void connectBgw()
Establishes a BGW session using previously obtained credentials.
void createFlex()
Creates a flexible instrument (flex).
void sendOrderCross()
Sends a cross order.
void sendMassCancel()
Submits a mass cancel request.
void replaceOrder()
Issues a replace for an existing live order.
void lookupInstruments()
Prints the list of instruments currently known to the client by the provided Symbol value.
void sendQuoteCancelRequest()
Cancels a previously submitted quote.
void cancelOrder()
Sends a cancel request for a specific order.
void sendOrder()
Sends a new order via BGW.
void sendMassQuote()
Sends a multiple quote request.
void showActiveOrders()
Displays active orders sent by this client session and their last-known statuses.
void showOrders()
Displays orders sent by this client session and their last-known statuses.
void sendQuote()
Sends a quote message.
void traderLogon()
Logs a trader into the connected BGW session.
void requestInstruments()
Submits a SecurityDefinitionRequest to fetch/refresh known instruments.