ib-csharp
ib-csharp copied to clipboard
TWS returns bad AgentDescription "0" (started 2016-01-07) and throws InvalidCastException
On Thursday 2016-01-07 my Application (usking krs.ats.ib-csharp) suddemly crashed with an InvalidCastException. I trcked this down to happen in IBClient.cs. TWS sends a bad code "0" for AgentDescription.
A possible fix looks like this: IBClient.cs, line 3770:
if (version >= 9)
{
rstr = ReadStr();
AgentDescription ad = AgentDescription.None;
if (!string.IsNullOrEmpty(rstr))
{
try
{
ad = (AgentDescription)EnumDescConverter.GetEnumValue(typeof(AgentDescription), rstr);
}
catch (Exception)
{
ad = AgentDescription.None;
}
}
order.Rule80A = ad;
order.PercentOffset = ReadDouble();
Same issue here. Used your fix temporarily.