示例#1
0
        private static bool IsMfd(HydraTaskSecurity taskSecurity)
        {
            var security = taskSecurity.Security;

            return(security.ExtensionInfo.ContainsKey(MfdHistorySource.MarketIdField) &&
                   security.ExtensionInfo.ContainsKey(MfdHistorySource.SecurityIdField));
        }
示例#2
0
        private static bool IsQuandl(HydraTaskSecurity taskSecurity)
        {
            var security = taskSecurity.Security;

            return(security.ExtensionInfo.ContainsKey(QuandlHistorySource.SecurityCodeField) &&
                   security.ExtensionInfo.ContainsKey(QuandlHistorySource.SourceCodeField));
        }
示例#3
0
        private TaskVisualSecurity ToVisualSecurity(HydraTaskSecurity security)
        {
            if (security == null)
            {
                throw new ArgumentNullException(nameof(security));
            }

            return(_visualSecurities.SafeAdd(security, key => new TaskVisualSecurity(key)));
        }
示例#4
0
        private bool DownloadData(HydraTaskSecurity security, Type dataType, object arg, RemoteStorageClient client)
        {
            var localStorage = StorageRegistry.GetStorage(security.Security, dataType, arg, _settings.Drive, _settings.StorageFormat);

            var remoteStorage = client.GetRemoteStorage(security.Security.ToSecurityId(), dataType, arg, _settings.StorageFormat);

            var endDate = DateTime.Today - TimeSpan.FromDays(_settings.Offset);
            var dates   = remoteStorage.Dates.Where(date => date >= _settings.StartFrom && date <= endDate).Except(localStorage.Dates).ToArray();

            if (dates.IsEmpty())
            {
                if (!CanProcess())
                {
                    return(false);
                }
            }
            else
            {
                this.AddInfoLog(LocalizedStrings.Str2308Params.Put(dataType.Name));

                foreach (var date in dates)
                {
                    if (!CanProcess())
                    {
                        return(false);
                    }

                    if (_settings.IgnoreWeekends && !security.IsTradeDate(date))
                    {
                        this.AddDebugLog(LocalizedStrings.WeekEndDate, date);
                        continue;
                    }

                    this.AddDebugLog(LocalizedStrings.StartDownloding, dataType, arg, date, security.Security.Id);

                    using (var stream = remoteStorage.LoadStream(date))
                    {
                        if (stream == Stream.Null)
                        {
                            this.AddDebugLog(LocalizedStrings.NoData);
                            continue;
                        }

                        this.AddInfoLog(LocalizedStrings.Str2309Params.Put(date));

                        localStorage.Drive.SaveStream(date, stream);

                        var info = localStorage.Serializer.CreateMetaInfo(date);

                        stream.Position = 0;
                        info.Read(stream);

                        if (dataType == typeof(Trade))
                        {
                            dataType = typeof(ExecutionMessage);
                            arg      = ExecutionTypes.Tick;
                        }
                        else if (dataType == typeof(OrderLogItem))
                        {
                            dataType = typeof(ExecutionMessage);
                            arg      = ExecutionTypes.OrderLog;
                        }
                        else if (dataType.IsCandle())
                        {
                            dataType = dataType.ToCandleMessageType();
                        }

                        RaiseDataLoaded(security.Security, dataType, arg, date, info.Count);
                    }
                }
            }

            return(true);
        }
示例#5
0
 public TaskVisualSecurity(HydraTaskSecurity taskSecurity)
 {
     TaskSecurity = taskSecurity;
 }
示例#6
0
 public void Add(HydraTaskSecurity security)
 {
     Add(security.Security);
     _securities.Add(security.Security, security);
 }