Assembla home | Assembla project page
 

Changeset 201

Show
Ignore:
Timestamp:
05/30/08 06:14:31 (4 months ago)
Author:
snovik
Message:

Changed: Optimisation on option engines

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/QLNet/QLNet/PricingEngine.cs

    r200 r201  
    5353        public void reset() { results_.reset(); } 
    5454 
    55         public virtual void calculate() {
     55        public virtual void calculate() { throw new NotSupportedException();
    5656 
    5757        #region Observer & Observable 
  • trunk/QLNet/QLNet/Pricingengines/vanilla/FDAmericanEngine.cs

    r165 r201  
    3030        - the correctness of the returned greeks is tested by reproducing numerical derivatives. 
    3131    */ 
    32     public class FDAmericanEngine : FDEngineAdapter<FDAmericanCondition<FDStepConditionEngine>, OneAssetOption.Engine, 
    33                                                     OneAssetOption.Arguments, OneAssetOption.Results>,  
     32    public class FDAmericanEngine : FDEngineAdapter<FDAmericanCondition<FDStepConditionEngine>, OneAssetOption.Engine>,  
    3433                                    IFDEngine { 
    3534        // required for generics 
  • trunk/QLNet/QLNet/Pricingengines/vanilla/FDShoutEngine.cs

    r165 r201  
    2929              reproducing numerical derivatives. 
    3030    */ 
    31     public class FDShoutEngine : FDEngineAdapter<FDShoutCondition<FDStepConditionEngine>, VanillaOption.Engine, 
    32                                                  OneAssetOption.Arguments, OneAssetOption.Results>, 
     31    public class FDShoutEngine : FDEngineAdapter<FDShoutCondition<FDStepConditionEngine>, VanillaOption.Engine>, 
    3332                                 IFDEngine { 
    3433        // required for generics 
  • trunk/QLNet/QLNet/Pricingengines/vanilla/FDVanillaEngine.cs

    r200 r201  
    160160    } 
    161161 
    162     public class FDEngineAdapter<Base, Engine, ArgumentsType, ResultsType> : FDVanillaEngine, IGenericEngine 
     162    public class FDEngineAdapter<Base, Engine> : FDVanillaEngine, IGenericEngine 
    163163        where Base : FDConditionEngineTemplate, new() 
    164         where Engine : IGenericEngine 
    165         where ArgumentsType : IPricingEngineArguments, new() 
    166         where ResultsType : IPricingEngineResults, new() { 
     164        where Engine : IGenericEngine, new() { 
    167165 
    168166        // a wrap-up of base engine 
     
    179177 
    180178        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 
    192192 
    193193        #region Observer & Observable 
     
    205205        public void update() { notifyObservers(); } 
    206206        #endregion 
    207         #endregion 
    208207    } 
    209208}