无法使用带有 R 的 IBrokers 连接到 TWS

Cannot connect to TWS using IBrokers with R

我的代码输出:

library(IBrokers)
tws <- twsConnect(port=7496)

Error in socketConnection(host = host, port = port, open = "ab", blocking = blocking) : 
  cannot open the connection
In addition: Warning message:
In socketConnection(host = host, port = port, open = "ab", blocking = blocking) :
  localhost:7496 cannot be opened

我已经检查了我在交易平台中的全局配置。该端口实际上是 7496.

> sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Linux Mint 20

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8      
 [8] LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] IBrokers_0.9-12 xts_0.12-0      zoo_1.8-8      

loaded via a namespace (and not attached):
[1] compiler_3.6.3  tools_3.6.3     grid_3.6.3      lattice_0.20-40

我正在使用最新的 Linux Mint。我的 IB 账户已被批准并入金。

终于成功了!结果是未选中“启用 ActiveX 和套接字客户端”复选框。我检查了一下,确实有效。