public void FXMktHist_CcyManagement()
        {
            FXMarketHistory     fxmh      = MarketTestTools.CreateMktHistory();
            List <CurrencyPair> cpListRef = MarketTestTools.CreateMarket().GetCurrencyPairs();

            TestTools <CurrencyPair> .ListComparisonTest(fxmh.CpList, cpListRef);
        }
        public void Allocation_Update()
        {
            Allocation alloc = AllocationsTools.GetAllocation();
            FXMarket   fx    = MarketTestTools.CreateMarket();

            alloc.Update(fx);
            Assert.AreEqual(alloc.GetElement(Currency.USD).Share, 0.1 / 1.1);
        }
        public void Allocation_CalculateTotal()
        {
            Allocation alloc = AllocationsTools.GetAllocation();
            FXMarket   fx    = MarketTestTools.CreateMarket();

            alloc.CalculateTotal(fx);
            Assert.IsTrue(alloc.Total.Equals(new Price(100 + 1 * 1000, Currency.USD)));
        }
        public void FXMkt_AddQuote()
        {
            FXMarket    fXMarket = MarketTestTools.CreateMarket();
            XChangeRate xrNew    = new XChangeRate(909, Currency.XBT, Currency.EUR);

            fXMarket.AddQuote(xrNew);
            Assert.IsTrue(xrNew.Equals(fXMarket.GetQuote(xrNew.CcyPair)));
        }
        public void FXMkt_ImpliedRate()
        {
            FXMarket     fXMarket  = MarketTestTools.CreateMarket();
            CurrencyPair cp1       = new CurrencyPair(Currency.ETH, Currency.XBT);
            XChangeRate  xrImplied = fXMarket.GetImpliedNewQuote(cp1);

            Assert.IsTrue(MarketTestTools.EthXbtRefRate.Equals(xrImplied));
        }
        public void FXMkt_CurrPairs()
        {
            FXMarket     fXMarket = MarketTestTools.CreateMarket();
            CurrencyPair cp1      = new CurrencyPair(Currency.ETH, Currency.USD);
            CurrencyPair cp2      = new CurrencyPair(Currency.XBT, Currency.ETH);

            Assert.IsTrue(fXMarket.FXContains(cp1) && !fXMarket.FXContains(cp2));
        }
        public void FXMkt_Currencies()
        {
            FXMarket fxMkt = MarketTestTools.CreateMarket();

            TestTools <Currency> .ListComparisonTest(fxMkt.CcyList,
                                                     new List <Currency> {
                Currency.XBT, Currency.USD, Currency.ETH, Currency.EUR
            });
        }
        public void FXMkt_SumPrices()
        {
            FXMarket fXMarket = MarketTestTools.CreateMarket();
            Price    p1       = new Price(10, Currency.ETH);
            Price    p2       = new Price(1, Currency.XBT);
            Price    pTotal   = fXMarket.SumPrices(p1, p2, Currency.XBT);

            Assert.IsTrue(pTotal.Equals(new Price(1 + 10 * MarketTestTools.EthXbtRefRate.Rate, Currency.XBT)));
        }
        public void FXMkt_FXConvert()
        {
            FXMarket fXMarket  = MarketTestTools.CreateMarket();
            double   amountRef = 100;
            Price    p         = new Price(amountRef, Currency.EUR);

            Assert.AreEqual(MarketTestTools.EurUsdRefRate.Rate * amountRef,
                            fXMarket.FXConvert(p, MarketTestTools.EurUsdRefRate.CcyPair.Ccy2));
        }
        public void AllocationHistory_Init()
        {
            FXMarketHistory   fxmh      = MarketTestTools.CreateMktHistory();
            AllocationHistory allocH    = AllocationsTools.GetAllocationHistory(fxmh);
            Allocation        alloc     = allocH.GetAllocation(MarketTestTools.date1);
            Allocation        allocTest = AllocationsTools.GetAllocation();

            allocTest.Update(MarketTestTools.CreateMarket());
            Assert.IsTrue(alloc.Total.Equals(allocTest.Total));
        }
        public void FXMkt_GetQuote()
        {
            FXMarket     fXMarket = MarketTestTools.CreateMarket();
            CurrencyPair cp1      = new CurrencyPair(Currency.EUR, Currency.USD);
            XChangeRate  eurUsd   = fXMarket.GetQuote(cp1, constructNewQuote: true);
            bool         test1    = MarketTestTools.EurUsdRefRate.Equals(eurUsd) && !fXMarket.FXContains(cp1);
            XChangeRate  eurUsd2  = fXMarket.GetQuote(cp1, constructNewQuote: true, useConstructedQuote: true);
            bool         test2    = MarketTestTools.EurUsdRefRate.Equals(eurUsd) && fXMarket.FXContains(cp1);

            Assert.IsTrue(test1 && test2);
        }
        public void Allocation_GetReturn()
        {
            Allocation alloc = AllocationsTools.GetAllocation();
            FXMarket   fx    = MarketTestTools.CreateMarket();
            FXMarket   fx2   = MarketTestTools.CreateMarket2();

            alloc.Update(fx);
            Allocation alloc2 = (Allocation)alloc.Clone();

            alloc2.Update(fx2);
            Assert.IsTrue(Math.Abs(1 / 1.1 * 0.05 - alloc2.GetReturn(alloc)) < Math.Pow(10, -6));
        }
        public void FXMktHist_GetRealFXMarket()
        {
            FXMarketHistory fxmh     = MarketTestTools.CreateMktHistory();
            FXMarket        fxNull   = fxmh.GetRealFXMarket(MarketTestTools.dateArt, isExactDate: true);
            FXMarket        fXMarket = fxmh.GetRealFXMarket(MarketTestTools.dateArt);

            if (fxNull != null)
            {
                Assert.IsTrue(false);
            }
            Assert.IsTrue(fXMarket.IsEquivalentTo(MarketTestTools.CreateMarket()));
        }