⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 swaptionprice.java

📁 金融资产定价,随机过程,MONTE CARLO 模拟 JAVA 程序和文档资料
💻 JAVA
字号:
/* WARANTY NOTICE AND COPYRIGHTThis program is free software; you can redistribute it and/ormodify it under the terms of the GNU General Public Licenseas published by the Free Software Foundation; either version 2of the License, or (at your option) any later version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.Copyright (C) Michael J. Meyermatmjm@mindspring.comspyqqqdia@yahoo.com*//* * SwaptionPrice.java * * Created on November 21, 2002, 21:09 PM */package Examples.Pricing;import Libor.LiborProcess.*;import Libor.LiborDerivatives.*;import Statistics.*;import Triggers.*;import LinAlg.*;/** <p>Bermudan Swaption. Limited functionality. Intended to support some  *  experiments. The underlying swap is assumed to end at the terminal *  date of the underlying Libor process.</p> *  * <p>Computes the prices of a complete set of coterminal European swaptions * with semiannual accrual terminating 20 years in the future (n=40). * The prices two Bermudan swaptions ending at the same date but with different  * starting dates.</p> * * @author  Michael J. Meyer */public class SwaptionPrice {                public static void main(String[] args)     {         // Libor process setup         int n=40, p;                   double kappa=0.04;   // strike rate                // Libor parameter sample          final LMM_Parameters lmmParams=new LMM_Parameters(n,LMM_Parameters.JR);         final LiborProcess LP=new LiborProcess(lmmParams);                // print the European swaption prices         for(p=1;p<39;p++){             final LiborDerivative eswpn=new Swaption(LP,p,p,n,kappa);             double eprice=eswpn.analyticForwardPrice(0)*LP.B0(n);             eprice=FinMath.round(eprice,5);             System.out.println(eprice);         }                  // compute the Bermudan swaption         p=4;                  final BermudanSwaption bswpn=new BermudanSwaption(LP,p,kappa);                  // naive exercise trigger         Trigger exercise=bswpn.pureTrigger();                  long before, after; double time;         before=System.currentTimeMillis();         // all prices forward prices at time T_n         int nPath=50000;             // number of Libor paths         double bprice=bswpn.monteCarloForwardPrice(nPath,exercise)*LP.B0(n);                    after=System.currentTimeMillis();         time=(after-before)*0.001;                String report=LP.toString()+         "\n\nBermudan payer swaption: "+         "semi annual, "+n/2+" non call "+p/2+", Strike: "+kappa+         "\nBermudan price: "+bprice+         "\nPaths: "+nPath+         "\ntime: "+time+" sec.";         System.out.println(report);                   } // end main                                                      } // end SwaptionPrice        

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -