示例#1
0
        private async Task <PricesPack> TryToCalculateNext(string assetPair, decimal volume, DateTime validFrom)
        {
            try
            {
                _log.Info(nameof(TryToCalculateNext), "Calculating next pack.", new
                {
                    assetPair,
                    volume,
                    validFrom
                });

                return(new PricesPack
                {
                    Buy = await _pricesService.CreateAsync(assetPair, OrderType.Buy,
                                                           volume, validFrom),
                    Sell = await _pricesService.CreateAsync(assetPair, OrderType.Sell,
                                                            volume, validFrom)
                });
            }
            catch (Exception e)
            {
                _log.Warning("Exception while trying to calculate next price.", e, assetPair);
                return(null);
            }
        }
示例#2
0
        public void Test_User_Buy_One_Level()
        {
            // arrange

            var assetPair  = "BTCUSD";
            var orderType  = OrderType.Buy;
            var baseVolume = 35m;

            // act

            var priceSnapshot = _pricesService
                                .CreateAsync(assetPair, orderType, baseVolume, DateTime.UtcNow)
                                .GetAwaiter()
                                .GetResult();

            // assert

            Assert.AreEqual(0.00580431m, priceSnapshot.BaseVolume);
            Assert.AreEqual(6150.32m, priceSnapshot.Value);
        }