I'm attempting to automate some strategies and ideally I'd like them running 24x7. Some are high-frequency FX so stability is important.
I've used a software package called FireDaemon to launch RE as a service with the appropriate command-line parameters. So at boot time, RE gets started automatically.
However, I've encountered a number of different exceptions while testing over the past week and was hoping someone could shed some more light on them because some of them prevent the trading strategy from restarting automatically.1.
I've posted in another thread, about the "Could not convert from NZD to USD for date 1/01/0001 12:00:00 AM." exception being thrown. If I manually attempt to restart the strategy, an error gets logged in the Output window and the strategy fails to start:Could not write to output file 'c:\dir\strategy.dll' -- 'The process cannot access the file because it is being used by another process. '
This is the only strategy that is using the file/dll. The sequence of events is:
1. RE started automatically using command line args: /W:"Watchlist" /P:"C:\dir\strategy.rep" /L
2. The NZD/USD conversion exception is thrown.
3. Manually starting the live strategy results in the above error.
The only way to recover is to shutdown RE and restart (and not accept saved positions). It seems like some part of RE has a file open on the strategy.dll even when the strategy fails to start.2.
When trading with the IB TWS plugin, this exception was thrown:An exception of type System.ArgumentException was thrown.
Unknown value for enum type Krs.Ats.IBNet.OrderStatus: ApiCancelled
at Krs.Ats.IBNet.EnumDescConverter.GetEnumValue(Type value, String description)
at Krs.Ats.IBNet.IBClient.ProcessMsg(IncomingMessage msgId)
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
After clicking on the dialog, RE then crashed. But all automated trading is halted until someone realises there's a dialog window and clicks on it and then waits for RE to restart. 3.
The strategy was happily trading away and then this exception was thrown:Cash was NaN
at RightEdge.Common.BaseSystemHistory.SimNewBar(NewBarInfo info)
at RightEdge.Common.SystemData.x56e784a497b3cb60(NewBarInfo x8d3f74e5f925679c)
at RightEdge.Common.Internal.SystemRunner.NewBar(Dictionary`2 bars)
at RightEdge.Shared.SystemWrapper.NewBar(Dictionary`2 bars)
at RightEdge.Shared.SystemWrapper.NewBar(Dictionary`2 bars)
at RightEdge.Shared.TradingModuleWrapper.NewBar(Dictionary`2 bars)
at RightEdge.LiveSystemwindow.x2e01f099ee7feedb(Dictionary`2 xd3a52115666f4605)
After clicking on the dialog, RE then crashed. Again, all automated trading is halted until the dialog was closed. It could be days before someone realizes something is amis.4.
I'm trying to automate a few strategies so FireDaemon is starting up a couple of instances of RE with different command line args. I occasionally get this error when the system reboots:An exception of type System.Configuration.ConfigurationErrorsException was thrown.
An error occurred loading a configuration file: The process cannot access the file 'C:\Documents and Settings\User\Local Settings\Application Data\Yye_Software\RightEdge.exe_StrongName_tzopmoluzdyjreykcjm2jskkq1rnwoju\2008.1.0.0\user.config' because it is being used by another process. (C:\Documents and Settings\User\Local Settings\Application Data\Yye_Software\RightEdge.exe_StrongName_tzopmoluzdyjreykcjm2jskkq1rnwoju\2008.1.0.0\user.config)
at System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignoreLocal)
at System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(ConfigurationSchemaErrors schemaErrors)
at System.Configuration.Configuration..ctor(String locationSubPath, Type typeConfigHost, Object hostInitConfigurationParams)
at System.Configuration.Internal.InternalConfigConfigurationFactory.System.Configuration.Internal.IInternalConfigConfigurationFactory.Create(Type typeConfigHost, Object hostInitConfigurationParams)
at System.Configuration.ClientSettingsStore.ClientSettingsConfigurationHost.OpenExeConfiguration(ConfigurationUserLevel userLevel)
at System.Configuration.ClientSettingsStore.GetUserConfig(Boolean isRoaming)
at System.Configuration.ClientSettingsStore.WriteSettings(String sectionName, Boolean isRoaming, IDictionary newSettings)
at System.Configuration.LocalFileSettingsProvider.SetPropertyValues(SettingsContext context, SettingsPropertyValueCollection values)
at RightEdge.xf266856f631ec016.OpenProject(String filename)
An exception of type System.IO.IOException was thrown.
The process cannot access the file 'C:\Documents and Settings\User\Local Settings\Application Data\Yye_Software\RightEdge.exe_StrongName_tzopmoluzdyjreykcjm2jskkq1rnwoju\2008.1.0.0\user.config' because it is being used by another process.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at System.Configuration.Internal.InternalConfigHost.StaticOpenStreamForRead(String streamName)
at System.Configuration.Internal.InternalConfigHost.System.Configuration.Internal.IInternalConfigHost.OpenStreamForRead(String streamName, Boolean assertPermissions)
at System.Configuration.Internal.DelegatingConfigHost.OpenStreamForRead(String streamName, Boolean assertPermissions)
at System.Configuration.ClientSettingsStore.ClientSettingsConfigurationHost.OpenStreamForRead(String streamName)
at System.Configuration.UpdateConfigHost.OpenStreamForRead(String streamName)
The only solution is to manually restart every instance of RE that has thrown the error. Again, it could be a while before someone realizes the strategy isn't trading.5.
Thanks to the wonders of Windows Automatic updates and automatic reboots, I logged on one morning to discover the machine had rebooted. When starting up, the live strategies had all thrown this error:An exception of type System.InvalidOperationException was thrown.
There is an error in XML document (0, 0).
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader)
at RightEdge.Common.PositionManager.LoadOpenPositions(String fileName)
at RightEdge.LiveSystemwindow.x0fa035c1818e31d7(SystemDataCreationSettings xb6b3da7953a69f26, String xe125219852864557)
at RightEdge.LiveSystemwindow.StartLiveSystem(xfb471916970b0c9e liveDataWindow, List`1 symbols, SystemDataCreationSettings settings, SystemRunInfo runInfo, RightEdgeCompiler compiler)
An exception of type System.Xml.XmlException was thrown.
Root element is missing.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.ThrowWithoutLineInfo(String res)
It seems like the LiveOpenPositions.xml file had become corrupted. Deleting the files and restarting fixed the problem. Not sure how best to solve this. Is it possible to automatically blow it away if its corrupted? Or else, is it possible to close it and flush it once finished writing to it? ie, write and flush to new file, and then replace existing file with new file?6.
I've configured FireDaemon to automatically start up both RightEdge and IB's TWS. However, RE starts much faster than TWS.
As a result, RE failed to connect because TWS wasn't yet running. I have selected to automatically reconnect every 5 seconds but the TWS plugin never connected to TWS. I had left it running for hours and TWS was definitely up and running. Not sure why it didn't connect.
When I did finally login to the machine, I manually started the live feed without any problems. However, manually starting the live strategy resulted in an output message: cannot write to strategy.dll. To solve this I had to restart RE.
These are some of the problems I've encountered when trying to automate a couple of strategies with IB so any assistance, comments, tips, work-arounds would be hugely appreciated.