Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="period"></param>
        /// <returns></returns>
        public bool ObtainDataBarProvider(TimeSpan period)
        {
            lock (this)
            {
                RuntimeDataSessionInformation sessionInfo = _dataDelivery.GetSymbolRuntimeSessionInformation(SessionInfo.Symbol);

                if (sessionInfo == null)
                {
                    SystemMonitor.OperationError("Failed to retrieve runtime session information for symbol [" + SessionInfo.Symbol.Name + "].");
                    return(false);
                }

                if (false == sessionInfo.AvailableDataBarPeriods.Contains(period))
                {
                    SystemMonitor.OperationError("Period not available for data bar provider creation.");
                    return(false);
                }
            }

            IDataBarHistoryProvider provider;

            lock (this)
            {
                if (_dataBarProviders.ContainsKey(period))
                {
                    SystemMonitor.OperationError("Period data bar already created.");
                    return(false);
                }

                provider = _manager.ObtainDataBarHistoryProvider(_dataDelivery.SourceId,
                                                                 _sessionInfo.Symbol, period);

                _dataBarProviders.Add(period, provider);
            }

            if (_dataBarProvider == null)
            {
                SetCurrentDataBarProvider(period);
            }

            if (DataBarProviderCreatedEvent != null)
            {
                DataBarProviderCreatedEvent(this, provider);
            }

            return(true);
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        bool GetProviders(Symbol symbol, out IQuoteProvider quotes, out IDataBarHistoryProvider bars)
        {
            quotes = _manager.ObtainQuoteProvider(_dataDelivery.SourceId, symbol);
            RuntimeDataSessionInformation sessionInformation = _dataDelivery.GetSymbolRuntimeSessionInformation(symbol);

            if (sessionInformation.AvailableDataBarPeriods == null || sessionInformation.AvailableDataBarPeriods.Count == 0)
            {
                quotes = null;
                bars   = null;
                SystemMonitor.OperationError("Can not close order since no suitable data provider sessions found.");
                return(false);
            }

            bars = _manager.ObtainDataBarHistoryProvider(_dataDelivery.SourceId, symbol, sessionInformation.AvailableDataBarPeriods[0]);

            if (quotes == null || quotes.Ask.HasValue == false || bars == null)
            {
                return(false);
            }

            return(true);
        }