public bool downloadDaily(string folderPath, string scriptName, bool bIsTestOn, bool bSaveData)
        {
            string outputsize = ddlDaily_OutputSize.SelectedValue;

            if (StockApi.getDaily(folderPath, scriptName, outputsize: outputsize, bIsTestModeOn: bIsTestOn, bSaveData: bSaveData, apiKey: Session["ApiKey"].ToString()) == null)
            {
                Response.Write("<script language=javascript>alert('Daily data not available for selected script.')</script>");
                return(false);
            }
            return(true);
        }
        public void ShowGraph(string scriptName)
        {
            string    folderPath = Server.MapPath("~/scriptdata/");
            bool      bIsTestOn = true;
            DataTable scriptData = null;
            DataTable tempData = null;
            string    expression = "";
            string    outputSize = "";
            string    fromDate = "", toDate = "";

            DataRow[] filteredRows = null;


            if (ViewState["FetchedData"] == null)
            {
                if (Session["IsTestOn"] != null)
                {
                    bIsTestOn = System.Convert.ToBoolean(Session["IsTestOn"]);
                }

                if (Session["TestDataFolder"] != null)
                {
                    folderPath = Session["TestDataFolder"].ToString();
                }
                if (Request.QueryString["size"] != null)
                {
                    outputSize = Request.QueryString["size"].ToString();
                    scriptData = StockApi.getDaily(folderPath, scriptName, outputsize: outputSize, bIsTestModeOn: bIsTestOn, bSaveData: false);
                }
                ViewState["FetchedData"] = scriptData;
            }
            else
            {
                if (ViewState["FromDate"] != null)
                {
                    fromDate = ViewState["FromDate"].ToString();
                }
                if (ViewState["ToDate"] != null)
                {
                    toDate = ViewState["ToDate"].ToString();
                }

                if ((fromDate.Length > 0) && (toDate.Length > 0))
                {
                    tempData     = (DataTable)ViewState["FetchedData"];
                    expression   = "Date >= '" + fromDate + "' and Date <= '" + toDate + "'";
                    filteredRows = tempData.Select(expression);
                    if ((filteredRows != null) && (filteredRows.Length > 0))
                    {
                        scriptData = filteredRows.CopyToDataTable();
                    }
                }
                else
                {
                    scriptData = (DataTable)ViewState["FetchedData"];
                }
            }
            if (scriptData != null)
            {
                chartdailyGraph.DataSource = scriptData;
                chartdailyGraph.DataBind();
                if (checkBoxOpen.Checked)
                {
                    showOpenLine(scriptData);
                }
                if (checkBoxHigh.Checked)
                {
                    showHighLine(scriptData);
                }
                if (checkBoxLow.Checked)
                {
                    showLowLine(scriptData);
                }
                if (checkBoxClose.Checked)
                {
                    showCloseLine(scriptData);
                }
                if (checkBoxCandle.Checked)
                {
                    showCandleStickGraph(scriptData);
                }
                if (checkBoxVolume.Checked)
                {
                    showVolumeGraph(scriptData);
                }
                if (checkBoxGrid.Checked)
                {
                    GridViewDaily.Visible    = true;
                    GridViewDaily.DataSource = scriptData;
                    GridViewDaily.DataBind();
                }
            }
        }
