Ejemplo n.º 1
0
            public IndexSeriesInfo(ICandleManager candleManager, Type candleType, IEnumerable <CandleSeries> innerSeries, DateTimeOffset?from, DateTimeOffset?to, IndexSecurity security, Action <Candle> processing, Action stopped)
            {
                if (innerSeries == null)
                {
                    throw new ArgumentNullException(nameof(innerSeries));
                }

                if (security == null)
                {
                    throw new ArgumentNullException(nameof(security));
                }

                _candleManager = candleManager ?? throw new ArgumentNullException(nameof(candleManager));
                _innerSeries   = innerSeries.ToHashSet();
                _from          = from;
                _to            = to;
                _processing    = processing ?? throw new ArgumentNullException(nameof(processing));
                _stopped       = stopped ?? throw new ArgumentNullException(nameof(stopped));

                candleManager.Processing += OnInnerSourceProcessCandle;
                candleManager.Stopped    += OnInnerSourceStopped;

                _builder = new IndexCandleBuilder(security, candleType, security.IgnoreErrors);

                //_innerSeries.ForEach(s =>
                //{
                //	s.ProcessCandle += OnInnerSourceProcessCandle;
                //	s.Stopped += OnInnerSourceStopped;

                //	_startedSeriesCount++;
                //});
            }
            public IndexSeriesInfo(ICandleManager candleManager, IEnumerable <CandleSeries> innerSeries, DateTimeOffset from, DateTimeOffset to, IndexSecurity security, Action <Candle> processing, Action stopped)
            {
                if (candleManager == null)
                {
                    throw new ArgumentNullException("candleManager");
                }

                if (innerSeries == null)
                {
                    throw new ArgumentNullException("innerSeries");
                }

                if (security == null)
                {
                    throw new ArgumentNullException("security");
                }

                if (processing == null)
                {
                    throw new ArgumentNullException("processing");
                }

                if (stopped == null)
                {
                    throw new ArgumentNullException("stopped");
                }

                _candleManager = candleManager;
                _innerSeries   = innerSeries;
                _from          = from;
                _to            = to;
                _processing    = processing;
                _stopped       = stopped;

                _builder = new IndexCandleBuilder(security);

                _innerSeries.ForEach(s =>
                {
                    s.ProcessCandle += OnInnerSourceProcessCandle;
                    s.Stopped       += OnInnerSourceStopped;

                    _startedSeriesCount++;
                });
            }
Ejemplo n.º 3
0
        void ICandleSource <Candle> .Start(CandleSeries series, DateTimeOffset?from, DateTimeOffset?to)
        {
            if (series == null)
            {
                throw new ArgumentNullException(nameof(series));
            }

            var indexSecurity = (IndexSecurity)series.Security;

            var basketInfo = new IndexSeriesInfo(_candleManager,
                                                 series.CandleType,
                                                 indexSecurity
                                                 .GetInnerSecurities(_securityProvider)
                                                 .Select(sec => new CandleSeries(series.CandleType, sec, IndexCandleBuilder.CloneArg(series.Arg, sec))
            {
                WorkingTime = series.WorkingTime.Clone(),
            })
                                                 .ToArray(),
                                                 from, to, indexSecurity,
                                                 c =>
            {
                //if (c.Series == null)
                //{
                //	c.Series = series;
                //	c.Source = this;
                //}

                _candleManager.Container.AddCandle(series, c);
                Processing?.Invoke(series, c);
            },
                                                 () => Stopped?.Invoke(series));

            _info.Add(series, basketInfo);

            basketInfo.Start();
        }