コード例 #1
0
        /// <summary>
        /// retrieve the static/current data associated with the option from BOSS
        /// </summary>
        /// <param name="SecurityID"></param>
        /// <returns></returns>
        private BOSSOption GetBOSSOption(int securityID, DateTime ValuationDate)
        {
            SqlCommand sqlCom = new SqlCommand("spOTCOptionPrice_GetSecurityData");

            sqlCom.CommandType = CommandType.StoredProcedure;
            sqlCom.Parameters.Add(new SqlParameter("@SecurityID", securityID));
            DataSet ds = db.FetchData(sqlCom);

            if (ds.Tables[0].Rows.Count == 0)
            {
                return(null);
            }
            DataRow    dr = ds.Tables[0].Rows[0];
            BOSSOption o  = new BOSSOption()
            {
                SecurityID             = securityID,
                SecurityName           = dr["Description"].ToString(),
                UnderlyingSecurityName = dr["UnderlyingDescription"].ToString(),
                Strike      = double.Parse(dr["StrikePrice"].ToString()),
                Maturity    = DateTime.Parse(dr["MatDate"].ToString()),
                Type        = (dr["SecuritySubTypeID"].ToString() == "6")  ? Option.OptionType.Call : Option.OptionType.Put,
                Style       = (dr["OptionStyleID"].ToString() == "1") ? Option.OptionStyle.American: Option.OptionStyle.European,
                FirstTraded = DateTime.Parse(dr["FirstTradeDate"].ToString())
            };

            //get underlying price
            o.UnderlyingPrice = GetUnderlyingPrice(securityID, ValuationDate);

            //get remaining data - can come from any of (up to) three sources, try the each one in the order specified below...

            //get dividends
            o.DividendSource = (DividendSourceData)SourceDataChooser(securityID, ValuationDate, new List <GetSourceDataDel>()
            {
                new GetSourceDataDel(GetDividends_ManualOverride),
                new GetSourceDataDel(GetDividends_BOSS),
                new GetSourceDataDel(GetDividends_Bloomberg)
            });

            //get volatility
            o.VolatilitySource = (VolatilitySourceData)SourceDataChooser(securityID, ValuationDate, new List <GetSourceDataDel>()
            {
                new GetSourceDataDel(GetVolatility_ManualOverride),
                new GetSourceDataDel(GetVolatility_Bloomberg)
            });

            //get rate
            o.RateSource = (RateSourceData)SourceDataChooser(securityID, ValuationDate, new List <GetSourceDataDel>()
            {
                new GetSourceDataDel(GetRate_ManualOverride),
                new GetSourceDataDel(GetRate_Bloomberg)
            });


            return(o);
        }
