Why can't I access orders function in trading toolbox?

function name: orders
I recently got Matlab 2018a with trading toolbox. When I type orders on the command line, I get "Undefined function or variable 'orders'. However, when I type which orders, Matlab shows me the full path of the file location. What is going on?

Answers (2)

Searching the documentation for the current release I found two different versions of the orders function in Trading Toolbox. The orders function requires that its first input be either a Bloomberg EMSX connection object or an IB Trader Workstation (SM) connection object. You cannot simply call it with zero input arguments or with a first argument that is different from one of those connection objects.
The examples on the documentation pages to which I linked show the whole workflow associated with using this function: initiating the connection, perform one or more operations using the connection, and closing the connection.
Hi Steven,
Thank you for your reply. I have been a long user of Matlab. If you call a function without input arguments, Matlab will give an error denoting the missing arguments. However, this function does not give any such error. Calling this function (without input argument) is like a variable that is not defined. Therefore, something is not right. Why don't you try it without any input argument and tell me what do you get?

2 Comments

AS, what you wrote would probably have been better placed as a comment on my answer, not an answer on its own.
If you try to call a function without the correct number of input arguments, it will probably error as you stated. However, the orders.m files in this toolbox are not regular functions, they are class methods and so the rules are a bit different.
Each of the orders.m files implements a method of one of the connection object classes. Unless a class method is a static method (which these are not) you MUST call the method with an instance of the class for which it is defined. These orders.m methods are "ordinary methods" as defined on the documentation page to which I linked above, and as stated on that page ordinary methods require an object of the class on which to operate.
To put it more simply, if you were to call orders.m with no inputs, how would MATLAB know whether you want to "Obtain Bloomberg EMSX order subscription" (call the method of the Bloomberg EMSX connection object) or "Request Interactive Brokers open order data" (call the method of the IB Trader Workstation (SM) connection object)? The answer is it "decides" how to behave based on what object you pass into orders.m when you call it.

Sign in to comment.

Asked:

AS
on 5 Apr 2018

Commented:

AS
on 7 Apr 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!