erdewit / ib_insync

Python sync/async framework for Interactive Brokers API
BSD 2-Clause "Simplified" License
2.85k stars 774 forks source link

Flex Reports from custom time? #326

Closed tankorsmash closed 3 years ago

tankorsmash commented 3 years ago

I'd like to be able to download a report from say, last quarter, rather than whatever the default is. I didn't see a mention of how to do it from the ib_insync docs, and the code seems to use some sort of non-public URL. I don't see anything about custom dates in the FlexReportV3 docs either

It seems like IBKR supports some sort of customization, given that when you download the flex report for their site, it sends the custom timeframe via query:

runOptions: {"queryId":"12345","queryType":"TCF","outputFormat":"XML","period":"LastQuarter","fromDate":"2021-01-04","toDate":"2021-01-04","noOfDays":1}

but appending f'&period=LastQuarter&fromDate=2021-01-04&toDate=2021-01-04&noOfDays=30 to the download() url doesn't seem to change anything either.

Is it possible to somehow download a flex report with a custom period, rather than the default 1 day?

tankorsmash commented 3 years ago

Ah, this might be to do with Trade Confirmation Flex Reports being customizable on download, but Activity Reports don't have the hardcoded "Today" on the page.

edit: no, downloading the Activity report stil lets you customize the date range using the same runOptions query params on download

erdewit commented 3 years ago

Feel free to ask IB about this.