public Computations CreateComputations(GlobeModel root, GlobeTraverser traverser) { var computations = new Computations(); computations.BaseActiveFormula = this.CreateBaseActiveFormula(); var portfolioAdjustmentTotal = computations.PortfolioAdjustmentTotal = root.PortfolioAdjustment; var baseWherePortfoioAdjustmentSetTotal = computations.BaseWherePortfoioAdjustmentSetTotal = this.CreateBaseWherePortfoioAdjustmentSetTotal(traverser, root); computations.BaseLessOverlayFormula = this.CreateBaseLessOverlayFormula( this.CreateRescaledBaseFormula( computations.BaseWherePortfoioAdjustmentSetTotal, computations.PortfolioAdjustmentTotal ) ); computations.CashBase = this.CreateBaseForCash(this.CreateBaseForCashFormula(root)); computations.CashRescaledBase = this.CreateRescaledBaseForCash(this.CreateRescaledBaseForCashFormula(computations.CashBase, baseWherePortfoioAdjustmentSetTotal, portfolioAdjustmentTotal)); computations.BaseLessOverlayPositiveTotal = this.CreateBaseLessOverlayPositiveTotalExpression(root, traverser, computations.BaseLessOverlayFormula, computations.CashRescaledBase); computations.BaseLessOverlayTotal = this.CreateBaseLessOverlayTotalExpression(root, traverser, computations.BaseLessOverlayFormula, computations.CashRescaledBase); computations.PortfolioScaledFormula = this.CreatePortfolioScaledFormula(computations.BaseLessOverlayFormula, computations.BaseLessOverlayPositiveTotal, computations.BaseLessOverlayTotal); computations.CashPortfolioScaled = this.CreateScaledCash(this.CreateCashScaledFormula(computations.CashRescaledBase, computations.BaseLessOverlayPositiveTotal, computations.BaseLessOverlayTotal)); computations.TrueExposureFormula = this.CreateTrueExposureFormula(); computations.TrueActiveFormula = this.CreateTrueActiveFormula(); return(computations); }
public RootModel( TargetingType targetingType, BroadGlobalActivePortfolio portfolio, TargetingTypeBasketBaseValueChangesetInfo latestTtbbvChangesetInfo, TargetingTypeBasketPortfolioTargetChangesetInfo latestTtbptChangesetInfo, BgaPortfolioSecurityFactorChangesetInfo latestPstoChangesetInfo, BuPortfolioSecurityTargetChangesetInfo latestPstChangesetInfo, GlobeModel globe, CashModel cash, Overlaying.RootModel factors, IExpression <Decimal?> portfolioScaledGrandTotalExpression, IExpression <Decimal?> trueExposureGrandTotal, IExpression <Decimal?> trueActiveGrandTotal, DateTime benchmarkDate, Boolean isUserPermittedToSave ) { this.TargetingType = targetingType; this.Portfolio = portfolio; this.LatestTtbbvChangeset = latestTtbbvChangesetInfo; this.LatestTtbptChangeset = latestTtbptChangesetInfo; this.LatestPstoChangeset = latestPstoChangesetInfo; this.LatestPstChangeset = latestPstChangesetInfo; this.Globe = globe; this.Cash = cash; this.Factors = factors; this.PortfolioScaledGrandTotal = portfolioScaledGrandTotalExpression; this.TrueExposureGrandTotal = trueExposureGrandTotal; this.TrueActiveGrandTotal = trueActiveGrandTotal; this.BenchmarkDate = benchmarkDate; this.IsUserPermittedToSave = isUserPermittedToSave; }
/// <summary> /// Populates the taxonomy with the information pulled from the breakdown. /// </summary> public void Populate(Taxonomy taxonomy, GlobeModel root) { foreach (var resident in root.Residents) { var node = this.CreateNodeOnceResolved(resident); taxonomy.RegisterResident(node); } }
protected IEnumerable <IValidationIssue> ValidateGlobe(GlobeModel globe, CalculationTicket ticket) { var models = this.tarverser.TraverseGlobe(globe); return(models.SelectMany(model => { return this.ValidateOnceResolved(model, ticket); })); }
public IEnumerable <IModel> TraverseGlobe(GlobeModel root) { var residents = root.Residents; foreach (var resident in residents) { var models = this.TraverseOnceResolved(resident); foreach (var model in models) { yield return(model); } } }
public GlobeModel CreateGlobeModel(ICollection <IGlobeResident> residents) { var result = new GlobeModel( residents, new NullableSumExpression( ValueNames.Base, residents.Select(x => this.picker.Base.TryPickExpression(x)), this.defaultValues.DefaultBase, this.commonParts.ValidateWhatever ), new SumExpression( ValueNames.Benchmark, residents.Select(x => this.picker.Benchmark.TryPickExpression(x)), this.defaultValues.DefaultBenchmark, this.commonParts.ValidateWhatever ), new SumExpression( ValueNames.Overlay, residents.Select(x => this.picker.Overlay.TryPickExpression(x)), this.defaultValues.DefaultOverlay, this.commonParts.ValidateWhatever ), new NullableSumExpression( ValueNames.PortfolioAdjsutment, residents.Select(x => this.picker.PortfolioAdjustment.TryPickExpression(x)), this.defaultValues.DefaultPortfolioAdjustment, this.commonParts.ValidateWhatever ), new NullableSumExpression( ValueNames.PortfolioScaled, residents.Select(x => this.picker.PortfolioScaled.TryPickExpression(x)), this.defaultValues.DefaultPortfolioScaled, this.commonParts.ValidateWhatever ), new NullableSumExpression( ValueNames.TrueExposure, residents.Select(x => this.picker.TrueExposure.TryPickExpression(x)), this.defaultValues.DefaultTrueExposure, this.commonParts.ValidateWhatever ), new NullableSumExpression( ValueNames.TrueActive, residents.Select(x => this.picker.TrueActive.TryPickExpression(x)), this.defaultValues.DefaultTrueActive, this.commonParts.ValidateWhatever ) ); return(result); }
protected void TraverseGlobe(GlobeModel globe, List <IExpression> result) { var models = this.traverser.TraverseGlobe(globe); foreach (var model in models) { this.TraverseOnceResolved(model, result); } result.Add(globe.Base); result.Add(globe.Benchmark); result.Add(globe.Overlay); result.Add(globe.PortfolioAdjustment); result.Add(globe.PortfolioScaled); result.Add(globe.TrueActive); result.Add(globe.TrueExposure); }
protected void SerializeGlobe(IJsonWriter writer, GlobeModel root, CalculationTicket ticket) { this.expressionWriter.SerializeOnceResolved(root.Benchmark, JsonNames.Benchmark, writer, ticket); this.expressionWriter.SerializeOnceResolved(root.Overlay, JsonNames.Overlay, writer, ticket); this.expressionWriter.SerializeOnceResolved(root.Base, JsonNames.Base, writer, ticket); this.expressionWriter.SerializeOnceResolved(root.PortfolioAdjustment, JsonNames.PortfolioAdjustment, writer, ticket); this.expressionWriter.SerializeOnceResolved(root.PortfolioScaled, JsonNames.PortfolioScaled, writer, ticket); this.expressionWriter.SerializeOnceResolved(root.TrueExposure, JsonNames.TrueExposure, writer, ticket); this.expressionWriter.SerializeOnceResolved(root.TrueActive, JsonNames.TrueActive, writer, ticket); writer.WriteArray(root.Residents, JsonNames.Residents, resident => { writer.Write(delegate { resident.Accept(new IBreakdownModelResident_Resolver(this, writer, ticket)); }); }); }
public IExpression <Decimal?> CreateBaseLessOverlayTotalExpression( GlobeModel root, GlobeTraverser traverser, IModelFormula <IModel, Decimal?> baseLessOverlayFormula, IExpression <Decimal?> cashRescaledBase ) { var models = traverser.TraverseGlobe(root); var result = new Expression <Decimal?>( ValueNames.BaseLessOverlayTotal, new BaseLessOverlayTotalFormula( models, baseLessOverlayFormula, cashRescaledBase ), this.commonParts.NullableDecimalValueAdapter, this.commonParts.ValidateWhatever ); return(result); }
/// <summary> /// Sum of the base values of the records that have their portfolio adjustment values set. /// </summary> public IExpression <Decimal?> CreateBaseWherePortfoioAdjustmentSetTotal(GlobeTraverser traverser, GlobeModel root) { var result = new Expression <Decimal?>( ValueNames.BaseWherePortfolioAdjustmentSetTotal, new Computing.BaseWherePortfoioAdjustmentSetTotalFormula(root, traverser), this.commonParts.NullableDecimalValueAdapter, this.commonParts.ValidateWhatever ); return(result); }
public IFormula <Decimal?> CreateBaseForCashFormula(GlobeModel root) { return(new Computing.BaseForCashFormula(root)); }