Example #1
0
 public CAverageValue(CLineContents lc)
 {
     amplitude    = (lc.high - lc.low) / lc.yes_last;
     priceAverage = (lc.last - lc.start) / 2;
     numAverage   = GetInflow(lc);
     time         = lc.time;
     rate         = lc.rate;
 }
Example #2
0
 public CAverageValue(CLineContents lc)
 {
     amplitude = (lc.high - lc.low) / lc.yes_last;
     priceAverage = (lc.last - lc.start) / 2;
     numAverage = GetInflow(lc);
     time = lc.time;
     rate = lc.rate;
 }
Example #3
0
        public void Push(CLineContents lc)
        {
            lstLc.Add(lc);

            // decrease
            nd.CheckDecrease(lc);
            if (nd.stop)
            {
                lstTest.Add(nd);
                nd = new NumDecreaseTest();
                nd.CheckDecrease(lc);
            }

            for (int i = lstTest.Count - 1; i >= 0; --i)
            {
                lstTest[i].CheckDecrease(lc);
                if (lstTest[i].checkCount <= 0)
                {
                    lstResult.Add(lstResult[i]);
                    lstTest.RemoveAt(i);
                }
            }

            // extremum
            if (MaxNum < lc.chg_num)
            {
                MaxNum = lc.chg_num;
            }
            if (MinNum > lc.chg_num)
            {
                MinNum = lc.chg_num;
            }
            if (MaxPrice < lc.last)
            {
                MaxPrice = lc.last;
            }
            if (MinPrice > lc.last)
            {
                MinPrice = lc.last;
            }

            // average
            if (lstAverage.Count > 0)
            {
                lstAverage[lstAverage.Count - 1].tomorrowRate = lc.rate;
            }

            lstAverage.Add(new CAverageValue(lc));
        }
Example #4
0
        static string GetCodeData(string code, string beginTime, string curTime)
        {
            try
            {
                string   url      = string.Format(GetHttpData.urlFormat, "", code, beginTime, curTime);
                string   contents = GetHttpData.GetUrltoHtml(url, "GB18030");
                string[] lines    = contents.Split('\n');

                // 记录数过滤。。。
                if (lines.Length <= 3)
                {
                    return(null);
                }

                CStockContents sc = new CStockContents();

                for (int j = lines.Length - 1; j > 0; --j)
                {
                    // 过滤停。。。
                    if (lines[j].Contains("None,") || lines[j] == "")
                    {
                        continue;
                    }

                    CLineContents lc = new CLineContents(lines[j]);
                    sc.Push(lc);

                    if (j == 1)
                    {
                        CLineContents lcTmp = GetRealtimeData(code);
                        if (lcTmp != null)
                        {
                            sc.Push(lcTmp);
                        }
                    }
                }
                string res = sc.GetResult();
                if (res != null || res != "")
                {
                    return(res);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString() + "\n" + code);
            }
            return(null);
        }
Example #5
0
        public void Push(CLineContents lc)
        {
            lstLc.Add(lc);

            // decrease
            nd.CheckDecrease(lc);
            if (nd.stop)
            {
                lstTest.Add(nd);
                nd = new NumDecreaseTest();
                nd.CheckDecrease(lc);
            }

            for (int i = lstTest.Count - 1; i >= 0; --i)
            {
                lstTest[i].CheckDecrease(lc);
                if (lstTest[i].checkCount <= 0)
                {
                    lstResult.Add(lstResult[i]);
                    lstTest.RemoveAt(i);
                }
            }

            // extremum
            if (MaxNum < lc.chg_num)
            {
                MaxNum = lc.chg_num;
            }
            if (MinNum > lc.chg_num)
            {
                MinNum = lc.chg_num;
            }
            if (MaxPrice < lc.last)
            {
                MaxPrice = lc.last;
            }
            if (MinPrice > lc.last)
            {
                MinPrice = lc.last;
            }

            // average
            if (lstAverage.Count > 0)
                lstAverage[lstAverage.Count - 1].tomorrowRate = lc.rate;

            lstAverage.Add(new CAverageValue(lc));
        }
Example #6
0
 public void CheckDecrease(CLineContents lc)
 {
     if (stop) // check result en queue
     {
         afterRate.Add((lc.price - stopValue) / stopValue);
         --checkCount;
     }
     else // decrease
     {
         if (lc.chg_num < decreaseAverage && lc.rate > -9.8f && lc.rate < -1f ||
             count >= 3 && lc.chg_num < decreaseAverage * 1.05f && lc.rate > -9.8f && lc.rate < 1f
             )
         {
             if (count == 0)
             {
                 decreaseAverage = lc.chg_num;
                 ++count;
                 name = lc.name;
             }
             else
             {
                 decreaseAverage = (float)(decreaseAverage + lc.chg_num) / 2;
             }
             stopValue = lc.price;
             time      = lc.time;
         }
         else if (lc.rate <= -9.8f)
         {
         }
         else
         {
             if (count >= 3)
             {
                 stop = true;
             }
             else
             {
                 count           = 0;
                 decreaseAverage = float.MaxValue;
             }
         }
     }
 }
