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

📄 tradinggainshistogram.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*//* * TradingGainsHistogram.java * * Created on March 19, 2002, 2:05 AM */package Examples.Trading;import hep.aida.*;import Statistics.*;import Market.*;import TradingStrategies.*;import Triggers.*;import java.lang.Math;import jas.hist.*;import jas.hep.*;import javax.swing.*;/** <p>Draws histogram of gains from trading for the trading strategies *  <code>StrategyAverageDown</code> trading a  *  <code>ConstantVolatilityAsset</code>. 100 shares are bought initially *  and then 100 more shares are bought whenever the asset price declines 5 *  percent from the level of the last buy.</p> *   *  <p>Console program, no user interaction.  *  All parameters fixed in source code.</p> * * @author Michael J. Meyer */public class TradingGainsHistogram {       public static void main(String[] argv)   {            int  T=50,           nPaths=400000,           nBins=100,           nSignChange=5,    // irrelevant but needed for asset constructor           triggerPercentage=5;                   double S_0=50,             mu=0.24,             sigma=0.31,             q=0.05,             r=0.07,             dt=0.02,             fixed_trc=10,    // fixed transaction costs             prop_trc=0.25;   // proportional transaction costs                                 ConstantVolatilityAsset       asset=new ConstantVolatilityAsset(T,dt,nSignChange,S_0,r,q,mu,sigma);              TradingStrategy        averageDown=new StrategyAverageDown                       (fixed_trc,prop_trc,asset,triggerPercentage);       double initialInvestment=averageDown.initialInvestment();                     RandomVariable        gainsFromTrading=averageDown.discountedGainsFromTrading();              // let the user know what's going on       String message=       "Asset: mu="+mu+", sigma="+sigma+", q="+q+", r="+r+"\n"+       "Strategy: average down, buy 100 more shares whenever the asset price\n"+       "declines "+triggerPercentage+"% from the level of the last buy.\n"+       "Initial investement: "+initialInvestment+"\n"+       "Transaction costs: fixed="+fixed_trc+", proportional="+prop_trc+"\n\n"+       "Computing histogram of gains from trading: "+nPaths+" paths, "+       nBins+" bins.";              System.out.println(message);              // show the histogram        gainsFromTrading.displayHistogram(nPaths,nBins,true);           } // end main} // end histogram

⌨️ 快捷键说明

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