/// <summary>
		/// —оздать <see cref="CacheableMarketDataDrive"/>.
		/// </summary>
		/// <param name="sourceDrive">»сходное хранилище маркет-данных.</param>
		/// <param name="cacheDrive"> эш-хранилище маркет-данных.</param>
		public CacheableMarketDataDrive(IMarketDataStorageDrive sourceDrive, IMarketDataStorageDrive cacheDrive)
		{
			if (sourceDrive == null)
				throw new ArgumentNullException("sourceDrive");

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

			_sourceDrive = sourceDrive;
			_cacheDrive = cacheDrive;
		}
Example #2
0
 public CandleStorage(Security security, object arg, IMarketDataStorageDrive drive, IMarketDataSerializer <TCandleMessage> serializer)
     : base(security, arg, drive, serializer)
 {
 }
Example #3
0
 public OrderLogStorage(Security security, IMarketDataStorageDrive drive, IMarketDataSerializer <ExecutionMessage> serializer)
     : base(security, ExecutionTypes.OrderLog, item => item.ServerTime, item => item.SecurityId, item => item.TransactionId, serializer, drive)
 {
 }
Example #4
0
 protected CandleMessageStorage(Security security, object arg, IMarketDataStorageDrive drive, IMarketDataSerializer <TCandleMessage> serializer)
     : base(security, arg, candle => candle.OpenTime, candle => candle.SecurityId, candle => candle.OpenTime.Truncate(), serializer, drive)
 {
 }
Example #5
0
 public TradeStorage(Security security, IMarketDataStorageDrive drive, IMarketDataSerializer <ExecutionMessage> serializer)
     : base(security, ExecutionTypes.Tick, trade => trade.ServerTime, trade => trade.SecurityId, trade => trade.TradeId ?? 0, serializer, drive)
 {
 }
Example #6
0
 public MarketDepthStorage(Security security, IMarketDataStorageDrive drive, IMarketDataSerializer <QuoteChangeMessage> serializer)
     : base(security, null, depth => depth.ServerTime, depth => depth.SecurityId, depth => depth.ServerTime.Truncate(), serializer, drive)
 {
 }
 public TransactionStorage(Security security, IMarketDataStorageDrive drive, IMarketDataSerializer <ExecutionMessage> serializer)
     : base(security, ExecutionTypes.Transaction, msg => msg.ServerTime, msg => msg.SecurityId, msg => msg.TransactionId, serializer, drive)
 {
     AppendOnlyNew = false;
 }
Example #8
0
 protected ConvertableStorage(Security security, object arg, Func <TMessage, DateTimeOffset> getTime, Func <TMessage, SecurityId> getSecurity, Func <TMessage, TId> getId, IMarketDataSerializer <TMessage> serializer, IMarketDataStorageDrive drive)
     : base(security, arg, getTime, getSecurity, getId, serializer, drive)
 {
 }
Example #9
0
 public PositionStorage(Security security, IMarketDataStorageDrive drive, IMarketDataSerializer <PositionChangeMessage> serializer)
     : base(security, null, value => value.ServerTime, value => value.SecurityId, value => value.ServerTime.StorageTruncate(serializer.TimePrecision), serializer, drive)
 {
 }
 public Level1Storage(Security security, IMarketDataStorageDrive drive, IMarketDataSerializer <Level1ChangeMessage> serializer)
     : base(security, null, value => value.ServerTime, value => value.SecurityId, value => value.ServerTime.Truncate(), serializer, drive)
 {
 }
Example #11
0
 public MarketDepthStorage(SecurityMarketDataDrive parent, Security security, IMarketDataStorageDrive drive, IMarketDataSerializer <QuoteChangeMessage> serializer)
     : base(parent, security, null, depth => depth.ServerTime, depth => depth.SecurityId, depth => depth.ServerTime.StorageTruncate(serializer.TimePrecision), serializer, drive)
 {
 }
Example #12
0
        public AllSecurityMarketDataStorage(Security security, object arg, Func <T, DateTimeOffset> getTime, Func <T, Security> getSecurity, Func <Security, IMarketDataDrive, IMarketDataStorage <T> > getStorage, IMarketDataStorageDrive drive)
        {
            if (security == null)
            {
                throw new ArgumentNullException("security");
            }

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

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

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

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

            _security = security;
            _getTime  = getTime;

            _arg  = arg;
            Drive = drive;

            _basket = new BasketMarketDataStorage <T>();

            var idGenerator = new SecurityIdGenerator();

            var parts = idGenerator.Split(security.Id);
            var code  = parts.Item1;

            var securities = InteropHelper
                             .GetDirectories(Path.Combine(Drive.Drive.Path, code.Substring(0, 1)), code + "*")
                             .Select(p => Path.GetFileName(p).FolderNameToSecurityId())
                             .Select(s =>
            {
                var id = idGenerator.Split(s);

                var clone   = security.Clone();
                clone.Id    = s;
                clone.Board = ExchangeBoard.GetOrCreateBoard(id.Item2);
                return(clone);
            });

            foreach (var sec in securities)
            {
                _basket.InnerStorages.Add(getStorage(sec, Drive.Drive));
            }
        }
        protected MarketDataStorage(SecurityId securityId, object arg, Func <TMessage, DateTimeOffset> getTime, Func <TMessage, SecurityId> getSecurityId, Func <TMessage, TId> getId, IMarketDataSerializer <TMessage> serializer, IMarketDataStorageDrive drive)
        {
            if (securityId.IsDefault())
            {
                throw new ArgumentException(LocalizedStrings.Str1025, nameof(securityId));
            }

            SecurityId = securityId;

            AppendOnlyNew = true;

            _getTime       = getTime ?? throw new ArgumentNullException(nameof(getTime));
            _getSecurityId = getSecurityId ?? throw new ArgumentNullException(nameof(getSecurityId));
            _getId         = getId ?? throw new ArgumentNullException(nameof(getId));
            Drive          = drive ?? throw new ArgumentNullException(nameof(drive));
            Serializer     = serializer ?? throw new ArgumentNullException(nameof(serializer));
            _arg           = arg;
        }
Example #14
0
        protected MarketDataStorage(SecurityId securityId, object arg, Func <TData, DateTimeOffset> getTime, Func <TData, SecurityId> getSecurityId, Func <TData, TId> getId, IMarketDataSerializer <TData> serializer, IMarketDataStorageDrive drive)
        {
            if (securityId == null)
            {
                throw new ArgumentNullException("securityId");
            }

            if (securityId == default(SecurityId))
            {
                throw new ArgumentException(LocalizedStrings.Str1025, "securityId");
            }

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

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

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

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

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

            SecurityId = securityId;

            AppendOnlyNew = true;

            _getTime       = getTime;
            _getSecurityId = getSecurityId;
            _getId         = getId;
            Drive          = drive;
            Serializer     = serializer;
            _arg           = arg;
        }
Example #15
0
        protected MarketDataStorage(Security security, object arg, Func <TData, DateTimeOffset> getTime, Func <TData, SecurityId> getSecurity, Func <TData, TId> getId, IMarketDataSerializer <TData> serializer, IMarketDataStorageDrive drive)
            : this(security.ToSecurityId(), arg, getTime, getSecurity, getId, serializer, drive)
        {
            if (security == null)
            {
                throw new ArgumentNullException("security");
            }

            if (security.Id.IsEmpty())
            {
                throw new ArgumentException(LocalizedStrings.Str1025, "security");
            }

            Security = security;
        }