예제 #1
0
        public bool downloadMACD(string folderPath, string scriptName, bool bIsTestOn, bool bSaveData)
        {
            string interval     = ddlMACD_Interval.SelectedValue;
            string series       = ddlMACD_Series.SelectedValue;
            string FastPeriod   = textboxMACD_FastPeriod.Text;
            string Slowperiod   = textboxMACD_SlowPeriod.Text;
            string SignalPeriod = textboxMACD_SignalPeriod.Text;

            if (StockApi.getMACD(folderPath, scriptName, day_interval: interval, seriestype: series, fastperiod: FastPeriod, slowperiod: Slowperiod, signalperiod: SignalPeriod, bIsTestModeOn: bIsTestOn, bSaveData: bSaveData, apiKey: Session["ApiKey"].ToString()) == null)
            {
                Response.Write("<script language=javascript>alert('MACD data not available for selected script.')</script>");
                return(false);
            }
            return(true);
        }
예제 #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    seriestype = "";
            string    fastperiod = "";
            string    slowperiod = "";
            string    signalperiod = "";
            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) && (Request.QueryString["seriestype"] != null) &&
                    (Request.QueryString["fastperiod"] != null) && (Request.QueryString["slowperiod"] != null) &&
                    (Request.QueryString["signalperiod"] != null))
                {
                    interval     = Request.QueryString["interval"];
                    seriestype   = Request.QueryString["seriestype"].ToString();
                    fastperiod   = Request.QueryString["fastperiod"].ToString();
                    slowperiod   = Request.QueryString["slowperiod"].ToString();
                    signalperiod = Request.QueryString["signalperiod"].ToString();

                    scriptData = StockApi.getMACD(folderPath, scriptName, day_interval: interval, seriestype: seriestype,
                                                  fastperiod: fastperiod, slowperiod: slowperiod, signalperiod: signalperiod,
                                                  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
                ///
                (chartMACD.Series["seriesMACD"]).XValueMember  = "Date";
                (chartMACD.Series["seriesMACD"]).XValueType    = ChartValueType.Date;
                (chartMACD.Series["seriesMACD"]).YValueMembers = "MACD";
                //(chartMACD.Series["seriesMACD"]).ToolTip = "MACD: Date:#VALX;   Value:#VALY";

                (chartMACD.Series["seriesMACD_Hist"]).XValueMember  = "Date";
                (chartMACD.Series["seriesMACD_Hist"]).XValueType    = ChartValueType.Date;
                (chartMACD.Series["seriesMACD_Hist"]).YValueMembers = "MACD_Hist";
                //(chartMACD.Series["seriesMACD_Hist"]).ToolTip = "MACD_Hist: Date:#VALX;   Value:#VALY";

                (chartMACD.Series["seriesMACD_Signal"]).XValueMember  = "Date";
                (chartMACD.Series["seriesMACD_Signal"]).XValueType    = ChartValueType.Date;
                (chartMACD.Series["seriesMACD_Signal"]).YValueMembers = "MACD_Signal";
                //(chartMACD.Series["seriesMACD_Signal"]).ToolTip = "MACD_Signal: Date:#VALX;   Value:#VALY";

                chartMACD.ChartAreas["chartareaMACD"].AxisX.Title          = "Date";
                chartMACD.ChartAreas["chartareaMACD"].AxisX.TitleAlignment = System.Drawing.StringAlignment.Center;
                chartMACD.ChartAreas["chartareaMACD"].AxisY.Title          = "Value";
                chartMACD.ChartAreas["chartareaMACD"].AxisY.TitleAlignment = System.Drawing.StringAlignment.Center;

                //chartMACD.Titles["titleMACD"].Text = $"{"Moving Average Convergence Divergence- "}{scriptName}";

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

                chartMACD.DataSource = scriptData;
                chartMACD.DataBind();
            }
        }