コード例 #2
0
ファイル: ValuationScreen.cs プロジェクト: colinnaylor/CN
        private void OptionTestButton_Click(object sender, EventArgs e)
        {
            string value = "";

            try {
                BOSSOption option = new BOSSOption()
                {
                    SecurityID             = 0,
                    SecurityName           = "Test Security",
                    UnderlyingSecurityName = "Underlying Test",
                    UnderlyingPrice        = 0.99,
                    UnderlyingVolatility   = 0.3,
                    Rate        = 0.04,
                    Strike      = 1.1,
                    Maturity    = DateTime.Parse("31 March 2012"),
                    Type        = OptionValue_DotNet.Option.OptionType.Call,
                    Style       = OptionValue_DotNet.Option.OptionStyle.European,
                    FirstTraded = DateTime.Parse("3 Jan 2012")
                };

                option.CalculateOptionValue(DateTime.Parse("1 Feb 2012"));

                value = option.OptionValue.ToString().Substring(0, 8);
            } catch (Exception ex) {
                value = ex.Message;
            } finally {
                if (value == "0.014459")
                {
                    string detail = "Strike = 1.1\r\n";
                    detail += "Underlying Price = 0.99\r\n";
                    detail += "Rate = 4%\r\n";
                    detail += "Vol = 30% = \r\n";
                    detail += "Maturity = 31 Mar 2012\r\n";
                    detail += "European Call\r\n";
                    detail += "Value date = 1 Feb 2012\r\n\r\n";
                    detail += "Calculated option price is " + value;

                    MessageBox.Show("Option valuation is working correctly\r\n\r\n" + detail);
                }
                else
                {
                    MessageBox.Show("Option valuation failed. [" + value + "]");
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// write the valuation data for this security/date
        /// </summary>
        /// <param name="ValuationDate"></param>
        /// <param name="Options"></param>
        internal void SaveOptionPrice(BOSSOption option, DateTime ValuationDate)
        {
            //delete if it is there already
            DeleteOptionPrice(option.SecurityID, ValuationDate);

            //insert
            SqlCommand sqlComInsert = new SqlCommand("spOTCOptionPrice_InsertPrice");

            sqlComInsert.CommandType = CommandType.StoredProcedure;

            sqlComInsert.Parameters.Add(new SqlParameter("@SecurityID", option.SecurityID));
            sqlComInsert.Parameters.Add(new SqlParameter("@PriceDate", ValuationDate));
            sqlComInsert.Parameters.Add(new SqlParameter("@UnderlyingPrice", option.UnderlyingPrice));

            sqlComInsert.Parameters.Add(new SqlParameter("@UnderlyingVolatility", option.UnderlyingVolatility));
            sqlComInsert.Parameters.Add(new SqlParameter("@VolatilitySource", option.VolatilitySource.Source.ToString()));
            sqlComInsert.Parameters.Add(new SqlParameter("@VolatilityCaptureTime", option.VolatilitySource.CaptureTime));

            sqlComInsert.Parameters.Add(new SqlParameter("@VolatilityBBTicker", option.VolatilitySource.BBData.Ticker));
            sqlComInsert.Parameters.Add(new SqlParameter("@VolatilityBBField", option.VolatilitySource.BBData.Field));

            sqlComInsert.Parameters.Add(new SqlParameter("@RiskFreeRate", option.Rate));
            sqlComInsert.Parameters.Add(new SqlParameter("@RiskFreeRateSource", option.RateSource.Source.ToString()));
            sqlComInsert.Parameters.Add(new SqlParameter("@RiskFreeRateCaptureTime", option.RateSource.CaptureTime));

            sqlComInsert.Parameters.Add(new SqlParameter("@RiskFreeRateBBTicker_Previous", option.RateSource.BBData_PreviousTerm.Ticker));
            sqlComInsert.Parameters.Add(new SqlParameter("@RiskFreeRateBBTicker_Next", option.RateSource.BBData_NextTerm.Ticker));
            sqlComInsert.Parameters.Add(new SqlParameter("@RiskFreeRateBBTicker_Previous_Value", option.RateSource.BBData_PreviousTerm.Value));
            sqlComInsert.Parameters.Add(new SqlParameter("@RiskFreeRateBBTicker_Next_Value", option.RateSource.BBData_NextTerm.Value));

            sqlComInsert.Parameters.Add(new SqlParameter("@DividendsSource", option.DividendSource.Source.ToString()));
            if (option.DividendSource.Source != BOSS_OptionValueManager.InputSourceData.InputSource.Missing)
            {
                sqlComInsert.Parameters.Add(new SqlParameter("@DivDetails", option.DisplayDividendString));
                sqlComInsert.Parameters.Add(new SqlParameter("@DividendCurrency", option.DividendSource.DividendCurrency));
                sqlComInsert.Parameters.Add(new SqlParameter("@DividendFXRate", option.DividendSource.DividendFXRate));
            }

            sqlComInsert.Parameters.Add(new SqlParameter("@Price", option.OptionValue));

            ExecSql(sqlComInsert);
        }
コード例 #4
0
ファイル: ValuationScreen.cs プロジェクト: colinnaylor/CN
        /// <summary>
        /// show the input source details in the tooltip, change colors etc...
        /// </summary>
        public void FormatValuationRows()
        {
            foreach (DataGridViewRow row in ValuationGridView.Rows)
            {
                BOSSOption o = (BOSSOption)row.DataBoundItem;

                //show the input source details in the tooltip, change colors etc...
                row.Cells["VolatilitySourceCharacter"].ToolTipText = o.VolatilitySource.ToString();
                row.Cells["RateSourceCharacter"].ToolTipText       = o.RateSource.ToString();
                row.Cells["DividendSourceCharacter"].ToolTipText   = o.DividendSource.ToString();

                //apply source colors
                row.Cells["VolatilitySourceCharacter"].Style.ForeColor = Utilities.GetSourceColour(o.VolatilitySource.Source);
                row.Cells["RateSourceCharacter"].Style.ForeColor       = Utilities.GetSourceColour(o.RateSource.Source);
                row.Cells["DividendSourceCharacter"].Style.ForeColor   = Utilities.GetSourceColour(o.DividendSource.Source);

                //set staus colour
                row.Cells["StatusCharacterColumn"].Style.ForeColor = Utilities.GetStatusColour(o.OptionValue > 0);
            }
        }
コード例 #5
0
        /// <summary>
        /// get a list of all of the options that we want to price (i.e. ones we have a balance in)
        /// </summary>
        /// <param name="ValuationDate"></param>
        /// <returns></returns>
        internal List <BOSSOption> GetBOSSOptionsToPrice(DateTime ValuationDate)
        {
            List <BOSSOption> options = new List <BOSSOption>();
            SqlCommand        sqlCom  = new SqlCommand("spOTCOptionPrice_GetSecuritiesToPrice");

            sqlCom.CommandType = CommandType.StoredProcedure;
            sqlCom.Parameters.Add(new SqlParameter("@PriceDate", ValuationDate));
            DataSet ds = db.FetchData(sqlCom);

            if (ds.Tables[0].Rows.Count != 0)
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    //get static data
                    int        SecurityID = int.Parse(dr["SecurityID"].ToString());
                    BOSSOption o          = GetBOSSOption(SecurityID, ValuationDate);
                    options.Add(o);
                }
            }
            return(options);
        }