Profile Picture

Decimal separator bug

Posted By Largo 7 Years Ago
Message
Posted Monday January 25 2010
In my country decimal separator for numbers is comma, not dot.
I have installed MS Visual Studio 2008 Pro.

When I try to run live any trading system (even without any my code) RE throws exception and crashes.
It stops on step 4 of 6.

Normally I could change locale within C# code, but it not works in RE:
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US",false);

What to do?



An exception of type System.InvalidOperationException was thrown.
Exception thrown while processing message: AccountValue
w Krs.Ats.IBNet.IBClient.ProcessMsg(IncomingMessage msgId)
w Krs.Ats.IBNet.IBClient.Run()
w System.Threading.ThreadHelper.ThreadStart_Context(Object state)
w System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
w System.Threading.ThreadHelper.ThreadStart()

Inner Exception:
An exception of type System.FormatException was thrown.
Nieprawidłowy format ciągu wejściowego.
w System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
w System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt)
w System.Double.Parse(String s, NumberStyles style, NumberFormatInfo info)
w System.Convert.ToDouble(String value)
w RightEdge.TWSCSharpPlugin.TWSPlugin.client_UpdateAccountValue(Object sender, UpdateAccountValueEventArgs e)
w Krs.Ats.IBNet.IBClient.RaiseEvent[T](EventHandler`1 event, Object sender, T e)
w Krs.Ats.IBNet.IBClient.OnUpdateAccountValue(UpdateAccountValueEventArgs e)
w Krs.Ats.IBNet.IBClient.updateAccountValue(String key, String value, String currency, String accountName)
w Krs.Ats.IBNet.IBClient.ProcessMsg(IncomingMessage msgId)
Posted Tuesday January 26 2010
This will be fixed in the next build, which should be out soon. Until then, you can download the source code for the TWS plugin and fix it yourself. See here for details on how to get the source. You will want to update the client_UpdateAccountValue method in TWSPlugin.cs to use the invariant culture when parsing the account value, like this:

buyingPower = Convert.ToDouble(e.Value, CultureInfo.InvariantCulture);

Thanks,
Daniel
Posted Tuesday January 26 2010
Thank you, Daniel!

Temporarily I changed decimal separator in Windows globally, it works, I can wait for Beta 15 version with this.


Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems