Skip to content

TWS returns bad AgentDescription "0" (started 2016-01-07) and throws InvalidCastException #15

@DrKoch

Description

@DrKoch

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();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions