![]() |
Enron Mail |
Please find attached the code for the HJM simulation model for option pricing and other necessities.
The model takes as inputs prices and volatilities and generates a daily spot price grid and respective transition probabilities - a framework for pricing options of multiple kinds. As it is, the model seems quite flexible and detailed. It takes care of fwd-fwd volatilities and uses different factor loadings for each month - this means that the model takes different PCAs as as the curve shrinks in time. Also, the user may define as many factors as the size of # of points in the fwd curve. One interesting aspect is the way I evolved the spot price to provide convergence to the prompt month price as the month approaches its end. Before shocking prices (spot and fwds) I get the expected spot for the next day by linear interpolation with the prompt fwd. By ensuring convergence, however, the model creates a spot price vol that converges to the prompt month vol. The phenomena is illustrated in the spreadsheet example where I call the model for each day of the first month to calculate the respective daily expected prices and vols. As usual, I put the whole project on o:\research\common\project\options\HJM. It is self-contained - no need for other files and the whole source code is there. To see the the spreadsheet you need to install the fwd-fwd vol function and the loading factor function. You will find these things on o:\research\custom. Note that this is not necessary to run the model itself. It just makes the spreadsheet more illustrative and the code more understandable. Regarding the last, I tried as much as possible to make the code clear and lean hoping that you feel confortable with its pieces and usability. These are the files: HJMsim.c - Main file HJM.c - Where the simulation is actully run Support.c - set of support functions for the simulation (fwd-fwd, PCA, etc...) NRC.c - set of NRC functions I used (changed variables from float to double) NRUTIL.c - modified to accomodate memory management of double tensors Please let me know your opinion and the bugs. Thanks.
|