public void select(DbConnection conn)
        {
            if (conn.State != ConnectionState.Open)
                conn.Open();

            DataTable tb = new DataTable();

            this.DAOList_ = new List<OPTION_POSITION_Table_DAO>();

            DbCommand dbCommand = conn.CreateCommand();

            string selectQuery = OPTION_POSITION_Table_DAOManager.SelectQuery_;

            //selectQuery = selectQuery.Replace("@KeyColumnValue@", this.KeyColumn_);

            dbCommand.CommandText = selectQuery;

            //DbDataAdapter dataAdapter = new DbDataAdapter(dbCommand, conn);
            DbDataAdapter dataAdapter = DataBaseConnectManager.CreateDataAdapter(dbCommand, conn);

            dataAdapter.Fill(tb);

            DataRow[] dr = tb.Select();
            int rowCount = dr.Length;

            foreach (DataRow item in dr)
            {
                OPTION_POSITION_Table_DAO dao = new OPTION_POSITION_Table_DAO();

                dao.POSITIONNAME_ = item[0].ToString();
                dao.CURRPRICE_ = item[1].ToString();
                dao.PREDIFF_ = item[2].ToString();
                dao.PREDIFFRATE_ = item[3].ToString();
                dao.CURRPRICE2_ = item[4].ToString();
                dao.PREDIFF2_ = item[5].ToString();
                dao.PREDIFFRATE2_ = item[6].ToString();
                dao.TRADINGAMT_ = item[7].ToString();
                dao.IMVOL_ = item[8].ToString();
                dao.GREEK_DELTA_ = item[9].ToString();
                dao.GREEK_GAMMA_ = item[10].ToString();
                dao.GREEK_VEGA_ = item[11].ToString();
                dao.GREEK_THETA_ = item[12].ToString();
                dao.GREEK_RHO_ = item[13].ToString();
                dao.TRADINGVALUE_ = item[14].ToString();
                dao.REMAINAMT_ = item[15].ToString();
                dao.REMAINAMTPREDIFF_ = item[16].ToString();

                this.DAOList_.Add(dao);
            }



        }
