Autotrading not submitting orders to IB

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: 76 times
Contact:

Autotrading not submitting orders to IB

Postby fbertram » 02 Jan 2015

Dear MultiCharts fans,

I am experiencing some issues with auto trading. I am using Portfolio Trader on a portfolio of about 180 stocks of daily data. My data are retrieved from MB Trading and my orders are submitted through IB Gateway. I am starting auto trading at night. Due to the way MultiCharts works, it should submit an order when the next bar opens, which should be 9:30am Eastern Time. Unfortunately, more often than not, MultiCharts does not submit the orders. Here is what I see:
* auto-trading is still turned on/ running in Portfolio Trader
* IB Gateway says it's connected to the IB API server and to 1 client
* the log shows "Error: connectivity between IB and Trader Workstation has been restored - data maintained". See attached screenshot.
* MultiCharts is still seeing real-time data
* starting and stopping auto-trading will not fix the problem
* exiting and re-opening IB Gateway will not fix the problem
* exiting and re-opening Portfolio Trader does fix the problem

I have difficulties understanding the message in the log. If the connection has been restored, that can't be too bad, right? But then again, it's an error... Can anybody help me decipher what this really means? Is this message possibly related to my issue? What I should be doing about it? Is this related to the "disable auto trading after X seconds on connection loss" setting? What should I set it to?


Thank you,
best regards, Felix
Attachments
errors.png
(176.05 KiB) Downloaded 922 times

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Autotrading not submitting orders to IB

Postby TJ » 02 Jan 2015

are you using a remote server?

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

Re: Autotrading not submitting orders to IB

Postby fbertram » 02 Jan 2015

Hi TJ,

I am using a dedicated headless system in my network, which I am logging into via Remote Desktop. Not sure that is the remote system you had in mind. Or did I completely misunderstand your question?

Thank you,
best regards, Felix

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Autotrading not submitting orders to IB

Postby TJ » 02 Jan 2015

Hi TJ,
I am using a dedicated headless system in my network, which I am logging into via Remote Desktop. Not sure that is the remote system you had in mind. Or did I completely misunderstand your question?
Thank you,
best regards, Felix
Well... anything that is not in front of you is "remote".

A headless server in the same network might be considered local.

The reason I ask is because more and more MultiCharts users are hosting their software in a remote location, in a rented server (some shared), which presents different connectivity challenges. And when there is problem, it needs a different set of eyes for debugging.

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

Re: Autotrading not submitting orders to IB

Postby fbertram » 02 Jan 2015

Hi TJ,

thanks for your reply.

Well, from the network perspective, my MultiCharts machine is local. Looking at the log, it seems there was something wrong at 4:27am, so 2 hours before the session began. However, the way I understand the log it was all recovered well in time. So I am not sure what I am looking for. I see the following possibilities:
* a problem with IB Gateway. What seems to speak against this is the log stating everything recovered and the fact that restarting IB didn't do anything.
* a problem with MB Trading. If Portfolio Trader does not receive new data indicating the start of the session, it would probably not submit my order. What seems to speak against this is the fact that I could see data coming into a chart window
* a problem with Portfolio Trader. This might explain why it took a restart of Portfolio Trader to fix things.

Any thoughts or suggestions?


Thank you,
best regards, Felix

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

Re: Autotrading not submitting orders to IB

Postby fbertram » 03 Jan 2015

OK, I gained some more insight during IB's nightly system maintenance. Here is what's happening:
* IB servers go down (e.g. for scheduled maintenance)
* IB Gateway keeps re-connecting every 30 seconds or so and fails (which is correct)
* Portfolio Trader keeps re-connecting every 60 seconds or so (and displays partial success, which is odd)
* IB servers come back online
* IB Gateway is unable to properly connect with the IB servers (will keep showing broken socket)
* closing Portfolio Trader and re-opening it will reset IB Gateway such, that IB Gateway re-connects with IB servers properly. Please note that the only thing I need to do is to quit and restart Portfolio Trader. I left IB Gateway alone (even though IB Gateway of course notices the client to go away)

