Beispiel #1
0
        protected override TimeSpan OnProcess()
        {
            var source = new RtsHistorySource
            {
                IsSystemOnly           = _settings.IsSystemOnly,
                LoadEveningSession     = _settings.LoadEveningSession,
                SaveRtsStdTrades       = _settings.SaveRtsStdTrades,
                SaveRtsStdCombinedOnly = _settings.SaveRtsStdCombinedOnly
            };

            if (_settings.UseTemporaryFiles != TempFiles.NotUse)
            {
                source.DumpFolder = GetTempPath();
            }

            // если фильтр по инструментам выключен (выбран инструмент все инструменты)
            var allSecurity = this.GetAllSecurity();
            var usdRur      = GetUsdRur(source.SecurityIdGenerator.GenerateId("USD/RUR", ExchangeBoard.Forts));

            var startDate = _settings.StartFrom;
            var endDate   = DateTime.Today - TimeSpan.FromDays(_settings.DayOffset);

            var allDates = startDate.Range(endDate, TimeSpan.FromDays(1)).ToArray();

            var secMap = new HashSet <Security>();

            if (allSecurity == null)
            {
                secMap.AddRange(Settings.Securities.Select(s => s.Security));
            }

            foreach (var date in allDates)
            {
                if (!CanProcess())
                {
                    break;
                }

                if (_settings.IgnoreWeekends && !ExchangeBoard.Forts.IsTradeDate(date.ApplyTimeZone(ExchangeBoard.Forts.TimeZone), true))
                {
                    this.AddDebugLog(LocalizedStrings.WeekEndDate, date);
                    continue;
                }

                this.AddInfoLog(LocalizedStrings.Str2823Params, date);

                var trades = source.LoadTicks(EntityRegistry.Securities, date);

                if (trades.Count == 0)
                {
                    this.AddDebugLog(LocalizedStrings.NoData);
                }
                else
                {
                    if (allSecurity == null)
                    {
                        trades = trades.Where(p => secMap.Contains(p.Key)).ToDictionary();
                    }

                    foreach (var pair in trades)
                    {
                        SaveSecurity(pair.Key);
                        SaveTicks(pair.Key, pair.Value);
                    }
                }

                if (_settings.UseTemporaryFiles == TempFiles.UseAndDelete)
                {
                    var dir = source.GetDumpFile(null, date, date, typeof(ExecutionMessage), ExecutionTypes.Tick);

                    if (Directory.Exists(dir))
                    {
                        Directory.Delete(dir, true);
                    }
                }

                _settings.StartFrom = date.AddDays(1);
                SaveSettings();
            }

            if (_settings.IsDownloadUsdRate)
            {
                var usdRurStorage = StorageRegistry.GetTradeStorage(usdRur, _settings.Drive, _settings.StorageFormat);

                foreach (var date in _settings.UsdRurStartFrom
                         .Range(endDate, TimeSpan.FromDays(1))
                         .Except(usdRurStorage.Dates))
                {
                    if (!CanProcess())
                    {
                        break;
                    }

                    if (_settings.IgnoreWeekends && !usdRur.Board.IsTradeDate(date.ApplyTimeZone(ExchangeBoard.Forts.TimeZone), true))
                    {
                        this.AddDebugLog(LocalizedStrings.WeekEndDate, date);
                        continue;
                    }

                    this.AddInfoLog(LocalizedStrings.Str2294Params, date, usdRur.Id);

                    var rate = FortsDailyData.GetRate(usdRur, date, date.Add(TimeSpan.FromDays(1)));

                    if (rate.Count == 0)
                    {
                        this.AddDebugLog(LocalizedStrings.NoData);
                    }
                    else
                    {
                        SaveTicks(usdRur, rate.Select(p => new ExecutionMessage
                        {
                            SecurityId    = usdRur.ToSecurityId(),
                            TradePrice    = p.Value,
                            ServerTime    = p.Key,
                            ExecutionType = ExecutionTypes.Tick
                        }).OrderBy(t => t.ServerTime));
                    }

                    _settings.UsdRurStartFrom = date.AddDays(1);
                    SaveSettings();
                }
            }

            if (CanProcess())
            {
                this.AddInfoLog(LocalizedStrings.Str2300);
            }

            return(base.OnProcess());
        }
