开云体育

ctrl + shift + ? for shortcuts
© 2025 开云体育
Date

Re: Retrieving past trades in an account

 

In TWS API you can only retrieve trades for the current trading day.

You can use two approaches:

The first one is to request executions, i.e. reqExecutions. Pros: it is well known and seems to be widely used, and can consume executions filters (including contracts traded). Cons: even with a filter it could still be pretty verbose because it can return numerous partial fills per order which the client needs to accumulate and collate.

The second one is to get completed orders, i.e. reqCompletedOrders. Pros: it returns concise trade data per each order. Cons: despite being in API releases for at least 2 years it's still poorly documented, and it spews all completed orders after each request so any filtering must be carried out by the client.

For trades going back beyond 1 day, reports should be downloaded from the account management website (or set up for automatic delivery by email).


Re: The right date format for reqHistoricalData for Java

Nick
 

开云体育

I suspect by TMZ it wants a time zone name, like "UTC", rather than a number. There was a discussion here not long ago which I think gives complete info on this.


On 2/20/2022 6:15 PM, olivier.vanparys@... wrote:

Hi Cheng,

I am facing the exact same issue, I have tried a slight variation for the timezone requirement since my date is in UTC. Yet I am getting the same error message:

Historical data query end date/time string [20220201 21:15:00[ +0000]] is invalid.? Format is 'YYYYMMDD{SPACE}hh:mm:ss[{SPACE}TMZ]'

Has anyone been able to guide you regarding the correct way to specif timezone in a string?



Retrieving past trades in an account

 

Hello, is there a way to retrieve past trades in an account for a given contract?? ?For example, I need to find out all the trades placed for SPY in my account.? Is it possible?


Re: The right date format for reqHistoricalData for Java

 

Hi Cheng,

I am facing the exact same issue, I have tried a slight variation for the timezone requirement since my date is in UTC. Yet I am getting the same error message:

Historical data query end date/time string [20220201 21:15:00[ +0000]] is invalid.? Format is 'YYYYMMDD{SPACE}hh:mm:ss[{SPACE}TMZ]'

Has anyone been able to guide you regarding the correct way to specif timezone in a string?


TWS on Windows 7: autoupdate fails, won't load

 

I've been running TWS on a Windows 7 machine successfully for many years until today. I'm on the latest version and after logging out on Friday I am unable to log in on a Win 7 machine. I tried on another Win7 machine and same thing - I get a message box regarding Java version and the log file lists several problems in sequence. Ultimately I think the problem is brittle TWS auto-install code that doesn't fail gracefully. I'm running the TWS on Win10 with no problems. Just wondering if anyone else is having the same problem and / or trying to bring this to the attention of the developer so it can be fixed ASAP. I'm going to now go file a ticket.

There are a number of prior errors, but this section is probably why the TWS won't run at all. (Strangely, the url below loads tar.gz file on the win7 / win10 machines with no issues):

[0:254] found installations: C:\Jts
[0:254] checkJavaExe (C:\Jts\jre\bin\java.exe, [out], 4, 4, 0)
[0:254] file doesn't exist
[0:254] checkJavaExe returning 0
[0:255] java version did not match in C:\Jts\jre
[0:255] Search sequence finished
[0:255] ERROR: No JVM found
[0:255] Download location: https://download2.interactivebrokers.com/installers/jres/windows-amd64-1.8.0_202.tar.gz
[0:255] Downloading JRE
[0:339] ERROR: InternetOpenUrl failed with error code 12029
[1:339] ERROR: Retry JRE download
[1:386] ERROR: InternetOpenUrl failed with error code 12029
[2:386] ERROR: Retry JRE download
[2:434] ERROR: InternetOpenUrl failed with error code 12029
[3:434] ERROR: Retry JRE download

Patrick


Re: python GUI for use with infinite run() loop

Eric Swanson
 

开云体育

Thanks Juergen!

On Feb 18, 2022, at 7:50 PM, 闯ü谤驳别苍 Reinold via groups.io <TwsApiOnGroupsIo@...> wrote:

?Its the topic on top int the Web interface or /g/twsapi/topic/5053887


Re: python GUI for use with infinite run() loop

 

Its the topic on top int the Web interface or /g/twsapi/topic/5053887


Re: python GUI for use with infinite run() loop

Eric Swanson
 

Is there a link for the code mentioned here? I would also like to see it!

btw- I wanted to thank you for posting this code. I am new to both Python and IBKR and was really struggling with with structuring a program to display data in tkinter from the ikbr callback functions. Your simple program is clear and works great, although I updated the tkinter code to use grid instead of pack functions. Now I feel like I can focus on developing the system I want to develop rather than continually working on the plumbing.


Re: python GUI for use with infinite run() loop

 

