{"id":7020,"date":"2025-08-28T22:11:58","date_gmt":"2025-08-29T03:11:58","guid":{"rendered":"https:\/\/librarytestdev.wpenginepowered.com\/?post_type=doc&#038;p=7020"},"modified":"2025-09-04T17:17:24","modified_gmt":"2025-09-04T22:17:24","slug":"receiving-solicited-and-unsolicited-order-fill-events","status":"publish","type":"doc","link":"https:\/\/library-staging.tradingtechnologies.com\/apis\/tt-core-sdk\/working-with-orders-and-fills\/receiving-solicited-and-unsolicited-order-fill-events\/","title":{"rendered":"Receiving Solicited and Unsolicited Order \/ Fill Events"},"content":{"rendered":"\n<p>\n  To receive solicited and unsolicited order \/ fill events, you\n  need to:\n<\/p>\n\n<ul>\n  <li>\n    Create a class that is derived from\n    ttsdk::IOrderBookEventHandler and defines your Order Book\n    event handler.\n    <ul>\n      <li>\n        You must provide implementations for the following\n        methods:\n        <ul>\n          <li>\n            virtual void OnExecutionReport(OrderPtr order,\n            ExecutionReportPtr execRpt) = 0;\n            <ul>\n              <li>\n                Callback fired when delivering execution report\n                messages\n              <\/li>\n            <\/ul>\n          <\/li>\n          <li>\n            virtual void OnReject(OrderPtr order,\n            RejectResponsePtr rejResp) = 0;\n            <ul>\n              <li>\n                Callback fired when delivering order reject\n                messages\n              <\/li>\n            <\/ul>\n          <\/li>\n          <li>\n            virtual void OnSendFailed(OrderPtr order, const\n            OrderProfile&amp; profile, const SendCode code) = 0;\n            <ul>\n              <li>\n                Callback fired when a request delivery surpasses\n                the timeout threshold\n              <\/li>\n            <\/ul>\n          <\/li>\n          <li>\n            virtual void OnUnsubscribed(const char* orderId) =\n            0;\n            <ul>\n              <li>\n                Callback fired when the unsubscribe request is\n                complete and it is safe to destroy the handler\n                object\n              <\/li>\n            <\/ul>\n          <\/li>\n        <\/ul>\n      <\/li>\n      <li>\n        You can also optionally provide implementations for the\n        following methods:\n        <ul>\n          <li>\n            virtual void OnPositionUpdate(const Position&amp;\n            updatedPosition) {};\n            <ul>\n              <li>Callback delivering position updates<\/li>\n            <\/ul>\n          <\/li>\n          <li>\n            virtual void OnAccountDownloadEnd(const uint64_t\n            accountId) {};\n            <ul>\n              <li>\n                Callback indicating that the given account has\n                been synchronized with the real time streams,\n                and orders and positions have been downloaded.\n              <\/li>\n            <\/ul>\n          <\/li>\n          <li>\n            virtual void OnAccountDownloadFailed(const uint64_t\n            accountId, const char* message) {};\n            <ul>\n              <li>\n                Callback indicating that the given account\u2019s\n                orders and positions downloads have failed and\n                the account is not usable.\n              <\/li>\n            <\/ul>\n          <\/li>\n          <li>\n            virtual void OnOrderBookDownloadEnd() {};\n            <ul>\n              <li>\n                Callback indicating that all orders and\n                positions for all accounts are downloaded and\n                synchronized with the real time stream.\n              <\/li>\n            <\/ul>\n          <\/li>\n        <\/ul>\n      <\/li>\n      <li>\n        Initialize the TT Core SDK passing your TTSDKOptions\n        instance variable, your SDK event handler instance\n        variable, and your Order Book event handler instance\n        variable.\n        <ul>\n          <li>\n            Note that both the SDK and Order Book event handlers\n            must have a lifespan that is valid for the life of\n            the SDK (until shutdown is completed).\n          <\/li>\n        <\/ul>\n      <\/li>\n    <\/ul>\n  <\/li>\n<\/ul>\n\n<p>\n  An <strong>OnAccountDownloadEnd<\/strong> event is fired when\n  an account is ready to be used for trading. And an\n  <strong>OnOrderBookDownloadEnd<\/strong> event is fired when\n  all accounts are ready.\n<\/p>\n\n<p>\n  The following code snippet demonstrates an example of this\n  process.\n<\/p>\n\n<div class=\"language-plaintext highlighter-rouge\">\n  <div class=\"highlight\">\n    <pre class=\"highlight\"><code>\n\n#include <iostream>\n#include <iomanip>\n#include <atomic>\n#include <sstream>\n#include <string.h>\n#include <tt_cplus_sdk.h>\n#include <condition_variable>\n\nstd::mutex mutex;\nstd::condition_variable sdkReadyCondition;\n\n\/\/\n\/\/  SDK event handler class\n\/\/\n\nclass SDKEventHandler : public ttsdk::IEventHandler\n{\n  public:\n      SDKEventHandler() : IEventHandler() {}\n      virtual ~SDKEventHandler() {}\n\n      \/\/ received on an SDK managed thread that can be used for processing.\n      \/\/ beware that time consuming tasks can delay the delivery of another status event.\n\n      virtual void OnStatus(const ttsdk::IEventHandler::Status status) override\n      {\n          std::cout  lock(mutex);\n      sdkReadyCondition.notify_one();\n    }\n    \n    \/\/ the SDK synchronizes the order book and positions by account.  as such, \n    \/\/ any given account can be able to trade without needing to wait \n    \/\/ for all accounts to be ready\n\n    virtual void OnAccountDownloadEnd(const uint64_t accountId) override\n    {\n      std::cout GetAlias()  lock(mutex);\n  if (sdkReadyCondition.wait_for(lock, std::chrono::seconds(300)) == std::cv_status::timeout)\n  {\n    std::cout &gt;&gt;&gt;&gt;\" &gt; command)\n  {\n    if (command == \"q\")\n    {\n      std::cout <\/condition_variable><\/tt_cplus_sdk.h><\/string.h><\/sstream><\/atomic><\/iomanip><\/iostream><\/code><\/pre>\n                  <\/div>\n                <\/div>\n","protected":false},"excerpt":{"rendered":"<p>To receive solicited and unsolicited order \/ fill events, you need to: Create a class that is derived from tts [&hellip;]<\/p>\n","protected":false},"author":2,"template":"wp-custom-template-single-doc-tt-core-sdk","meta":{"_acf_changed":false,"footnotes":""},"docs-category":[448],"class_list":["post-7020","doc","type-doc","status-publish","hentry","docs-category-working-with-orders-and-fills"],"acf":[],"_links":{"self":[{"href":"https:\/\/library-staging.tradingtechnologies.com\/ja\/wp-json\/wp\/v2\/doc\/7020","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/library-staging.tradingtechnologies.com\/ja\/wp-json\/wp\/v2\/doc"}],"about":[{"href":"https:\/\/library-staging.tradingtechnologies.com\/ja\/wp-json\/wp\/v2\/types\/doc"}],"author":[{"embeddable":true,"href":"https:\/\/library-staging.tradingtechnologies.com\/ja\/wp-json\/wp\/v2\/users\/2"}],"version-history":[{"count":0,"href":"https:\/\/library-staging.tradingtechnologies.com\/ja\/wp-json\/wp\/v2\/doc\/7020\/revisions"}],"wp:attachment":[{"href":"https:\/\/library-staging.tradingtechnologies.com\/ja\/wp-json\/wp\/v2\/media?parent=7020"}],"wp:term":[{"taxonomy":"docs-category","embeddable":true,"href":"https:\/\/library-staging.tradingtechnologies.com\/ja\/wp-json\/wp\/v2\/docs-category?post=7020"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}