1 / 9

Ass 2/3 – One Solution

Ass 2/3 – One Solution. Holding amount double value(Scenario). FinancialEntity name double value(Scenario). Instrument currency. Bond …. Option …. Equity …. Instruments & Portfolios. sax.DocumentHandler. FinancialEntityFactory FinancialEntity make(String)

alfredp
Download Presentation

Ass 2/3 – One Solution

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Ass 2/3 – One Solution CSC407

  2. Holding amount double value(Scenario) FinancialEntity name double value(Scenario) Instrument currency Bond … Option … Equity … Instruments & Portfolios sax.DocumentHandler FinancialEntityFactory FinancialEntity make(String) register(FinancialEntity) * prototypes * Portfolio CSC407

  3. FinancialEntity name double value(Scenario) PricingFunction double value(FinancialEntity, Scenario) boolean canPrice(FinancialEntity) PricingFunctionFactory PricingFunction getDefault(FinancialEntity) register(PricingFunction) Pricing Functions prototypes * 1 1 BondPricingFunction EquityPricingFunction FXFuturesPricingFunction 2 1..2 IRCurve EquityIndex FXRate CSC407

  4. Pricing Function Code public class EquityPricingFunction extends PricingFunction { public boolean canPrice(FinancialEntity fe) { return fe instanceof Equity; } public double value(FinancialEntity fe, Scenario s) { Equity e = (Equity)fe; … } public initialize(FinancialEntity fe) { Equity e = (Equity)fe; equityIndex = MarketData.getEquityIndex(fe.currency()); } private EquityIndex equityIndex; } CSC407

  5. IRCurve double get(Scenario, double yrs) EquityIndex double get(Scenario) FXRate double get(Scenario); IRCurveImpl double yrs[], rates[] MarketData MarketData name currency static getEquityIndex(currency) … activate(Scenario, Shift) deactivate(Scenario) returns IRCurveShift IRCurveSwitch * Shift indexed by active scenario CSC407

  6. Shift percentage activate(Scenario) deactivate() Scenario name activate(int tid) deactivate() Scenarios ScenarioSet * 1 * MarketData activate(Scenario, Shift) on CSC407

  7. Shift Scenario Scenario Shift IRCurveShift IRCurveSwitch Shift IRCurveShift Scenario Shift IRCurveShift Shift Holding = 1 Holding = 1 Portfolio Portfolio Holding = 10 Holding = 23 BondPF Equity Bond EquityPF Object Diagram ScenarioSet IRCurveImpl Potfolio CSC407

  8. Scenario Activation Thread.run() { int tid = ThreadSet.getNextId(); while(ScenarioSet.stillMore()) { Scenario s = ScenarioSet.getNextScenarioToProcess(); s.activate(tid); s.saveResult(Portfolio.getRoot().value(s)); s.deactivate(); } } Scenario.activate(tid) { for each Shift s { shift.activate(this); } } Shift.activate(Scenario s) { marketData.activate(s, this) } EquityIndexSwitch.activate(Scenario s, Shift shift) { activeScenarios[s.getId()] = new EquityIndexShift(shift); } CSC407

  9. MarketData Pricing Code public class EquityIndexImpl extends EquityIndex { public double get(Scenario s) { return level; } double level; } public class EquityIndexShift extends EquityIndex { public double get(Scenario s) { return e.get(s) * (1+shift.getPercentage()); } EquityIndex e; Shift shift; } public class EquityIndexSwitch extends EquityIndex { public double get(Scenario s) { if(s == null) return eq.get(s); else return activeScenarios[s.getId()].get(s); } EquityIndex activeScenarios[] = new EquityIndex[MAX_THREADS]; EqutyIndex eq; } CSC407

More Related