TT CORE SDK

Responding to External Algo Requests

Responding to External Algo Requests

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.

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:

  • virtual const char* GetOrderId() const;
    • Returns the unique TT order id of this algo.
  • virtual InstrumentPtr GetInstrument() const;
    • 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.
  • virtual AlgoDefinitionPtr GetAlgoDefinition() const;
    • Returns information related to the algo’s definition.
  • virtual ExecutionReportPtr GetCurrentState() const;
    • Returns the current state of the algo.
  • virtual bool GenerateSyntheticFill(const double fillPrc, const double fillQty)
    • Generates and sends a fill message for the given qty and price. May not be applicable for all algo types.
  • virtual bool GenerateUserResponse(const char* msg, const ttsdk::UserParameter params[], const size_t numParams)
    • 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.
  • virtual bool FailAlgo(const char* message)
    • Sets this algo as failed and sends a message to the user indicating failed status.
  • virtual bool StopAlgo(const char* message)
    • Sets this algo as finished and sends a message to the user indicating finished status.
  • virtual void OnPendingRequestCompleted(const AlgoResponseCode code, const char* message = nullptr)
    • 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.

The ttsdk::SDKAlgoRequestPtr parameter contains methods to get information about the algo itself, including:

  • virtual const char* GetOrderId() const
  • virtual ttsdk::OrderType GetOrderType() const
  • virtual ttsdk::OrderSide GetSide() const
  • virtual ttsdk::TimeInForce GetTimeInForce() const
  • virtual double GetPrice() const
  • virtual double GetQuantity() const
  • virtual uint64_t GetUserId() const
  • virtual uint64_t GetCurrentUserId() const
  • virtual uint64_t GetAccountId() const
  • virtual const char* GetClearingAccount() const
  • virtual uint64_t GetInstrumentId() const
  • virtual uint64_t GetAlgoDefinitionId() const
  • virtual const char* GetText() const
  • virtual const char* GetTextA() const
  • virtual const char* GetTextB() const
  • virtual const char* GetTextC() const
  • virtual const char* GetTextTT() const
  • virtual uint32_t GetUserParameterCount() const
  • virtual UserParameter GetUserParameter(const uint32_t index) const