//Retreive data from config to initialise the rule public override void Init() { //At a minumum need SymbolCode & CloseTime or CloseMinsFromOpen if (StrategyConfig.Config.TryGetValue(StrategyConfiguration.EXCHANGE, out SymbolCode)) { IsInitialised = false; } if (SymbolCode == "" || SymbolCode == null) { IsInitialised = false; } bool initSuccess = false; if (RuleConfig.Params.TryGetValue(RuleConfiguration.REDUCERISKAFTEROPEN, out object reduceRiskAfterOpen)) { if (TimeSpan.TryParse(reduceRiskAfterOpen.ToString(), out ReduceRiskAfterOpen)) { initSuccess = true; } } if (RuleConfig.Params.TryGetValue(RuleConfiguration.REDUCERISKTIME, out object reduceRiskTime)) { if (TimeSpan.TryParse(reduceRiskTime.ToString(), out ReduceRiskTime)) { initSuccess = true; } } if (!initSuccess) { IsInitialised = false; } DateTimeZoneCalc = new DateTimeZoneCalculator(SymbolCode); //Wait until OpenForTrading notifies before becoming active IsActive = false; }
//Retreive data from config to initialise the rule public override void Init() { //At a minumum need SymbolCode & CloseTime or CloseMinsFromOpen SymbolCode = StrategyConfig.Exchange; if (SymbolCode == "" || SymbolCode == null) { IsInitialised = false; } bool initSuccess = false; if (RuleConfig.Params.TryGetValue(RuleConfiguration.REDUCERISKAFTEROPEN, out object reduceRiskAfterOpen)) { if (TimeSpan.TryParse(reduceRiskAfterOpen.ToString(), out ReduceRiskAfterOpen)) { initSuccess = true; } } if (RuleConfig.Params.TryGetValue(RuleConfiguration.REDUCERISKTIME, out object reduceRiskTime)) { if (TimeSpan.TryParse(reduceRiskTime.ToString(), out ReduceRiskTime)) { initSuccess = true; } } if (!initSuccess) { IsInitialised = false; } DateTimeZoneCalc = new DateTimeZoneCalculator(SymbolCode); //Listen for state updates for the OpenTime StateManager.ListenForStateUpdates(); }
//Retreive data from config to initialise the rule public override void Init() { //At a minumum need SymbolCode & CloseTime or CloseMinsFromOpen SymbolCode = StrategyConfig.Exchange; if (String.IsNullOrEmpty(SymbolCode)) { IsInitialised = false; } bool initSuccess = false; if (RuleConfig.Params.TryGetValue(RuleConfiguration.TERMINATEAFTEROPEN, out object terminateAfterOpen)) { if (TimeSpan.TryParse(terminateAfterOpen.ToString(), out TerminateAfterOpen)) { initSuccess = true; } } if (RuleConfig.Params.TryGetValue(RuleConfiguration.TERMINATETIME, out object terminateTime)) { if (TimeSpan.TryParse(terminateTime.ToString(), out TerminateTime)) { initSuccess = true; } } if (!initSuccess) { IsInitialised = false; } DateTimeZoneCalc = new DateTimeZoneCalculator(SymbolCode); //Listen for state updates for the OpenTime StateManager.ListenForStateUpdates(); }
public override void Init() { //At a minumum need SymbolCode to determine TimeZone & OpenTime SymbolCode = StrategyConfig.Exchange; if (String.IsNullOrEmpty(SymbolCode)) { IsInitialised = false; } if (!RuleConfig.Params.TryGetValue(RuleConfiguration.OPENTIME, out object openTime)) { IsInitialised = false; } ; if (!TimeSpan.TryParse(openTime.ToString(), out OpenTime)) { IsInitialised = false; } //Configure which days of the week to trade if (RuleConfig.Params.TryGetValue(RuleConfiguration.OPENWEEKDAYS, out object openWeekDays)) { if (openWeekDays is IEnumerable OpenWeekDaysArray) { foreach (object day in OpenWeekDaysArray) { switch (day.ToString()) { case "Monday": OpenMonday = true; break; case "Tuesday": OpenTuesday = true; break; case "Wednesday": OpenWednesday = true; break; case "Thursday": OpenThursday = true; break; case "Friday": OpenFriday = true; break; case "Saturday": OpenSaturday = true; break; case "Sunday": OpenSunday = true; break; } } } } //Configure specific dates to trade if (RuleConfig.Params.TryGetValue(RuleConfiguration.OPENANYDATE, out object openAnyDate)) { Boolean.TryParse(openAnyDate.ToString(), out OpenAnyDate); } if (!OpenAnyDate) { if (RuleConfig.Params.TryGetValue(RuleConfiguration.OPENDATES, out object openDates)) { if (openDates is IEnumerable OpenDatesArray) { foreach (object date in OpenDatesArray) { if (DateTime.TryParse(date.ToString(), out DateTime dateTime)) { OpenDates.Add(dateTime); } } } } } DateTimeZoneCalc = new DateTimeZoneCalculator(SymbolCode); }