Why can't I access orders function in trading toolbox?
Show older comments
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)
Steven Lord
on 5 Apr 2018
0 votes
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.
AS
on 6 Apr 2018
0 votes
2 Comments
Steven Lord
on 6 Apr 2018
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.
AS
on 7 Apr 2018
Categories
Find more on Transaction Cost Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!