gpt4 book ai didi

r - 使用IBrokers包的问题

转载 作者:行者123 更新时间:2023-12-01 01:23:44 25 4
gpt4 key购买 nike

我试图使用带有最简单代码的 IBrokers 包,如下所示:

library(IBrokers)

tws <- twsConnect()

aapl.csv <- file("AAPL.csv", open="wa")

# run an infinite-loop ( <C-c> to break )
reqMktData(tws, twsSTK("AAPL"),
eventWrapper=eWrapper.MktData.CSV(1),
file=aapl.csv)

close(aapl.csv)
close(tws)

我收到此错误:
2 1 321 Error validating request:-'oc' : 
cause - Incorrect generic tick list of 100,101,104,106,165,221,225,236.
Legal ones for (STK)

一切都悬而未决...

整个日志在这里:
R version 2.13.0 (2011-04-13)
Copyright (C) 2011 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-pc-mingw32/x64 (64-bit)

> library(IBrokers)
Loading required package: xts
Loading required package: zoo

Attaching package: 'zoo'

The following object(s) are masked from 'package:base':

as.Date, as.Date.numeric

IBrokers version 0.9-3:
Implementing API Version 9.64
This software comes with NO WARRANTY. Not intended for production use!
See ?IBrokers for details
Warning messages:
1: package 'IBrokers' was built under R version 2.13.2
2: package 'xts' was built under R version 2.13.2
3: package 'zoo' was built under R version 2.13.2
>
> tws <- twsConnect()
>
> aapl.csv <- file("AAPL.csv", open="a")
>
> # run an infinite-loop ( <C-c> to break )
> reqMktData(tws, twsSTK("AAPL"),
+ eventWrapper=eWrapper.MktData.CSV(1),
+ file=aapl.csv)
2 -1 2104 Market data farm connection is OK:cashfarm
2 -1 2104 Market data farm connection is OK:usfarm
2 -1 2106 HMDS data farm connection is OK:ushmds2a
2 1 321 Error validating request:-'oc' : cause - Incorrect generic tick list of 100,101,104,106,165,221,225,236. Legal ones for (STK) are: 100(Option Volume),101(Option Open Interest),104(Historical Volatility),105(Average Opt Volume),106(Option Implied Volatility),107(Close Implied Volatility),125(Bond analytic data),165(Misc. Stats),166(CScreen),225(Auction),233(RTVolume),236(inventory),258/47(Fundamentals),291(Close Implied Volatility),293(TradeCount),294(TradeRate),295(VolumeRate),318(LastRTHTrade),370(ParticipationMonitor),370(ParticipationMonitor),377(CttTickTag),377(CttTickTag),381(IB Rate),384(RfqTickRespTag),384(RfqTickRespTag),387(DMM),388(Issuer Fundamentals),391(IBWarrantImpVolCompeteTick),407(FuturesMargins),411(Real-Time Historical Volatility)

> (Command cancelled)
>
> close(aapl.csv)
> close(tws)

我在这里做错了什么?高度赞赏任何解决方案或指向引用的想法。

最佳答案

该错误表示您的勾选列表不正确。如果将其与它报告的有效数据进行比较,您会发现 221 是罪魁祸首。谢天谢地,做 ?reqMktData告诉我们您可以使用 tickGenerics 指定您自己的勾选列表。选项。所以就做类似的事情

> reqMktData(tws, twsSTK("AAPL"), 
eventWrapper=eWrapper.MktData.CSV(1),
file=aapl.csv, tickGenerics="100,101,104,106,165,225,236")

你应该很高兴去。

关于r - 使用IBrokers包的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7996459/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com