MATLAB: Create “Adaptive Algo” Order – Interactive Broker API

algorithmic tradingibtwsinteractive brokersTrading Toolbox

I'm trying to determine the matlab method of creating an "Adaptive Algo" order in the Interactive Broker api. The c# method is stated here: https://interactivebrokers.github.io/tws-api/ibalgos.html#adaptive however, I can't figure out its matlab equivalent
C#:
Order baseOrder = OrderSamples.LimitOrder("BUY", 1000, 1);
...
AvailableAlgoParams.FillAdaptiveParams(baseOrder, "Normal");
client.placeOrder(nextOrderId++, ContractSamples.USStockAtSmart(), baseOrder);
...
public static void FillAdaptiveParams(Order baseOrder, string priority)
{
baseOrder.AlgoStrategy = "Adaptive";
baseOrder.AlgoParams = new List<TagValue>();
baseOrder.AlgoParams.Add(new TagValue("adaptivePriority", priority));
}
What I've done so far in Matlab:
% Create TWS connection and Create Order
ib = ibtws('',7496);
ibOrder = ib.Handle.createOrder;
ibOrder.action = 'BUY';
ibOrder.totalQuantity = 1000;
ibOrder.orderType = 'LMT';
% Specifying Adaptive Algo Order
ibOrder.algoStrategy = "Adaptive";

Best Answer

I have not tested this, but it should work. I'm about 99.75% sure. Let me know how it goes. If you want to change the algo, the same concept will apply. Create the algo properties, then set the value. Easy.
% Connect to IBTWS or GATEWAY
ib = ibtws('',4001,0);
% Create Contract
contract = ib.Handle.createContract;
contract.symbol = 'AAPL';
contract.secType = 'STK';
contract.exchange = 'SMART';
contract.primaryExchange = 'SMART';
contract.currency = 'USD';
% Create Order
order = ib.Handle.createOrder;
order.action = 'BUY';
order.totalQuantity = 1000;
order.orderType = 'LMT';
order.lmtPrice = '274.25';
% Add properties for Algo order
order.algoStrategy = 'Adaptive';
addproperty(order.algoParams,'adaptivePriority');
order.algoParams.adaptivePriority = 'Normal';
% Place the order
id = orderid(ib);
exec = createOrder(ib,contract,order,id);
% Check order status after 5 seconds
pause(5);
exec(1,1).STATUS
Related Question