To submit an order and start receiving order/fill updates, you:
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.