Changeset 201
- Timestamp:
- 05/30/08 06:14:31 (4 months ago)
- Files:
-
- trunk/QLNet/QLNet/PricingEngine.cs (modified) (1 diff)
- trunk/QLNet/QLNet/Pricingengines/vanilla/FDAmericanEngine.cs (modified) (1 diff)
- trunk/QLNet/QLNet/Pricingengines/vanilla/FDShoutEngine.cs (modified) (1 diff)
- trunk/QLNet/QLNet/Pricingengines/vanilla/FDVanillaEngine.cs (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/QLNet/QLNet/PricingEngine.cs
r200 r201 53 53 public void reset() { results_.reset(); } 54 54 55 public virtual void calculate() { }55 public virtual void calculate() { throw new NotSupportedException(); } 56 56 57 57 #region Observer & Observable trunk/QLNet/QLNet/Pricingengines/vanilla/FDAmericanEngine.cs
r165 r201 30 30 - the correctness of the returned greeks is tested by reproducing numerical derivatives. 31 31 */ 32 public class FDAmericanEngine : FDEngineAdapter<FDAmericanCondition<FDStepConditionEngine>, OneAssetOption.Engine, 33 OneAssetOption.Arguments, OneAssetOption.Results>, 32 public class FDAmericanEngine : FDEngineAdapter<FDAmericanCondition<FDStepConditionEngine>, OneAssetOption.Engine>, 34 33 IFDEngine { 35 34 // required for generics trunk/QLNet/QLNet/Pricingengines/vanilla/FDShoutEngine.cs
r165 r201 29 29 reproducing numerical derivatives. 30 30 */ 31 public class FDShoutEngine : FDEngineAdapter<FDShoutCondition<FDStepConditionEngine>, VanillaOption.Engine, 32 OneAssetOption.Arguments, OneAssetOption.Results>, 31 public class FDShoutEngine : FDEngineAdapter<FDShoutCondition<FDStepConditionEngine>, VanillaOption.Engine>, 33 32 IFDEngine { 34 33 // required for generics trunk/QLNet/QLNet/Pricingengines/vanilla/FDVanillaEngine.cs
r200 r201 160 160 } 161 161 162 public class FDEngineAdapter<Base, Engine , ArgumentsType, ResultsType> : FDVanillaEngine, IGenericEngine162 public class FDEngineAdapter<Base, Engine> : FDVanillaEngine, IGenericEngine 163 163 where Base : FDConditionEngineTemplate, new() 164 where Engine : IGenericEngine 165 where ArgumentsType : IPricingEngineArguments, new() 166 where ResultsType : IPricingEngineResults, new() { 164 where Engine : IGenericEngine, new() { 167 165 168 166 // a wrap-up of base engine … … 179 177 180 178 public void calculate() { 181 optionBase.setupArguments(arguments_); 182 optionBase.calculate(results_); 183 } 184 185 #region IGenericEngine copy-cat 186 protected IPricingEngineArguments arguments_ = new ArgumentsType(); 187 protected IPricingEngineResults results_ = new ResultsType(); 188 189 public IPricingEngineArguments getArguments() { return arguments_; } 190 public IPricingEngineResults getResults() { return results_; } 191 public void reset() { results_.reset(); } 179 optionBase.setupArguments(getArguments()); 180 optionBase.calculate(getResults()); 181 } 182 183 184 #region IGenericEngine wrap-up 185 // we do not need to register with the wrapped engine because all we need is containers for parameters and results 186 protected IGenericEngine engine_ = new Engine(); 187 188 public IPricingEngineArguments getArguments() { return engine_.getArguments(); } 189 public IPricingEngineResults getResults() { return engine_.getResults(); } 190 public void reset() { engine_.reset(); } 191 #endregion 192 192 193 193 #region Observer & Observable … … 205 205 public void update() { notifyObservers(); } 206 206 #endregion 207 #endregion208 207 } 209 208 }