Beispiel #2
0
        protected override TimeSpan OnProcess()
        {
            var source = new RtsHistorySource
            {
                ExchangeBoard = ExchangeBoard.Ux,
                IsSystemOnly  = _settings.IsSystemOnly,
            };

            if (_settings.UseTemporaryFiles != TempFiles.NotUse)
            {
                source.DumpFolder = GetTempPath();
            }

            // если фильтр по инструментам выключен (выбран инструмент все инструменты)
            var allSecurity = this.GetAllSecurity();

            var startDate = _settings.StartFrom;
            var endDate   = DateTime.Today - TimeSpan.FromDays(_settings.DayOffset);

            var allDates = startDate.Range(endDate, TimeSpan.FromDays(1)).ToArray();

            var secMap = new HashSet <Security>();

            if (allSecurity == null)
            {
                secMap.AddRange(Settings.Securities.Select(s => s.Security));
            }

            foreach (var date in allDates)
            {
                if (!CanProcess())
                {
                    break;
                }

                if (_settings.IgnoreWeekends && !ExchangeBoard.Ux.WorkingTime.IsTradeDate(date, true))
                {
                    this.AddDebugLog(LocalizedStrings.WeekEndDate, date);
                    continue;
                }

                this.AddInfoLog(LocalizedStrings.Str2823Params, date);

                var trades = source.LoadTrades(EntityRegistry.Securities, date);

                if (trades.Count == 0)
                {
                    this.AddDebugLog(LocalizedStrings.NoData);
                }
                else
                {
                    if (allSecurity == null)
                    {
                        trades = trades.Where(p => secMap.Contains(p.Key)).ToDictionary();
                    }

                    foreach (var pair in trades)
                    {
                        SaveSecurity(pair.Key);
                        SaveTrades(pair.Key, pair.Value);
                    }
                }

                if (_settings.UseTemporaryFiles == TempFiles.UseAndDelete)
                {
                    var dir = source.GetDumpFile(null, date, date, typeof(Trade), null);

                    if (Directory.Exists(dir))
                    {
                        Directory.Delete(dir, true);
                    }
                }

                _settings.StartFrom = date.AddDays(1);
                SaveSettings();
            }

            if (CanProcess())
            {
                this.AddInfoLog(LocalizedStrings.Str2300);
            }

            return(base.OnProcess());
        }
Beispiel #3
0
		protected override TimeSpan OnProcess()
		{
			var source = new RtsHistorySource
			{
				ExchangeBoard = ExchangeBoard.Ux,
				IsSystemOnly = _settings.IsSystemOnly,
			};

			if (_settings.UseTemporaryFiles != TempFiles.NotUse)
				source.DumpFolder = GetTempPath();

			// если фильтр по инструментам выключен (выбран инструмент все инструменты)
			var allSecurity = this.GetAllSecurity();

			var startDate = _settings.StartFrom;
			var endDate = DateTime.Today - TimeSpan.FromDays(_settings.DayOffset);

			var allDates = startDate.Range(endDate, TimeSpan.FromDays(1)).ToArray();

			var secMap = new HashSet<Security>();

			if (allSecurity == null)
				secMap.AddRange(Settings.Securities.Select(s => s.Security));

			foreach (var date in allDates)
			{
				if (!CanProcess())
					break;

				if (_settings.IgnoreWeekends && !ExchangeBoard.Ux.WorkingTime.IsTradeDate(date, true))
				{
					this.AddDebugLog(LocalizedStrings.WeekEndDate, date);
					continue;
				}

				this.AddInfoLog(LocalizedStrings.Str2823Params, date);

				var trades = source.LoadTrades(EntityRegistry.Securities, date);

				if (trades.Count == 0)
				{
					this.AddDebugLog(LocalizedStrings.NoData);
				}
				else
				{
					if (allSecurity == null)
						trades = trades.Where(p => secMap.Contains(p.Key)).ToDictionary();

					foreach (var pair in trades)
					{
						SaveSecurity(pair.Key);
						SaveTrades(pair.Key, pair.Value);
					}
				}

				if (_settings.UseTemporaryFiles == TempFiles.UseAndDelete)
				{
					var dir = source.GetDumpFile(null, date, date, typeof(Trade), null);

					if (Directory.Exists(dir))
						Directory.Delete(dir, true);
				}

				_settings.StartFrom = date.AddDays(1);
				SaveSettings();
			}

			if (CanProcess())
				this.AddInfoLog(LocalizedStrings.Str2300);

			return base.OnProcess();
		}
