Example #1
0
        // assert

        private void AssertPublishedIndex(Contract.IndexTickPrice indexTickPrice)
        {
            var indexValue = GetIndexValue(_step);

            var stepsCount = GetPrices(0).Count - 1; // without header

            Assert.Equal(indexValue, indexTickPrice.Ask);
            Assert.Equal(indexTickPrice.Ask, indexTickPrice.Bid);
        }
        public void Publish(Contract.IndexTickPrice tickPrice)
        {
            _publisher.ProduceAsync(new Contract.IndexTickPrice
            {
                Source     = tickPrice.Source,
                AssetPair  = tickPrice.AssetPair,
                Ask        = tickPrice.Ask ?? 0,
                Bid        = tickPrice.Bid ?? 0,
                Timestamp  = tickPrice.Timestamp,
                AssetsInfo = tickPrice.AssetsInfo.Select(x => new Contract.AssetInfo(x.AssetId, x.Weight, x.Price, x.IsDisabled)).ToList()
            });

            _log.Info($"Published tick price: {tickPrice.ToJson()}.");
        }
Example #3
0
        private void Publish(IndexHistory indexHistory)
        {
            var assetsInfo   = new List <Contract.AssetInfo>();
            var frozenAssets = indexHistory.AssetsSettings.Where(x => x.IsDisabled).Select(x => x.AssetId).ToList();

            foreach (var asset in indexHistory.Weights.Keys.ToList())
            {
                var isFrozen = frozenAssets.Contains(asset);

                assetsInfo.Add(new Contract.AssetInfo(asset, indexHistory.Weights[asset], indexHistory.MiddlePrices[asset], isFrozen));
            }

            // Publish index to RabbitMq
            var tickPrice = new Contract.IndexTickPrice(RabbitMqSource, _indexName.ToUpper(), indexHistory.Value, indexHistory.Value, indexHistory.Time, assetsInfo);

            _tickPricePublisher.Publish(tickPrice);
        }