¿ªÔÆÌåÓý

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

Re: How to Get SPX/SPXW Quote price or current price

 

Which versions of TWS API and TWS/IBGW you are using?

Reason why I ask is that the root cause for your errors are not the data requests, but by the fact that your TWS API did not negotiate a valid common server version during connection with TWS/IBGW.
  • Error "It does not support historical data backfill" is caused at a "server version" of < 16
  • Error "It does not support delta-neutral orders" is caused at a "server version" < 40

Depending on the exact TWS API and TWS/IBGW, sever versions are now in the range of 170 to 180.

You need to review your connection logic for any issues and you can check the negotiated version after connection with the serverVersion() method of the EClient object.

´³¨¹°ù²µ±ð²Ô


On Thu, Dec 21, 2023 at 09:25 AM, <arunmak654@...> wrote:

i am trying to get the current price of SPX or SPXW but i am getting error. while trying with request Historical data getting the below error

error :? "It does not support historical data backfill."

?

code snippet:

const contract = {

? symbol: 'SPX',

? secType: 'IND',

? exchange: 'CBOE',

? currency: 'USD'

};

?

ibClient.reqHistoricalData( 1, contract, '', '1 D', '1 min', 'TRADES', 1, 1, false, [] );

?

also i tried with request market data still getting error as "It does not support delta-neutral orders"

?

Thanks in advance

?

const contract = {

? symbol: 'SPX',

? secType: 'IND',

? exchange: 'CBOE',

? currency: 'USD'

};

ib.reqMktData(1, contract, '', false);

?


How to Get SPX/SPXW Quote price or current price

 

i am trying to get the current price of SPX or SPXW but i am getting error. while trying with request Historical data getting the below error

error :? "It does not support historical data backfill."

?

code snippet:

const contract = {

? symbol: 'SPX',

? secType: 'IND',

? exchange: 'CBOE',

? currency: 'USD'

};

?

ibClient.reqHistoricalData( 1, contract, '', '1 D', '1 min', 'TRADES', 1, 1, false, [] );

?

also i tried with request market data still getting error as "It does not support delta-neutral orders"

?

Thanks in advance

?

const contract = {

? symbol: 'SPX',

? secType: 'IND',

? exchange: 'CBOE',

? currency: 'USD'

};

ib.reqMktData(1, contract, '', false);

?


Re: updatePortfolioEx not returning EUR.USD position

 

Thank you Jurgen,

Yes I have the checked. NO idea what can be wrong, always worked before.


Re: updatePortfolioEx not returning EUR.USD position

 

I don't have that much hands-on experience with FOREX, but there is a TWS/IBGW configuration parameter in "Global Configuration -> API -> Settings" called "Include virtual FX positions when sending portfolio." You might have to select that option if it currently is not.

´³¨¹°ù²µ±ð²Ô


updatePortfolioEx not returning EUR.USD position

 

Hello,
?
I am using the function reqAccountUpdates.
All my postions are coming back on the updatePortfolioEx but the position on FOREX.
?
I have 30k EUR.USD on my position but that never comes back on the updatePortfolioEx, it used to work just fine.
?
Anyone know what was changed or what should I do to get that position again?
?
Thank you for any help.

?


Re: Is there a way to automate retrieving margin report?

 

I wonder if it is now possible.?


Re: Python Datetime Processing (US/Eastern)

Python1382
 

That worked for me. Thanks.


Re: Running w/ Bash Scripts, C++, & Watchdogs

 

I've been dealing with IB's API for years now, here are some takeaways when it comes to stalling:

1. Do not run your binaries from Windows Terminal, rather use plain cmd.exe. Windows Terminal for me also crashed at random times, it gets frozen. Just by using cmd.exe you're good to go. In my case, I launch my binary from PowerShell, this is what I use: `Start-Process -FilePath 'cmd.exe' -ArgumentList "/k main.exe" -WindowStyle Maximized`.
2. Make sure you use asynchronous?code. I don't know python, but in C# that is done by using async methods. Otherwise you'll lock the main thread and perhaps Windows doesn't like it long term, which relates to point #3.?
3. Make sure your code handles Object destruction. If you only get stalled after a long?time and at random times, it seems it is related to memory problems. In .NET that is related to the behaviour of the Garbage Collector. I personally never invoke it, but because I pay attention to destroy/reuse objects at running time.?

Hope it helps,
Daniel.?


On Fri, Dec 15, 2023 at 1:47?AM Mark Murphy <markm@...> wrote:

Hi Brendan,

I¡¯ve done many of the tasks that would be required to make such a monitoring system, but not roll my own.? But that gets a little off topic for the group.? You might want to consider signals instead of watching a file.? Send a user defined signal to your bash monitor.? Have the bash program trap for that custom signal.? Also have a timer like functionality to ensure you¡¯ve received the custom signal within a defined heartbeat period. If you haven¡¯t received it, then force the restart, wait for a defined warm up time, and then wait for the heartbeat again.? Of course, you¡¯d want to setup the os (linux) to ensure your monitor is always running and restart of not.

mark

