I tried many times, but it went wrong and i don't know how to fix it.
I used the DiscreteAveragingAsianOption method to price the arithmetic option where i used the MCDiscreteArithmeticAPEngine to generize the Monte Carlo path of Underlying prices. But I cann't correctly quote the two functions. If there are any python docs or examples to price the arithmetc option? I searched the internet for a long time with little materials.Some of my codes are as follows: process2 = GeneralizedBlackScholesProcess(QuoteHandle(underlying), YieldTermStructureHandle(dividendYield), YieldTermStructureHandle(riskFreeRate), BlackVolTermStructureHandle(volatility)) #asian settings averageType = Average().Arithmetic runningAccumulator = 1 pastFixings = 0 fixingDates = [] isBrownianbridge = False isAntitheticvariate = True isControlvariate = False requiredSamples = 10000 requiredTolerance = 1e-3 maxSamples = 100000 seed = 42 enginestr = 'pr' option = DiscreteAveragingAsianOption(averageType, runningAccumulator, pastFixings, fixingDates, payoff, excercise) engine = MCDiscreteArithmeticAPEngine(process2, enginestr, isBrownianbridge, isAntitheticvariate, isControlvariate, requiredSamples, requiredTolerance, maxSamples, seed) Plz tell what's wrong or how to quote the two functions!! |
If you're asking for the next step, that would be option.setPricingEngine(engine) print option.NPV() If you tried that and didn't work, it might be because you're not defining any fixing dates, and a discrete-averaging Asian option needs some. If it still doesn't work, please attach a complete example. Luigi On Tue, Apr 11, 2017 at 11:04 AM floatwing <[hidden email]> wrote: I tried many times, but it went wrong and i don't know how to fix it. ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Thank you for your reply first! I am not asking for the next step. I mean there might be argument errors in the MCDiscreteGeometricAPEngine function(the arguments the function needs is hard to find in python), event when i set the fixingDates = [Date(30,12,2017)] for example.By the way, what does 'fixingDates' mean? I will attatch the new code to the poster, can you have a check what's wrong to my code?It result in the python kernel died.Codes are as follows:
from QuantLib import * import matplotlib.pyplot as plt #global data stday = 12 stmonth = March styear = 2017 todaysDate = Date(stday, stmonth, styear) Settings.instance().evaluationDate = todaysDate calendar = China() dayCounter = Actual365Fixed() settlementDate = todaysDate riskFreeRate = FlatForward(settlementDate, 0.035, dayCounter) #option parameters edday = 28 edmonth = March edyear = 2017 K = 8 exercise = EuropeanExercise(Date(edday, edmonth, edyear)) payoff = PlainVanillaPayoff(Option.Call, K) #market data underlying = SimpleQuote(9) volatility = BlackConstantVol(todaysDate, calendar, 0.20, dayCounter) dividendYield = FlatForward(settlementDate, 0.001, dayCounter) process1 = BlackScholesMertonProcess(QuoteHandle(underlying), YieldTermStructureHandle(dividendYield), YieldTermStructureHandle(riskFreeRate), BlackVolTermStructureHandle(volatility)) process2 = GeneralizedBlackScholesProcess(QuoteHandle(underlying), YieldTermStructureHandle(dividendYield), YieldTermStructureHandle(riskFreeRate), BlackVolTermStructureHandle(volatility)) #asian settings #try: averageType = Average().Arithmetic runningAccumulator = 0 pastFixings = 0 fixingDates = [settlementDate] option = DiscreteAveragingAsianOption(averageType, runningAccumulator, pastFixings, fixingDates, payoff, exercise) stepPerYear = 12 MCstr = 'PseudoRandom' isBB = True isAV = True isCV = True nrequire = 10000 tolerance = 0.0002 nmax = 15000 seed = 100 seednum = LecuyerUniformRng(1000).next().value() priceEngine1 = MCDiscreteArithmeticAPEngine(process2, MCstr, isBB, isAV, isCV, nrequire, tolerance, nmax, seed) priceEngine2 = MCDiscreteGeometricAPEngine(process2, MCstr, isBB, isAV, 100,0.005, 150, 50)# may need a argument(maxTimeStepsPerYear) option.setPricingEngine(priceEngine2) print option.delta() |
Hello, thanks for bringing this up. There's a couple of things we should fix with the engine. In the meantime:ut First, the discrete Asian option calculates the average price (the one that goes into the payoff) at a number of fixings dates specified by the contract. The Monte Carlo engine needs at least one of them to be in the future, otherwise everything is determined and there's no point in doing a Monte Carlo simulation. However, trying the calculation with missing fixing dates should raise an exception, not crash the program. We'll try to fix that in a future release, but in the meantime, passing a sensible list of dates will cause the calculation to succeed. Second: depending on whether you use the Arithmetic or Geometric engine (it's not clear from your example) you'll need a different runningAccumulator value. The Arithmetic average adds the fixings, so you need a starting value of 0; the Geometric average multiplies the fixings, so you need to start from 1 (a 0 will cause the NPV to be null). This, too, could be improved, meaning that when there's no past fixings the correct value should be chosen by the engine; but in the meantime, you can specify it yourself. Luigi On Tue, Apr 18, 2017 at 11:58 AM floatwing <[hidden email]> wrote: Thank you for your reply first! I am not asking for the next step. I mean ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Free forum by Nabble | Edit this page |