{"id":7033,"date":"2025-08-28T22:12:00","date_gmt":"2025-08-29T03:12:00","guid":{"rendered":"https:\/\/librarytestdev.wpenginepowered.com\/?post_type=doc&#038;p=7033"},"modified":"2025-09-04T17:17:30","modified_gmt":"2025-09-04T22:17:30","slug":"responding-to-external-algo-requests","status":"publish","type":"doc","link":"https:\/\/library-staging.tradingtechnologies.com\/apis\/tt-core-sdk\/creating-a-tt-application-server\/responding-to-external-algo-requests\/","title":{"rendered":"Responding to External Algo Requests"},"content":{"rendered":"\n<p>\n    A response must be sent for each external algo request.  Failure to do so within ten seconds will result in In-Flight-Order-Action (IFOA) errors being displayed in the TT user interface. This is one such example.\n<\/p>\n<p>There are two parameters that are passed to almost all of the external algo request callback functions:  ttsdk::SDKAlgoPtr algoOrder and ttsdk::SDKAlgoRequestPtr req. The ttsdk::SDKAlgoPtr parameter contains methods to get information about the current state of the algo as well as methods to send responses, including:<\/p>\n\n<ul>\n    <li>\n        virtual const char* GetOrderId() const;\n        <ul>\n            <li>Returns the unique TT order id of this algo.<\/li>\n        <\/ul>\n    <\/li>\n    <li>\n        virtual InstrumentPtr GetInstrument() const;\n        <ul>\n            <li>Returns the instrument referenced by the algo. Might be null if the user did not specify an instrument in the tradition manner in the algo requests.\n            <\/li>\n        <\/ul>\n    <\/li>\n    <li>\n        virtual AlgoDefinitionPtr GetAlgoDefinition() const;\n\n        <ul>\n            <li>Returns information related to the algo\u2019s definition.<\/li>\n        <\/ul>\n    <\/li>\n    <li>\n        virtual ExecutionReportPtr GetCurrentState() const;\n\n        <ul>\n            <li>Returns the current state of the algo.\n            <\/li>\n        <\/ul>\n    <\/li>\n    <li>\n        virtual bool GenerateSyntheticFill(const double fillPrc, const double fillQty)\n        <ul>\n            <li>Generates and sends a fill message for the given qty and price.  May not be applicable for all algo types.\n            <\/li>\n        <\/ul>\n    <\/li>\n    <li>\n        virtual bool GenerateUserResponse(const char* msg, const ttsdk::UserParameter params[], const size_t numParams) \n\n        <ul>\n            <li>Generates and sends a restatement message to the user containing the given information.  Generally used to send an update which is not in response to a direct request.<\/li>\n        <\/ul>\n    <\/li>\n    <li>\n        virtual bool FailAlgo(const char* message) \n        <ul>\n            <li>Sets this algo as failed and sends a message to the user indicating failed status.\n            <\/li>\n        <\/ul>\n    <\/li>\n    <li>\n        virtual bool StopAlgo(const char* message)\n        <ul>\n            <li>Sets this algo as finished and sends a message to the user indicating finished status.\n            <\/li>\n        <\/ul>\n    <\/li>\n    <li>\n        virtual void OnPendingRequestCompleted(const AlgoResponseCode code, const char* message = nullptr) \n\n        <ul>\n            <li>Must be called when a request from the user is completed. If the algo request action was successful, return AlgoResponseCode::ok; otherwise pass in a code that describes the reason for failure. \n            <\/li>\n        <\/ul>\n    <\/li>\n<\/ul>\n\n<p>The ttsdk::SDKAlgoRequestPtr parameter contains methods to get information about the algo itself, including:<\/p>\n<ul>\n    <li>virtual const char* GetOrderId() const\n    <\/li>\n    <li>virtual ttsdk::OrderType GetOrderType() const \n    <\/li>\n    <li>virtual ttsdk::OrderSide GetSide() const<\/li>\n    <li>virtual ttsdk::TimeInForce GetTimeInForce() const <\/li>\n    <li>virtual double GetPrice() const \n    <\/li>\n    <li>virtual double GetQuantity() const \n    <\/li>\n    <li>virtual uint64_t GetUserId() const \n    <\/li>\n    <li>virtual uint64_t GetCurrentUserId() const \n    <\/li>\n    <li>virtual uint64_t GetAccountId() const \n    <\/li>\n    <li>virtual const char* GetClearingAccount() const \n    <\/li>\n    <li>virtual uint64_t GetInstrumentId() const \n    <\/li>\n    <li>virtual uint64_t GetAlgoDefinitionId() const \n    <\/li>\n    <li>virtual const char* GetText() const \n    <\/li>\n    <li>virtual const char* GetTextA() const \n    <\/li>\n    <li>virtual const char* GetTextB() const \n    <\/li>\n    <li>virtual const char* GetTextC() const \n    <\/li>\n    <li>virtual const char* GetTextTT() const \n    <\/li>\n    <li>virtual uint32_t GetUserParameterCount() const \n    <\/li>\n    <li>virtual UserParameter GetUserParameter(const uint32_t index) const \n    <\/li>\n\n    \n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>A response must be sent for each external algo request. Failure to do so within ten seconds will result in In- [&hellip;]<\/p>\n","protected":false},"author":2,"template":"wp-custom-template-single-doc-tt-core-sdk","meta":{"_acf_changed":false,"footnotes":""},"docs-category":[449],"class_list":["post-7033","doc","type-doc","status-publish","hentry","docs-category-creating-a-tt-application-server"],"acf":[],"_links":{"self":[{"href":"https:\/\/library-staging.tradingtechnologies.com\/ja\/wp-json\/wp\/v2\/doc\/7033","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\/7033\/revisions"}],"wp:attachment":[{"href":"https:\/\/library-staging.tradingtechnologies.com\/ja\/wp-json\/wp\/v2\/media?parent=7033"}],"wp:term":[{"taxonomy":"docs-category","embeddable":true,"href":"https:\/\/library-staging.tradingtechnologies.com\/ja\/wp-json\/wp\/v2\/docs-category?post=7033"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}