public void PortfolioPVFact() { InstrumentFunctions.CreateAsianSwap("swpFake", "Jan-19", "xx", "USD", 0.0, 0.0, "NYC", "NYC", "2b", "2b", Value, "disco", Value); var model = new Mock <IAssetFxModel>(); model.Setup(m => m.GetPriceCurve("xx", null)).Returns(new ConstantPriceCurve(100, DateTime.Today, TestProviderHelper.CurrencyProvider)); var fModel = new Mock <IFundingModel>(); fModel.Setup(fm => fm.GetDf(It.IsAny <Currency>(), It.IsAny <DateTime>(), It.IsAny <DateTime>())).Returns(1.0); model.Setup(m => m.FundingModel).Returns(fModel.Object); ContainerStores.GetObjectCache <IAssetFxModel>().PutObject("model", new SessionItem <IAssetFxModel>() { Name = "model", Value = model.Object }); Assert.Equal("Could not find portfolio or trade with name trd", InstrumentFunctions.AssetPortfolioPV("out", "trd", "xxx", Value)); Assert.Equal("Could not find model with name xxx", InstrumentFunctions.AssetPortfolioPV("out", "swpFake", "xxx", Value)); Assert.Equal("out¬0", InstrumentFunctions.AssetPortfolioPV("out", "swpFake", "model", Value)); Assert.Equal("out¬1", InstrumentFunctions.AssetPortfolioPV("out", "swpFake", "model", "USD")); }
public void AssetPnLAttributionExplainWithActivityFacts() { InstrumentFunctions.CreateAsianSwap("swpFake", "Jan-19", "xx", "USD", 0.0, 0.0, "NYC", "NYC", "2b", "2b", Value, "disco", Value); var model = new Mock <IAssetFxModel>(); ContainerStores.GetObjectCache <IAssetFxModel>().PutObject("model", new SessionItem <IAssetFxModel>() { Name = "model", Value = model.Object }); var pnlAttribMock = new Mock <IPnLAttributor>(); pnlAttribMock .Setup(p => p.ExplainAttribution(It.IsAny <Portfolio>(), It.IsAny <Portfolio>(), It.IsAny <IAssetFxModel>(), It.IsAny <IAssetFxModel>(), It.IsAny <Currency>(), It.IsAny <ICurrencyProvider>(), It.IsAny <bool>())) .Returns(new ResultCube()); ContainerStores.PnLAttributor = pnlAttribMock.Object; Assert.Equal("Could not find portfolio or trade with name trdS", InstrumentFunctions.AssetPnLAttributionExplainWithActivity("outzzy", "trdS", "trdE", "ms1", "ms2", "USD", false)); Assert.Equal("Could not find portfolio or trade with name trdE", InstrumentFunctions.AssetPnLAttributionExplainWithActivity("outzzy", "swpFake", "trdE", "ms1", "ms2", "USD", false)); Assert.Equal("Could not find model with name ms1", InstrumentFunctions.AssetPnLAttributionExplainWithActivity("outzzy", "swpFake", "swpFake", "ms1", "ms2", "USD", false)); Assert.Equal("Could not find model with name ms2", InstrumentFunctions.AssetPnLAttributionExplainWithActivity("outzzy", "swpFake", "swpFake", "model", "ms2", "USD", false)); Assert.Equal("outzzy¬0", InstrumentFunctions.AssetPnLAttributionExplainWithActivity("outzzy", "swpFake", "swpFake", "model", "model", "USD", false)); pnlAttribMock.Verify(p => p.ExplainAttribution(It.IsAny <Portfolio>(), It.IsAny <Portfolio>(), It.IsAny <IAssetFxModel>(), It.IsAny <IAssetFxModel>(), It.IsAny <Currency>(), It.IsAny <ICurrencyProvider>(), It.IsAny <bool>()), Times.Once); }
public void FilterPortfolioByNameFacts() { InstrumentFunctions.CreateAsianSwap("swpFake", "Jan-19", "xx", "USD", 0.0, 0.0, "NYC", "NYC", "2b", "2b", Value, "disco", Value); InstrumentFunctions.CreatePortfolio("pfOutK", new object[, ] { { "swpFake" } }, Value, Value, Value, Value); Assert.Equal("Portfolio hhhh not found", InstrumentFunctions.FilterPortfolioByName("filterPfOutKk", "hhhh", new object[] { "swpFake" })); Assert.Equal("filterPfOutKk¬0", InstrumentFunctions.FilterPortfolioByName("filterPfOutKk", "pfOutK", new object[] { "swpFake" })); }
public void CreateAsianSwapFact() { Assert.Equal("Calendar xxx not found in cache", InstrumentFunctions.CreateAsianSwap("swp", "Jan-19", "xx", "ZAR", 0.0, 0.0, "xxx", "xxx", "2z", "2f", Value, "disco", Value)); Assert.Equal("Calendar xxx not found in cache", InstrumentFunctions.CreateAsianSwap("swp", "Jan-19", "xx", "ZAR", 0.0, 0.0, "NYC", "xxx", "2z", "2f", Value, "disco", Value)); Assert.Equal("Could not parse date generation type - sqw", InstrumentFunctions.CreateAsianSwap("swp", "Jan-19", "xx", "ZAR", 0.0, 0.0, "NYC", "NYC", "2b", "2b", "sqw", "disco", Value)); Assert.Equal("swppp¬0", InstrumentFunctions.CreateAsianSwap("swppp", "Jan-19", "xx", "ZAR", 0.0, 0.0, "NYC", "NYC", "2b", "2b", Value, "disco", Value)); Assert.Equal("swppq¬0", InstrumentFunctions.CreateAsianSwap("swppq", DateTime.Today.ToOADate(), "xx", "ZAR", 0.0, 0.0, "NYC", "NYC", "2b", "2b", Value, "disco", Value)); Assert.Equal("swppz¬0", InstrumentFunctions.CreateAsianSwap("swppz", new object[, ] { { DateTime.Today.ToOADate(), DateTime.Today.AddDays(100).ToOADate() } }, "xx", "ZAR", 0.0, 0.0, "NYC", "NYC", "2b", "2b", "BusinessDays", "disco", Value)); }