Beispiel #4
0
		protected override TimeSpan OnProcess()
		{
			var source = new RtsHistorySource
			{
				IsSystemOnly = _settings.IsSystemOnly,
				LoadEveningSession = _settings.LoadEveningSession,
				SaveRtsStdTrades = _settings.SaveRtsStdTrades,
				SaveRtsStdCombinedOnly = _settings.SaveRtsStdCombinedOnly
			};

			if (_settings.UseTemporaryFiles != TempFiles.NotUse)
				source.DumpFolder = GetTempPath();

			// если фильтр по инструментам выключен (выбран инструмент все инструменты)
			var allSecurity = this.GetAllSecurity();
			var usdRur = GetUsdRur(source.SecurityIdGenerator.GenerateId("USD/RUR", ExchangeBoard.Forts));

			var startDate = _settings.StartFrom;
			var endDate = DateTime.Today - TimeSpan.FromDays(_settings.DayOffset);

			var allDates = startDate.Range(endDate, TimeSpan.FromDays(1)).ToArray();

			var secMap = new HashSet<Security>();

			if (allSecurity == null)
				secMap.AddRange(Settings.Securities.Select(s => s.Security));

			foreach (var date in allDates)
			{
				if (!CanProcess())
					break;

				if (_settings.IgnoreWeekends && !ExchangeBoard.Forts.IsTradeDate(date.ApplyTimeZone(ExchangeBoard.Forts.TimeZone), true))
				{
					this.AddDebugLog(LocalizedStrings.WeekEndDate, date);
					continue;
				}

				this.AddInfoLog(LocalizedStrings.Str2823Params, date);

				var trades = source.LoadTicks(EntityRegistry.Securities, date);

				if (trades.Count == 0)
				{
					this.AddDebugLog(LocalizedStrings.NoData);
				}
				else
				{
					if (allSecurity == null)
						trades = trades.Where(p => secMap.Contains(p.Key)).ToDictionary();

					foreach (var pair in trades)
					{
						SaveSecurity(pair.Key);
						SaveTicks(pair.Key, pair.Value);
					}
				}

				if (_settings.UseTemporaryFiles == TempFiles.UseAndDelete)
				{
					var dir = source.GetDumpFile(null, date, date, typeof(ExecutionMessage), ExecutionTypes.Tick);

					if (Directory.Exists(dir))
						Directory.Delete(dir, true);
				}
				
				_settings.StartFrom = date.AddDays(1);
				SaveSettings();
			}

			if (_settings.IsDownloadUsdRate)
			{
				var usdRurStorage = StorageRegistry.GetTradeStorage(usdRur, _settings.Drive, _settings.StorageFormat);

				foreach (var date in _settings.UsdRurStartFrom
					.Range(endDate, TimeSpan.FromDays(1))
					.Except(usdRurStorage.Dates))
				{
					if (!CanProcess())
						break;

					if (_settings.IgnoreWeekends && !usdRur.Board.IsTradeDate(date.ApplyTimeZone(ExchangeBoard.Forts.TimeZone), true))
					{
						this.AddDebugLog(LocalizedStrings.WeekEndDate, date);
						continue;
					}

					this.AddInfoLog(LocalizedStrings.Str2294Params, date, usdRur.Id);

					var rate = FortsDailyData.GetRate(usdRur, date, date.Add(TimeSpan.FromDays(1)));

					if (rate.Count == 0)
					{
						this.AddDebugLog(LocalizedStrings.NoData);
					}
					else
					{
						SaveTicks(usdRur, rate.Select(p => new ExecutionMessage
						{
							SecurityId = usdRur.ToSecurityId(),
							TradePrice = p.Value,
							ServerTime = p.Key,
							ExecutionType = ExecutionTypes.Tick
						}).OrderBy(t => t.ServerTime));	
					}

					_settings.UsdRurStartFrom = date.AddDays(1);
					SaveSettings();
				}	
			}

			if (CanProcess())
				this.AddInfoLog(LocalizedStrings.Str2300);

			return base.OnProcess();
		}