TT CORE SDK 2.0.1.1
TT CORE SDK documentation
Loading...
Searching...
No Matches
order.h
Go to the documentation of this file.
1/***************************************************************************
2 *
3 * Unpublished Work Copyright (c) 2018-2020
4 * Trading Technologies International, Inc.
5 * All Rights Reserved Worldwide
6 *
7 * * * * S T R I C T L Y P R O P R I E T A R Y * * *
8 *
9 * WARNING: This program (or document) is unpublished, proprietary property
10 * of Trading Technologies International, Inc. and is to be maintained in
11 * strict confidence. Unauthorized reproduction, distribution or disclosure
12 * of this program (or document), or any program (or document) derived from
13 * it is prohibited by State and Federal law, and by local law outside of
14 * the U.S.
15 *
16 ***************************************************************************/
17#pragma once
18
19#include "consts.h"
20#include "enums/OrderType.h"
21#include "enums/OrderSide.h"
22#include "enums/TimeInForce.h"
23#include "enums/MarketId.h"
24#include "instrument.h"
25#include "execution_report.h"
26#include "reject_response.h"
27#include "position.h"
28#include "shared_ptr.h"
29#include "sdkalgo.h"
30#include "export_value.h"
31#include <vector>
32
33 // Example computing the expire date in C++ for December 19, 2026.
34 // timespec now;
35 // clock_gettime(CLOCK_REALTIME, &now);
36 // tm utc, local;
37 // gmtime_r(&now.tv_sec, &utc);
38 // localtime_r(&now.tv_sec, &local);
39 //
40 // utc.tm_isdst = -1; // This assumes time_t unit is seconds. True
41 // time_t bias = now.tv_sec - mktime(&utc); // on all known systems.
42 // Bias is the offset in seconds from local time to UTC time.
43 // tm gtdate;
44 // gtdate.tm_isdst = -1; // Let local system decide.
45 // gtdate.tm_sec = gtdate.tm_min = gtdate.tm_hour = 0;
46 // gtdate.tm_mday = 19; // Day of the month (1-31).
47 // gtdate.tm_mon = 11; // Month of the year (0-11).
48 // gtdate.tm_year = 2026 - 1900; // Year since 1900.
49 // time_t seconds = mktime(&gtdate) + bias; // Seconds since epoch UTC.
50 // The mktime function will take the local time into account.
51 // In order to convert to UTC add the bias.
52 // new_order.set_expire_date(seconds * 1000000000ULL); // Seconds to nanoseconds.
53
54namespace ttsdk
55{
59 {
60 enum class Instruction
61 {
62 Work = 0,
63 Hold = 1,
64 };
65
66 uint64_t request_id = 0;
69 uint64_t expire_date = 0; // nanoseconds since the epoch UTC
72 uint64_t account_id = 0;
74 char clearing_acct_override[128] = {0};
75 double price = NAN;
76 double trigger_price = NAN;
77 double quantity = NAN;
78 double display_quantity = NAN;
79 double minimum_quantity = NAN;
80 char text[128] = { 0 };
81 char text_a[128] = { 0 };
82 char text_b[128] = { 0 };
83 char text_c[128] = { 0 };
84 char text_tt[128] = { 0 };
85 char sender_sub_id[128] = { 0 };
90 bool leave_on_restart = true;
91
99 std::vector<ttsdk::UserParameter> params;
101 std::vector<uint64_t> leg_account_ids;
103
104
107 uint64_t server_price_time = 0;
109 };
110
114 {
115 uint64_t request_id = 0;
117 double price = NAN;
118 double quantity = NAN;
121 uint64_t server_price_time = 0;
123 };
124
125
126 class Order;
128
136 {
137 public:
169
170 virtual ~IOrderEventHandler() noexcept = default;
171
173 virtual void OnExecutionReport(OrderPtr order, ExecutionReportPtr execRpt) = 0;
174
175 virtual void OnEpiqUpdate(OrderPtr order, double epiq) {};
176
177 virtual void OnExportValuesUpdate(OrderPtr order, const ttsdk::ExportValues& exports) {};
178
180 virtual void OnReject(OrderPtr order, RejectResponsePtr rejResp) = 0;
181
183 virtual void OnSendFailed(OrderPtr order, const OrderProfile& profile, const SendCode code) = 0;
184
186 // destroy the handler object (sdk will no longer use it)
187 // orderId is null when unsubscribed from all order events
188 virtual void OnUnsubscribed(const char* orderId) = 0;
189
190 };
192
193
196 class Order : public shared_base
197 {
198 public:
199 explicit Order() {};
200 ~Order() {};
201
202 virtual const char* GetOrderId() const noexcept = 0;
203 virtual double GetEpiq() const noexcept = 0;
204 virtual void Subscribe(IOrderEventHandler& listener) noexcept = 0;
205 virtual void Unsubscribe() noexcept = 0;
206 virtual ExecutionReportPtr GetCurrentState() const noexcept = 0;
207 virtual InstrumentPtr GetInstrument() const noexcept = 0;
208
209 virtual void SendNew(const OrderProfile& profile) noexcept = 0;
210 virtual void SendChange(const OrderProfile& profile) noexcept = 0;
211 virtual void SendChange(const OrderPrcQtyProfile& profile) noexcept = 0;
212 virtual void SendCancel(const OrderProfile& profile) noexcept = 0;
213
214 virtual void SetParent(SDKAlgoPtr parent = nullptr) noexcept = 0;
217 virtual bool IsAppsSDKAlgoOrder() noexcept = 0;
218
221 virtual bool SubscribeExportValues() noexcept = 0;
222 virtual bool UnSubscribeExportValues() noexcept = 0;
223 virtual bool IsAlgoOrder() noexcept = 0;
225
229 virtual OrderPtr GetPreviousOrder() const noexcept = 0;
230
231 private:
232 Order(const Order&) = delete;
233 Order& operator=(Order&) = delete;
234 Order(Order&&) = delete;
235 Order& operator=(Order&&) = delete;
236 };
237
238
246 {
247 public:
248 virtual ~IOrderBookEventHandler() noexcept = default;
249
251 virtual void OnPositionUpdate(const Position& updatedPosition) {};
252
255 virtual void OnAccountDownloadEnd(const uint64_t accountId) {};
256
260 virtual void OnAccountDownloadFailed(const uint64_t accountId, const char* message) {};
261
264 virtual void OnOrderBookDownloadEnd() {};
265
266
268 virtual void OnRiskReserved(const uint64_t instrumentId, const uint64_t accountId,
269 const RiskSide side, const bool successful) {};
271 virtual void OnRiskReleased(const uint64_t instrumentId, const uint64_t accountId,
272 const RiskSide side, const bool successful) {};
273
274
275 };
277
278}
Interface for listening to order and position events. There is one OrderBookEventHandler set in the S...
Definition order.h:246
virtual void OnAccountDownloadFailed(const uint64_t accountId, const char *message)
Indicates the given account orders and positions downloads have failed and the account if not usable....
Definition order.h:260
virtual void OnRiskReserved(const uint64_t instrumentId, const uint64_t accountId, const RiskSide side, const bool successful)
Callback for a reserve risk request. Orders sent before a PR is acked will be rejected.
Definition order.h:268
virtual ~IOrderBookEventHandler() noexcept=default
virtual void OnRiskReleased(const uint64_t instrumentId, const uint64_t accountId, const RiskSide side, const bool successful)
Callback for a release reserve risk request.
Definition order.h:271
virtual void OnOrderBookDownloadEnd()
Indicates all orders and positions for all accounts are downloaded and synchronized with the realtime...
Definition order.h:264
virtual void OnAccountDownloadEnd(const uint64_t accountId)
Indicates the given account have been synchronized with the realtime streams, orders and positions ha...
Definition order.h:255
Interface for listening to order events.
Definition order.h:136
virtual void OnExportValuesUpdate(OrderPtr order, const ttsdk::ExportValues &exports)
Definition order.h:177
virtual void OnSendFailed(OrderPtr order, const OrderProfile &profile, const SendCode code)=0
Callback fired when a request delivery surpasses the timeout threshold.
virtual void OnEpiqUpdate(OrderPtr order, double epiq)
Definition order.h:175
virtual ~IOrderEventHandler() noexcept=default
virtual void OnReject(OrderPtr order, RejectResponsePtr rejResp)=0
Callback delivering order reject messages.
virtual void OnUnsubscribed(const char *orderId)=0
Callback fired when the unsubscribe request is complete and it is safe to.
virtual void OnExecutionReport(OrderPtr order, ExecutionReportPtr execRpt)=0
Callback delivering execution report messages.
an interface to interact with the order.
Definition order.h:197
virtual InstrumentPtr GetInstrument() const noexcept=0
virtual bool IsAppsSDKAlgoOrder() noexcept=0
Method which indicates if this order is a SDK Algo order that is/was being managed by this applicatio...
virtual bool UnSubscribeExportValues() noexcept=0
virtual bool IsAlgoOrder() noexcept=0
virtual void SendCancel(const OrderProfile &profile) noexcept=0
virtual const char * GetOrderId() const noexcept=0
virtual void Unsubscribe() noexcept=0
virtual bool SubscribeExportValues() noexcept=0
virtual double GetEpiq() const noexcept=0
virtual void SetParent(SDKAlgoPtr parent=nullptr) noexcept=0
virtual OrderPtr GetPreviousOrder() const noexcept=0
Method which returns the previous order for the use case when TTINT replaces an existing order with a...
virtual void SendNew(const OrderProfile &profile) noexcept=0
virtual ExecutionReportPtr GetCurrentState() const noexcept=0
virtual void SendChange(const OrderProfile &profile) noexcept=0
MarketId
Definition MarketId.h:29
RiskSide
Definition RiskSide.h:23
OrderType
Definition OrderType.h:29
OrderSide
Definition OrderSide.h:29
Definition of an order price/qty change.
Definition order.h:114
uint64_t server_price_time
Price Server timestamp (mdrc_recv_time);.
Definition order.h:121
uint64_t price_subscription_id
Definition order.h:116
uint64_t order_stimulus_received
User listener timestamp (order_stimulus_receieved_oc)
Definition order.h:122
Definition of an order to provide when submitting.
Definition order.h:59
uint64_t server_price_time
Price Server timestamp (mdrc_recv_time);.
Definition order.h:107
ttsdk::MarketId colocation
colocation value for algo orders
Definition order.h:97
bool leave_on_restart
Definition order.h:90
char text_a[128]
Definition order.h:81
uint32_t order_tag_default_id
Definition order.h:73
OrderSide side
Definition order.h:70
uint64_t account_id
Definition order.h:72
std::vector< ttsdk::UserParameter > params
specific parameters to set on outgoing algo orders
Definition order.h:99
TimeInForce tif
Definition order.h:71
uint64_t price_subscription_id
Definition order.h:67
uint64_t order_stimulus_received
User listener timestamp (order_stimulus_receieved_oc)
Definition order.h:108
char text[128]
Definition order.h:80
char text_tt[128]
Definition order.h:84
std::vector< uint64_t > leg_account_ids
Specific for ASE spreads to set accounts on different legs. The accounts are set sequentially as prov...
Definition order.h:101
OrderType type
Definition order.h:68
uint64_t request_id
Definition order.h:66
double quantity
Definition order.h:77
char text_b[128]
Definition order.h:82
double display_quantity
Definition order.h:78
double minimum_quantity
Definition order.h:79
char clearing_acct_override[128]
Definition order.h:74
char text_c[128]
Definition order.h:83
char sender_sub_id[128]
Definition order.h:85
double trigger_price
Definition order.h:76
ttsdk::UserDisconnectAction user_disconnect_action
Definition order.h:95
Instruction instruction
Definition order.h:102
uint64_t expire_date
Definition order.h:69