btw- I wanted to thank you for posting this code.? I am new to both Python and IBKR and was really struggling with with structuring a program to display data in tkinter from the ikbr callback functions.? Your simple program is clear and works great, although I updated the tkinter code to use grid instead of pack functions.? ?Now I feel like I can focus on developing the system I want to develop rather than continually working on the plumbing.


Re: Volume and Float and Outstanding Shares

 

Volume you get from IB, outstanding shares and float from for example Yahoo finance.

With fibs you mean some fibonacci retracements I assume? These you will have to calculate yourself.


Volume and Float and Outstanding Shares

 

开云体育

Hey gals/guys,
Is it possible to get this type of information on a daily basis for a handful of stocks.
Also, wrt, fibs, is that something we need to calculate and draw for ourselves, from market data,? or can that be included in a query.

Thanks again for your help.


Locked Re: CME CPI INDEX (CPI@)

 

This is not the place to ask this sort of question. Ask IBKR, or ask on their forum.

I'm locking this thread.

Richard King Moderator


Locked CME CPI INDEX (CPI@)

 

Hello,

Searching for derivatives based on the Consumer Pricing Index, found this name "CME CPI INDEX (CPI@)" via the IB browser search tool, but it appears that there are no contracts whatsoever linked to this index, I would like put options ideally, any ideas?

Thanks,
Jonathan


TWS error

 

I am getting the following error from TWS in the terminal window which I use to start TWS.?

JTS-CCPDispatcherS3-52: Couldn't write to log file - java.io.IOException: write beyond end of stream
Might anyone have an idea of what is causing this or what I could do to resolve it?


Re: how to set the AON (all or None) orders attribute using IBapi (by python or anything else language)

 

Dear, absolutely no problem: in coding it's normal...it was my fault.

Thanks so much for your suggest: it has been fundamental to find solution
;-)

Luigi


Re: how to set the AON (all or None) orders attribute using IBapi (by python or anything else language)

 

I believe this naming rule for object fields/properties is mostly just a C# thing, and the online documentation looks pretty C#-centric since even though it offers switch buttons for other languages they seem to do very little. So being a C# user myself, I'm sorry I misguided you somewhat.


Re: How to print / return size of position for a given contract

 

Perhaps a look to the ib-ruby-project is helpful.

Using ib-gateway,? the current positions (req_portfoliopositions)? are stored in an array. Just open the console ()

U =? G.clients.last
puts U.portfolio_values.as_table
┌──────────┬────────────────────────────────────────────┬─────┬────────┬─────────┬──────────┬────────────┬──────────┐
│????????? │??????????????????????????????????????????? │ pos │ entry? │ market? │ value??? │ unrealized │ realized │
╞══════════╪════════════════════════════════════════════╪═════╪════════╪═════════╪══════════╪════════════╪══════════╡
│ U1? │ Stock: BEPC USD NYSE?????????????????????? │? 75 │ 47.447 │?? 34.73 │? 2604.71 │??? -953.79 │????????? │
│ U1? │ Option: BOSS 20220318 put 50.0 DTB EUR???? │? -2 │? 1.539 │?? 0.638 │? -127.67 │???? 180.13 │????????? │

#then
boss = U.portfolio_values.find{|y| y.symbol =='BOSS'}
puts "Found #{boss.position.to_i} #{boss.contract.sec_type} (#{boss.contract.to_human}) in the portfolio"
--> Found -2 option (<Option: BOSS 20220318 put 50.0 DTB EUR>) in the portfolio


Re: how to set the AON (all or None) orders attribute using IBapi (by python or anything else language)

 

Dears all, I have found!
all the problems are caused by the name: it's not AllOrNone BUT allOrNone.
Unfortunately in the documentation is reported the first one.

Thanks to all.

best wishes

luigi


Re: How to print / return size of position for a given contract

 

Bryce,

you might want to check the and in particular the where the IBKR example shows exactly what you are trying to do. In fact you might want to work through the entire guide to get a better feel for the API components, objects, and the flow of information.

Judging from your question and the sample code you posted if feels like you are struggling with the asynchronous nature of the IBKR TWS API and how to structure your client application accordingly. We cannot teach you the prerequisite skills here in the TWS API group. So if you are still having significant difficulties after having worked through the API Guide, take a look at the and the related discussion group.

While ib_insync is and can be used fully asynchronously as well, Ewald de Wit has also added methods to the library that provide for an easy to use linear style of programming that many Python users are more familiar with. Related to your question, for example, ib_insync provides a positions() method that places the request with IBKR, waits for and collects all responses, and returns all open positions to you in a list for easy processing.

Hope this helped,

闯ü谤驳别苍


On Sun, Feb 13, 2022 at 09:59 PM, Bryce Turner wrote:
Just wondering if anyone has any ideas? Any help appreciated; thanks!


Re: How to print / return size of position for a given contract

 

Just wondering if anyone has any ideas? Any help appreciated; thanks!