public void Allocation_AddValue()
        {
            Allocation alloc = AllocationsTools.GetAllocation();

            alloc.AddValue(new Price(1, Currency.XBT));
            Assert.AreEqual(alloc.GetElement(Currency.XBT).Amount, 1 + 1);
        }
        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 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 Allocaton_GetCurrencyPairs()
        {
            Allocation alloc = AllocationsTools.GetAllocation();

            TestTools <CurrencyPair> .ListComparisonTest(alloc.GetCurrencyPairs(Currency.EUR),
                                                         new List <CurrencyPair> {
                new CurrencyPair(Currency.USD, Currency.EUR),
                new CurrencyPair(Currency.XBT, Currency.EUR)
            });
        }
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);
        }
Beispiel #7
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);
        }
        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 Allocation_AddTransaction_DepositCrypto()
        {
            Allocation  alloc = AllocationsTools.GetAllocation();
            Transaction DCtx  = new Transaction("ID_DC",
                                                TransactionType.Deposit,
                                                DateTime.UtcNow,
                                                null,
                                                new Price(0.1, Currency.XBT));
            Allocation newAlloc = alloc.AddTransaction(DCtx);

            Assert.AreEqual(newAlloc.GetElement(Currency.XBT).Amount, 1);
        }
        public void Allocation_AddTransaction_DepositFiat()
        {
            Allocation  alloc = AllocationsTools.GetAllocation();
            Transaction DFtx  = new Transaction("ID_DF",
                                                TransactionType.Deposit,
                                                DateTime.UtcNow,
                                                null,
                                                new Price(100, Currency.USD));
            Allocation newAlloc = alloc.AddTransaction(DFtx);

            Assert.AreEqual(newAlloc.GetElement(Currency.USD).Amount, 200);
        }
        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));
        }
        public void Allocation_AddTransaction_WithDrawCrypto()
        {
            Allocation  alloc = AllocationsTools.GetAllocation();
            Transaction WCtx  = new Transaction("ID_WdCrypto",
                                                TransactionType.WithDrawal,
                                                DateTime.UtcNow,
                                                new Price(0.5, Currency.XBT),
                                                null,
                                                new Price(0.01, Currency.XBT));
            Allocation newAlloc = alloc.AddTransaction(WCtx);

            Assert.AreEqual(newAlloc.GetElement(Currency.XBT).Amount, 1 - 0.01);
        }
        public void Allocation_AddTransaction_WithDrawFiat()
        {
            Allocation  alloc = AllocationsTools.GetAllocation();
            Transaction WFtx  = new Transaction("ID_WDFiat",
                                                TransactionType.WithDrawal,
                                                DateTime.UtcNow,
                                                new Price(20, Currency.USD),
                                                null,
                                                new Price(2, Currency.USD));
            Allocation newAlloc = alloc.AddTransaction(WFtx);

            Assert.AreEqual(newAlloc.GetElement(Currency.USD).Amount, 100 - 20 - 2);
        }
Beispiel #14
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 Allocation_AddTransaction_Trade()
        {
            Allocation  alloc = AllocationsTools.GetAllocation();
            Price       Fees  = new Price(50, Currency.USD);
            Transaction Ttx   = new Transaction("ID_Trade",
                                                TransactionType.Trade,
                                                DateTime.UtcNow,
                                                new Price(0.5, Currency.XBT),
                                                new Price(450, Currency.USD),
                                                Fees);
            Allocation newAlloc = alloc.AddTransaction(Ttx);
            bool       test1    = newAlloc.GetElement(Currency.XBT).Amount == 0.5;
            bool       test2    = newAlloc.GetElement(Currency.USD).Amount == 100 + 450 - 50;
            bool       test3    = newAlloc.Fees.Price.Equals(Fees);

            Assert.IsTrue(test1 && test2 && test3);
        }
        public void Allocation_GetKeyType()
        {
            Allocation alloc = AllocationsTools.GetAllocation();

            Assert.AreEqual(TimeSeriesKeyType.Allocation, alloc.GetKeyType());
        }
        public void Allocation_GetTimeSeriesKey()
        {
            Allocation alloc = AllocationsTools.GetAllocation();

            Assert.IsTrue(alloc.GetTimeSeriesKey() == null);
        }