Click here to Skip to main content
15,884,990 members
Articles / Programming Languages / C#

Option pricing with discrete dividends using the Binomial Tree model

Rate me:
Please Sign up or sign in to vote.
4.07/5 (5 votes)
17 Jun 2007CPOL4 min read 42.9K   675   30  
Pricing European and American call and put options using the binomial tree model. Handles discrete dividends paid on underlying.
namespace BinomialTreeUI
{
    partial class Form1
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.label1 = new System.Windows.Forms.Label();
            this.txtStockPrice = new System.Windows.Forms.TextBox();
            this.label2 = new System.Windows.Forms.Label();
            this.txtStrike = new System.Windows.Forms.TextBox();
            this.label3 = new System.Windows.Forms.Label();
            this.rdoCall = new System.Windows.Forms.RadioButton();
            this.rdoPut = new System.Windows.Forms.RadioButton();
            this.label4 = new System.Windows.Forms.Label();
            this.label5 = new System.Windows.Forms.Label();
            this.txtVol = new System.Windows.Forms.TextBox();
            this.label6 = new System.Windows.Forms.Label();
            this.txtTimeToExpiration = new System.Windows.Forms.TextBox();
            this.label7 = new System.Windows.Forms.Label();
            this.txtRate = new System.Windows.Forms.TextBox();
            this.txtYield = new System.Windows.Forms.TextBox();
            this.label8 = new System.Windows.Forms.Label();
            this.chkFuture = new System.Windows.Forms.CheckBox();
            this.label9 = new System.Windows.Forms.Label();
            this.chkAmerican = new System.Windows.Forms.CheckBox();
            this.label10 = new System.Windows.Forms.Label();
            this.label11 = new System.Windows.Forms.Label();
            this.label12 = new System.Windows.Forms.Label();
            this.label13 = new System.Windows.Forms.Label();
            this.label14 = new System.Windows.Forms.Label();
            this.label15 = new System.Windows.Forms.Label();
            this.label16 = new System.Windows.Forms.Label();
            this.label17 = new System.Windows.Forms.Label();
            this.label18 = new System.Windows.Forms.Label();
            this.date1 = new System.Windows.Forms.TextBox();
            this.date2 = new System.Windows.Forms.TextBox();
            this.date3 = new System.Windows.Forms.TextBox();
            this.date4 = new System.Windows.Forms.TextBox();
            this.dividend1 = new System.Windows.Forms.TextBox();
            this.dividend2 = new System.Windows.Forms.TextBox();
            this.dividend3 = new System.Windows.Forms.TextBox();
            this.dividend4 = new System.Windows.Forms.TextBox();
            this.button1 = new System.Windows.Forms.Button();
            this.label19 = new System.Windows.Forms.Label();
            this.lblResult = new System.Windows.Forms.Label();
            this.lblSteps = new System.Windows.Forms.Label();
            this.txtSteps = new System.Windows.Forms.TextBox();
            this.SuspendLayout();
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(31, 13);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(124, 13);
            this.label1.TabIndex = 0;
            this.label1.Text = "Enter Price of Underlying";
            // 
            // txtStockPrice
            // 
            this.txtStockPrice.Location = new System.Drawing.Point(307, 9);
            this.txtStockPrice.Name = "txtStockPrice";
            this.txtStockPrice.Size = new System.Drawing.Size(100, 20);
            this.txtStockPrice.TabIndex = 1;
            this.txtStockPrice.Text = "50";
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(31, 55);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(89, 13);
            this.label2.TabIndex = 2;
            this.label2.Text = "Enter Strike Price";
            // 
            // txtStrike
            // 
            this.txtStrike.Location = new System.Drawing.Point(307, 51);
            this.txtStrike.Name = "txtStrike";
            this.txtStrike.Size = new System.Drawing.Size(100, 20);
            this.txtStrike.TabIndex = 3;
            this.txtStrike.Text = "50";
            // 
            // label3
            // 
            this.label3.AutoSize = true;
            this.label3.Location = new System.Drawing.Point(31, 100);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(64, 13);
            this.label3.TabIndex = 4;
            this.label3.Text = "Call or Put ?";
            // 
            // rdoCall
            // 
            this.rdoCall.AutoSize = true;
            this.rdoCall.Checked = true;
            this.rdoCall.Location = new System.Drawing.Point(308, 96);
            this.rdoCall.Name = "rdoCall";
            this.rdoCall.Size = new System.Drawing.Size(42, 17);
            this.rdoCall.TabIndex = 5;
            this.rdoCall.TabStop = true;
            this.rdoCall.Text = "Call";
            this.rdoCall.UseVisualStyleBackColor = true;
            // 
            // rdoPut
            // 
            this.rdoPut.AutoSize = true;
            this.rdoPut.Location = new System.Drawing.Point(374, 96);
            this.rdoPut.Name = "rdoPut";
            this.rdoPut.Size = new System.Drawing.Size(41, 17);
            this.rdoPut.TabIndex = 6;
            this.rdoPut.Text = "Put";
            this.rdoPut.UseVisualStyleBackColor = true;
            // 
            // label4
            // 
            this.label4.AutoSize = true;
            this.label4.Location = new System.Drawing.Point(31, 138);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(211, 13);
            this.label4.TabIndex = 7;
            this.label4.Text = "Risk-free rate annual(absolute, not percent)";
            // 
            // label5
            // 
            this.label5.AutoSize = true;
            this.label5.Location = new System.Drawing.Point(31, 182);
            this.label5.Name = "label5";
            this.label5.Size = new System.Drawing.Size(45, 13);
            this.label5.TabIndex = 8;
            this.label5.Text = "Volatility";
            // 
            // txtVol
            // 
            this.txtVol.Location = new System.Drawing.Point(307, 176);
            this.txtVol.Name = "txtVol";
            this.txtVol.Size = new System.Drawing.Size(100, 20);
            this.txtVol.TabIndex = 9;
            this.txtVol.Text = "0.4";
            // 
            // label6
            // 
            this.label6.AutoSize = true;
            this.label6.Location = new System.Drawing.Point(31, 226);
            this.label6.Name = "label6";
            this.label6.Size = new System.Drawing.Size(127, 13);
            this.label6.TabIndex = 10;
            this.label6.Text = "Time to Expiration (Years)";
            // 
            // txtTimeToExpiration
            // 
            this.txtTimeToExpiration.Location = new System.Drawing.Point(307, 218);
            this.txtTimeToExpiration.Name = "txtTimeToExpiration";
            this.txtTimeToExpiration.Size = new System.Drawing.Size(100, 20);
            this.txtTimeToExpiration.TabIndex = 11;
            this.txtTimeToExpiration.Text = "0.5";
            // 
            // label7
            // 
            this.label7.AutoSize = true;
            this.label7.Location = new System.Drawing.Point(31, 270);
            this.label7.Name = "label7";
            this.label7.Size = new System.Drawing.Size(227, 13);
            this.label7.TabIndex = 12;
            this.label7.Text = "Dividend yield or foreign interest rate (absolute)";
            // 
            // txtRate
            // 
            this.txtRate.Location = new System.Drawing.Point(307, 134);
            this.txtRate.Name = "txtRate";
            this.txtRate.Size = new System.Drawing.Size(100, 20);
            this.txtRate.TabIndex = 13;
            this.txtRate.Text = "0.05";
            // 
            // txtYield
            // 
            this.txtYield.Location = new System.Drawing.Point(307, 260);
            this.txtYield.Name = "txtYield";
            this.txtYield.Size = new System.Drawing.Size(100, 20);
            this.txtYield.TabIndex = 14;
            // 
            // label8
            // 
            this.label8.AutoSize = true;
            this.label8.Location = new System.Drawing.Point(31, 317);
            this.label8.Name = "label8";
            this.label8.Size = new System.Drawing.Size(118, 13);
            this.label8.TabIndex = 15;
            this.label8.Text = "Is it a futures contract ?";
            // 
            // chkFuture
            // 
            this.chkFuture.AutoSize = true;
            this.chkFuture.Location = new System.Drawing.Point(307, 313);
            this.chkFuture.Name = "chkFuture";
            this.chkFuture.Size = new System.Drawing.Size(62, 17);
            this.chkFuture.TabIndex = 16;
            this.chkFuture.Text = "Future?";
            this.chkFuture.UseVisualStyleBackColor = true;
            // 
            // label9
            // 
            this.label9.AutoSize = true;
            this.label9.Location = new System.Drawing.Point(31, 355);
            this.label9.Name = "label9";
            this.label9.Size = new System.Drawing.Size(226, 13);
            this.label9.TabIndex = 17;
            this.label9.Text = "American ( If not checked assumed European)";
            // 
            // chkAmerican
            // 
            this.chkAmerican.AutoSize = true;
            this.chkAmerican.Checked = true;
            this.chkAmerican.CheckState = System.Windows.Forms.CheckState.Checked;
            this.chkAmerican.Location = new System.Drawing.Point(307, 354);
            this.chkAmerican.Name = "chkAmerican";
            this.chkAmerican.Size = new System.Drawing.Size(130, 17);
            this.chkAmerican.TabIndex = 18;
            this.chkAmerican.Text = "American Style Option";
            this.chkAmerican.UseVisualStyleBackColor = true;
            // 
            // label10
            // 
            this.label10.AutoSize = true;
            this.label10.Location = new System.Drawing.Point(31, 393);
            this.label10.Name = "label10";
            this.label10.Size = new System.Drawing.Size(258, 13);
            this.label10.TabIndex = 19;
            this.label10.Text = "Enter up to four dividend dates(in years) and amounts";
            // 
            // label11
            // 
            this.label11.AutoSize = true;
            this.label11.Location = new System.Drawing.Point(38, 419);
            this.label11.Name = "label11";
            this.label11.Size = new System.Drawing.Size(69, 13);
            this.label11.TabIndex = 20;
            this.label11.Text = "Date in years";
            // 
            // label12
            // 
            this.label12.AutoSize = true;
            this.label12.Location = new System.Drawing.Point(64, 446);
            this.label12.Name = "label12";
            this.label12.Size = new System.Drawing.Size(43, 13);
            this.label12.TabIndex = 21;
            this.label12.Text = "Amount";
            // 
            // label13
            // 
            this.label13.AutoSize = true;
            this.label13.Location = new System.Drawing.Point(64, 505);
            this.label13.Name = "label13";
            this.label13.Size = new System.Drawing.Size(43, 13);
            this.label13.TabIndex = 23;
            this.label13.Text = "Amount";
            // 
            // label14
            // 
            this.label14.AutoSize = true;
            this.label14.Location = new System.Drawing.Point(38, 478);
            this.label14.Name = "label14";
            this.label14.Size = new System.Drawing.Size(69, 13);
            this.label14.TabIndex = 22;
            this.label14.Text = "Date in years";
            // 
            // label15
            // 
            this.label15.AutoSize = true;
            this.label15.Location = new System.Drawing.Point(255, 446);
            this.label15.Name = "label15";
            this.label15.Size = new System.Drawing.Size(43, 13);
            this.label15.TabIndex = 25;
            this.label15.Text = "Amount";
            // 
            // label16
            // 
            this.label16.AutoSize = true;
            this.label16.Location = new System.Drawing.Point(229, 419);
            this.label16.Name = "label16";
            this.label16.Size = new System.Drawing.Size(69, 13);
            this.label16.TabIndex = 24;
            this.label16.Text = "Date in years";
            // 
            // label17
            // 
            this.label17.AutoSize = true;
            this.label17.Location = new System.Drawing.Point(255, 505);
            this.label17.Name = "label17";
            this.label17.Size = new System.Drawing.Size(43, 13);
            this.label17.TabIndex = 27;
            this.label17.Text = "Amount";
            // 
            // label18
            // 
            this.label18.AutoSize = true;
            this.label18.Location = new System.Drawing.Point(229, 478);
            this.label18.Name = "label18";
            this.label18.Size = new System.Drawing.Size(69, 13);
            this.label18.TabIndex = 26;
            this.label18.Text = "Date in years";
            // 
            // date1
            // 
            this.date1.Location = new System.Drawing.Point(110, 416);
            this.date1.Name = "date1";
            this.date1.Size = new System.Drawing.Size(100, 20);
            this.date1.TabIndex = 28;
            // 
            // date2
            // 
            this.date2.Location = new System.Drawing.Point(307, 419);
            this.date2.Name = "date2";
            this.date2.Size = new System.Drawing.Size(100, 20);
            this.date2.TabIndex = 29;
            // 
            // date3
            // 
            this.date3.Location = new System.Drawing.Point(110, 477);
            this.date3.Name = "date3";
            this.date3.Size = new System.Drawing.Size(100, 20);
            this.date3.TabIndex = 30;
            // 
            // date4
            // 
            this.date4.Location = new System.Drawing.Point(308, 476);
            this.date4.Name = "date4";
            this.date4.Size = new System.Drawing.Size(100, 20);
            this.date4.TabIndex = 31;
            // 
            // dividend1
            // 
            this.dividend1.Location = new System.Drawing.Point(110, 443);
            this.dividend1.Name = "dividend1";
            this.dividend1.Size = new System.Drawing.Size(100, 20);
            this.dividend1.TabIndex = 32;
            // 
            // dividend2
            // 
            this.dividend2.Location = new System.Drawing.Point(307, 444);
            this.dividend2.Name = "dividend2";
            this.dividend2.Size = new System.Drawing.Size(100, 20);
            this.dividend2.TabIndex = 33;
            // 
            // dividend3
            // 
            this.dividend3.Location = new System.Drawing.Point(110, 504);
            this.dividend3.Name = "dividend3";
            this.dividend3.Size = new System.Drawing.Size(100, 20);
            this.dividend3.TabIndex = 34;
            // 
            // dividend4
            // 
            this.dividend4.Location = new System.Drawing.Point(308, 501);
            this.dividend4.Name = "dividend4";
            this.dividend4.Size = new System.Drawing.Size(100, 20);
            this.dividend4.TabIndex = 35;
            // 
            // button1
            // 
            this.button1.Location = new System.Drawing.Point(270, 556);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(166, 60);
            this.button1.TabIndex = 36;
            this.button1.Text = "Calculate";
            this.button1.UseVisualStyleBackColor = true;
            this.button1.Click += new System.EventHandler(this.button1_Click);
            // 
            // label19
            // 
            this.label19.AutoSize = true;
            this.label19.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label19.Location = new System.Drawing.Point(31, 598);
            this.label19.Name = "label19";
            this.label19.Size = new System.Drawing.Size(62, 24);
            this.label19.TabIndex = 37;
            this.label19.Text = "Result";
            // 
            // lblResult
            // 
            this.lblResult.AutoSize = true;
            this.lblResult.BackColor = System.Drawing.SystemColors.ControlLight;
            this.lblResult.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.lblResult.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.lblResult.Location = new System.Drawing.Point(99, 597);
            this.lblResult.Name = "lblResult";
            this.lblResult.Size = new System.Drawing.Size(22, 26);
            this.lblResult.TabIndex = 38;
            this.lblResult.Text = "0";
            // 
            // lblSteps
            // 
            this.lblSteps.AutoSize = true;
            this.lblSteps.Location = new System.Drawing.Point(35, 556);
            this.lblSteps.Name = "lblSteps";
            this.lblSteps.Size = new System.Drawing.Size(116, 13);
            this.lblSteps.TabIndex = 39;
            this.lblSteps.Text = "Number of steps in tree";
            // 
            // txtSteps
            // 
            this.txtSteps.Location = new System.Drawing.Point(157, 556);
            this.txtSteps.Name = "txtSteps";
            this.txtSteps.Size = new System.Drawing.Size(100, 20);
            this.txtSteps.TabIndex = 40;
            this.txtSteps.Text = "100";
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(447, 668);
            this.Controls.Add(this.txtSteps);
            this.Controls.Add(this.lblSteps);
            this.Controls.Add(this.lblResult);
            this.Controls.Add(this.label19);
            this.Controls.Add(this.button1);
            this.Controls.Add(this.dividend4);
            this.Controls.Add(this.dividend3);
            this.Controls.Add(this.dividend2);
            this.Controls.Add(this.dividend1);
            this.Controls.Add(this.date4);
            this.Controls.Add(this.date3);
            this.Controls.Add(this.date2);
            this.Controls.Add(this.date1);
            this.Controls.Add(this.label17);
            this.Controls.Add(this.label18);
            this.Controls.Add(this.label15);
            this.Controls.Add(this.label16);
            this.Controls.Add(this.label13);
            this.Controls.Add(this.label14);
            this.Controls.Add(this.label12);
            this.Controls.Add(this.label11);
            this.Controls.Add(this.label10);
            this.Controls.Add(this.chkAmerican);
            this.Controls.Add(this.label9);
            this.Controls.Add(this.chkFuture);
            this.Controls.Add(this.label8);
            this.Controls.Add(this.txtYield);
            this.Controls.Add(this.txtRate);
            this.Controls.Add(this.label7);
            this.Controls.Add(this.txtTimeToExpiration);
            this.Controls.Add(this.label6);
            this.Controls.Add(this.txtVol);
            this.Controls.Add(this.label5);
            this.Controls.Add(this.label4);
            this.Controls.Add(this.rdoPut);
            this.Controls.Add(this.rdoCall);
            this.Controls.Add(this.label3);
            this.Controls.Add(this.txtStrike);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.txtStockPrice);
            this.Controls.Add(this.label1);
            this.Name = "Form1";
            this.Text = "FM 506 - Binomial Option Pricing Model";
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.TextBox txtStockPrice;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.TextBox txtStrike;
        private System.Windows.Forms.Label label3;
        private System.Windows.Forms.RadioButton rdoCall;
        private System.Windows.Forms.RadioButton rdoPut;
        private System.Windows.Forms.Label label4;
        private System.Windows.Forms.Label label5;
        private System.Windows.Forms.TextBox txtVol;
        private System.Windows.Forms.Label label6;
        private System.Windows.Forms.TextBox txtTimeToExpiration;
        private System.Windows.Forms.Label label7;
        private System.Windows.Forms.TextBox txtRate;
        private System.Windows.Forms.TextBox txtYield;
        private System.Windows.Forms.Label label8;
        private System.Windows.Forms.CheckBox chkFuture;
        private System.Windows.Forms.Label label9;
        private System.Windows.Forms.CheckBox chkAmerican;
        private System.Windows.Forms.Label label10;
        private System.Windows.Forms.Label label11;
        private System.Windows.Forms.Label label12;
        private System.Windows.Forms.Label label13;
        private System.Windows.Forms.Label label14;
        private System.Windows.Forms.Label label15;
        private System.Windows.Forms.Label label16;
        private System.Windows.Forms.Label label17;
        private System.Windows.Forms.Label label18;
        private System.Windows.Forms.TextBox date1;
        private System.Windows.Forms.TextBox date2;
        private System.Windows.Forms.TextBox date3;
        private System.Windows.Forms.TextBox date4;
        private System.Windows.Forms.TextBox dividend1;
        private System.Windows.Forms.TextBox dividend2;
        private System.Windows.Forms.TextBox dividend3;
        private System.Windows.Forms.TextBox dividend4;
        private System.Windows.Forms.Button button1;
        private System.Windows.Forms.Label label19;
        private System.Windows.Forms.Label lblResult;
        private System.Windows.Forms.Label lblSteps;
        private System.Windows.Forms.TextBox txtSteps;

    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
Tanveer Ansari specializes in application of .NET and Java to building automated trading systems. He also builds statistical (time series and bayesian) models to predict asset prices.

He is available for technology consulting for the financial markets at info@tanveeransari.com

Comments and Discussions