TT CORE SDK 2.0.1.1
TT CORE SDK documentation
Loading...
Searching...
No Matches
tt_cplus_sdk.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
20#ifndef DEPRECATE_SUPER_STRING
21 #define DEPRECATE_SUPER_STRING
22#endif
23#ifndef SUPER_STRING_IS_STD_STRING
24 #define SUPER_STRING_IS_STD_STRING
25#endif
26
27
28#include <sys/types.h>
29#include "consts.h"
30#include "sdk_options.h"
31#include "account.h"
32#include "customer_profile.h"
33#include "instrument.h"
34#include "algo_definition.h"
35#include "instrument_search.h"
36#include "prices.h"
37#include "order.h"
38#include "fill.h"
39#include "position.h"
40#include "connection.h"
41#include "enums/MarketId.h"
42#include "sdkalgo.h"
43
44
45namespace ttsdk {
46
47
49 {
50 public:
51 enum class Status
52 {
53 INITIALIZED, // SDK has been initialized but it not fully ready (some aspects of the SDK might still be negotiating)
54 READY, // SDK is fully functional
55 UNAUTHORIZED, // SDK is no longer permissioned
56 RECOMMEND_UPDATE, // SDK should be upgraded
57 REQUIRES_UPDATE, // SDK must be upgraded
58 FORCED_SHUTDOWN, // SDK is being forced to shutdown due to error
59 SDKALGO_CONNECTED, // SDK Algo support is connected and ready
60 EDGE_NOT_CONNECTED, // SDK could not connect to the edge for synthetic and position data
61 SDKALGO_NOT_CONNECTED, // SDK could not connect to the edge for SDK Algo support
62 DOWN, // SDK is down
63 INVALID_PRICE_CONFIG, // Invalid Price Config file was downloaded
64 ORDER_THROTTLE_LIMIT_EXCEEDED, // Number of orders sent in 1 second exceeded the limit
65 EDGE_DISCONNECTED, // SDK lost connectivity to the edge - it will reconnect
66 };
67
69 virtual ~IEventHandler() {};
70 virtual void OnStatus(const Status status) = 0;
72 virtual void OnInstrumentUpdated(InstrumentPtr /*oldInstrument*/, InstrumentPtr /*newInstrument*/) {};
73 virtual void OnInstrumentDeleted(InstrumentPtr /*deletedInstrument*/) {};
74 virtual void OnAlgoDefinitionUpdated(AlgoDefinitionPtr /*oldAlgo*/, AlgoDefinitionPtr /*newAlgo*/) {};
75 virtual void OnAlgoDefinitionDeleted(AlgoDefinitionPtr /*deletedAlgo*/) {};
76 };
78
79
90
95
99
100 //----------------------------------------------------------------------------
101
103 {
109 LogAlways = 100 // this level is used for messages which must be logged regardless of the minimal logging level
111
112#ifdef _WINDOWS
115 // in the TT log file as an INFO level message.
116 void TTLogInfo(const char *format, ...);
119 // in the TT log file as an WARNING level message.
120 void TTLogWarning(const char *format, ...);
123 // in the TT log file as an ERROR level message.
124 void TTLogError(const char *format, ...);
127 // in the TT log file as the specified level message.
128 void TTLog(const LogLevel level, const char* category, const char* msg);
129#else
130 void TTLogInfo(const char *format, ...) __attribute__((format(printf, 1, 2)));
132 void TTLogError(const char *format, ...) __attribute__((format(printf, 1, 2)));
134#endif
135 //-----------------------------------------------------------------------------------
136
140
144
148
151 InstrumentPtr GetInstrument(const MarketId market, const char* product, const ProductType type, const char* alias, Instrument::ResponseCode& code);
152
159
163
168
175
176
178 const uint64_t accountId = 0,
180 const uint64_t minTimestamp = 0,
181 const uint64_t maxTimestamp = 0,
182 const char* orderId = nullptr);
183
184
186 const bool implieds, const bool allowTTImplieds,
187 const bool includeSimPrices,
190 const bool implieds, const bool allowTTImplieds,
191 const bool includeSimPrices,
194
200
206
207
208 // Position Reserve Order support
212 bool ReserveRisk(InstrumentPtr instrument, const uint64_t accountId, const RiskSide side,
213 const double quantity, const double maxClipSize) noexcept;
215 bool ReleaseRisk(InstrumentPtr instrument, const uint64_t accountId, const RiskSide side) noexcept;
218
219 const char* const GetExchAssocId() noexcept;
220
221}
virtual void OnAccountStatus(const AccountConnectionStatus &connectionStatus)
virtual void OnInstrumentUpdated(InstrumentPtr, InstrumentPtr)
virtual void OnStatus(const Status status)=0
virtual void OnInstrumentDeleted(InstrumentPtr)
virtual void OnAlgoDefinitionUpdated(AlgoDefinitionPtr, AlgoDefinitionPtr)
virtual void OnAlgoDefinitionDeleted(AlgoDefinitionPtr)
Interface for listening to order and position events. There is one OrderBookEventHandler set in the S...
Definition order.h:246
Interface for listening to price subscription events.
Definition prices.h:187
Interface for listening to sdk algo events.
Definition sdkalgo.h:41
Interface for listening to time and sales subscription events.
Definition prices.h:211
void void TTLogWarning(const char *format,...) __attribute__((format(printf
void void void TTLogError(const char *format,...) __attribute__((format(printf
InstrumentPtr GetInstrument(const uint64_t instrumentId, Instrument::ResponseCode &code)
Gets the instrument definition (active only).
MarketId
Definition MarketId.h:29
RiskSide
Definition RiskSide.h:23
void UnsubscribeTimeAndSales(const uint64_t subscriptionId) noexcept
const char *const GetExchAssocId() noexcept
OrderPtr CreateOrderFromPriceSub(uint64_t priceSubscriptionId)
Create orders for exchange or synthetic (ASE/AGG) instruments.
InstrumentSearchResultsPtr SearchInstruments(const char *query, const char *markets, Instrument::ResponseCode &code)
Searches for instrument (active only).
AccountCollectionPtr GetAccounts()
Returns the user accounts.
void void void void TTLog(const LogLevel level, const char *category, const char *msg)
OrderPtr CreateAlgoOrder(AlgoDefinitionPtr algo, InstrumentPtr instrument)
Create order for an ADL Algo (akin to launching an algo in the gui)
void Shutdown() noexcept
Shutdown the TT CoreSDK shared library.
uint64_t SubscribeTimeAndSales(InstrumentPtr instrument, const bool includeSimPrices, ITimeSalesEventHandlerPtr listener) noexcept
CustomerProfileCollectionPtr GetCustomerProfiles()
Returns the CustomerProfiles.
OrderPtr CreateOrder(InstrumentPtr instrument)
bool Initialize(const TTSDKOptions &options, IEventHandlerPtr sdkEventObserver, IOrderBookEventHandlerPtr orderHandler, ISDKAlgoManagerPtr algoManager=nullptr) noexcept
Initialize the TT CoreSDK shared library.
void UnsubscribePrices(const uint64_t subscriptionId) noexcept
PositionReserveBucket GetRiskBucket(InstrumentPtr instrument, const uint64_t accountId) noexcept
Returns the current position reserve bucket for the instrument and account.
void StartAccount(const uint64_t accountId)
starts orders,fills and positions for the given account.
uint64_t SubscribePrices(InstrumentPtr instrument, const uint16_t depth, const bool implieds, const bool allowTTImplieds, const bool includeSimPrices, IPriceEventHandlerPtr listener) noexcept
void TTLogInfo(const char *format,...) __attribute__((format(printf
const char * Version() noexcept
Returns the version of the SDK.
bool ReleaseRisk(InstrumentPtr instrument, const uint64_t accountId, const RiskSide side) noexcept
Releases the previously allocated quantity of risk for the given instrumentId/accountId/side.
AlgoDefinitionPtr GetAlgoDefinition(const char *algoName, AlgoDefinition::ResponseCode &code)
Gets the algo definition (active only).
bool ReserveRisk(InstrumentPtr instrument, const uint64_t accountId, const RiskSide side, const double quantity, const double maxClipSize) noexcept
Reserves a quantity of risk for the given instrumentId/accountId/side to be used to by this app to av...
bool DownloadFills(IFillDownloadCallbackHandlerPtr obj, const uint64_t accountId=0, const ttsdk::MarketId marketId=ttsdk::MarketId::INVALID, const uint64_t minTimestamp=0, const uint64_t maxTimestamp=0, const char *orderId=nullptr)
@ LogCritical