Beispiel #1
0
        private static void RefreshSilverPrice(StockInfo silverInfo)
        {
            string url = "";
            try
            {
                if (silverInfo == null)
                    return;

                url = "http://data.91jin.com/data.aspx?a=quotation&code=AG&callback=jsonp1390282593069";
                WebRequest request = WebRequest.Create(url);
                WebResponse rs = request.GetResponse();
                StreamReader reader = new StreamReader(rs.GetResponseStream(), Encoding.GetEncoding("gb2312"));
                string silverMessage = reader.ReadToEnd();
                reader.Close();
                rs.Close();

                Regex regex = new Regex("\"UpdateTime\":\"(.*)\",\"SellPrice\":\"(.*)\",\"BuyPrice\":\"(.*)\",\"OpenPrice\":\"(.*)\",\"ClosePrice\":\"(.*)\",\"MaxPrice\":\"(.*)\",\"LastPrice\":\"(.*)\",\"MinPrice\":\"(.*)\"");
                Match matche = regex.Matches(silverMessage)[0];

                silverInfo.Now = matche.Groups[1].Value.Value<DateTime>();
                silverInfo.PriceTodayStart = matche.Groups[4].Value.Value<decimal>();
                silverInfo.PriceYesterdayEnd = matche.Groups[5].Value.Value<decimal>();
                silverInfo.PriceTodayHigh = matche.Groups[6].Value.Value<decimal>();
                silverInfo.PriceNow = matche.Groups[7].Value.Value<decimal>();
                silverInfo.PriceTodayLow = matche.Groups[8].Value.Value<decimal>();

            }
            catch (Exception ex)
            {
                MessageSvc.Default.Write(MessageLevel.Error, ex, "刷新个股信息失败,网址:{0}", url);
            }
        }
Beispiel #2
0
 private void SilverInfoChanged(StockInfo silverInfo)
 {
     //silverInfo
 }
Beispiel #3
0
 //用箭头表示相对上一个交易日的涨跌
 private string GetUpOrDownArrowCompareToLastDay(StockInfo stock)
 {
     if (stock.PriceNow == 0 || stock.PriceNow == stock.PriceYesterdayEnd) return " ";
     return stock.PriceNow > stock.PriceYesterdayEnd ? "↑" : "↓";
 }
Beispiel #4
0
        //超过警戒线用红色,低于警戒线用绿色
        private Color GetWarnColor(StockInfo stock)
        {
            Color color = Color.Black, up = Color.Red, down = Color.Green;

            if (!Constants.Setting.ShowWarn || stock.PriceNow == 0 || !stock.Warn) return color;

            if ((stock.WarnPrice_Max != 0 && stock.PriceNow > stock.WarnPrice_Max)
                || ((stock.WarnPercent_Max != 0 && stock.SurgedRange > stock.WarnPercent_Max)))
            {
                color = up;
            }

            if ((stock.WarnPrice_Min != 0 && stock.PriceNow < stock.WarnPrice_Min) || ((stock.WarnPercent_Min != 0 && stock.SurgedRange < stock.WarnPercent_Min)))
            {
                color = down;
            }
            return color;
        }
Beispiel #5
0
 private StockInfo GetStock(SQLiteDataReader reader)
 {
     StockInfo stock = new StockInfo()
     {
         Code = reader["Code"].ToJString(),
         No = reader["No"].ToJString(),
         SpellingInShort = reader["SpellingInShort"].ToJString(),
         Name = reader["Name"].ToJString(),
         WarnPercent_Max = reader["WarnPercent_Max"].Value<decimal>(),
         WarnPercent_Min = reader["WarnPercent_Min"].Value<decimal>(),
         WarnPrice_Max = reader["WarnPrice_Max"].Value<decimal>(),
         WarnPrice_Min = reader["WarnPrice_Min"].Value<decimal>(),
         BuyCount = reader["BuyCount"].Value<int>(),
         BuyPrice = reader["BuyPrice"].Value<decimal>(),
         ShowInFolatWindow = reader["ShowInFolatWindow"].Value<bool>(),
         HasProfitBefore = reader["HasProfit"].Value<decimal>(),
         Order = reader["Order"].Value<decimal>(),
         ProfitHistory = reader["ProfitHistory"].ToJString(),
         Warn = reader["Warn"].Value<bool>(),
         Description = reader["Description"].ToJString(),
     };
     return stock;
 }