Ejemplo n.º 1
0
        public bool downloadVWAP(string folderPath, string scriptName, bool bIsTestOn, bool bSaveData)
        {
            string interval = ddlVWAP_Interval.SelectedValue;

            if (StockApi.getVWAP(folderPath, scriptName, day_interval: interval, bIsTestModeOn: bIsTestOn, bSaveData: bSaveData, apiKey: Session["ApiKey"].ToString()) == null)
            {
                Response.Write("<script language=javascript>alert('VWAP data not available for selected script.')</script>");
                return(false);
            }
            return(true);
        }
Ejemplo n.º 2
0
        public void ShowGraph(string scriptName)
        {
            string    folderPath = Server.MapPath("~/scriptdata/");
            bool      bIsTestOn = true;
            DataTable scriptData = null;
            DataTable tempData = null;
            string    expression = "";
            string    interval = "";
            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["interval"] != null)
                {
                    interval = Request.QueryString["interval"];

                    scriptData = StockApi.getVWAP(folderPath, scriptName, day_interval: interval, 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)
            {
                ////time,Real Lower Band,Real Middle Band,Real Upper Band
                ///
                (chartVWAP.Series["seriesVWAP"]).XValueMember  = "Date";
                (chartVWAP.Series["seriesVWAP"]).XValueType    = ChartValueType.Date;
                (chartVWAP.Series["seriesVWAP"]).YValueMembers = "VWAP";
                //(chartVWAP.Series["seriesVWAP"]).ToolTip = "VWAP: Date:#VALX;   Value:#VALY";

                chartVWAP.ChartAreas["chartareaVWAP"].AxisX.Title             = "Date";
                chartVWAP.ChartAreas["chartareaVWAP"].AxisX.TitleAlignment    = System.Drawing.StringAlignment.Center;
                chartVWAP.ChartAreas["chartareaVWAP"].AxisY.Title             = "Value";
                chartVWAP.ChartAreas["chartareaVWAP"].AxisY.TitleAlignment    = System.Drawing.StringAlignment.Center;
                chartVWAP.ChartAreas["chartareaVWAP"].AxisX.LabelStyle.Format = "g";

                //chartVWAP.Titles["titleVWAP"].Text = $"{"Volume Weighted Average Price - "}{scriptName}";

                if (chartVWAP.Annotations.Count > 0)
                {
                    chartVWAP.Annotations.Clear();
                }

                chartVWAP.DataSource = scriptData;
                chartVWAP.DataBind();
            }
        }
Ejemplo n.º 3
0
        public void ShowGraph(string scriptName)
        {
            string    folderPath = Server.MapPath("~/scriptdata/");
            bool      bIsTestOn = true;
            DataTable intraData = null;
            DataTable vwapData = null;
            DataTable tempData = null;
            string    expression = "";
            string    outputSize = "";
            string    interval_intra = "";
            string    interval_vwap = "";
            string    fromDate = "", toDate = "";

            DataRow[] filteredRows = null;


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

                if (Session["TestDataFolder"] != null)
                {
                    folderPath = Session["TestDataFolder"].ToString();
                }
                if ((Request.QueryString["size"] != null) && (Request.QueryString["interval_intra"] != null))
                {
                    outputSize     = Request.QueryString["size"].ToString();
                    interval_intra = Request.QueryString["interval_intra"];
                    intraData      = StockApi.getIntraday(folderPath, scriptName, time_interval: interval_intra, outputsize: outputSize, bIsTestModeOn: bIsTestOn, bSaveData: false);
                    ViewState["FetchedDataIntra"] = intraData;
                }
                else
                {
                    ViewState["FetchedDataIntra"] = null;
                    intraData = null;
                }
                if (Request.QueryString["interval_vwap"] != null)
                {
                    interval_vwap = Request.QueryString["interval_vwap"];

                    vwapData = StockApi.getVWAP(folderPath, scriptName, day_interval: interval_vwap, bIsTestModeOn: bIsTestOn, bSaveData: false);
                    ViewState["FetchedDataVWAP"] = vwapData;
                }
                else
                {
                    ViewState["FetchedDataVWAP"] = null;
                    vwapData = 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["FetchedDataIntra"];
                    expression   = "Date >= '" + fromDate + "' and Date <= '" + toDate + "'";
                    filteredRows = tempData.Select(expression);
                    if ((filteredRows != null) && (filteredRows.Length > 0))
                    {
                        intraData = filteredRows.CopyToDataTable();
                    }

                    tempData.Clear();
                    tempData = null;

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

            if ((intraData != null) && (vwapData != null))
            {
                showCandleStickGraph(intraData);
                showVWAP(vwapData);
            }
        }