开云体育

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

Re: ib.reqTickers() conflicts with ib.reqTickByTickData()

 

These two methods are very different:
?
reqTickers(*contracts,?regulatorySnapshot=False)

Request and return a list of snapshot tickers. The list is returned when all tickers are ready.

This method is blocking.

?

reqTickByTickData(contract,?tickType,?numberOfTicks=0,?ignoreSize=False)

Subscribe to tick-by-tick data and return the Ticker that holds the ticks in ticker.tickByTicks.

?

Can you post more code snippet, and more importantly what you are trying to achieve?


Re: Unable to determine when an order is submitted

 

开云体育

Hi Elat,

<snip Moreover the status gets fired once and not for each status.

PL] Ouch, that is one reason why my code is not executing the way I expect. I’ll do some tweaking.

?

Thanks for your input.

Pranav


Re: Unable to determine when an order is submitted

 

Hi Prenav,?
?
be careful on choosing the status.. I've noticed in paper trading that stutus (PreSubmitted) could never be reached as those statuses are executed very quickly. Moreover the status gets fired once and not for each status.
?
Elat


ib.reqTickers() conflicts with ib.reqTickByTickData()

 

Hello Everyone, when building the APP (not in a notebook Jupyter), if call the ib.reqTickers() after having called ib.reqTickByTickData() it goes in overflow and crashes. But, if I call reqTickers() before reqTickByTickData works perfectly! I have tried with ib.sleep(30) but nothing. Any help? Thank you.


Re: Unable to determine when an order is submitted

 

Might work in simulation, but remember in real trade there will be delay after placing order:
?

? ? stop_loss_trade = ib.placeOrder(contract, stop_loss_order)

# BELOW might not be true always so quickly!

? ? if stop_loss_trade.isActive():

?

You should stick to event driven for robustness as you had before.


Re: Unable to determine when an order is submitted

 

开云体育

Hi biney59,

Thanks for your suggestion.

?

I got rid of the event logic and the program is working as I want it to at least in the simulator.

?

Here is a snippet of the modified code.

? ? # Create the limit order (parent order)

? ? limit_order = LimitOrder(order_type, order_quantity, limit_price, outsideRth=True, transmit=False)

? ?

? ? # Place the limit order

? ? print("Placing limit order")

? ? parent_trade = ib.placeOrder(contract, limit_order)

? ?

? ? # Create the stop loss order (child order)

? ? stop_loss_order = Order()

? ? stop_loss_order.action = stop_loss_action

? ? stop_loss_order.orderType = "STP"

? ? stop_loss_order.totalQuantity = order_quantity

? ? stop_loss_order.auxPrice = stop_loss_price

? ? stop_loss_order.parentId = parent_trade.order.orderId

? ? stop_loss_order.transmit = True

? ?

? ? # Place the stop loss order (this transmits both orders)

? ? print("Placing stop loss order")

? ? stop_loss_trade = ib.placeOrder(contract, stop_loss_order)

? ? if stop_loss_trade.isActive():

? ? ? ? ib.disconnect()

? ? ? ? print("Exiting")

? ? ? ? sys.exit(0)

? ? # Run the event loop to process order status updates

? ? ib.run()

?

?

Pranav


Re: Unable to determine when an order is submitted

 

PreSubmitted is not the status you want, as that still does not mean active. What you want is Submitted. You can look at for different possible statuses.
?
But for your case, even simpler, trade object already has method which will verify if Submitted. Use that.


Unable to determine when an order is submitted

 

Hi all,

I am unable to determine when an order is submitted. See the below code of
my on_order_status event. What am I doing wrong? The on_order_status event
does fire. I suspect I have the if condition wrong but am not certain.


# Event handler for order status updates
def on_order_status(trade):
print("order status event fired")
if trade == stop_loss_trade and trade.orderStatus.status ==
"PreSubmitted":
print("Stop loss order submitted, disconnecting.")
ib.disconnect()
sys.exit(0)

Pranav


Re: groups of events into one event

 

Thanks so much. I didn’t know about the event kit notebook…..that will be useful, or the ticker event.


Re: groups of events into one event

 

开云体育

Hi,

You can use the event that is on the ticker.

You are referring to the ib_async.IB() events, which will emit updates for any ticker that is active. But there is a ticker event too, which will only emit when that particular ticker has updates. Which is what I think you are asking for



So use the Ticker.updateEvent of the individual ticker. By the way in eventkit there si a notebook with examples on how to use events. There are plenty of examples on how aggregate and disaggregate events.

Cheers


On 17 Mar 2025, at 05:51, in_woolloomooloo via groups.io <brendan.t.sands@...> wrote:

Hi,
When using TickerUpdateEvent, or pendingTickersEvent, is there a way to collect individual stock events into a grouped event......for example if I have 10 stocks in a portfolio that is streaming ticks but i want an event to occur only over a set of say 5 of those stocks. I seem to remember seeing something from Ewald where he collected several events into 1....maybe Im not remembering correct as i cant find it now!!!
?
Asking the question an alternate way, what would be the most efficient/fastest way for say 2 sets of 5 stock portfolios to respond to events over their respective holdings, and not have to also filter through the events of the other 5 also?
?
Thanks
B.


groups of events into one event

 

Hi,
When using TickerUpdateEvent, or pendingTickersEvent, is there a way to collect individual stock events into a grouped event......for example if I have 10 stocks in a portfolio that is streaming ticks but i want an event to occur only over a set of say 5 of those stocks. I seem to remember seeing something from Ewald where he collected several events into 1....maybe Im not remembering correct as i cant find it now!!!
?
Asking the question an alternate way, what would be the most efficient/fastest way for say 2 sets of 5 stock portfolios to respond to events over their respective holdings, and not have to also filter through the events of the other 5 also?
?
Thanks
B.


