[Rquantlib-commits] r274 - pkg/RQuantLib/src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Jul 17 18:46:48 CEST 2010


Author: knguyen
Date: 2010-07-17 18:46:48 +0200 (Sat, 17 Jul 2010)
New Revision: 274

Modified:
   pkg/RQuantLib/src/asian.cpp
Log:
asian option

Modified: pkg/RQuantLib/src/asian.cpp
===================================================================
--- pkg/RQuantLib/src/asian.cpp	2010-07-17 00:31:25 UTC (rev 273)
+++ pkg/RQuantLib/src/asian.cpp	2010-07-17 16:46:48 UTC (rev 274)
@@ -64,9 +64,7 @@
 
         boost::shared_ptr<StrikedTypePayoff> payoff(new PlainVanillaPayoff(optionType,strike));
 
-        Date exDate = today + int(maturity * 360 + 0.5);
-        boost::shared_ptr<Exercise> exercise(new EuropeanExercise(exDate));
-        
+      
 
         Average::Type averageType = Average::Geometric;
         Rcpp::List rl = R_NilValue;
@@ -76,6 +74,9 @@
             boost::shared_ptr<PricingEngine> 
                 engine(new
                        AnalyticContinuousGeometricAveragePriceAsianEngine(stochProcess));        
+            
+            Date exDate = today + int(maturity * 360 + 0.5);
+            boost::shared_ptr<Exercise> exercise(new EuropeanExercise(exDate));        
             ContinuousAveragingAsianOption option(averageType, payoff, exercise);
             option.setPricingEngine(engine);
             
@@ -111,11 +112,15 @@
             Real runningSum = 0.0;
             Size pastFixing = 0;
 
+            boost::shared_ptr<Exercise> exercise(new
+                                                 EuropeanExercise(fixingDates[fixings-1]));
+
             DiscreteAveragingAsianOption option(Average::Arithmetic, 
                                                 runningSum,
                                                 pastFixing, 
                                                 fixingDates,
-                                                payoff, exercise);
+                                                payoff, 
+                                                exercise);
             option.setPricingEngine(engine);
             rl = Rcpp::List::create(Rcpp::Named("value") = option.NPV(),
                                     Rcpp::Named("delta") = R_NaN,



More information about the Rquantlib-commits mailing list