I will support this with the proper log files tomorrow (after I stitched the various pieces of log files back together).

This seems to indicate that there is a bug somewhere in the way how IB Gateway and/or Portfolio Trader handle a temporary disconnect.

Did anybody else see a similar issue?

Cheers, Felix

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

Re: Autotrading not submitting orders to IB

Postby fbertram » 03 Jan 2015

attached you'll find the logs. To make it easier to find things in there, I have colored them:
* green section: system working as desired
* red section: scheduled maintenance at IB
* orange section: system not coming back up after IB is back online
* blue section: system working OK after exit and re-start of Portfolio Trader

Any comments highly appreciated.


Thank you,
best regards, Felix
Attachments
2015i02-2045.zip
log files
(1.17 MiB) Downloaded 132 times

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

Re: Autotrading not submitting orders to IB

Postby fbertram » 04 Jan 2015


User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Autotrading not submitting orders to IB

Postby Henry MultiСharts » 05 Jan 2015

Hello Felix,

The description is confusing:
In this thread you say that "IB Gateway is unable to properly connect with the IB servers (will keep showing broken socket)".
In PM you say that "If IB goes down, Portfolio Trader fails to re-connect properly after IB becomes available again".
Please specify the particular issue you have.

If you use IB Gateway only (without Portfolio Trader) - is it able to properly re-connect with the IB servers after server maintenance?

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

Re: Autotrading not submitting orders to IB

Postby fbertram » 05 Jan 2015

Hi Henry,

thank you for your follow-up. I am sorry if I wasn't clear enough. On initial connect, everything is fine. The problem only occurs, after something happened to the connection, e.g. downtime at IB. After an outage, MultiCharts fails to reliably re-connect. Sometimes it does, but more often it doesn't.

When this failure occurs, the status seems a bit ambiguous:
* IB Gateway shows a green light for the connection status to both the API server and the client
* IB Gateway's log file continues to show 'DISCONNECT_ON_BROKEN_SOCKET'
* Portfolio Trader's log file shows 'Error: Connectivity between IB and Trader Workstation has been restored - data maintained."

Please have a look at the log files I attached above, they should hopefully clarify this.


Thank you,
best regards, Felix

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Autotrading not submitting orders to IB

Postby Henry MultiСharts » 06 Jan 2015

Felix, please do the following:
1. Enable the option "Create API message log file" in TWS/Gateway->Configure->API->Settings, set the "Logging level" to "Detail".
2. Make sure MultiCharts logging is enabled (it is often disabled by anti-virus/UAC): Save the attached file, unzip the reg file corresponding to your version of MultiCharts. Double-click on it and confirm registry modifications. Upon next start of MultiCharts/PortfolioTrader - regular application logging will be enabled.

When the described behavior is replicated please do not restart MultiCharts/PortfolioTrader and provide the following information for further analysis (send it so support@multicharts.com):
1) Specify exact version and build number of MultiCharts are you running (in MultiCharts go to Help tab-> About);
2) Specify the version of TWS/Gateway and Java you are running (TWS/Gateway Help tab->About);
3) MultiCharts logs (keep in mind that the logs from the previous run are erased when you start MC): In MultiCharts go to Help->Feedback->Send logs. Please let me know that you have uploaded the logs. If you want to send the logs manually please follow this guide: https://www.multicharts.com/trading-sof ... harts_Logs
4) IB API log (txt files saved in your settings directory, usually it is C:\JTS). There will be multiple files in the settings directory named the following way: log.*DayOfWeek*.txt, api.*ClientID*.*DayOfWeek*.log, ibgateway.*DayOfWeek*.log - attach all files for the day the issue is replicated;
5) Specify your PC time zone and exact time the issue was replicated;
6) Attach screenshots demonstrating the issue in Gateway and PortfolioTrader.
Attachments
all_traces_on.zip
(3.4 KiB) Downloaded 129 times

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

Re: Autotrading not submitting orders to IB

Postby fbertram » 07 Jan 2015

Hi Henry,
thanks a lot for your response. I will try to get you the additional data you requested asap.

Best regards, Felix


Return to “MultiCharts”