On Dec 14, 2023, at 3:47 PM, Brendan Lydon <blydon12@...> wrote:

Mark,

Thank you for the swift suggestion. I thought it would be cool to write my own, which I have pretty much done already just working out the kinks, but that 'immortal python' looks cool. I also thought about using the subprocess module with python and still might as I have worked with that extensively.

Ideally, I wanted to use this as an exercise to improve my linux/bash scripting and do it all from scratch as it definitely seems doable. So, I kind of want to do it all from my .sh file and work with loops and such. Have you ever developed something similar in bash?

Thanks,
Brendan




--
Daniel


Re: Running w/ Bash Scripts, C++, & Watchdogs

 

¿ªÔÆÌåÓý

Hi Brendan,

?

Another way to do this is having some kind of RequestSystemTime api setup within your process.

And monitoring process will query it and if the process start responding with stale time then you know that you process is stuck.

?

Sometimes IB Gateway freezes for me, so I have used this method from TWS API, to find out the freeze and then restart IB Gateway.

?

I hope it helps.

?

Thanks,

??? Vinit

?

From: [email protected] <[email protected]> On Behalf Of Brendan Lydon
Sent: Friday, December 15, 2023 7:10 PM
To: [email protected]
Subject: Re: [TWS API] Running w/ Bash Scripts, C++, & Watchdogs

?

Mark,

Yes, I have been using caffeine-indicator for a while to ensure that. Thanks for your input. It is a bit off topic. I just thought maybe this would be a place where someone has built something similar. Very close to finishing this, but I like your signals suggestion instead. I think that would be much more clean. Going to look into doing that. Hopefully this is my last major hurdle before I am running continuously all day long! Probably not!

Thanks,
Brendan


Re: Running w/ Bash Scripts, C++, & Watchdogs

 

Mark,

Yes, I have been using caffeine-indicator for a while to ensure that. Thanks for your input. It is a bit off topic. I just thought maybe this would be a place where someone has built something similar. Very close to finishing this, but I like your signals suggestion instead. I think that would be much more clean. Going to look into doing that. Hopefully this is my last major hurdle before I am running continuously all day long! Probably not!

Thanks,
Brendan


Re: Running w/ Bash Scripts, C++, & Watchdogs

 

¿ªÔÆÌåÓý


Hi Brendan,

I¡¯ve done many of the tasks that would be required to make such a monitoring system, but not roll my own. ?But that gets a little off topic for the group. ?You might want to consider signals instead of watching a file. ?Send a user defined signal to your bash monitor. ?Have the bash program trap for that custom signal. ?Also have a timer like functionality to ensure you¡¯ve received the custom signal within a defined heartbeat period. If you haven¡¯t received it, then force the restart, wait for a defined warm up time, and then wait for the heartbeat again. ?Of course, you¡¯d want to setup the os (linux) to ensure your monitor is always running and restart of not.

mark

On Dec 14, 2023, at 3:47 PM, Brendan Lydon <blydon12@...> wrote:

Mark,

Thank you for the swift suggestion. I thought it would be cool to write my own, which I have pretty much done already just working out the kinks, but that 'immortal python' looks cool. I also thought about using the subprocess module with python and still might as I have worked with that extensively.

Ideally, I wanted to use this as an exercise to improve my linux/bash scripting and do it all from scratch as it definitely seems doable. So, I kind of want to do it all from my .sh file and work with loops and such. Have you ever developed something similar in bash?

Thanks,
Brendan



Re: Running w/ Bash Scripts, C++, & Watchdogs

 

Mark,

Thank you for the swift suggestion. I thought it would be cool to write my own, which I have pretty much done already just working out the kinks, but that 'immortal python' looks cool. I also thought about using the subprocess module with python and still might as I have worked with that extensively.

Ideally, I wanted to use this as an exercise to improve my linux/bash scripting and do it all from scratch as it definitely seems doable. So, I kind of want to do it all from my .sh file and work with loops and such. Have you ever developed something similar in bash?

Thanks,
Brendan


automatic adjustment of stop limit in bracket order based on fill price

 

I would like adjust the limit price (auxPrice) of a child stop limit order, with the new limit price calculated from the parent order fill price, instead of the originally submitted entry order limit price.?

My current approach is to receive callbacks from the entry order, establish the parent fill price, and re-send the stop limit order (with the same orderId) with an adjusted limit price (auxPrice) calculated from the parent fill price.??

Is this a pretty standard way of doing it, or is there a better way??

This is a bit of wishful thinking, but it would be nice?if it could be achieved in the original order submission - i.e specify an offset in the stop limit order object rather than a fixed limit price.? But I can't see anything in the documentation to indicate anything like that.


Re: Running w/ Bash Scripts, C++, & Watchdogs

 

¿ªÔÆÌåÓý


Hi Brendan,

A process monitor is what you¡¯re looking for. ?There are some that will also accept getting a heartbeat from a monitored program and if not received it will restart, etc.

I did a quick search for ¡°python process monitor¡± and came up with a stackoverflow answer:


