예제 #1
0
        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)));
        }
예제 #4
0
        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)));
        }
예제 #5
0
        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));
        }
예제 #6
0
        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));
        }
예제 #7
0
        public void FXMkt_Currencies()
        {
            FXMarket fxMkt = MarketTestTools.CreateMarket();

            TestTools <Currency> .ListComparisonTest(fxMkt.CcyList,
                                                     new List <Currency> {
                Currency.XBT, Currency.USD, Currency.ETH, Currency.EUR
            });
        }
예제 #8
0
        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)));
        }
예제 #9
0
        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));
        }
예제 #10
0
        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));
        }
예제 #11
0
        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);
        }
예제 #12
0
        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));
        }
예제 #13
0
        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()));
        }