public override void Write(BinaryWriter writer, object obj) { byte value = 0; writer.Write(value); StrategyStatusInfo strategyStatusInfo = obj as StrategyStatusInfo; writer.Write(strategyStatusInfo.DateTime.Ticks); writer.Write((byte)strategyStatusInfo.Type); writer.Write(strategyStatusInfo.Solution); writer.Write(strategyStatusInfo.Mode); }
public void StartStrategy(Strategy strategy, StrategyMode mode) { this.strategy = strategy; if (mode == StrategyMode.Backtest) { this.framework.Mode = FrameworkMode.Simulation; } else { this.framework.Mode = FrameworkMode.Realtime; } if (this.framework.eventManager.status != EventManagerStatus.Running) { this.framework.eventManager.Start(); } StrategyStatusInfo strategyStatusInfo = new StrategyStatusInfo(this.framework.clock.DateTime, StrategyStatusType.Started); strategyStatusInfo.Solution = ((strategy.Name == null) ? "Solution" : strategy.Name); strategyStatusInfo.Mode = mode.ToString(); this.framework.eventServer.OnLog(new GroupEvent(strategyStatusInfo, null)); strategy.OnStrategyStart_(); if (!this.framework.IsExternalDataQueue) { Dictionary<IDataProvider, InstrumentList> dictionary = new Dictionary<IDataProvider, InstrumentList>(); while (this.requests.Count != 0) { Dictionary<IDataProvider, InstrumentList> dictionary2 = new Dictionary<IDataProvider, InstrumentList>(this.requests); this.requests.Clear(); foreach (KeyValuePair<IDataProvider, InstrumentList> current in new Dictionary<IDataProvider, InstrumentList>(dictionary2)) { InstrumentList instrumentList = null; if (!dictionary.TryGetValue(current.Key, out instrumentList)) { instrumentList = new InstrumentList(); dictionary[current.Key] = instrumentList; } InstrumentList instrumentList2 = new InstrumentList(); foreach (Instrument current2 in current.Value) { if (!instrumentList.Contains(current2)) { instrumentList.Add(current2); instrumentList2.Add(current2); } } if (current.Key is SellSideStrategy && this.framework.SubscriptionManager != null) { this.framework.SubscriptionManager.Subscribe(current.Key, instrumentList2); } } } this.status = StrategyStatus.Running; this.requests = dictionary; if (this.requests.Count == 0) { Console.WriteLine(string.Concat(new object[] { DateTime.Now, " StrategyManager::StartStrategy ", strategy.Name, " has no data requests, stopping..." })); this.StopStrategy(); return; } foreach (KeyValuePair<IDataProvider, InstrumentList> current3 in this.requests) { if (!(current3.Key is SellSideStrategy) && this.framework.SubscriptionManager != null) { this.framework.SubscriptionManager.Subscribe(current3.Key, current3.Value); } } } }
public void StartStrategy(Strategy strategy, StrategyMode mode) { this.strategy = strategy; if (mode == StrategyMode.Backtest) { this.framework.Mode = FrameworkMode.Simulation; } else { this.framework.Mode = FrameworkMode.Realtime; } if (this.framework.eventManager.status != EventManagerStatus.Running) { this.framework.eventManager.Start(); } StrategyStatusInfo strategyStatusInfo = new StrategyStatusInfo(this.framework.clock.DateTime, StrategyStatusType.Started); strategyStatusInfo.Solution = ((strategy.Name == null) ? "Solution" : strategy.Name); strategyStatusInfo.Mode = mode.ToString(); this.framework.eventServer.OnLog(new GroupEvent(strategyStatusInfo, null)); strategy.OnStrategyStart_(); if (!this.framework.IsExternalDataQueue) { Dictionary <IDataProvider, InstrumentList> dictionary = new Dictionary <IDataProvider, InstrumentList>(); while (this.requests.Count != 0) { Dictionary <IDataProvider, InstrumentList> dictionary2 = new Dictionary <IDataProvider, InstrumentList>(this.requests); this.requests.Clear(); foreach (KeyValuePair <IDataProvider, InstrumentList> current in new Dictionary <IDataProvider, InstrumentList>(dictionary2)) { InstrumentList instrumentList = null; if (!dictionary.TryGetValue(current.Key, out instrumentList)) { instrumentList = new InstrumentList(); dictionary[current.Key] = instrumentList; } InstrumentList instrumentList2 = new InstrumentList(); foreach (Instrument current2 in current.Value) { if (!instrumentList.Contains(current2)) { instrumentList.Add(current2); instrumentList2.Add(current2); } } if (current.Key is SellSideStrategy && this.framework.SubscriptionManager != null) { this.framework.SubscriptionManager.Subscribe(current.Key, instrumentList2); } } } this.status = StrategyStatus.Running; this.requests = dictionary; if (this.requests.Count == 0) { Console.WriteLine(string.Concat(new object[] { DateTime.Now, " StrategyManager::StartStrategy ", strategy.Name, " has no data requests, stopping..." })); this.StopStrategy(); return; } foreach (KeyValuePair <IDataProvider, InstrumentList> current3 in this.requests) { if (!(current3.Key is SellSideStrategy) && this.framework.SubscriptionManager != null) { this.framework.SubscriptionManager.Subscribe(current3.Key, current3.Value); } } } }