I really need your help on this one. I've been banging my head for hours. Here's the problem: I'm trying to use R.Net to execute some r functions as part of my trading system. If a open RightEdge and start a simulation, everything works as expected, the simulation ends, and there are no errors. However, if I start a second simulation, RightEdge hangs on the call to REngine.GetInstance() and even clicking cancel won't work. If I open RightEdge again and start another simulation, everything works again.
It's important to note that R.Net is expected to work as a singleton. The only way to create an REngine instance is to call REngine.GetInstance(). I initially tought that my problem was in my r code, so I started logging all output and error message from R to a file. It turns out that my code runs properly, however after the simulation is completed the log file cannot be deleted because it's still being used by RightEdge. I suspect that the problem is that RightEdge doesn't completely dispose and release the trading system at the end of a simulation.
You can easily repro this problem as follows.
1. Create a new RightEdge trading system with the default (empty) template
2. Download R.Net 1.6
and Dynamic Interop 0.7.4
and unpack the packages
3. Reference RDotNet.dll, RDotNet.NativeLibrary.dll, and DynamicInterop.dll in your project
4. Replace MySystem with the class definition below
5. Select a short time range a run the simulation one time
6. Try to delete temp.txt in the RightEdge program folder, you should get an error message that the file is being used
7. Run the simulation again, this time RightEdge should hang forever
8. Become my hero by fixing this problem!
public class MySystem : MySystemBase
public override void Startup()
REngine engine = REngine.GetInstance();
engine.Evaluate(@"logger = file('test.txt', open='w')");
Please note that I played with the Dispose() but I couldn't find anything that works. I really hope you guys can help me with this!