public void FXMktHist_CcyManagement() { FXMarketHistory fxmh = MarketTestTools.CreateMktHistory(); List <CurrencyPair> cpListRef = MarketTestTools.CreateMarket().GetCurrencyPairs(); TestTools <CurrencyPair> .ListComparisonTest(fxmh.CpList, cpListRef); }
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 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 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 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 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_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_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 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 }); }
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 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 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())); }
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 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); }