Beispiel #1
0
        public static void LoadData(baseDS.priceDataDataTable tbl, string timeScale, DateTime frDate, string stockCode)
        {
            WriteLog(common.SysSeverityLevel.Informational, "", timeScale + " " + frDate.ToString() + " " + stockCode);
            string eCode = "DB000";

            try
            {
                if (tbl.Count > 0)
                {
                    common.SysLog.WriteLog(DateTime.Now.ToString() + common.Consts.constTab + "test 00: LoadData ", Settings.sysFileUserLog);
                }

                priceDataTA.ClearBeforeFill = false;
                if (timeScale == AppTypes.MainDataTimeScale.Code)
                {
                    eCode = "DB001";
                    priceDataTA.FillByCodeFromDate(tbl, stockCode, frDate);
                }
                else
                {
                    eCode = "DB002 " + priceDataTA.Connection.State.ToString();

                    priceDataTA.FillByTypeCodeFromDate(tbl, timeScale, stockCode, frDate);
                }
            }
            catch (Exception er)
            {
                WriteLog(common.SysSeverityLevel.Error, eCode, er);
            }
        }
Beispiel #2
0
 //public static void LoadAbnormalData(baseDS.priceDataDataTable tbl, string code, DateTime frDate, DateTime toDate, string timeScale)
 //{
 //    priceDataTA.ClearBeforeFill = false;
 //    if (timeScale == AppTypes.MainDataTimeScale.Code)
 //    {
 //        priceDataTA.FillAbnormal(tbl, code, frDate, toDate);
 //    }
 //    else
 //    {
 //        priceDataTA.FillAbnomalSumData(tbl, code, timeScale, frDate, toDate);
 //    }
 //}
 public static void LoadData(baseDS.priceDataDataTable tbl, string timeScale, DateTime frDate, DateTime toDate, string stockCode)
 {
     priceDataTA.ClearBeforeFill = false;
     if (timeScale == AppTypes.MainDataTimeScale.Code)
     {
         if (frDate == DateTime.MinValue && toDate == DateTime.MaxValue)
         {
             priceDataTA.FillByCode(tbl, stockCode);
         }
         else
         {
             priceDataTA.FillByDateCode(tbl, frDate, toDate, stockCode);
         }
     }
     else
     {
         if (frDate == DateTime.MinValue && toDate == DateTime.MaxValue)
         {
             priceDataTA.FillByTypeCode(tbl, timeScale, stockCode);
         }
         else
         {
             priceDataTA.FillByTypeDateCode(tbl, timeScale, frDate, toDate, stockCode);
         }
     }
 }
Beispiel #3
0
 public static baseDS.priceDataRow GetLastPriceData(string stockCode)
 {
     baseDS.priceDataDataTable priceTbl = priceDataTA.GetLastPrice(stockCode);
     if (priceTbl.Count == 0)
     {
         return(null);
     }
     return(priceTbl[0]);
 }
Beispiel #4
0
 public static void UpdateData(baseDS.priceDataDataTable tbl)
 {
     try
     {
         priceDataTA.Update(tbl);
         tbl.AcceptChanges();
     }
     catch (Exception e)
     {
         foreach (baseDS.priceDataRow row in tbl.Rows)
         {
             if (row.HasErrors)
             {
                 WriteSyslog(e, row.stockCode + " Date: " + row.onDate);
             }
         }
     }
 }
Beispiel #5
0
        public static void LoadData(baseDS.priceDataDataTable tbl, string timeScale, string stockCode, int maxCount)
        {
            string dataTbl = "";
            string cond    = "stockCode=N'" + stockCode.Trim() + "'";

            if (timeScale == AppTypes.MainDataTimeScale.Code)
            {
                dataTbl = "priceData";
            }
            else
            {
                dataTbl = "priceDataSum";
                cond   += (cond == ""?"" : " AND ") + "type=N'" + timeScale + "'";
            }
            string sqlCmd =
                "SELECT * FROM " +
                "(SELECT TOP " + maxCount.ToString() + " onDate,stockCode,openPrice,closePrice,lowPrice,highPrice,volume FROM " + dataTbl + common.Consts.constCRLF +
                "WHERE " + cond + " ORDER BY onDate DESC)a" + common.Consts.constCRLF +
                "ORDER BY onDate";

            LoadFromSQL(tbl, sqlCmd);
        }
Beispiel #6
0
        //public static void LoadAbnormalData(baseDS.priceDataDataTable tbl, string code, DateTime frDate, DateTime toDate, string timeScale)
        //{
        //    priceDataTA.ClearBeforeFill = false;
        //    if (timeScale == AppTypes.MainDataTimeScale.Code)
        //    {
        //        priceDataTA.FillAbnormal(tbl, code, frDate, toDate);
        //    }
        //    else
        //    {
        //        priceDataTA.FillAbnomalSumData(tbl, code, timeScale, frDate, toDate);
        //    }
        //}
        public static void LoadData(baseDS.priceDataDataTable tbl, string timeScale, DateTime frDate, DateTime toDate, string stockCode)
        {
            try
            {
                common.SysLog.WriteLog("AAA0: ", Settings.sysFileUserLog);
                //priceDataTA.Connection.ConnectionString = @"Data Source=HAIQUAN\MSSQLSERVER2008;Initial Catalog=stock;User ID=sa;Password=123";
                common.SysLog.WriteLog("AAA: " + priceDataTA.Connection.ConnectionString, Settings.sysFileUserLog);

                priceDataTA.ClearBeforeFill = false;
                if (timeScale == AppTypes.MainDataTimeScale.Code)
                {
                    if (frDate == DateTime.MinValue && toDate == DateTime.MaxValue)
                    {
                        priceDataTA.FillByCode(tbl, stockCode);
                    }
                    else
                    {
                        priceDataTA.FillByDateCode(tbl, frDate, toDate, stockCode);
                    }
                }
                else
                {
                    if (frDate == DateTime.MinValue && toDate == DateTime.MaxValue)
                    {
                        priceDataTA.FillByTypeCode(tbl, timeScale, stockCode);
                    }
                    else
                    {
                        priceDataTA.FillByTypeDateCode(tbl, timeScale, frDate, toDate, stockCode);
                    }
                }
            }
            catch (Exception er)
            {
                WriteLog(common.SysSeverityLevel.Alert, "ABC", er);
            }
        }