Example #7
0
        static CLineContents GetRealtimeData(string code)
        {
            DateTime dt = new DateTime(DateTime.Now.Ticks);

            // dapan is out data after 17,maybe, but gegu delay a day;
            if (dt.DayOfWeek != DayOfWeek.Sunday && dt.DayOfWeek != DayOfWeek.Saturday && dt.Hour > 9 && dt.Hour < 15)
            {
                string nowData = GetHttpData.GetUrltoHtml(string.Format(GetHttpData.nowFormat, code));

                int start = nowData.LastIndexOf('{');
                nowData = nowData.Substring(start, nowData.IndexOf('}') - start + 1);
                JsonData tmpData = JsonMapper.ToObject(nowData);

                CLineContents lc2 = new CLineContents();
                try
                {
                    lc2.time     = (string)tmpData["time"];
                    lc2.code     = (string)tmpData["code"];
                    lc2.name     = (string)tmpData["name"];
                    lc2.last     = (float)((double)tmpData["price"]);
                    lc2.high     = (float)(double)tmpData["high"];
                    lc2.low      = (float)(double)tmpData["low"];
                    lc2.start    = (float)(double)tmpData["open"];
                    lc2.yes_last = (float)((double)tmpData["yestclose"]);
                    lc2.price    = (float)(double)tmpData["updown"];
                    lc2.rate     = (float)((double)tmpData["percent"] * 100);
                    lc2.chg_rate = 0;
                    lc2.chg_num  = (int)tmpData["volume"];
                    //lc2.chg_value = (float)(double)tmpData["turnover"];
                    lc2.total    = 0;
                    lc2.total_on = 0;
                }
                catch (Exception e) { Console.WriteLine(e.ToString() + "\n" + nowData); }

                if (lc2.start >= float.Epsilon)
                {
                    return(lc2);
                }
            }
            return(null);
        }
Example #8
0
        static CLineContents GetRealtimeData(string code)
        {
            DateTime dt = new DateTime(DateTime.Now.Ticks);
            // dapan is out data after 17,maybe, but gegu delay a day;
            if (dt.DayOfWeek != DayOfWeek.Sunday && dt.DayOfWeek != DayOfWeek.Saturday && dt.Hour > 9 && dt.Hour < 15)
            {
                string nowData = GetHttpData.GetUrltoHtml(string.Format(GetHttpData.nowFormat, code));

                int start = nowData.LastIndexOf('{');
                nowData = nowData.Substring(start, nowData.IndexOf('}') - start + 1);
                JsonData tmpData = JsonMapper.ToObject(nowData);

                CLineContents lc2 = new CLineContents();
                try
                {
                    lc2.time = (string)tmpData["time"];
                    lc2.code = (string)tmpData["code"];
                    lc2.name = (string)tmpData["name"];
                    lc2.last = (float)((double)tmpData["price"]);
                    lc2.high = (float)(double)tmpData["high"];
                    lc2.low = (float)(double)tmpData["low"];
                    lc2.start = (float)(double)tmpData["open"];
                    lc2.yes_last = (float)((double)tmpData["yestclose"]);
                    lc2.price = (float)(double)tmpData["updown"];
                    lc2.rate = (float)((double)tmpData["percent"] * 100);
                    lc2.chg_rate = 0;
                    lc2.chg_num = (int)tmpData["volume"];
                    //lc2.chg_value = (float)(double)tmpData["turnover"];
                    lc2.total = 0;
                    lc2.total_on = 0;
                }
                catch (Exception e) { Console.WriteLine(e.ToString() + "\n" + nowData); }

                if (lc2.start >= float.Epsilon)
                {
                    return lc2;
                }
            }
            return null;
        }
Example #9
0
        static string GetCodeData(string code, string beginTime, string curTime)
        {
            try
            {
                string url = string.Format(GetHttpData.urlFormat, "", code, beginTime, curTime);
                string contents = GetHttpData.GetUrltoHtml(url, "GB18030");
                string[] lines = contents.Split('\n');

                // 记录数过滤。。。
                if (lines.Length <= 3) return null;

                CStockContents sc = new CStockContents();

                for (int j = lines.Length - 1; j > 0; --j)
                {
                    // 过滤停。。。
                    if (lines[j].Contains("None,") || lines[j] == "")
                        continue;

                    CLineContents lc = new CLineContents(lines[j]);
                    sc.Push(lc);

                    if (j == 1)
                    {
                        CLineContents lcTmp = GetRealtimeData(code);
                        if(lcTmp != null)
                            sc.Push(lcTmp);
                    }
                }
                string res = sc.GetResult();
                if (res != null || res != "")
                    return (res);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString() + "\n" + code);
            }
            return null;
        }
Example #10
0
 static float GetInflow(CLineContents lc)
 {
     return (float)lc.chg_value - lc.yes_last * lc.chg_num;
 }
Example #11
0
 static float GetNumAverage(CLineContents lc)
 {
     return (float)lc.chg_value / lc.chg_num;
 }
Example #12
0
 static float GetInflow(CLineContents lc)
 {
     return((float)lc.chg_value - lc.yes_last * lc.chg_num);
 }
Example #13
0
 static float GetNumAverage(CLineContents lc)
 {
     return((float)lc.chg_value / lc.chg_num);
 }
Example #14
0
 public void CheckDecrease(CLineContents lc)
 {
     if (stop) // check result en queue
     {
         afterRate.Add((lc.price - stopValue) / stopValue);
         --checkCount;
     }
     else // decrease
     {
         if (lc.chg_num < decreaseAverage && lc.rate > -9.8f && lc.rate < -1f
             || count >= 3 && lc.chg_num < decreaseAverage * 1.05f && lc.rate > -9.8f && lc.rate < 1f
             )
         {
             if (count == 0)
             {
                 decreaseAverage = lc.chg_num;
                 ++count;
                 name = lc.name;
             }
             else
             {
                 decreaseAverage = (float)(decreaseAverage + lc.chg_num) / 2;
             }
             stopValue = lc.price;
             time = lc.time;
         }
         else if (lc.rate <= -9.8f)
         {
         }
         else
         {
             if (count >= 3)
             {
                 stop = true;
             }
             else
             {
                 count = 0;
                 decreaseAverage = float.MaxValue;
             }
         }
     }
 }