¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

Hoping for some help on individual lot information


 

Hello!??

I'm a long time reader, first time poster.?

I have one contract which I purchase multiple times at multiple prices. So for example:

10 shares AAPL at $100
10 shares AAPL at $200

reqPositions() returns a single Position of 20 shares AAPL with avg price of $150.??

Is there any way to get individual lot information through the API instead of the aggregate? Thank you in advance.

--Jonathan


 

On Wed, Nov 18, 2020 at 01:03 AM, <jsheena@...> wrote:
Is there any way to get individual lot information through the API instead of the aggregate? Thank you in advance.
No, there isn't with IB. For your open positions they only provide the total shares and the total cost of buying these shares.
You would have to build and store your own database with the details of each trade. Then you can calculate yourself what you are looking for.


 

You can request a list of all today¡¯s executions, and/or set up to receive both order and execution (and commission report) records every time they are created.

Then you can either store them in a database to maintain ¡°state¡± with IB, or just hold them in memory to work out which are part of the current open positions.


 

Thank you Nich, and J G

Alas.? I'll store everything in my own database and maybe come up with a way to check against an offline IB report.

This group is a fantastic resource.? Thank you for helping!

--Jonathan


Nick
 

¿ªÔÆÌåÓý

You can request executions for up to 1 week previous to the current day. You have to set the Trade Log in TWS to check the boxes for all days of the week.

You might also look into Flex reports. They are not part of the api but some people have semi-automated the process of running the reports and scraping desired info from them.


On 11/18/2020 4:35 PM, jsheena@... wrote:

Thank you Nich, and J G

Alas.? I'll store everything in my own database and maybe come up with a way to check against an offline IB report.

This group is a fantastic resource.? Thank you for helping!

--Jonathan


 

Thanks, Nick.
One issue I had with Flex reports was in trying to match up executions in reports with executions reported through the API.? I couldn't find any matching identifier (like executionID, permID, or orderID) between the API and the flex report.? Do you know what might work??
Thanks again


Nick
 

¿ªÔÆÌåÓý

I think the OrderRef field is available in Flex reports. You can set that text field to any value you want when you place the order.


On 11/18/2020 8:48 PM, jsheena@... wrote:

Thanks, Nick.
One issue I had with Flex reports was in trying to match up executions in reports with executions reported through the API.? I couldn't find any matching identifier (like executionID, permID, or orderID) between the API and the flex report.? Do you know what might work??
Thanks again


 

OrderRef is available in flex reports but only for the last 24 hours so they have to be received daily to avoid losing track.


 

Thank you.
I've added an orderref to test it out.