callthetapaths.java
来自「金融资产定价,随机过程,MONTE CARLO 模拟 JAVA 程序和文档资料」· Java 代码 · 共 102 行
JAVA
102 行
/* 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*//* * PathBranchDemo.java * * Created on March 29, 2002, 9:10 PM */package Examples.Paths;import Market.*;import Options.*;import Graphics.*;/** <p>Displays paths of the call theta computed along simulated * paths of the unerlying.</p> * * @author Michael J. Meyer */public class CallThetaPaths { /** Displays a new path of the theta of a one year call whenever * the window is clicked. */ public static void main(String[] args) { int T=50, // time steps to horizon nPaths=10000, nSignChange=5, // irrelevant but needed for asset constructor w=600, h=350, xOffset=70, yOffset=70; final double S_0=50, mu=0.24, sigma=0.31, q=0.0, r=0.07, dt=0.02, K=100, depth=Math.abs(K-S_0); final double[] path=new double[T+1]; // the underlying, nSignChange=8 final ConstantVolatilityAsset asset=new ConstantVolatilityAsset(T,dt,8,S_0,r,q,mu,sigma); // the call final BlackScholesCall call=new BlackScholesCall(K,asset); double y0=call.analyticTheta(0); PathFrame window=new PathFrame ("Call theta",w,h,xOffset,yOffset,T,dt,y0){ public double[] nextPath() { asset.newPath(Market.Flag.MARKET_PROBABILITY); int T=call.get_T(); for(int t=0;t<T+1;t++) path[t]=call.analyticTheta(t); return path; } }; // end Window window.show(); } // end main } // end PathBranchDemo
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?