Good morning all,
I think that it would be really useful to be able to define a payoff using a script. But it seems that such a solution does not yet exist. The aim would be to allow users specify a payoff in a script which would not require the C++ project to be recompiled. The payoff script could be used in the MC engine. Here are some suggestions, ___________________________________________________________________ Development phase 1 could enable the following for use in a MC engine: (i) at run-time, the user would pass in 1: an array which contained the constants required to specify the payoff, and 2: the payoff script for a vanilla call, the input array would be of length 1 and it would contain the strike. the payoff script would just be: value = DiscFact[numTimeSteps - 1] * max( 0, Spot[numTimeSteps - 1] - input_array[0] ); (ii) after some initial pre-processing, the evaluation script would be called once for each simulation (iii) there are 3 predefined variables: numTimeSteps the number of time steps in the path Spot[0, ... , numTimeSteps-1] array of spot prices for one given path DiscFact[0, ... , numTimeSteps-1] array of discount factors (iv) the payoff scripting language would need: for loop, if statement the assignment operator some basic comparison operators ==, >=, <=, <, > some simple maths operators: +,-,*./,^, some simple functions, exp(.), log(..), min(.,,), max(.,.) the only types would be double (real) and array of doubles ___________________________________________________________________ It would be nice if it were set-up in such a way that it worked well with a range of different underlying types: equity, fx, interest-rate, commodity, credit. Possible extentions: A: enable it to be called from (my favourite) excel B: allow the user to give names to the input variables, for example strike, this will make scripts much more legible C: allow functions to be defined in the scripts D: for efficiency there would be numerous vector based functions available which would be much faster than for-loops E: allow multi factor underlyings, so the spot above would become a matrix S[ num_underlyings, num_time_steps] If we're a little bit clever in designing the code, then they would be much code re-use when extending it to be used in the PDE solver, though in that case, clearly the user wouldn't have access to a full (simulation) path spot[0,..,numTimeSteps-1] Regards Philip P.S. there is an old discussion which touches on this: http://old.nabble.com/Question-regarding-range-of-strings-in-ObjectHandler-td18009446.html ------------------------------------------------------------------------------ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Free forum by Nabble | Edit this page |