Skip to main content

IbMatlab (version 0.0.4)

This is IbMatlab version 0.0.4 (svn revision 327). This release adds very simple code for submitting a limit order on a contract. We have now broken up the demo code into three scripts in order to test the three elementary tools provided:
(1) Historical Data Requests
(2) Market Data Requests
(3) Entering Limit Orders

Again, please remember that this code is very crude and under development. It is only intended to stimulate further discussion and development (and should only ever be used with IB's simulated/paper trading account). We would appreciate any feedback.

[2009-11-17 - Update] Added file IbMatlab-r356.zip which contains the omitted 'Events'.

IbMatlab

asudjian's picture

Have you had a chance testing your code with the new IB API? It seems IB has changed the ActiveX API from the older version especialy on the event handling.

Events Package Folder

asudjian's picture

I just started studying your codes. I notice that that the "Events" package folder is empty. Is it on purpose or you just forget to include the files in the zipped file?

Missing Events

leptokurtosis's picture

Hi. Yes, you are right. The events files are missing. I will upload a new zip file shortly.

using demoHistoricalData, demoReqMarketData, etc

dakarxcr's picture

I am using Matlab R2008b with the TWS API and I get continual errors when running the demos on the IB edemo account.

Is there something missing from the Zip file or am I doing something wrong?

Thanks

Rob

Java API

Michael's picture

Hi, I was wondering if it possible to use the JAVA API instead? ActiveX is only for windows available.

I'm new to Java and therefore I cannot help a lot, but willing to learn and participated.

Thanks,
Michael

Yes, I think it is possible

leptokurtosis's picture

Yes, I think it is possible to link Matlab to TWS via the Java API. I have recently started to look into this myself and hope to have some code/posts in a couple weeks.

Update

leptokurtosis's picture

I have uploaded a new zip file which contains the missing events. Please let me know if you have any problems running the examples.

Update

leptokurtosis's picture

I have uploaded a new zip file which contains the missing events. Please let me know if you have any problems running the examples.

IbMatlab is really neat

riggster's picture

Hey, I really like what you have done. I was working on writing my own functions, to more easily work with IB's ActiveX API in Matlab, but I found this and I thought, why reinvent the wheel. Hey, I saw that revision 0.0.4 was posted in Nov 2009. Have you been updating your functions at all since then.

IbMatlab Development

leptokurtosis's picture
riggster wrote:

Have you been updating your functions at all since [November 2009]?

Hi. Thanks for your comment. This was a project I started about a year ago but then got bogged down with other things and never got back to it. I have received a few emails from people interested in it so I may give it some more attention when I can.
Please feel free to email me any thoughts/comments/suggestions and code. Perhaps I should even start a subversion project repo to combine other's input.
Thanks!

This helps a bit...

sjev's picture

Hi, found your site thanks to riggster. Have been trying to build an IB interface class on my own and things were going well, EXCEPT for one thing: when I pass a class method as a callback handler to the activex component, the class can not be destructed afterwards. 'clear classes' gives a warning that the class still exists. I see that you're using event listeners instead of direct callback and with your code the class destructs ok.
I'll try to rewrite my code with event listeners as well, using yours for reference. Any interest in my (future) code?

-Sjev (http://matlab-trading.blogspot.com/)

P.S. Is it not better to write code in a single classdef file rather than a directory structure?

SVN Server

leptokurtosis's picture
sjev wrote:

Any interest in my (future) code?

-Sjev (http://matlab-trading.blogspot.com/)

Hi Sjev,

In response to another reader, I have put together a very simple SVN (subversion) server for my IbMatlab. I have not had a chance to edit/update my code in some time but will take a look at it again in the coming weeks.

In the meantime, if you would like access to the SVN server in order to add/edit code please let me know and I'll email you with details.

code on svn

sjev's picture

Yes, I'd like to have a look at the svn rep. My e-mail can be found on my blog.

classdef: single file or multiple files

leptokurtosis's picture
sjev wrote:

Is it not better to write code in a single classdef file rather than a directory structure?

I found that if all the code is in a single classdef then any change to that file will require the class to be removed and reloaded.

However, if the functions/methods are defined in the classdef file but are implemented in their own file, then the code can be changed without the class needing to be reloaded. This is quite useful when developing code.

Check Positions

MathieuHamel's picture

Great job accomplished! Thank you for sharing it!

I was wondering how you would monitor current positions hold within an account. Would you define a new class or more simply add a method to your TWS class using reqAcctUpdates() ActiveX API methods? Would you use the IbEvent generic event and add cases to ibEventProcessor (updateAccountTime, ...Value and ...PortfolioEx)?

I would definitely appreciate some insight on this.

Best Regards,

Re:

leptokurtosis's picture

Hi MathieuHamel,

I have actually re-written much of the IB<->Matlab connector in Java as I think Java is a better solution than ActiveX (namely because Java is cross-platform and ActiveX is Windows-only).

If you are interested in giving the Java connector a try, send me a message and I'll send you either the recent .jar packages or Subversion repo access. I will post some the .jar packages on this blog in a few days when I have a chance to write some easy Matlab examples.

Dealing with positions and orders is a little more tricky but next on my to-do list.

-leptokurtosis