示例#1
0
        private DataTable GetOCForGivenOption(string ocType, string expityDate)
        {
            FetchOC(ocType);
            string selectQuery = string.Empty;

            //DataTable dt = toDataTable(filteredObject);
            DataTable dt = OCHelper.toDataTable(MySession.Current.RecordsObject);

            if (!expityDate.Trim().Equals(string.Empty))
            {
                selectQuery = "(ExpiryDate = #" + expityDate + "#)";
            }
            else
            {
                selectQuery = "(ExpiryDate = #" + ddlExpiryDates.SelectedValue + "#)";
            }

            DataRow[] drs = dt.Select(selectQuery, "StrikePrice ASC");

            //make a new "results" datatable via clone to keep structure
            DataTable dtData = dt.Clone();

            //Import the Rows
            foreach (DataRow d in drs)
            {
                dtData.ImportRow(d);
            }

            return(dtData);
        }
示例#2
0
 private void FetchOC(string ocType)
 {
     MySession.Current.RecordsObject = OCHelper.GetOC(ocType);
     currentPrice = MySession.Current.RecordsObject.underlyingValue;
     FillExpiryDates(ddlExpiryDates);
     UpdateStrikePriceDetails();
 }
示例#3
0
        private void PopulateSPLowerRange(FilterConditions filterConditions)
        {
            int iLowerStrikePriceRange = OCHelper.RoundTo100(MySession.Current.RecordsObject.underlyingValue - (OCHelper.DefaultSP(rblOCType.SelectedValue) * iPercentageRage / 100));

            int iUpperStrikePrice = iLowerStrikePriceRange;

            ddlSPLowerRange.Items.Clear();

            foreach (int item in MySession.Current.RecordsObject.strikePrices)
            {
                if (item >= iLowerStrikePriceRange &&
                    item < MySession.Current.RecordsObject.underlyingValue &&
                    item % filterConditions.SPDifference == 0)
                {
                    ddlSPLowerRange.Items.Add(item.ToString());

                    //find the max strike price which meets this criteria to reduce filter size
                    iUpperStrikePrice = Math.Max(iUpperStrikePrice, item);
                }
            }

            //Select the Max strike price in the ddlb
            if (filterConditions.SPLowerRange == 0)
            {
                filterConditions.SPLowerRange = iUpperStrikePrice;
            }
            Utility.SelectDataInCombo(ddlSPLowerRange, filterConditions.SPLowerRange.ToString());
        }
示例#4
0
        private void FillStrikePrice(DropDownList ddlSP)
        {
            List <int> expiryDates = OCHelper.GetOCSPList(rblOCType.SelectedValue);

            foreach (int item in expiryDates)
            {
                ddlSP.Items.Add(item.ToString());
            }
        }
示例#5
0
        private void FillExpiryDates(DropDownList ddlExpDt)
        {
            List <string> expiryDates = OCHelper.GetOCExpList(rblOCType.SelectedValue);

            foreach (string item in expiryDates)
            {
                ddlExpDt.Items.Add(item);
            }
        }
示例#6
0
        public void FillAllExpiryDates(string ocType, System.Web.UI.WebControls.DropDownList ddlExpDt)
        {
            List <string> expiryDates = OCHelper.GetOCExpList(ocType);

            foreach (string item in expiryDates)
            {
                ddlExpDt.Items.Add(item);
            }
        }
示例#7
0
        public void FillAllStrikePrice(string ocType, System.Web.UI.WebControls.DropDownList ddlSP)
        {
            List <int> expiryDates = OCHelper.GetOCSPList(ocType);

            foreach (int item in expiryDates)
            {
                ddlSP.Items.Add(item.ToString());
            }
        }
示例#8
0
        private void FillExpiryDates(DropDownList ddlExpDt)
        {
            List <string> expiryDates;

            if (MySession.Current.RecordsObject == null)
            {
                expiryDates = OCHelper.GetOCExpList(rblOCType.SelectedValue);
            }
            else
            {
                expiryDates = MySession.Current.RecordsObject.expiryDates;
            }

            foreach (string item in expiryDates)
            {
                ddlExpDt.Items.Add(item);
            }
        }
