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

📄 americanbasketprice.java

📁 金融资产定价,随机过程,MONTE CARLO 模拟 JAVA 程序和文档资料
💻 JAVA
字号:
/* * AmericanBasketPrice.java * * Created on November 13, 2002, 8:47 PM */package Examples.Pricing;import Market.*;import Options.*;import Triggers.*;import LinAlg.*;/** Computes the price of the American option from the Haugh/Kogan paper  *  under the naive exercise policy for various values of the parameter alpha. * * @author  Michael J. Meyer */public class AmericanBasketPrice {        public static void main(String[] args)    {                long before, after;        double time;                // European price, one time step to horizon        final int dim=5,                   T=10,                  nPath=10000,                  nBranch=1000;                final double dt=3.0/T, r=0.05, q=0.1, sigma=0.2, K=100.0;                        // basket of uncorrelated assets, one time step to horizon        final double[] S_0=new double[dim];        for(int i=0;i<dim;i++)S_0[i]=100;        DiagonalBasket         assets=new DiagonalBasket(1,3.0,S_0,r,q,sigma);                // European call on maximum        BasketOption         EuroCallOnMaximum=new BasketOption(assets,"eurocall"){                        public double currentDiscountedPayoff(){                                ColtVector[] S=get_underlying().get_S();                double[] B=get_underlying().get_B();                double max=0, S_iT;                for(int i=0;i<dim;i++){ S_iT=S[1].getQuick(i);                                        if(S_iT>max)max=S_iT; }                return (max>K/B[1])? max-K/B[1] : 0;            }        }; // end CallOnMaximum                double         euroPrice=EuroCallOnMaximum.discountedMonteCarloPrice(400000);                System.out.println("euroPrice="+euroPrice);                                // American call on maximum        assets=new DiagonalBasket(T,dt,S_0,r,q,sigma);                        AmericanBasketOption         CallOnMaximum=new AmericanBasketOption(assets){                        public double currentDiscountedPayoff(int t){                                ColtVector[] S=get_underlying().get_S();                double[] B=get_underlying().get_B();                double max=0, S_it;                for(int i=0;i<dim;i++){ S_it=S[t].getQuick(i);                                        if(S_it>max)max=S_it; }                return (max>K/B[t])? max-K/B[t] : 0;            }        }; // end CallOnMaximum                        /* pure exercise policy and corresponding price        before=System.currentTimeMillis();                Trigger pureExercise=CallOnMaximum.pureExercise(nBranch);        double  purePrice=        CallOnMaximum.discountedMonteCarloPrice(nPath,pureExercise);                after=System.currentTimeMillis();        time=0.001*(after-before);                System.out.println("purePrice="+purePrice+", time: "+time);        */                        // cvx exercise policy and corresponding price        before=System.currentTimeMillis();        double alpha=0.85, beta=150;        Trigger cvx=CallOnMaximum.convexTrigger(alpha,beta,nBranch);        double  cvxPrice=        CallOnMaximum.discountedMonteCarloPrice(nPath,cvx);                after=System.currentTimeMillis();        time=0.001*(after-before);                System.out.println("cvxPrice="+cvxPrice+", time: "+time);                /*        // upper bound        before=System.currentTimeMillis();        double upperBd=CallOnMaximum.upperBound(nPath,naiveExercise);        after=System.currentTimeMillis();        time=0.001*(after-before);                System.out.println("Upper bound = "+upperBd+", time: "+time);        */            } // end main    }

⌨️ 快捷键说明

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