// ********************************************************************** public static void Deactivate() { foreach (IConnector connector in connectors) { IStockProvider sp = connector as IStockProvider; if (sp != null) { sp.Unsubscribe(); } ITicksProvider tp = connector as ITicksProvider; if (tp != null) { tp.Unsubscribe(); } ISettingsProvider stp = connector as ISettingsProvider; if (stp != null) { stp.Unsubscribe(); } ITradesProvider trp = connector as ITradesProvider; if (trp != null) { trp.Unsubscribe(); } } Activated = false; }
// ********************************************************************** static MarketProvider() { foreach (IConnector connector in connectors) { IStockProvider sp = connector as IStockProvider; if (sp != null) { sp.Connected += new StatusUpdateHandler(StockConnected); sp.Disconnected += StockStatus.Disconnected; sp.Broken += StockStatus.SetError; sp.StockHandler += new StockHandler(StockHandler); } ITicksProvider tp = connector as ITicksProvider; if (tp != null) { tp.Connected += TicksStatus.Connected; tp.Disconnected += TicksStatus.Disconnected; tp.Broken += TicksStatus.SetError; tp.TickHandler += new TickHandler(TickHandler); } ISettingsProvider stp = connector as ISettingsProvider; if (stp != null) { stp.Connected += SettingsStatus.Connected; stp.Disconnected += SettingsStatus.Disconnected; stp.Broken += SettingsStatus.SetError; stp.SettingsHandler += new SettingsHandler(SettingsHandler); } ITradesProvider trp = connector as ITradesProvider; if (trp != null) { trp.Connected += TradeStatus.Connected; trp.Disconnected += TradeStatus.Disconnected; trp.Broken += TradeStatus.SetError; trp.TradesHandler += new TradesHandler(TradesHandler); } } Receiver = new IDataReceiver[1]; Receiver[0] = new NullReceiver(); Activated = false; }
// ********************************************************************** public static void Activate() { if (!isReplayMode) { foreach (IConnector connector in connectors) { connector.Setup(); IStockProvider sp = connector as IStockProvider; if (sp != null) { if (sp == stockProvider) { sp.Subscribe(cfg.u.SecCode); } else { sp.Unsubscribe(); } } ITicksProvider tp = connector as ITicksProvider; if (tp != null) { tp.Subscribe(); } ISettingsProvider stp = connector as ISettingsProvider; if (stp != null) { stp.Subscribe(); } ITradesProvider trp = connector as ITradesProvider; if (trp != null) { trp.Subscribe(); } } } Activated = true; }
// ********************************************************************** public static void SetMode(bool replay, bool nullTader) { if (isReplayMode != replay) { if (isReplayMode = replay) { foreach (IConnector connector in connectors) { IStockProvider sp = connector as IStockProvider; if (sp != null) { sp.Unsubscribe(); } ITicksProvider tp = connector as ITicksProvider; if (tp != null) { tp.Unsubscribe(); } ISettingsProvider stp = connector as ISettingsProvider; if (stp != null) { stp.Unsubscribe(); } ITradesProvider trp = connector as ITradesProvider; if (trp != null) { trp.Unsubscribe(); } } } } isNullTrader = nullTader; Activate(); }