示例#1
0
文件: OrderCache.cs 项目: forkme7/MT
        public override void Start()
        {
            var orders = _marginTradingBlobRepository.Read <List <Order> >(LykkeConstants.StateBlobContainer, BlobName) ?? new List <Order>();

            _orderCache.InitOrders(orders);

            base.Start();
        }
示例#2
0
        public override void Start()
        {
            _quotes =
                _blobRepository
                .Read <Dictionary <string, InstrumentBidAskPair> >(LykkeConstants.StateBlobContainer, BlobName)
                ?.ToDictionary(d => d.Key, d => d.Value) ??
                new Dictionary <string, InstrumentBidAskPair>();

            base.Start();
        }
示例#3
0
        public override void Start()
        {
            var state =
                _blobRepository.Read <Dictionary <string, OrderBook> >(LykkeConstants.StateBlobContainer, BlobName)
                ?.ToDictionary(d => d.Key, d => d.Value) ??
                new Dictionary <string, OrderBook>();

            using (_contextFactory.GetWriteSyncContext($"{nameof(OrderBookSaveService)}.{nameof(Start)}"))
            {
                _orderBookList.Init(state);
            }

            base.Start();
        }
示例#4
0
        public override void Start()
        {
            var graphData = _blobRepository.Read <Dictionary <string, List <GraphBidAskPair> > >("prices", "graph")
                            ?.ToDictionary(d => d.Key, d => d.Value) ??
                            new Dictionary <string, List <GraphBidAskPair> >();

            if (graphData.Count > 0)
            {
                FixGraphData(graphData);
                _micrographCacheService.InitCache(graphData);
            }

            base.Start();
        }
示例#5
0
        public override void Start()
        {
            var orders = _marginTradingBlobRepository.Read <List <Order> >(LykkeConstants.StateBlobContainer, BlobName) ?? new List <Order>();

            orders.ForEach(o =>
            {
                // migrate orders to add LegalEntity field
                // todo: can be removed once published to prod
                if (o.LegalEntity == null)
                {
                    o.LegalEntity = _accountsCacheService.Get(o.ClientId, o.AccountId).LegalEntity;
                }
            });

            _orderCache.InitOrders(orders);

            base.Start();
        }
示例#6
0
        public override void Start()
        {
            _log.WriteInfo(nameof(QuoteCacheService), nameof(Start), "Quote cache init started.");

            var blobQuotes =
                _blobRepository
                .Read <Dictionary <string, InstrumentBidAskPair> >(LykkeConstants.StateBlobContainer, BlobName)
                ?.ToDictionary(d => d.Key, d => d.Value) ??
                new Dictionary <string, InstrumentBidAskPair>();

            _log.WriteInfo(nameof(QuoteCacheService), nameof(Start),
                           $"{blobQuotes.Count} quotes read from blob.");

            var orderBooks = _externalOrderbookService.GetOrderBooks();

            _log.WriteInfo(nameof(QuoteCacheService), nameof(Start),
                           $"{orderBooks.Count} order books read from {nameof(IExternalOrderbookService)}.");

            var result = new Dictionary <string, InstrumentBidAskPair>();

            foreach (var orderBook in orderBooks)
            {
                if (!blobQuotes.TryGetValue(orderBook.AssetPairId, out var quote) ||
                    orderBook.Timestamp > quote.Date)
                {
                    result.Add(orderBook.AssetPairId, orderBook.GetBestPrice());
                }
            }

            foreach (var remainsToAdd in blobQuotes.Keys.Except(result.Keys))
            {
                var item = blobQuotes[remainsToAdd];
                result.Add(item.Instrument, item);
            }

            _cache = result;

            _log.WriteInfo(nameof(QuoteCacheService), nameof(Start),
                           $"Quote cache initialised with total {result.Count} items.");

            base.Start();
        }