B******y 发帖数: 2255 | 1 俺想每天存几个symbol的option的收盘数据,目前是每天手动存。想写个程序自动下载
数据,但不知用什么url.
比如下载AAPL当天的option收盘数据,怎么生成url呢?
请大牛指点,谢谢了。 | x********o 发帖数: 2092 | | B******y 发帖数: 2255 | | x********o 发帖数: 2092 | 4 不知道他们是怎么用的。我上班看option的macro用下面的代码。
对于call:
Call yahoo_stock_option_query('aapl', '2012-03', "10")
put用这个:
Call yahoo_stock_option_query('aapl', '2012-03, "14")
yahoo_stock_option_query代码:
Private Sub yahoo_stock_option_query(tickname As String, expdate As String,
position As String)
Worksheets("Temp").Activate
Worksheets("Temp").Cells.Clear
Range("A1").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://finance.yahoo.com/q/op?s=" & tickname & "&m=" & expdate, Destination:=Range( _
"$A$1"))
.Name = "op?s=" & tickname & "&m=" & expdate
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = position
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
Range("A13").Select
End Sub | B******y 发帖数: 2255 | 5 谢谢了。你是在投行工作吗?
看这个code好像背后是调用YQL,昨天在网上看到有人介绍,俺再钻钻吧。 |
|