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

            TestTools <CurrencyPair> .ListComparisonTest(fxmh.CpList, cpListRef);
        }
        public void FXMktHist_GetArtificialFXMarket()
        {
            FXMarketHistory fxMH  = MarketTestTools.CreateMktHistory();
            FXMarket        fxArt = fxMH.GetArtificialFXMarket(MarketTestTools.dateArt, new CurrencyPair(Currency.EUR, Currency.USD));
            XChangeRate     xr    = fxArt.GetQuote(Currency.EUR, Currency.USD, true);

            Assert.AreEqual(MarketTestTools.EurUsdArtRate.Rate, xr.Rate, Math.Pow(10, -6));
        }
        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 FXMktHist_GetAllDates()
        {
            FXMarketHistory fxmh   = MarketTestTools.CreateMktHistory();
            FXMarket        artMkt = fxmh.GetArtificialFXMarket(MarketTestTools.dateArt);

            TestTools <DateTime> .ListComparisonTest(fxmh.GetAllDates().ToList(),
                                                     new List <DateTime> {
                MarketTestTools.date1, MarketTestTools.dateArt, MarketTestTools.date2
            });
        }
Beispiel #5
0
        public void AggPnL_Equation()
        {
            FXMarketHistory fxmh = MarketTestTools.CreateMktHistory(true, true);
            SortedList <DateTime, Transaction> txL = AllocationsTools.GetTransactionList();
            AggregatedPnL pnl = new AggregatedPnL(Currency.USD);

            pnl.AddTransactions(txL, fxmh);
            PnLElement elmt = pnl.ToTable(fxmh)["Total"];

            Assert.IsTrue(elmt.Position - elmt.Deposit + elmt.Withdrawal == elmt.TotalPnLWithFees);
        }
Beispiel #6
0
        public void AggPnL_AddTransaction()
        {
            FXMarketHistory fxmh = MarketTestTools.CreateMktHistory(true, true);
            SortedList <DateTime, Transaction> txL = AllocationsTools.GetTransactionList();
            AggregatedPnL pnl = new AggregatedPnL(Currency.USD);

            pnl.AddTransactions(txL, fxmh);
            Dictionary <string, PnLElement> table = pnl.ToTable(fxmh);

            TestTools <PnLElement> .DictionaryTest(pnlref, table);
        }
        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()));
        }
        public void AllocationHistory_Update()
        {
            FXMarketHistory   fxmh   = MarketTestTools.CreateMktHistory();
            AllocationHistory allocH = AllocationsTools.GetAllocationHistory(fxmh, Fiat: Currency.EUR);
            CurrencyPair      testCP = new CurrencyPair(Currency.EUR, Currency.USD);

            //fxmh.ConstructQuotes(testCP);
            allocH.UpdateHistory(Currency.EUR, fxmh);
            Price total = allocH.GetLastAllocation().Total;

            Assert.IsTrue(total
                          .Equals(new Price(932.687, Currency.EUR), precision: 2));
        }
Beispiel #9
0
        public void AggPnL_EquationXCCY()
        {
            FXMarketHistory fxmh = MarketTestTools.CreateMktHistory(true, true);

            fxmh.ConstructQuotes(new CurrencyPair(Currency.EUR, Currency.USD));
            SortedList <DateTime, Transaction> txL = AllocationsTools.GetTransactionList();
            AggregatedPnL pnl = new AggregatedPnL(Currency.EUR);

            pnl.AddTransactions(txL, fxmh);
            PnLElement elmt = pnl.ToTable(fxmh)["Total"];

            Assert.IsTrue(Math.Abs(elmt.Position - elmt.Deposit + elmt.Withdrawal - elmt.TotalPnLWithFees) < 0.00001);
        }
        public void FXMktHistory_GetQuote()
        {
            FXMarketHistory fxMH = MarketTestTools.CreateMktHistory();
            CurrencyPair    cp   = new CurrencyPair(Currency.XBT, Currency.USD);
            Tuple <DateTime, XChangeRate> xr1 =
                fxMH.GetQuote(MarketTestTools.dateArt, cp,
                              isArtificial: true);
            Tuple <DateTime, XChangeRate> xr2 =
                fxMH.GetQuote(MarketTestTools.dateArt, cp,
                              isArtificial: false, isExactDate: false);
            Tuple <DateTime, XChangeRate> xr3 =
                fxMH.GetQuote(MarketTestTools.dateArt, cp,
                              isArtificial: false, isExactDate: true);
            bool test1 = xr1.Item1 == MarketTestTools.dateArt &&
                         xr1.Item2.Equals(MarketTestTools.XbtUsdArtRate);
            bool test2 = xr2.Item1 == MarketTestTools.date1 &&
                         xr2.Item2.Equals(fxMH.GetRealFXMarket(MarketTestTools.date1).GetQuote(cp));
            bool test3 = xr3.Item1 == MarketTestTools.dateArt &&
                         xr3.Item2 == null;

            Assert.IsTrue(test1 && test2 && test3);
        }