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

Event Filter - submit two events
http://www.smartquant.com/forums/viewtopic.php?f=60&t=14981
Page 1 of 1

Author:  mikembb [ Mon Oct 28, 2019 3:41 pm ]
Post subject:  Event Filter - submit two events

Dear Team,

could you please assist me, on how I could send submit a bar in the below code in addition to the trade that fired the event in the first place?


Code:
public override Event Filter(Event e)
        {
                switch (e.TypeId)
                {
                    case DataObjectType.Level2:
                        return null;

                    case EventType.Trade:
                        var t = (Trade)e;

                        var b = new Bar(t.DateTime, t.DateTime.AddSeconds(1), t.InstrumentId, BarType.Time, 1, t.Price, t.Price, t.Price, t.Price, t.Size);
                        ///How can I submit this bar in addition to the trade?
                        return t;
                }
        }



Thanks
Mike

Author:  skuvv [ Mon Oct 28, 2019 5:01 pm ]
Post subject:  Re: Event Filter - submit two events

Hi,
sending events from a filter is not a good idea, however you can do it using
framework.EventManager.OnEvent(e);
You can keep framework in your constructor for future use.

Author:  mikembb [ Mon Oct 28, 2019 6:13 pm ]
Post subject:  Re: Event Filter - submit two events

thanks.

Could you help me on how I can put a bar into a Event (e)?

Thanks
Mike

Author:  skuvv [ Tue Oct 29, 2019 9:46 am ]
Post subject:  Re: Event Filter - submit two events

Bar inherits from Event, so just put it:
Code:
framework.EventManager.OnEvent(bar);

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