Esempio n. 1
0
		/// <summary>
		/// Получить тайм-фрейм свечи от сервера SmartCOM.
		/// </summary>
		/// <param name="security">Инструмент, для которого необходимо начать получать исторические свечи.</param>
		/// <param name="timeFrame">Тайм-фрейм.</param>
		/// <param name="from">Временная точка отсчета.</param>
		/// <param name="count">Количество свечек.</param>
		/// <param name="direction">Направление поиска относительно параметра from. Если значение равно <see cref="SmartComHistoryDirections.Forward"/>,
		/// то данные ищутся от from в сторону увеличения времени. Если значение равно <see cref="SmartComHistoryDirections.Backward"/>, то свечи
		/// ищутся до from в сторону уменьшения времени.</param>
		public void RequestCandles(Security security, SmartComTimeFrames timeFrame, DateTimeOffset from, long count, SmartComHistoryDirections direction)
		{
			if (security == null)
				throw new ArgumentNullException("security");

			if (timeFrame == null)
				throw new ArgumentNullException("timeFrame");

			if (count <= 0)
				throw new ArgumentOutOfRangeException("count", count, LocalizedStrings.Str1890);

			// http://stocksharp.com/forum/yaf_postst658_provierka-na-vriemia-birzhi-pri-zaghruzkie-istorii.aspx
			//if (from > MarketTime)
			//	throw new ArgumentOutOfRangeException("from", from, "Параметр from не может быть больше текущего времени биржи.");

			//var token = _candleTokens.SafeAdd(new Tuple<Security, SmartTimeFrames>(security, timeFrame), key => new CandleToken(security, timeFrame));

			var transactionId = TransactionIdGenerator.GetNextId();
			var tf = (TimeSpan)timeFrame;

			var scope = Scope<CandleSeries>.Current;
			_series.Add(transactionId, scope == null ? new CandleSeries(typeof(TimeFrameCandle), security, tf) : scope.Value);

			SendInMessage(new MarketDataMessage
			{
				TransactionId = transactionId,
				//SecurityId = GetSecurityId(security),
				From = from,
				DataType = MarketDataTypes.CandleTimeFrame,
				Arg = tf,
				IsSubscribe = true,
				Count = count,
				ExtensionInfo = new Dictionary<object, object>
				{
					{ "Direction", direction },
				}
			}.FillSecurityInfo(this, security));
		}
Esempio n. 2
0
        /// <summary>
        /// Получить тайм-фрейм свечи от сервера SmartCOM.
        /// </summary>
        /// <param name="security">Инструмент, для которого необходимо начать получать исторические свечи.</param>
        /// <param name="timeFrame">Тайм-фрейм.</param>
        /// <param name="from">Временная точка отсчета.</param>
        /// <param name="count">Количество свечек.</param>
        /// <param name="direction">Направление поиска относительно параметра from. Если значение равно <see cref="SmartComHistoryDirections.Forward"/>,
        /// то данные ищутся от from в сторону увеличения времени. Если значение равно <see cref="SmartComHistoryDirections.Backward"/>, то свечи
        /// ищутся до from в сторону уменьшения времени.</param>
        public void RequestCandles(Security security, SmartComTimeFrames timeFrame, DateTimeOffset from, long count, SmartComHistoryDirections direction)
        {
            if (security == null)
            {
                throw new ArgumentNullException(nameof(security));
            }

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

            if (count <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(count), count, LocalizedStrings.Str1890);
            }

            // http://stocksharp.com/forum/yaf_postst658_provierka-na-vriemia-birzhi-pri-zaghruzkie-istorii.aspx
            //if (from > MarketTime)
            //	throw new ArgumentOutOfRangeException("from", from, "Параметр from не может быть больше текущего времени биржи.");

            //var token = _candleTokens.SafeAdd(new Tuple<Security, SmartTimeFrames>(security, timeFrame), key => new CandleToken(security, timeFrame));

            var transactionId = TransactionIdGenerator.GetNextId();
            var tf            = (TimeSpan)timeFrame;

            var scope = Scope <CandleSeries> .Current;

            _series.Add(transactionId, scope == null ? new CandleSeries(typeof(TimeFrameCandle), security, tf) : scope.Value);

            SendInMessage(new MarketDataMessage
            {
                TransactionId = transactionId,
                //SecurityId = GetSecurityId(security),
                From          = from,
                DataType      = MarketDataTypes.CandleTimeFrame,
                Arg           = tf,
                IsSubscribe   = true,
                Count         = count,
                ExtensionInfo = new Dictionary <object, object>
                {
                    { "Direction", direction },
                }
            }.FillSecurityInfo(this, security));
        }