neurallayer / roboquant

Roboquant is a fast, flexible, user-friendly and completely free algorithmic trading platform
https://www.roboquant.org
Apache License 2.0
335 stars 43 forks source link

Having some trouble with IBKR module - historical feed and charts printing #73

Open giabaocorn20 opened 7 months ago

giabaocorn20 commented 7 months ago

Hello,

I've been testing the functionality of the IBKR module and have noticed a couple of discrepancies. While everything seems to be working fine, I've encountered issues with the historical data feed not being displayed in the notebook, even though I can see API messages being sent to the IB Gateway. Additionally, the charts are not appearing as expected.

I've set up a paper trading account and successfully logged in using the provided username and password. Despite this, the historical data isn't showing up in the notebook, and the charts are not being printed.

Could you assist me in troubleshooting this matter?

The API responds to the call Screenshot 2024-01-27 142009

But there is nothing being printed out. Just an empty [] Screenshot 2024-01-27 142033

The charts aren't being created as well Screenshot 2024-01-27 142047

Thank you.

jbaron commented 7 months ago

Which version are you using of roboquant? The historic data is perhaps related to issue #69, but that is only fixed in the 2.2.0-SNAPSHOT release.

giabaocorn20 commented 7 months ago

Hi, I'm using the 2.2.0-SNAPSHOT release version. and for the rest, I did exactly the same as the example on jupyter notebook

jbaron commented 7 months ago

I just did a quick test, and no problems retrieving historic data:

val feed = IBKRHistoricFeed()

// This assumes you have a valid market subscription for US stocks
val symbols = listOf("TSLA", "GOOGL", "JPM")
val assets = symbols.map { Asset(it, AssetType.STOCK, "USD", "") }
feed.retrieve(assets)
feed.waitTillRetrieved()
println("historic feed with ${feed.timeline.size} events and ${feed.assets.size} assets")
feed.disconnect()

Same as you, I see all the data logger in the IB Gateway. So in your case, it is not a subscription issue I guess.

Is there any output on the console that something goes wrong?

jbaron commented 7 months ago

Also tried the IBKR notebook and is also working. See screenshot below for the first few cells in the notebook (using Jupyter-Lab btw).

Screenshot 2024-01-28 at 20 11 46

giabaocorn20 commented 7 months ago

Hi, thank you for your help. I tried to run the code that you sent me. Apparently the historic feed has 0 events and 0 assets. Screenshot 2024-01-28 152220 and the console printed out a warning like this, i dont know if its the reason affect this historical feed or not? Screenshot 2024-01-28 151324 FYI: I am running using IB Gateway 10.27

jbaron commented 7 months ago

Possible version differences?

For IBKR I run 10.19, both the installed TWS API and IB GW. For the TWS API, this is also the stable version.

giabaocorn20 commented 7 months ago

Hello, Yes, i just downloaded the 10.19 version and I think it's give better information that the 10.27 version. As it told that i didn't have a valid data subscription. However I'm currently experiencing an issue with the data subscription for Canadian stocks on the 10.19 version of the platform. Despite having an active subscription for the Canadian Security Exchange (CSE), I'm encountering a message indicating a lack of data subscription for this market.

I've attempted to implement the following code:

val symbols = listOf("TRUL")
val assets = symbols.map { Asset(it, AssetType.STOCK, "CAD")}

val feed = IBKRHistoricFeed()
feed.retrieve(assets)
feed.waitTillRetrieved()
println("Historic feed with ${feed.timeline.size} events and ${feed.assets.size} assets")
feed.assets

However, I'm still receiving a notification stating that there is no data subscription. I suspect there might be an issue with how I've mapped the assets. Could you please assist me in reviewing the asset mapping for Canadian stocks? Additionally, I recommend updating the link from IB Gateway in the Jupyter notebook, as it currently directs to the 10.27 version instead of the 10.19 version.

Your help in resolving this matter is greatly appreciated. Thank you for your assistance.

jbaron commented 7 months ago

I remember there is some IBKR account setting that you want to share you data-subscription with the paper-trade account.