public void Init() { Utils.Logger.Info("****WebsitesMonitor:Init()"); var sqTask = new SqTask() { Name = "WebsitesMonitor", ExecutionFactory = WebsitesMonitorExecution.ExecutionFactoryCreate, }; sqTask.Triggers.Add(new SqTrigger() { Name = "SpIndexChanges", SqTask = sqTask, TriggerType = TriggerType.DailyOnUsaMarketDay, // Market close is sometimes 16:00, sometimes 13:00. Better to be relative to market open. // 5min after release time 17:15 ET, which is 1h15min after market close. Market open: 9:30 ET. Start = new RelativeTime() { Base = RelativeTimeBase.BaseOnUsaMarketOpen, TimeOffset = TimeSpan.FromMinutes((17 - 9.5) * 60 + 20) }, TriggerSettings = new Dictionary <object, object>() { { TaskSetting.ActionType, WsMonTaskSettingAction.SpIndexChanges } } }); SqTaskScheduler.gSqTasks.Add(sqTask); }
public void Init() { Utils.Logger.Info("****Overmind:Init()"); var sqTask = new SqTask() { Name = "Overmind", ExecutionFactory = OvermindExecution.ExecutionFactoryCreate, }; sqTask.Triggers.Add(new SqTrigger() { Name = "MorningCheck", SqTask = sqTask, TriggerType = TriggerType.Daily, Start = new RelativeTime() { Base = RelativeTimeBase.BaseOnAbsoluteTimeMidnightUtc, TimeOffset = TimeSpan.FromMinutes(9 * 60 + 5) }, // Activate every day 9:05 UTC, TriggerSettings = new Dictionary <object, object>() { { TaskSetting.ActionType, OvermindTaskSettingAction.MorningCheck } } }); sqTask.Triggers.Add(new SqTrigger() { Name = "MiddayCheck", SqTask = sqTask, TriggerType = TriggerType.Daily, Start = new RelativeTime() { Base = RelativeTimeBase.BaseOnAbsoluteTimeMidnightUtc, TimeOffset = TimeSpan.FromMinutes(16 * 60 + 45) }, // Activate every day 16:45 UTC TriggerSettings = new Dictionary <object, object>() { { TaskSetting.ActionType, OvermindTaskSettingAction.MiddayCheck } } }); SqTaskScheduler.gSqTasks.Add(sqTask); }
// Another feauture that was not implemented. Maybe not needed ever: //Periodically check that VirtualBroker is alive and ready(every 60 minutes, if no answer for second time, make phonecall). Skip this one. Reasons: //- not easy to implement.VBroker should be happy to get incoming Tcp messages //- that is unusual, and it means I have to play with security, allowing another IP to access the VBroker server. But when IPs change, that is a lot of hassle //- currently, there are 2 extra simulations intraday. If VbServer is down, the simulation that is 30min before marketClose would be spotted by HealthMon. //- this feature can be mimicked: buy doing UberVXX task Simulation every hour.In that case VBrokerMonitorScheduler will notice that OK message didn't come in the last hour. //- Sum: this feauture is not necessary, and takes time to implement.Don't do it now. private void AddVbTasksToScheduler() { try { var uberVxxTask = new SqTask() { Name = "UberVXX", NameForTextToSpeech = "Uber V X X ", ExecutionFactory = HmVbTradeStrategyExecution.ExecutionFactoryCreate, }; uberVxxTask.Triggers.Add(new SqTrigger() { Name = "MarketOpen+25min", SqTask = uberVxxTask, TriggerType = TriggerType.DailyOnUsaMarketDay, Start = new RelativeTime() { Base = RelativeTimeBase.BaseOnUsaMarketOpen, TimeOffset = TimeSpan.FromMinutes(25) } }); uberVxxTask.Triggers.Add(new SqTrigger() { Name = "MarketClose-35min", SqTask = uberVxxTask, TriggerType = TriggerType.DailyOnUsaMarketDay, Start = new RelativeTime() { Base = RelativeTimeBase.BaseOnUsaMarketClose, TimeOffset = TimeSpan.FromMinutes(-35) } }); uberVxxTask.Triggers.Add(new SqTrigger() { Name = "MarketClose-15sec", SqTask = uberVxxTask, TriggerType = TriggerType.DailyOnUsaMarketDay, Start = new RelativeTime() { Base = RelativeTimeBase.BaseOnUsaMarketClose, TimeOffset = TimeSpan.FromMinutes(-15) } // from -20sec to -15sec. From start, the trade executes in 2seconds }); SqTaskScheduler.gSqTasks.Add(uberVxxTask); var harryLongTask = new SqTask() { Name = "HarryLong", NameForTextToSpeech = "Harry Long ", ExecutionFactory = HmVbTradeStrategyExecution.ExecutionFactoryCreate, }; harryLongTask.Triggers.Add(new SqTrigger() { Name = "MarketOpen+30min", SqTask = harryLongTask, TriggerType = TriggerType.DailyOnUsaMarketDay, Start = new RelativeTime() { Base = RelativeTimeBase.BaseOnUsaMarketOpen, TimeOffset = TimeSpan.FromMinutes(30) } }); harryLongTask.Triggers.Add(new SqTrigger() { Name = "MarketClose-31min", SqTask = harryLongTask, TriggerType = TriggerType.DailyOnUsaMarketDay, Start = new RelativeTime() { Base = RelativeTimeBase.BaseOnUsaMarketClose, TimeOffset = TimeSpan.FromMinutes(-31) } }); harryLongTask.Triggers.Add(new SqTrigger() { Name = "MarketClose-11sec", SqTask = harryLongTask, TriggerType = TriggerType.DailyOnUsaMarketDay, Start = new RelativeTime() { Base = RelativeTimeBase.BaseOnUsaMarketClose, TimeOffset = TimeSpan.FromMinutes(-11) } // Give UberVXX priority (executing at -15sec). That is more important because that can change from full 100% long to -200% short. This Harry Long strategy just slowly modifies weights, so if one trade is missed, it is not a problem. }); SqTaskScheduler.gSqTasks.Add(harryLongTask); } catch (Exception e) { Utils.Logger.Error(e, "AddVbTasksToScheduler"); //HealthMonitorMessage.SendException("BrokerScheduler.RecreateTasksAndLoop Thread", e, HealthMonitorMessageID.ReportErrorFromVirtualBroker); } }
public void Init() { Utils.Logger.Info("****BrAccChecker:Init()"); var sqTask = new SqTask() { Name = "BrAccChecker", ExecutionFactory = BrAccCheckerExecution.ExecutionFactoryCreate, }; // trigger times: it is worth doing: 5 minutes after Open, 5 minutes after close, because that is when trades happen. // also schedule at every whole hours: 10:00, 11:00, ... but if it is OTH, only execute portfolio position updates if lastDate is more than 5h old. // user can also initiate forced update, but this is the automatic ones. sqTask.Triggers.Add(new SqTrigger() { Name = "AtApplicationStartupCheck", SqTask = sqTask, TriggerType = TriggerType.AtApplicationStartup, Start = new RelativeTime() { Base = RelativeTimeBase.Unknown, TimeOffset = TimeSpan.FromSeconds(10) }, // a bit later then App startup, to give time to Gateways to connect TriggerSettings = new Dictionary <object, object>() { { TaskSetting.ActionType, BrAccCheckerTaskSettingAction.AtApplicationStartupCheck } } }); sqTask.Triggers.Add(new SqTrigger() { Name = "OpenCheck", SqTask = sqTask, TriggerType = TriggerType.DailyOnUsaMarketDay, Start = new RelativeTime() { Base = RelativeTimeBase.BaseOnUsaMarketOpen, TimeOffset = TimeSpan.FromMinutes(5) }, TriggerSettings = new Dictionary <object, object>() { { TaskSetting.ActionType, BrAccCheckerTaskSettingAction.OpenCheck } } }); sqTask.Triggers.Add(new SqTrigger() { Name = "CloseCheck", SqTask = sqTask, TriggerType = TriggerType.DailyOnUsaMarketDay, Start = new RelativeTime() { Base = RelativeTimeBase.BaseOnUsaMarketClose, TimeOffset = TimeSpan.FromMinutes(5) }, TriggerSettings = new Dictionary <object, object>() { { TaskSetting.ActionType, BrAccCheckerTaskSettingAction.CloseCheck } } }); // at every whole hours: 10:10, 11:10, ... but not in OTH, when positions will not change sqTask.Triggers.Add(new SqTrigger() { Name = "PeriodicCheck", SqTask = sqTask, TriggerType = TriggerType.Periodic, Start = new RelativeTime() { Base = RelativeTimeBase.BaseOnAbsoluteTimeAtEveryHourUtc, TimeOffset = TimeSpan.FromMinutes(10) }, TriggerSettings = new Dictionary <object, object>() { { TaskSetting.ActionType, BrAccCheckerTaskSettingAction.PeriodicCheck } } }); SqTaskScheduler.gSqTasks.Add(sqTask); }