Beispiel #3
0
        public void ShowGraph(string scriptName)
        {
            string    folderPath = Server.MapPath("~/scriptdata/");
            bool      bIsTestOn = true;
            DataTable ohlcData = null;
            DataTable sma1Data = null;
            DataTable sma2Data = null;
            DataTable tempData = null;
            string    expression = "";
            string    outputSize = "";
            string    interval1 = "";
            string    period1 = "";
            string    seriestype1 = "";
            string    interval2 = "";
            string    period2 = "";
            string    seriestype2 = "";
            string    fromDate = "", toDate = "";

            DataRow[] filteredRows = null;


            if (((ViewState["FetchedDataOHLC"] == null) || (ViewState["FetchedDataSMA1"] == null) || (ViewState["FetchedDataSMA2"] == null)) ||
                ((((DataTable)ViewState["FetchedDataOHLC"]).Rows.Count == 0) || (((DataTable)ViewState["FetchedDataSMA1"]).Rows.Count == 0) ||
                 (((DataTable)ViewState["FetchedDataSMA2"]).Rows.Count == 0)))
            {
                if (Session["IsTestOn"] != null)
                {
                    bIsTestOn = System.Convert.ToBoolean(Session["IsTestOn"]);
                }

                if (Session["TestDataFolder"] != null)
                {
                    folderPath = Session["TestDataFolder"].ToString();
                }
                if (Request.QueryString["size"] != null)
                {
                    outputSize = Request.QueryString["size"].ToString();
                    ohlcData   = StockApi.getDaily(folderPath, scriptName, outputsize: outputSize, bIsTestModeOn: bIsTestOn, bSaveData: false);
                    ViewState["FetchedDataOHLC"] = ohlcData;
                }
                else
                {
                    ViewState["FetchedDataOHLC"] = null;
                    ohlcData = null;
                }

                if ((Request.QueryString["period1"] != null) && (Request.QueryString["interval1"] != null) && (Request.QueryString["seriestype1"] != null))
                {
                    interval1   = Request.QueryString["interval1"].ToString();
                    period1     = Request.QueryString["period1"].ToString();
                    seriestype1 = Request.QueryString["seriestype1"].ToString();

                    sma1Data = StockApi.getSMA(folderPath, scriptName, day_interval: interval1, period: period1,
                                               seriestype: seriestype1, bIsTestModeOn: bIsTestOn, bSaveData: false);
                    ViewState["FetchedDataSMA1"] = sma1Data;
                }
                else
                {
                    ViewState["FetchedDataSMA1"] = null;
                    sma1Data = null;
                }

                if ((Request.QueryString["period2"] != null) && (Request.QueryString["interval2"] != null) && (Request.QueryString["seriestype2"] != null))
                {
                    interval2   = Request.QueryString["interval2"].ToString();
                    period2     = Request.QueryString["period2"].ToString();
                    seriestype2 = Request.QueryString["seriestype2"].ToString();

                    sma2Data = StockApi.getSMA(folderPath, scriptName, day_interval: interval2, period: period2,
                                               seriestype: seriestype2, bIsTestModeOn: bIsTestOn, bSaveData: false);
                    ViewState["FetchedDataSMA2"] = sma2Data;
                }
                else
                {
                    ViewState["FetchedDataSMA2"] = null;
                    sma2Data = null;
                }
            }

            //else
            //{
            if (ViewState["FromDate"] != null)
            {
                fromDate = ViewState["FromDate"].ToString();
            }
            if (ViewState["ToDate"] != null)
            {
                toDate = ViewState["ToDate"].ToString();
            }

            if ((fromDate.Length > 0) && (toDate.Length > 0))
            {
                tempData     = (DataTable)ViewState["FetchedDataOHLC"];
                expression   = "Date >= '" + fromDate + "' and Date <= '" + toDate + "'";
                filteredRows = tempData.Select(expression);
                if ((filteredRows != null) && (filteredRows.Length > 0))
                {
                    ohlcData = filteredRows.CopyToDataTable();
                }

                tempData.Clear();
                tempData = null;

                tempData     = (DataTable)ViewState["FetchedDataSMA1"];
                expression   = "Date >= '" + fromDate + "' and Date <= '" + toDate + "'";
                filteredRows = tempData.Select(expression);
                if ((filteredRows != null) && (filteredRows.Length > 0))
                {
                    sma1Data = filteredRows.CopyToDataTable();
                }

                tempData.Clear();
                tempData = null;

                tempData     = (DataTable)ViewState["FetchedDataSMA2"];
                expression   = "Date >= '" + fromDate + "' and Date <= '" + toDate + "'";
                filteredRows = tempData.Select(expression);
                if ((filteredRows != null) && (filteredRows.Length > 0))
                {
                    sma2Data = filteredRows.CopyToDataTable();
                }
            }
            else
            {
                ohlcData = (DataTable)ViewState["FetchedDataOHLC"];
                sma1Data = (DataTable)ViewState["FetchedDataSMA1"];
                sma2Data = (DataTable)ViewState["FetchedDataSMA2"];
            }
            //}

            if ((ohlcData != null) && (sma1Data != null) && (sma2Data != null))
            {
                showCandleStickGraph(ohlcData);
                showSMA(sma1Data, "SMA1");
                showSMA(sma2Data, "SMA2");
            }
        }