File: graph.R

package info (click to toggle)
quantlib-swig 0.9.0-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 58,200 kB
  • ctags: 105,353
  • sloc: cpp: 1,047,001; ansic: 133,430; ml: 54,990; cs: 34,216; java: 23,659; perl: 17,882; python: 8,891; lisp: 2,337; ruby: 1,140; sh: 458; makefile: 355
file content (21 lines) | stat: -rw-r--r-- 882 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
quote <- function(x) {sapply(x, function(x1) {
todaysDate <- Date(15, "May", 1998)
Settings_instance()$setEvaluationDate(d=todaysDate)
settlementDate <- Date(17, "May", 1998)
riskFreeRate <- FlatForward(settlementDate, 0.05, Actual365Fixed())
exercise <- EuropeanExercise(Date(17, "May", 1999))
payoff <- PlainVanillaPayoff("Call", 8.0)
underlying <- SimpleQuote(x1)
volatility <- BlackConstantVol(todaysDate, TARGET(), 0.10, Actual365Fixed())
dividendYield <- FlatForward(settlementDate, 0.05, Actual365Fixed())
process <- BlackScholesMertonProcess(QuoteHandle(underlying),
		YieldTermStructureHandle(dividendYield),
		YieldTermStructureHandle(riskFreeRate),
		BlackVolTermStructureHandle(volatility))
option <- VanillaOption(process, payoff, exercise)
Instrument_setPricingEngine(option, s_arg2=AnalyticEuropeanEngine())
value <- option$NPV()
value
})}

curve(quote,xlim=c(1,20))