Basically, I want to use python to query my IB order history and do some analyze afterwards. But I could not find any existing API for me to query these data, does anyone have experience to do this?
Asked
Active
Viewed 4,976 times
5
-
Welcome to StackOverflow! Please read the info about [how to ask a good question](https://stackoverflow.com/help/how-to-ask) and [how to give a reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). This will make it much easier for others to help you. – Aditi Feb 23 '18 at 07:17
-
Interactive Brokers has a documented API. You should attempt to implement a solution and return if you run into specific issues. – Anthony L Feb 23 '18 at 07:18
-
1Yes, I know IB has an API but I could find what I want. – Niucool Ki Feb 26 '18 at 20:07
-
What you want is not done with the api but with account management on the web. https://www.interactivebrokers.com/en/software/etmug/employeetrackmgmt.htm#cshid=employeetrack/etreports/ib_activity_flex.htm – brian Mar 01 '18 at 23:21
-
Thanks, Brian, so there are no program ways to retrieve the order history, right? – Niucool Ki Mar 02 '18 at 06:55
-
You can write a small program to fetch the statements from the internet. You can also log the orders when you make them and when they are filled so you always have a record. – brian Mar 02 '18 at 17:13
2 Answers
6
You have to use flex queries for that purpose. It has full transaction history including trades, open positions, net asset value history and exchange rates.
Istvan Kardkovacs
- 249
- 2
- 5
-
-
@CorneliuMaftuleac https://www.interactivebrokers.com/en/software/allocationfunds/topics/flexqueries.htm – ed22 Nov 02 '20 at 23:25
2
TWS API doesn't have this functionality. You can't retreive order history, but you can get open orders using recOpenOrders request and capture executions in realtime by listening to execDetails event - just write them to a file and analyse aftewards.
VictorS
- 191
- 3