Пример #1
0
        public void SetUp()
        {
            _accountAssetsRepository.GetAllAsync().Result.ForEach(aa =>
                                                                  _accountAssetsRepository.Remove(aa.TradingConditionId, aa.BaseAssetId, "BTCUSD"));
            _accountAssetsManager.UpdateAccountAssetsCache().GetAwaiter().GetResult();

            _ordersCache.InitOrders(new List <Order>());

            _overnightSwapCache.ClearAll();

            _quoteCacheService.GetAllQuotes().Values.ForEach(x => _quoteCacheService.RemoveQuote(x.Instrument));

            _overnightSwapHistoryRepository.GetAsync().Result.ForEach(x =>
                                                                      _overnightSwapHistoryRepository.DeleteAsync(x));
        }
Пример #2
0
        public async Task Is_Swaps_Correct()
        {
            _bestPriceConsumer.SendEvent(this, new BestPriceChangeEventArgs(new InstrumentBidAskPair {
                Instrument = "EURUSD", Bid = 1.02M, Ask = 1.04M
            }));

            _accountAssetsRepository.AddOrReplaceAsync(new AccountAssetPair
            {
                TradingConditionId  = MarginTradingTestsUtils.TradingConditionId,
                BaseAssetId         = "USD",
                Instrument          = "EURUSD",
                LeverageInit        = 100,
                LeverageMaintenance = 150,
                SwapLong            = 100,
                SwapShort           = 100
            }).Wait();

            await _accountAssetsManager.UpdateAccountAssetsCache();

            var dayOrder = new Order
            {
                AccountAssetId = "USD",
                Instrument     = "EURUSD",
                Volume         = 20,
                OpenDate       = new DateTime(2017, 01, 01, 20, 50, 0),
                CloseDate      = new DateTime(2017, 01, 02, 20, 50, 0),
                MatchedOrders  = new MatchedOrderCollection(new List <MatchedOrder> {
                    new MatchedOrder()
                    {
                        Volume = 20
                    }
                }),
                SwapCommission = 100
            };

            var swapsForDay = _swapService.GetSwaps(dayOrder);

            var twoDayOrder = new Order
            {
                AccountAssetId = "USD",
                Instrument     = "EURUSD",
                Volume         = 20,
                OpenDate       = new DateTime(2017, 01, 01, 20, 50, 0),
                CloseDate      = new DateTime(2017, 01, 03, 20, 50, 0),
                MatchedOrders  = new MatchedOrderCollection(new List <MatchedOrder>()
                {
                    new MatchedOrder()
                    {
                        Volume = 20
                    }
                }),
                SwapCommission = 100
            };

            var swapsFor2Days = _swapService.GetSwaps(twoDayOrder);

            Assert.AreEqual(5.69863014m, swapsForDay);
            Assert.AreEqual(11.39726027m, swapsFor2Days);
        }