MATLAB: Am I encountering unrecognized property ‘expiry’ error while accessing the contact data

ibinteractive brokersinteractivebrokersMATLABtws

Why am I encountering unrecognized property 'expiry' error while accessing the contact data?
I am trying to create a contract and get the Interactive Brokers data, but I am encountering the following error messages for the below code snippet:
>> ibs = ibtws('',7496);
>> pause(1);
>> ibContractData = ibs.Handle.createContract;
>> ibContractData.symbol = 'EUR';
>> ibContractData.secType = 'FUT';
>> ibContractData.exchange = 'GLOBEX';
>> ibContractData.expiry='201806';
>> ibContractData.currency = 'USD';
>> rtd=getdata(ibs,ibContractData)
>> close(ibs);
Unrecognized property 'expiry' for class 'Interface.AE6A66F3_8FA9_4076_9C1F_3728B10A4CC7'.
Error in Untitled (line 9)
ibContractData.expiry='201806';

Best Answer

You are encountering the error messages because there is no "expiry" property for the "ibContractData".
To resolve this issue, you need to use the property "LastTradeDateOrContractMonth" as follows:
>> ibContractData.LastTradeDateOrContractMonth = '201806';