【问题标题】:Retrieve the historical close price for each stock from yahoo finance?从雅虎财经检索每只股票的历史收盘价?
【发布时间】:2014-02-10 05:28:53
【问题描述】:

我正在 vb.net 中编写程序。我的程序将生成每只股票的收盘价回报图。现在,我必须去雅虎财经并选择日期并下载。然后我在 excel 中打开文件并复制收盘价的列。然后我将这些值粘贴到记事本中。最后,我的程序读取记事本文件并生成图表。

那么,无论如何我可以在 vb.net 中输入符号并获得所需的所有值,而无需执行所有这些步骤?

【问题讨论】:

    标签: vb.net yahoo-finance


    【解决方案1】:

    盗自http://www.vb-helper.com/howto_net_graph_stock_history.html

    下面的代码将为您提供从雅虎检索股票报价所需的信息。您只需将股票代码传递给 GetStockPrices。我相信,默认情况下,它会从谷歌财经下载一年的历史数据。

    真的,您只需 google:'vb.net 下载股票报价历史记录' - 您会在那里找到大量资料。

    ' Get the prices for this symbol.
    Private Function GetStockPrices(ByVal symbol As String) As _
        List(Of Single)
        ' Compose the URL.
        Dim url As String = _
            "http://www.google.com/finance/historical?output=csv&q=" _
            & symbol
    
        ' Get the result.
        ' Get the web response.
        Dim result As String = GetWebResponse(url)
    
        ' Get the historical prices.
        Dim lines() As String = result.Split( _
            New String() {vbCr, vbLf}, _
            StringSplitOptions.RemoveEmptyEntries)
        Dim prices As New List(Of Single)()
    
        ' Process the lines, skipping the header.
        For i As Integer = 1 To lines.Length - 1
            Dim line As String = lines(i)
            prices.Add(Single.Parse(line.Split(","c)(4)))
        Next i
    
        Return prices
    End Function
    

    【讨论】:

    • 相信我,我试过谷歌,但他们都给了我疯狂的代码或与 SQL 有关的东西。我真的只是一个初学者。此外,代码不起作用。还是谢谢
    猜你喜欢
    • 2018-04-21
    • 2023-03-16
    • 1970-01-01
    • 2013-11-06
    • 1970-01-01
    • 1970-01-01
    • 2022-01-22
    • 1970-01-01
    • 2022-12-05
    相关资源
    最近更新 更多