Ejemplo n.º 2
0
        public void select(DbConnection conn)
        {
            if (conn.State != ConnectionState.Open)
            {
                conn.Open();
            }

            DataTable tb = new DataTable();

            this.DAOList_ = new List <OPTION_POSITION_Table_DAO>();

            DbCommand dbCommand = conn.CreateCommand();

            string selectQuery = OPTION_POSITION_Table_DAOManager.SelectQuery_;

            //selectQuery = selectQuery.Replace("@KeyColumnValue@", this.KeyColumn_);

            dbCommand.CommandText = selectQuery;

            //DbDataAdapter dataAdapter = new DbDataAdapter(dbCommand, conn);
            DbDataAdapter dataAdapter = DataBaseConnectManager.CreateDataAdapter(dbCommand, conn);

            dataAdapter.Fill(tb);

            DataRow[] dr       = tb.Select();
            int       rowCount = dr.Length;

            foreach (DataRow item in dr)
            {
                OPTION_POSITION_Table_DAO dao = new OPTION_POSITION_Table_DAO();

                dao.POSITIONNAME_     = item[0].ToString();
                dao.CURRPRICE_        = item[1].ToString();
                dao.PREDIFF_          = item[2].ToString();
                dao.PREDIFFRATE_      = item[3].ToString();
                dao.CURRPRICE2_       = item[4].ToString();
                dao.PREDIFF2_         = item[5].ToString();
                dao.PREDIFFRATE2_     = item[6].ToString();
                dao.TRADINGAMT_       = item[7].ToString();
                dao.IMVOL_            = item[8].ToString();
                dao.GREEK_DELTA_      = item[9].ToString();
                dao.GREEK_GAMMA_      = item[10].ToString();
                dao.GREEK_VEGA_       = item[11].ToString();
                dao.GREEK_THETA_      = item[12].ToString();
                dao.GREEK_RHO_        = item[13].ToString();
                dao.TRADINGVALUE_     = item[14].ToString();
                dao.REMAINAMT_        = item[15].ToString();
                dao.REMAINAMTPREDIFF_ = item[16].ToString();

                this.DAOList_.Add(dao);
            }
        }
        public void build(OPTION_POSITION_Table_DAO dao)
        {
            this.nameParsing(dao.POSITIONNAME_);

            this.currPrice_ = Convert.ToDouble(dao.CURRPRICE_);

            this.delta_ = Convert.ToDouble(dao.GREEK_DELTA_);
            this.gamma_ = Convert.ToDouble(dao.GREEK_GAMMA_);
            this.vega_  = Convert.ToDouble(dao.GREEK_VEGA_);
            this.theta_ = Convert.ToDouble(dao.GREEK_THETA_);
            this.rho_   = Convert.ToDouble(dao.GREEK_RHO_);

            this.imVol_ = Convert.ToDouble(dao.IMVOL_);
        }
        public void loadDataFromExcelSheet(Excel.Worksheet activeWorksheet)
        {
            this.callOptionViewModelList_.Clear();
            this.putOptionViewModelList_.Clear();

            this.call_strikeData_.Clear();
            this.put_strikeData_.Clear();
            this.call_imvolData_.Clear();
            this.put_imvolData_.Clear();

            Excel.Range rngColumnA = activeWorksheet.get_Range("A1:A300");

            try
            {
                Excel.Range callNameRng = rngColumnA.Find("콜옵션 종목명");
                Excel.Range callDataRng = callNameRng.CurrentRegion;

                int callOptionCount = callDataRng.Rows.Count;

                OptionViewModel sumCallOVM = new OptionViewModel();

                for (int i = 1; i < callOptionCount; i++)
                {
                    OPTION_POSITION_Table_DAO dao = new OPTION_POSITION_Table_DAO();

                    dao.POSITIONNAME_ = (string)callNameRng.get_Offset(i, 0).Value;
                    dao.CURRPRICE_ = (callNameRng.get_Offset(i, 1).Value2).ToString();
                    dao.PREDIFF_ = (callNameRng.get_Offset(i, 2).Value2).ToString();
                    dao.PREDIFFRATE_ = (callNameRng.get_Offset(i, 3).Value2).ToString();
                    dao.CURRPRICE2_ = (callNameRng.get_Offset(i, 4).Value2).ToString();
                    dao.PREDIFF2_ = (callNameRng.get_Offset(i, 5).Value2).ToString();
                    dao.PREDIFFRATE2_ = (callNameRng.get_Offset(i, 6).Value2).ToString();
                    dao.TRADINGAMT_ = (callNameRng.get_Offset(i, 7).Value2).ToString();
                    dao.IMVOL_ = (callNameRng.get_Offset(i, 8).Value2).ToString();
                    dao.GREEK_DELTA_ = (callNameRng.get_Offset(i, 9).Value2).ToString();
                    dao.GREEK_GAMMA_ = (callNameRng.get_Offset(i, 10).Value2).ToString();
                    dao.GREEK_VEGA_ = (callNameRng.get_Offset(i, 11).Value2).ToString();
                    dao.GREEK_THETA_ = (callNameRng.get_Offset(i, 12).Value2).ToString();
                    dao.GREEK_RHO_ = (callNameRng.get_Offset(i, 13).Value2).ToString();
                    dao.TRADINGVALUE_ = (callNameRng.get_Offset(i, 14).Value2).ToString();
                    dao.REMAINAMT_ = (callNameRng.get_Offset(i, 15).Value2).ToString();
                    dao.REMAINAMTPREDIFF_ = (callNameRng.get_Offset(i, 16).Value2).ToString();

                    OptionViewModel ovm = new OptionViewModel();
                    ovm.build(dao);

                    if (ovm.ImVol_ > 5)
                    {
                        if (!(this.call_strikeData_.Contains(ovm.Strike_)))
                        {
                            this.call_strikeData_.Add(ovm.Strike_);
                            this.call_imvolData_.Add(ovm.ImVol_);
                        }
                    }

                    this.callOptionViewModelList_.Add(ovm);
                    
                }

                Excel.Range putNameRng = rngColumnA.Find("풋옵션 종목명");
                Excel.Range putDataRng = callNameRng.CurrentRegion;

                int putOptionCount = putDataRng.Rows.Count;

                for (int i = 1; i < putOptionCount; i++)
                {
                    OPTION_POSITION_Table_DAO dao = new OPTION_POSITION_Table_DAO();

                    dao.POSITIONNAME_ = (string)putNameRng.get_Offset(i, 0).Value;
                    dao.CURRPRICE_ = (putNameRng.get_Offset(i, 1).Value2).ToString();
                    dao.PREDIFF_ = (putNameRng.get_Offset(i, 2).Value2).ToString();
                    dao.PREDIFFRATE_ = (putNameRng.get_Offset(i, 3).Value2).ToString();
                    dao.CURRPRICE2_ = (putNameRng.get_Offset(i, 4).Value2).ToString();
                    dao.PREDIFF2_ = (putNameRng.get_Offset(i, 5).Value2).ToString();
                    dao.PREDIFFRATE2_ = (putNameRng.get_Offset(i, 6).Value2).ToString();
                    dao.TRADINGAMT_ = (putNameRng.get_Offset(i, 7).Value2).ToString();
                    dao.IMVOL_ = (putNameRng.get_Offset(i, 8).Value2).ToString();
                    dao.GREEK_DELTA_ = (putNameRng.get_Offset(i, 9).Value2).ToString();
                    dao.GREEK_GAMMA_ = (putNameRng.get_Offset(i, 10).Value2).ToString();
                    dao.GREEK_VEGA_ = (putNameRng.get_Offset(i, 11).Value2).ToString();
                    dao.GREEK_THETA_ = (putNameRng.get_Offset(i, 12).Value2).ToString();
                    dao.GREEK_RHO_ = (putNameRng.get_Offset(i, 13).Value2).ToString();
                    dao.TRADINGVALUE_ = (putNameRng.get_Offset(i, 14).Value2).ToString();
                    dao.REMAINAMT_ = (putNameRng.get_Offset(i, 15).Value2).ToString();
                    dao.REMAINAMTPREDIFF_ = (putNameRng.get_Offset(i, 16).Value2).ToString();

                    OptionViewModel ovm = new OptionViewModel();
                    ovm.build(dao);

                    if (ovm.ImVol_ > 5)
                    {
                        if (!(this.put_strikeData_.Contains(ovm.Strike_)))
                        {
                            this.put_strikeData_.Add(ovm.Strike_);
                            this.put_imvolData_.Add(ovm.ImVol_);
                        }
                    }

                    this.putOptionViewModelList_.Add(ovm);

                }

                this.gbmParaViewModel_.CurrentPrice_ = (this.call_strikeData_[0] + this.call_strikeData_[this.call_strikeData_.Count - 1]) / 2;

                this.call_strikeData_.Reverse();
                this.call_imvolData_.Reverse();

                this.put_strikeData_.Reverse();
                this.put_imvolData_.Reverse();

                this.gbmParaViewModel_.Call_Interpolation_ = this.call_imvolFitting();
                this.gbmParaViewModel_.Put_Interpolation_ = this.put_imvolFitting();

            }
            catch (Exception)
            {
                System.Windows.MessageBox.Show("Load PowerBase TR_8586 Data.");
                throw;
            }
        }
        public void loadDataFromExcelSheet(Excel.Worksheet activeWorksheet)
        {
            this.callOptionViewModelList_.Clear();
            this.putOptionViewModelList_.Clear();

            this.call_strikeData_.Clear();
            this.put_strikeData_.Clear();
            this.call_imvolData_.Clear();
            this.put_imvolData_.Clear();

            Excel.Range rngColumnA = activeWorksheet.get_Range("A1:A300");

            try
            {
                Excel.Range callNameRng = rngColumnA.Find("콜옵션 종목명");
                Excel.Range callDataRng = callNameRng.CurrentRegion;

                int callOptionCount = callDataRng.Rows.Count;

                OptionViewModel sumCallOVM = new OptionViewModel();

                for (int i = 1; i < callOptionCount; i++)
                {
                    OPTION_POSITION_Table_DAO dao = new OPTION_POSITION_Table_DAO();

                    dao.POSITIONNAME_     = (string)callNameRng.get_Offset(i, 0).Value;
                    dao.CURRPRICE_        = (callNameRng.get_Offset(i, 1).Value2).ToString();
                    dao.PREDIFF_          = (callNameRng.get_Offset(i, 2).Value2).ToString();
                    dao.PREDIFFRATE_      = (callNameRng.get_Offset(i, 3).Value2).ToString();
                    dao.CURRPRICE2_       = (callNameRng.get_Offset(i, 4).Value2).ToString();
                    dao.PREDIFF2_         = (callNameRng.get_Offset(i, 5).Value2).ToString();
                    dao.PREDIFFRATE2_     = (callNameRng.get_Offset(i, 6).Value2).ToString();
                    dao.TRADINGAMT_       = (callNameRng.get_Offset(i, 7).Value2).ToString();
                    dao.IMVOL_            = (callNameRng.get_Offset(i, 8).Value2).ToString();
                    dao.GREEK_DELTA_      = (callNameRng.get_Offset(i, 9).Value2).ToString();
                    dao.GREEK_GAMMA_      = (callNameRng.get_Offset(i, 10).Value2).ToString();
                    dao.GREEK_VEGA_       = (callNameRng.get_Offset(i, 11).Value2).ToString();
                    dao.GREEK_THETA_      = (callNameRng.get_Offset(i, 12).Value2).ToString();
                    dao.GREEK_RHO_        = (callNameRng.get_Offset(i, 13).Value2).ToString();
                    dao.TRADINGVALUE_     = (callNameRng.get_Offset(i, 14).Value2).ToString();
                    dao.REMAINAMT_        = (callNameRng.get_Offset(i, 15).Value2).ToString();
                    dao.REMAINAMTPREDIFF_ = (callNameRng.get_Offset(i, 16).Value2).ToString();

                    OptionViewModel ovm = new OptionViewModel();
                    ovm.build(dao);

                    if (ovm.ImVol_ > 5)
                    {
                        if (!(this.call_strikeData_.Contains(ovm.Strike_)))
                        {
                            this.call_strikeData_.Add(ovm.Strike_);
                            this.call_imvolData_.Add(ovm.ImVol_);
                        }
                    }

                    this.callOptionViewModelList_.Add(ovm);
                }

                Excel.Range putNameRng = rngColumnA.Find("풋옵션 종목명");
                Excel.Range putDataRng = callNameRng.CurrentRegion;

                int putOptionCount = putDataRng.Rows.Count;

                for (int i = 1; i < putOptionCount; i++)
                {
                    OPTION_POSITION_Table_DAO dao = new OPTION_POSITION_Table_DAO();

                    dao.POSITIONNAME_     = (string)putNameRng.get_Offset(i, 0).Value;
                    dao.CURRPRICE_        = (putNameRng.get_Offset(i, 1).Value2).ToString();
                    dao.PREDIFF_          = (putNameRng.get_Offset(i, 2).Value2).ToString();
                    dao.PREDIFFRATE_      = (putNameRng.get_Offset(i, 3).Value2).ToString();
                    dao.CURRPRICE2_       = (putNameRng.get_Offset(i, 4).Value2).ToString();
                    dao.PREDIFF2_         = (putNameRng.get_Offset(i, 5).Value2).ToString();
                    dao.PREDIFFRATE2_     = (putNameRng.get_Offset(i, 6).Value2).ToString();
                    dao.TRADINGAMT_       = (putNameRng.get_Offset(i, 7).Value2).ToString();
                    dao.IMVOL_            = (putNameRng.get_Offset(i, 8).Value2).ToString();
                    dao.GREEK_DELTA_      = (putNameRng.get_Offset(i, 9).Value2).ToString();
                    dao.GREEK_GAMMA_      = (putNameRng.get_Offset(i, 10).Value2).ToString();
                    dao.GREEK_VEGA_       = (putNameRng.get_Offset(i, 11).Value2).ToString();
                    dao.GREEK_THETA_      = (putNameRng.get_Offset(i, 12).Value2).ToString();
                    dao.GREEK_RHO_        = (putNameRng.get_Offset(i, 13).Value2).ToString();
                    dao.TRADINGVALUE_     = (putNameRng.get_Offset(i, 14).Value2).ToString();
                    dao.REMAINAMT_        = (putNameRng.get_Offset(i, 15).Value2).ToString();
                    dao.REMAINAMTPREDIFF_ = (putNameRng.get_Offset(i, 16).Value2).ToString();

                    OptionViewModel ovm = new OptionViewModel();
                    ovm.build(dao);

                    if (ovm.ImVol_ > 5)
                    {
                        if (!(this.put_strikeData_.Contains(ovm.Strike_)))
                        {
                            this.put_strikeData_.Add(ovm.Strike_);
                            this.put_imvolData_.Add(ovm.ImVol_);
                        }
                    }

                    this.putOptionViewModelList_.Add(ovm);
                }

                this.gbmParaViewModel_.CurrentPrice_ = (this.call_strikeData_[0] + this.call_strikeData_[this.call_strikeData_.Count - 1]) / 2;

                this.call_strikeData_.Reverse();
                this.call_imvolData_.Reverse();

                this.put_strikeData_.Reverse();
                this.put_imvolData_.Reverse();

                this.gbmParaViewModel_.Call_Interpolation_ = this.call_imvolFitting();
                this.gbmParaViewModel_.Put_Interpolation_  = this.put_imvolFitting();
            }
            catch (Exception)
            {
                System.Windows.MessageBox.Show("Load PowerBase TR_8586 Data.");
                throw;
            }
        }
        public void build(OPTION_POSITION_Table_DAO dao)
        {
            this.nameParsing(dao.POSITIONNAME_);

            this.currPrice_ = Convert.ToDouble(dao.CURRPRICE_);

            this.delta_ = Convert.ToDouble(dao.GREEK_DELTA_);
            this.gamma_ = Convert.ToDouble(dao.GREEK_GAMMA_);
            this.vega_ = Convert.ToDouble(dao.GREEK_VEGA_);
            this.theta_ = Convert.ToDouble(dao.GREEK_THETA_);
            this.rho_ = Convert.ToDouble(dao.GREEK_RHO_);

            this.imVol_ = Convert.ToDouble(dao.IMVOL_);

        }