示例#9
0
        private void AddBlankRows(DataTable dataTable, int iRowCount)
        {
            int rowstoadd = 0;

            if (dataTable.Rows.Count + iRowCount < MAX_ROWS_ALLOWED)
            {
                rowstoadd = iRowCount;
            }
            if (dataTable.Rows.Count + iRowCount >= MAX_ROWS_ALLOWED)
            {
                rowstoadd = MAX_ROWS_ALLOWED - dataTable.Rows.Count;
            }

            for (int iCount = 0; iCount < rowstoadd; iCount++)
            {
                dataTable.Rows.Add(false, "", "CE", "BUY", OCHelper.DefaultSP(rblOCType.SelectedValue), "", "", "1",
                                   "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "");
            }
        }
示例#10
0
        private void PopulateSPExpiry(FilterConditions filterConditions)
        {
            int iUpperStrikePriceRange = OCHelper.RoundTo100(MySession.Current.RecordsObject.underlyingValue + (OCHelper.DefaultSP(rblOCType.SelectedValue) * iPercentageRage / 100));
            int iLowerStrikePriceRange = OCHelper.RoundTo100(MySession.Current.RecordsObject.underlyingValue - (OCHelper.DefaultSP(rblOCType.SelectedValue) * iPercentageRage / 100));

            //List<int> strikePrices = MySession.Current.RecordsObject.strikePrices;
            ddlSPExpiry.Items.Clear();

            ddlSPExpiry.Items.Add("NONE");

            foreach (var item in MySession.Current.RecordsObject.strikePrices)
            {
                if (item < iUpperStrikePriceRange && item > iLowerStrikePriceRange && item % filterConditions.SPDifference == 0 &&
                    item < filterConditions.SPHigherRange && item > filterConditions.SPLowerRange)
                {
                    ddlSPExpiry.Items.Add(item.ToString());
                }
            }

            if (filterConditions.SPExpiry != 0)
            {
                Utility.SelectDataInCombo(ddlSPExpiry, filterConditions.SPExpiry.ToString());
            }
        }
示例#11
0
        private void GridviewDataBind(DataTable dataTable)
        {
            int avgOfSP = 0;

            foreach (DataRow row in dataTable.Rows)
            {
                if (row["Strike Price"] != null && row["Strike Price"].ToString().Trim().Length > 0)
                {
                    avgOfSP += Convert.ToInt32(row["Strike Price"]);
                }
            }

            if (dataTable.Rows.Count > 0)
            {
                avgOfSP = avgOfSP / dataTable.Rows.Count;
            }

            int columnDiff = 0;

            if (rblOCType.SelectedValue.Equals(NIFTY))
            {
                columnDiff = NIFTY_COL_DIFF;
            }
            if (rblOCType.SelectedValue.Equals(BANKNIFTY))
            {
                columnDiff = BANKNIFTY_COL_DIFF;
            }

            //Assign header value to the center column
            dataTable.Columns[SELECTED_SP_COL_INDEX].ColumnName = avgOfSP.ToString();
            for (int icount = SELECTED_SP_COL_INDEX - 1; icount >= LOWER_SP_COL_START_INDEX; icount--)
            {
                dataTable.Columns[icount].ColumnName =
                    Math.Round(Convert.ToDouble(avgOfSP - (SELECTED_SP_COL_INDEX - icount) * columnDiff), 0).ToString();
            }
            //Assign value to the right columns from the center
            for (int icount = SELECTED_SP_COL_INDEX + 1; icount <= HIGHER_SP_COL_END_INDEX; icount++)
            {
                dataTable.Columns[icount].ColumnName =
                    Math.Round(Convert.ToDouble(avgOfSP + (icount - SELECTED_SP_COL_INDEX) * columnDiff), 0).ToString();
            }

            int lotsSize = 0;

            if (rblOCType.SelectedValue.Equals(NIFTY))
            {
                lotsSize = NIFTY_LOT_SIZE;
            }
            if (rblOCType.SelectedValue.Equals(BANKNIFTY))
            {
                lotsSize = BANKNIFTY_LOT_SIZE;
            }

            foreach (DataRow row in dataTable.Rows)
            {
                //Get latest premium value from the OC
                if (row[CONTRACT_TYP_COL_INDEX].ToString().Equals(enumContractType.CE.ToString()))
                {
                    Records.Datum.CE1 cE1 = OCHelper.GetCE(rblOCType.SelectedValue, row[EXP_DATE_COL_INDEX].ToString(),
                                                           Convert.ToInt32(row[SP_COL_INDEX]));
                    if (cE1 != null)
                    {
                        row[CMP_COL_INDEX] = cE1.lastPrice.ToString();
                    }
                    else
                    {
                        row[CMP_COL_INDEX] = "0";
                    }
                }

                if (row[CONTRACT_TYP_COL_INDEX].ToString().Equals(enumContractType.PE.ToString()))
                {
                    Records.Datum.PE1 pE1 = OCHelper.GetPE(rblOCType.SelectedValue, row[EXP_DATE_COL_INDEX].ToString(),
                                                           Convert.ToInt32(row[SP_COL_INDEX]));
                    if (pE1 != null)
                    {
                        row[CMP_COL_INDEX] = pE1.lastPrice.ToString();
                    }
                    else
                    {
                        row[CMP_COL_INDEX] = "0";
                    }
                }

                for (int icount = LOWER_SP_COL_START_INDEX; icount <= HIGHER_SP_COL_END_INDEX; icount++)
                {
                    row[icount] = Convert.ToString(Convert.ToInt32(row[LOTS_COL_INDEX]) * lotsSize *
                                                   CalculateExpiryValue(row[CONTRACT_TYP_COL_INDEX].ToString(),
                                                                        row[TRANSTYP_COL_INDEX].ToString(),
                                                                        Convert.ToDouble(row[SP_COL_INDEX]),
                                                                        Convert.ToDouble(row[CMP_COL_INDEX]),
                                                                        Convert.ToDouble(dataTable.Columns[icount].ColumnName)));
                }
            }

            MySession.Current.StrategyBuilderDt = dataTable;
            gvStrategy.DataSource = dataTable;
            gvStrategy.DataBind();
        }