I personally use PM2 for node.js and any other executable/shell I want to monitor (this is under linux).

mark

On Dec 14, 2023, at 2:44 PM, Brendan Lydon <blydon12@...> wrote:

Hi,

I have been running an algorithm from a main.exe in a .sh file, pre-compiled. I have python processes I do following the end of the day to get statistics and what not on my models and trades after the successful completion of my main.exe. What I have noticed is oftentimes maybe once per day at random my algorithm will stall and not continue forward in my main while loop. So, I took the liberty of adding a heartbeat to my main loop and am writing to a heartbeat.sts file in my repo every 10 seconds or so (playing with optimal time still). My bash script then sits in a loop the entire time main.exe runs and pulls the latest timestamp from the heartbeat.sts file and gets a time delta from the current time to the latest pulse from the program and will terminate the current main.exe PID and restart a new one if we have not seen a pulse in a while. This loop does this all day as long as my main.exe does not exit gracefully. If it does exit gracefully (@ 4PM EST), it breaks the loop and continues to my EOD statistics. So, my question is has anyone else built something like this "Watchdog" to deal with stalls & reduce downtime? I have made a lot of adjustments with my system logs and initializing of the project when I startup to accomodate this. Also, filling data gaps, etc to accommodate this. I don't mind writing a solution to something and not ever having it execute.

So, I guess I wanted to see if anyone had thoughts or experiences with these types of scripts, where you are constantly keeping things up and running and never being offline. Side note, with all due respect, please refrain from responses like "why is your program stalling? Are you doing sleeps? You need to rethink your design." Firstly, the answer is no to those first 2 questions, and sometimes things just stall. Its not a connection problem, its a computer science problem. Also, I am very pleased with my current and final design...

Thanks



Running w/ Bash Scripts, C++, & Watchdogs

 

Hi,

I have been running an algorithm from a main.exe in a .sh file, pre-compiled. I have python processes I do following the end of the day to get statistics and what not on my models and trades after the successful completion of my main.exe. What I have noticed is oftentimes maybe once per day at random my algorithm will stall and not continue forward in my main while loop. So, I took the liberty of adding a heartbeat to my main loop and am writing to a heartbeat.sts file in my repo every 10 seconds or so (playing with optimal time still). My bash script then sits in a loop the entire time main.exe runs and pulls the latest timestamp from the heartbeat.sts file and gets a time delta from the current time to the latest pulse from the program and will terminate the current main.exe PID and restart a new one if we have not seen a pulse in a while. This loop does this all day as long as my main.exe does not exit gracefully. If it does exit gracefully (@ 4PM EST), it breaks the loop and continues to my EOD statistics. So, my question is has anyone else built something like this "Watchdog" to deal with stalls & reduce downtime? I have made a lot of adjustments with my system logs and initializing of the project when I startup to accomodate this. Also, filling data gaps, etc to accommodate this. I don't mind writing a solution to something and not ever having it execute.

So, I guess I wanted to see if anyone had thoughts or experiences with these types of scripts, where you are constantly keeping things up and running and never being offline. Side note, with all due respect, please refrain from responses like "why is your program stalling? Are you doing sleeps? You need to rethink your design." Firstly, the answer is no to those first 2 questions, and sometimes things just stall. Its not a connection problem, its a computer science problem. Also, I am very pleased with my current and final design...

Thanks


Re: Direct orders to TGATE are routed SMART, status stay dark blue

 

Hi Michael,

thanks for your answer, althought it did not solve my problem ("rth"-attribute was already set and the order warning did not cause the problem). However, in case someone has the same problem in the future, Id like to share the solution:

In the TWS-configuration in the "presets" --> "stocks" section you find the box "Prefer SMART". TWS will SMART route all orders if Smart-routing is available, regardless of the routing selection defined for the ticker. And only if you navigate with the mouse over the small info-icon they tell you, that this also applies to orders send via the API!

I never changed this setting, so i dont know if the setting changed by itself in the last week or if the way the setting works changed. However: I checked the box and now everything works fine again.

Regards,
Daniel


Re: What is AlgoId for?

 

On Thu, Oct 19, 2023 at 04:17 PM, Richard L King wrote:

Nice one IBKR!

The strike me as pretty funny too ?


Re: Direct orders to TGATE are routed SMART, status stay dark blue

 

Hello Daniel,

I send my orders to Tradegate too. I while ago I had to check a new configuration setting in the IB gateway: "API->Precautions->Bypass Redirect Order warning for Stock API Orders". I cannot remember if it was the same issue you are describing, but it helped getting my TGATE orders working again.
Also if you are placing your orders after 5.30 p.m. you have to set the "rth"-Attribute to true. I don't know if it's the same in Excel as I use the Java API.

Hope I could help you.

Regards,
Michael


Re: new primary location of tws api documentation

 

also, though my pull requests at github were forwarded to the api team, there is a new way to report issues with the documentation:
Issues with the documentation can be reported to api@... in the future.
they seem to be pretty responsive.


Re: new primary location of tws api documentation

 

Thank you! I did not know they had moved their API documentation.