Re: discrepancy with historic data

 

thanks for the responses. i realised/figured out that the open print will get the first trade after 9.30.00 which isn't necessarily the open auction.


Re: Why strike price 5635 missing from SPX option chain for 2025-03-14?

 

If it's missing in TWS, then there's no API issue (at least not on the last mile).
I doubt it wasn't available on the market, so only reasonable explanation is that the gamma was so high it hit some ceiling in TWS.
?
Out of curiosity, did you have the checkbox for local calculations selected or not? Not sure if that is the problem or not so you might want to test (including re-launching TWS after changing it).
Configuration > Volatility and Analytics > Use Local PC to calculate Bid / Ask IV
?
Please let us know here of your results.


Re: Why strike price 5635 missing from SPX option chain for 2025-03-14?

 

Sorry, I attach here the screen shot for the missing strike?

Screenshot 2025-03-15 at 11.34.28?AM.png


Why strike price 5635 missing from SPX option chain for 2025-03-14?

 

My algo tried to define options contract for strike price 5635 with expiry on 2025-04-14 (0DTE), but got error message saying "Unknown contract". I then found that this particular strike (5635) was missing from the options chain (spot was trading at around 5610 at that moment). I suppose SPX's strikes are listed every 5 points (unless the strike is very far away from spot or it is long dated like a year ahead). Is this common ? How do you guys' code cater for this missing strike ??


What does the following error message mean?

 

ib_async.wrapper: ERROR orderStatus: No order found for orderId 109 and clientId 2

This message happens right after I issue ib.connectAsync(). I am pretty sure it is printed out from ib_async. What does it mean and what do I need to do?


Re: discrepancy with historic data

 

For the opening there's an auction and the price of the auction is the opening price (code=Q); note the high volume.
In-between the first ticks and the big auction there are some odd-lot trades (code=I) that could not be matched.
?
On the other hand, ticks relate to normal trade and the first tick is different than the opening auction price.
?
There is a good explanation on CME client systems wiki if you are so technically inclined. Here's an intro video that summarizes the approach.
I assume it's similar on the exchange you mentioned.
?
Net, for you as a trader, if you want to catch the opening price, you need to use:
- MOO orders (MKT with TIF=OPG) -> you get what price you get but guaranteed
- LOO orders (LMT with TIF=OPG) -> you try to make the market and have a say in the auction; if your limit is way off the auction price, it stays as normal LMT order after the auction
- LMT orders that are enabled for outside liquid hours (LMT with TIF=GTC and Outside RTH = True)
- OVERNIGHT orders
- non-US Auctions: MOO orders (MTL with TIF=AUC)
?
NB: IB might simulate MKT orders even if they are earmarked for open (TIF=OPG).
NB2: Back testing and paper trade cannot deal with the opening auction.
?
How and where you want to include the opening price - you need to really think about it hard.
?
* Liquidity: For 1 lot, don't worry about it. If you have $10m exposure and you need to get out cause some news came out, then you wouldn't be asking here. So don't worry about it.
* Trading Strategy: If 90.21 vs 90.28 is a deal breaker for your strategy, then the strategy is wrong 100%. I said.


Re: discrepancy with historic data

 

Hey woolloomooloo,?
?
Yahoo Finance shows the opening price was $90.25. Perhaps they had the same issue as you (seeing the two numbers of 9.21 and 9.28) and just took an average of the two lol.
?
?
Pulling up BIDU's opening price data on 2/5/25, I show the following price action (note that I'm on MST so the market opens at 7:30 for me):
?
?
The above data is sorted Z-A and the bottom-most 4 rows have a code of T indicating those trades were made during non-regular trading hours.?Hovering over and clicking on the code's link takes me to this site here:
?
I imagine the the API's opening price of $90.28 is based on the 4th row (whose value is $90.28 and is the final row having a code of T) or perhaps it's the 5th row's data (whose value is $90.29^8, whatever that means).
?
A few rows further up, we find your $90.21 for the ISLAND exchange with a code of Q, which I believe is the number that you saw a month ago.?
?
All that to say, the two numbers are valid for different reasons. Hopefully that helps clear up the mystery that you were staring down. I for one hate to endure mysteries when my money is involved.?
?
?


Re: Automatic bid or ask price change until funded

 

How about the Relative/Pegged to Primary order-type? I have used them in the past and they're pretty neat. IB continually adjusts your order's limit price as the market moves. You can also set an offset to be a penny or more competitive than the market to help it fill quicker. The order type allows one to set a limit as well.?
?
You can read more about it here: https://www.interactivebrokers.com/en/trading/ordertypes.php


Re: Automatic bid or ask price change until funded

 

Well, you can make your 'emulated IB Algo' as complicated as you like. To start with a timer (like I described above) seems like the simplest and most logical choice.
To make you algo 'smarter' you can also look how the market ('last') price is moving. If the current price is moving towards your limit price, you can simply sit and wait and 'let the market come to you'. If market price is moving away from your current limit price, you have to decide how bad you want the order filled. If you want very much to have the order filled, you must 'chase the market' and move your limit price faster towards the market price ...
That's why the IB Algo has this 'aggressiveness' parameter.
You could for example create a parameter in your algo, that specifies the 'change rate' of your limit price. That would be 'how much cents per minute' you want your limit to change. A high change rate would compare with a high aggressiveness in the IB Algo ....
What I describe above is basically how I fill my orders manually. I start with a limit price that is very much in my favour (right at the bid or ask price), and start changing the limit price until filled. With a liquid security that is usually around the mid price. And with options it is usually also very close to the model price that my orders are filled.
?
?
?