hi dareminator, thanks for your very useful comparison of openquant and amibroker. Are there any (part) of sample codes for basic automation trading framework with executing order with IB available for both products in order that we could compare how the code looks like basically? (of course without any strategy ideas etc....) Or could you show parts of your code to see the differences in the programming of both products? thanks!
ophth1, both tools provide sample code and good support forums you could learn from. For Amibroker, check http://www.amibroker.com/at/index.html. Here is a small snippet from that site: Placing and transmitting Market Buy Order for 100 shares when MACD crosses above Signal line: Code: Buy = Cross( MACD(), Signal() ); if( LastValue( Buy ) ) { ibc = GetTradingInterface("IB"); // check if we are connected OK if( ibc.IsConnected() ) { // check if we do not have already open position on this stock if( ibc.GetPositionSize( Name() ) == 0 ) { // transmit order ibc.PlaceOrder( Name(), "Buy", 100, "MKT", 0, 0, "Day", True ); } } } OpenQuant installs a large number of sample projects. The best way to learn is to download a 30-day trial version of OpenQuant and play with it in a paper-trading account. A piece of code I copied from their "Bollinger Bands with 5-Minute Bars" sample project (http://www.smartquant.com/strategies/strategy_14.htm) Code: public override void OnBar(Bar bar) { if (bbl.Contains(bar.DateTime)) { if (!HasPosition) { // cancel previos buy limit if (buyLimit != null) buyLimit.Cancel(); // calculate limit price double buyPrice = bbl.Last * (1 - Percent / 100); // place new limit orders buyLimit = BuyLimitOrder(Qty, buyPrice, "Entry"); buyLimit.Send(); } else { barsFromEntry++; // close position at the second bar after entry if (barsFromEntry == 2) { barsFromEntry = 0; sellLimit.Cancel(); Sell(Qty, "Exit (Second Bar After Entry)"); } } } }
hi dareminator,, thanks for your reply! I had a closer look at openquant and the concept seems to be much clearer than amibroker from a coding point of view. However, there are some remaining questions concerning the event driven concept: - if you try to do a kind of market scanner, which you basically needs to start with in order to find something of interest, how can it be done in openquant? As far as I learned, it is not possible to import instruments during the run by scripting. But the instruments are the ticker symbols which define what to scan for, right? Does it mean you have to import manually 5000+ symbols in order to start such a script? - if those 5000+ symbols are imported and scanned in RT mode for something interesting (condition == true), is it possible to define for those symbols (instruments), where you consider to buy or afterwards to sell, a more precise time interval for scanning the data than for the others? thanks!
hi! I've got an additional question: If I do a stop loss limit with IB, as far as I understand, IB will perform the sell by itself and the question is: what about the synchronisation with the running strategy in Openquant? how will OQ know that these shares are sold and at which price in order to adjust portefolio and cash available? Is there a sync option to adjust what is in the portfolio and what OQ believes is in the portfolio? Furthermore: is it possible not only to debug the sources of OQ in visual studio, but also let the strategy run in Visual studio and add then there some more interfaces etc., which are not available in OQ (such as buttons for some actions etc.). THANKS!!!
I haven't needed or used market scanner functionality, so can't help you there. There is a demo video about it (video 12) at http://www.smartquant.com/openquant.php While you are there, I suggest you watch the other videos and read "OpenQuant Getting Started Guide" and "OpenQuant Strategy Development Guide". It will help answer many questions.
OpenQuant will only know about orders generated from within OpenQuant. It does not know about manual orders you enter from TWS. There is no good way to synchronize them. It is fairly easy to add user interface functionality if you know your way around .net events and either vb or c#. You can create a .net assembly (dll) with a dialog box containing the buttons / elements you want, and activate this dialog from within your OQ code.
hi and thanks again! I know that there is no good way of synchronisation. but I am not talking about entering manually any additional orders, but putting a stop loss order into the IB interface from OQ. I assume that you will often do this even for security reasons. Thus, how to determine if IB fullfilled the order in the meantime due to falling share values if there will be no ack to OQ? In the OQ manual, I could not find any hint to this not unimportant topic... THANKS!
You will receive the OnOrderFilled event whenever an order executes. One possible use case is: you send your entry order. When you receive the OnOrderFilled call for that, you send a profit and stop-loss order in a One-Cancel-All group. When one of these exit orders execute, you receive the OnOrderFilled event for the order that executed, and OnOrderCancelled event for the order that got the automatic OCA cancel by IB. OpenQuant has all the event notifications you need, and you can keep OpenQuant and IB states in sync as long as: 1) all orders are generated from within Openquant, and not manualy entered into TWS, and 2) your TWS instance does not lose its connection to IB servers (it does happen sometimes).
FYI There is a BrokerInfo class (not described in the strategy development guide) in OpenQuant API that allows to request different information directly from IB. There is a discussion thread on SmartQuant forums and even a sample code that allows to synchronize IB and OQ accounts on the fly. Regards, Anton
hi dareminator! thanks again for your replies! Coming from a complete different area of interest, I am really surprised about the impressions we got in the last week. Our intention was to try some algorithms/idea we got from research in system biology on financial trading. Basically, we were looking for a framework which is just easy to use for automated trading. Looking at so many products in the last weeks, I can share you impression that OPenQUant might be one of the better ones. However, in comparison of the products we have in other fields, all of them are highly underdeveloped from our point of view. Furthermore, all of them are lacking from more complex samples to setup up the really basic steps for automated trading easily. Our idea was to find a kind of open underlying framework just having kind-of-built-in the basic routines for automated trading, lacking of course strategies etc.... ;-). However, all we could find until now are just small code snippets. Do you know any software or framework project which has such this basic infrastructure ready to use or someone who is selling this as an addition to some of these software products? Furthermore, looking at all these products e.g. as Openquant, there are so many things which nobody would except for programming outside this financial world: e.g. OPenquant and RightEdge which might be the best in terms of object oriented programming, are using C#, but are lacking of the possibility to use Visual studio to produce real EXE. You just can use the debugger (wow...), but you will always relay on the software, which is really less capable than c# itself. I am still not sure, if it might be the best idea to throw away OQ, amibroker etc, and just use visual studio e.g. c#, which is indeed capable to do an rapid event driven and object orientated software, in combination with the IB interface. That would you give complete control about all events. What are your directions for the future? thanks!