Beispiel #7
0
 public static void LoadDataOneRow(baseDS.priceDataDataTable tbl, DateTime frDate, DateTime toDate, string stockCode)
 {
     priceDataTA.ClearBeforeFill = false;
     priceDataTA.FillOneByDateStockCode(tbl, frDate, toDate, stockCode);
 }
Beispiel #8
0
 public static void UpdateData(baseDS.priceDataDataTable tbl)
 {
     priceDataTA.Update(tbl);
     tbl.AcceptChanges();
 }
Beispiel #9
0
        private void InitAndDrawIndexes()
        {
            baseDS.priceDataDataTable tbl1 = Gateway.PriceData.GetPriceData("VN-IDX", "D1", DateTime.Now.AddDays(-20), DateTime.Now);
            baseDS.priceDataDataTable tbl2 = Gateway.PriceData.GetPriceData("HNX-IDX", "D1", DateTime.Now.AddDays(-20), DateTime.Now);
            #region VNINDEX
            decimal[] yValues = new decimal[tbl1.Count];
            string[]  xValues = new string[tbl1.Count];
            for (int idx = 0; idx < tbl1.Count; idx++)
            {
                yValues[idx] = tbl1[idx].closePrice;
                xValues[idx] = tbl1[idx].onDate.ToShortDateString();
            }
            Chart lineChart = lineCurvesChartType1.getChart();
            lineChart.Series["Series1"].LegendText = "VN-Index";
            lineChart.Series["Series1"].XValueType = ChartValueType.Date;
            lineChart.Series["Series1"].YValueType = ChartValueType.Int32;
            //lineChart.Legends["Series1"].Title = "VN-Index";
            //lineChart.Legends["Series1"].DockedToChartArea = "Default";
            lineChart.Series["Series1"].MarkerStyle = MarkerStyle.None;
            lineChart.Series["Series1"].Points.DataBindXY(xValues, yValues);
            lineChart.Series["Series1"].Color = System.Drawing.Color.Red;
            lineChart.Series["Series1"].IsValueShownAsLabel = true;

            // Set Doughnut chart type
            lineChart.Series["Series1"].ChartType = SeriesChartType.Line;

            // Set labels style
            lineChart.Series["Series1"]["PieLabelStyle"] = "Inside";

            // Set Doughnut radius percentage
            lineChart.Series["Series1"]["DoughnutRadius"] = "99";

            // Explode data point with label "Italy"
            lineChart.Series["Series1"].Points[yValues.Length - 1]["Exploded"] = "true";

            // Enable 3D
            lineChart.ChartAreas["Default"].Area3DStyle.Enable3D  = false;
            lineChart.ChartAreas["Default"].AxisX.IsMarginVisible = true;

            // Set drawing style
            lineChart.Series["Series1"]["PieDrawingStyle"] = "SoftEdge";
            #endregion VNINDEX
            //HNX series
            #region HNX
            //decimal[] yValues2 = new decimal[tbl2.Count];
            //string[] xValues2 = new string[tbl2.Count];
            //for (int idx = 0; idx < tbl2.Count; idx++)
            //{
            //    yValues2[idx] = tbl2[idx].closePrice;
            //    xValues2[idx] = tbl2[idx].onDate.ToShortDateString();
            //}
            //lineChart.Series["Series2"].XValueType = ChartValueType.Date;
            //lineChart.Series["Series2"].YValueType = ChartValueType.Int32;
            //lineChart.Series["Series2"].Points.DataBindXY(xValues2, yValues2);
            //lineChart.Series["Series2"].Color = Color.Green;
            //lineChart.Series["Series2"].IsValueShownAsLabel = true;
            //lineChart.Series["Series2"].LegendText = "HNX-Index";

            ////lineChart.Series["Series2"].Label =

            //// Set Doughnut chart type
            //lineChart.Series["Series2"].ChartType = SeriesChartType.Line;

            //// Set labels style
            //lineChart.Series["Series2"]["PieLabelStyle"] = "Inside";


            //// Explode data point with label "Italy"
            //lineChart.Series["Series2"].Points[yValues2.Length - 1]["Exploded"] = "true";


            #endregion HNX
            //END HNX series
            Title title4 = new Title();
            title4.Font         = new System.Drawing.Font("Trebuchet MS", 14.25F, System.Drawing.FontStyle.Bold);
            title4.ForeColor    = System.Drawing.Color.FromArgb(((int)(((byte)(26)))), ((int)(((byte)(59)))), ((int)(((byte)(105)))));
            title4.Name         = "Title1";
            title4.ShadowColor  = System.Drawing.Color.FromArgb(((int)(((byte)(32)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
            title4.ShadowOffset = 1;
            title4.Text         = "BIỂU ĐỒ CHỈ SỐ VN-INDEX TUẦN QUA";
            lineChart.Titles.Clear();
            lineChart.Titles.Add(title4);
        }