Retrieving currently open orders

Questions about MultiCharts and user contributed studies.
User avatar
fbertram
Posts: 166
Joined: 16 Oct 2014
Location: Seattle, USA
Has thanked: 36 times
Been thanked: 73 times
Contact:

Retrieving currently open orders

Postby fbertram » 15 Feb 2015

Dear MultiCharts fans,

Is there any way to retrieve the currently open orders from Powerlanguage? This would be a useful feature for Portfolio Trader, where open orders can no longer be determined by the trading signal alone. Also, I would really like to monitor what's at the broker programmatically, instead of making assumptions.

Out of curiosity: would the situation be better in .Net, where I could talk to TWS directly?

Any hints highly appreciated.

Thank you,
Best regards,

Felix

orion
Posts: 250
Joined: 01 Oct 2014
Has thanked: 65 times
Been thanked: 104 times

Re: Retrieving currently open orders

Postby orion » 15 Feb 2015

This would be a useful feature not just for PT but also for anyone who does auto trading with MC. As of now, PL does not have any means of getting open orders or positions at the broker. All position updates are via message "push" by the broker. I discussed this with Andrew a month back and the only "pull" is on start of auto trading when positions at the broker are downloaded.

At the minimum, having a PL keyword ReqPositions which does a pull update of positions at the broker would be a great idea. If possible, ReqAllOpenOrders would be great too but is not as essential as ReqPositions. These map directly to corresponding calls in the IB API (and other APIs like CQG) and so it seems like MC should be able to provide these PL keywords with minimal effort since these would be PL wrappers around the broker API.

While MC.NET has unmanaged orders, I don't know if it has such pull capability and I am interested in knowing.

User avatar
fbertram
Posts: 166
Joined: 16 Oct 2014
Location: Seattle, USA
Has thanked: 36 times
Been thanked: 73 times
Contact:

Re: Retrieving currently open orders

Postby fbertram » 16 Feb 2015

I am looking at the IB API for C#:
https://www.interactivebrokers.com/en/s ... pi/api.htm

It seems that reqOpenOrders() would return the information. All requests are asynchronous, but that shouldn't be too much of an issue to overcome. In the .Net edition, one could probably call into the API more or less directly. With the Powerlanguage edition, there would be no way around writing a DLL as it seems. Can be done, but there might be faster ways to get a similar result: I am working on some Perl code to parse the audit trail XML files created by TWS.

It is a bit disappointing having to do that, as MultiCharts' order and position tracker has all the i formation I need... but is not voluntarily handing it to my code.


Cheers, Felix

orion
Posts: 250
Joined: 01 Oct 2014
Has thanked: 65 times
Been thanked: 104 times

Re: Retrieving currently open orders

Postby orion » 16 Feb 2015

I am looking at the IB API: It seems that reqOpenOrders() would return the information. All requests are asynchronous, but that shouldn't be too much of an issue to overcome. Can be done, but there might be faster ways to get a similar result: I am working on some Perl code to parse the audit trail XML files created by TWS.
IB API has ReqOpenOrders and ReqPositions. Of the two, the more important is ReqPositions to be able to do bullet-proof strategy synchronization. ReqOpenOrders does not help with strategy sync which is the first order of business for robust trading. ReqPositions is also perhaps less effort for the MC team to design than ReqOpenOrders. I empathize with your Perl code and I am doing likewise. However, it would be great if MC could do this for the benefit of all users for as many brokers as is reasonably possible (IB and CQG being top on my personal list).

User avatar
Henry MultiСharts
Posts: 9083
Joined: 25 Aug 2011
Has thanked: 1258 times
Been thanked: 2920 times

Re: Retrieving currently open orders

Postby Henry MultiСharts » 18 Feb 2015

The new backtesting/auto trading engine coming in MultiCharts 9.1 will provide direct order control. It will be possible to receive a list of orders from broker, including current orders' state and parameters.

In MultiCharts .NET that is already possible to get Order and Position Tracker information in your code using the TradeManager.

User avatar
fbertram
Posts: 166
Joined: 16 Oct 2014
Location: Seattle, USA
Has thanked: 36 times
Been thanked: 73 times
Contact:

Re: Retrieving currently open orders

Postby fbertram » 18 Feb 2015

Thanks Henry, that's great news! Is there a tentative target date for 9.1 yet?

User avatar
Henry MultiСharts
Posts: 9083
Joined: 25 Aug 2011
Has thanked: 1258 times
Been thanked: 2920 times

Re: Retrieving currently open orders

Postby Henry MultiСharts » 18 Feb 2015

Thanks Henry, that's great news! Is there a tentative target date for 9.1 yet?
There is no ETA for this version at the moment.

orion
Posts: 250
Joined: 01 Oct 2014
Has thanked: 65 times
Been thanked: 104 times

Re: Retrieving currently open orders

Postby orion » 18 Feb 2015

The new backtesting/auto trading engine coming in MultiCharts 9.1 will provide direct order control. It will be possible to receive a list of orders from broker, including current orders' state and parameters.
Henry, this is great! Will we be able to do the same for positions? Do a demand pull of positions at the broker and not just get the list of positions in the OPT which we can do today with GetPositionQuantity?

User avatar
Henry MultiСharts
Posts: 9083
Joined: 25 Aug 2011
Has thanked: 1258 times
Been thanked: 2920 times

Re: Retrieving currently open orders

Postby Henry MultiСharts » 20 Feb 2015

The new backtesting/auto trading engine coming in MultiCharts 9.1 will provide direct order control. It will be possible to receive a list of orders from broker, including current orders' state and parameters.
Henry, this is great! Will we be able to do the same for positions? Do a demand pull of positions at the broker and not just get the list of positions in the OPT which we can do today with GetPositionQuantity?
I am sorry to say but the new backtesting/auto trading engine feature is no longer targeted to MC 9.1. It has been postponed until one of the future versions of MultiCharts. We are still working on the technical specifications of this functionality, so it can be different in the final product. We will keep you updated on the progress we have.

orion
Posts: 250
Joined: 01 Oct 2014
Has thanked: 65 times
Been thanked: 104 times

Re: Retrieving currently open orders

Postby orion » 20 Feb 2015

I am sorry to hear that but I understand. It is better to push it out and have an engine that lives up the same high standards that we have come to expect of MC than try to get a quick release that is not well thought out. Users who feel the need for functionality such as unmanaged orders can try out MC.NET and I myself may do that over the course of this year.

User avatar
fbertram
Posts: 166
Joined: 16 Oct 2014
Location: Seattle, USA
Has thanked: 36 times
Been thanked: 73 times
Contact:

Re: Retrieving currently open orders

Postby fbertram » 09 Mar 2015

I have shared some code that retrieves the order status based on TWS's audit trails:
viewtopic.php?f=20&t=48295

Cheers, Felix


Return to “MultiCharts”