SmartQuant Discussion
http://www.smartquant.com/forums/

IB Provider - Level2Update Exception
http://www.smartquant.com/forums/viewtopic.php?f=86&t=14726
Page 1 of 1

Author:  mikembb [ Thu Jul 20, 2017 11:47 am ]
Post subject:  IB Provider - Level2Update Exception

Dear Team,

my client has upgraded to Version: 1.0.6407.31947 and he got the following error with the IB provider when subscribing for SP and VIX future:
Quote:
EventManager::OnException Exception occured in EventHandler - 07/19/2017 15:57:44.213 SmartQuant.Level2Update - System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
at System.Collections.Generic.SortedList`2.RemoveAt(Int32 index)
at SmartQuant.OrderBook.Set(Level2Update update)
at SmartQuant.DataManager.vA6tN4tX0w(Level2Update )
at SmartQuant.EventManager.qmfsIbV3aI(Event )
at SmartQuant.EventManager.OnEvent(Event e)

Time is in EST.

With his previous version, this did not happen.

Any idea what might have changed that caused this error?

Thanks
Mike

Author:  mikembb [ Thu Apr 12, 2018 3:41 pm ]
Post subject:  Re: IB Provider - Level2Update Exception

Hi there.

I fixed it with this MyEventFilter.cs

Code:
using System;
using System.Collections.Generic;
using SmartQuant;

namespace OpenQuant
{
    public class MyEventFilter : EventFilter
    {
        public MyEventFilter(Framework framework)
            : base(framework)
        {
            //Global
        }

        public override Event Filter(Event e)
        {
            try
            {
                switch (e.TypeId)
                {
                    case DataObjectType.Level2:
                    case DataObjectType.Level2Snapshot:
                    case DataObjectType.Level2Update:

                        return null;
                        break;
                }
                return e;
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error in MyEventsFilter. Error is: {0}", ex.Message);
                return null;
            }
        }
    }
}


and this call in the Scenario:
framework.EventManager.Filter = new MyEventFilter(framework);

therefore, I conclude, that it is not possible to use Level2 data with the IB provider as of now.

Page 1 of 1 All times are UTC + 3 hours
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/