TT CORE SDK

Submitting Orders

Submitting Orders

To submit an order and start receiving order/fill updates, you:

  • Create an instance of ttsdk::OrderPtr class and call the ttsdk::CreateOrder() method passing an InstrumentPtr reference that defines the instrument for which you want to submit an order.
  • If you have derived a class from ttsdk::IOrderEventHandler to receive order / fill events for specific solicited orders, call the Subscribe() method of the OrderPtr instance passing an instance of the event handler.
  • Create an instance of ttsdk::OrderProfile and fill in the order’s parameters.
  • Call the SendNew() method of the OrderPtr instance passing the OrderProfile instance.

The following code snippet demonstrates an example of this process.



ttsdk::OrderProfile profile_;
ttsdk::OrderPtr order_;
OrderObserver orderObs_;

void SubmitOrder(ttsdk::InstrumentPtr instrument, double price, double qty)
{
    order_ = ttsdk::CreateOrder(instrument);
    if (!order_)
    {
        std::cout << "Order creation failed." << std::endl;
        return;
    }

    order_->Subscribe(orderObs_);

    profile_.request_id++;
    profile_.account_id = 12345;
    profile_.side = ttsdk::OrderSide::Buy;
    profile_.price = price
    profile_.quantity = qty;
    profile_.type = ttsdk::OrderType::Limit;
    profile_.tif = ttsdk::TimeInForce::Day;
    order_->SendNew(profile_);
}
                      
  

The OrderProfile class has a member named LeaveOnRestart. It is set to true by default. If you are writing a TT Application Server, setting this to false will result in the order being deleted after your application is restarted.