示例#1
0
		protected override void OnStarted()
		{
			Logger.Info("Waiting for TraderConnected event.");
			_connectorManager.TraderConnectedEvent.WaitOne();

			Connector = _connectorManager.Trader;

			Logger.Info("Waiting for PortfolioFoundEvent event.");
			PortfolioFoundEvent.WaitOne();

			Portfolio = _portfolio;

			Logger.Info("Waiting for SecurityFound event.");
			SecurityFoundEvent.WaitOne();

			Logger.Info("Configuring QStrategy.");

			Security = _security;
			Volume = _strategyConfiguration.Volume;

			_ordersCheckTimer = new Timer(CheckOrdersElapsed, null, 0, _strategyConfiguration.OrdersCheckInterval.Milliseconds);

			_series = new CandleSeries(typeof(TimeFrameCandle), _security, _strategyConfiguration.CandleTimeFrame)
			{
				From = CurrentTime - TimeSpan.FromTicks(_strategyConfiguration.CandleTimeFrame.Ticks * _strategyConfiguration.IndicatorLength)
			};

			_connectorManager.CandleManager.Start(_series);

			Security
				.WhenChanged(Connector)
				.Do(ProcessSecurityChange)
				.Apply(this);

			_series
				.WhenCandlesChanged()
				.Do(ProcessCandle)
				.Apply(this);

			base.OnStarted();
		}