如何计算一天的价值变化

本文关键字:变化 一天 何计算 计算 | 更新日期: 2023-09-27 18:20:07

我正在尝试计算股指一天的价值变化如下所述:http://www.codeproject.com/Articles/37550/Stock-quote-and-chart-from-Yahoo-in-C

在C#中如何计算?

如何计算一天的价值变化

正在从文章中返工GetQuote方法。。。如果将符号传递给此方法,它将返回Days Value Change。

public string GetDaysValueChange(string symbol)
{
    // Set the return string to null.
    string result = null;            
    try
    {
        // Use Yahoo finance service to download stock data from Yahoo
        //  Note that f=w1 tells the service we just want the Days Value Change
        string yahooURL = @"http://download.finance.yahoo.com/d/quotes.csv?s=" + 
                          symbol + "&f=w1";
        // Initialize a new WebRequest.
        HttpWebRequest webreq = (HttpWebRequest)WebRequest.Create(yahooURL);
        // Get the response from the Internet resource.
        HttpWebResponse webresp = (HttpWebResponse)webreq.GetResponse();
        // Read the body of the response from the server.
        StreamReader strm = 
          new StreamReader(webresp.GetResponseStream(), Encoding.ASCII);
        result = strm.ReadLine().Replace("'"", "");
        strm.Close();
    }
    catch
    {
        // Handle exceptions.
    }
    // Return the stock quote data in XML format.
    return result;
}