¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 ¿ªÔÆÌåÓý
Date

Re: IB Routinely Misses Stops and Hidden LMTs

 

Apologies if I'm being slow, the image shows two ES brackets, both of which have triggered stops. Assuming your last column is the average fill they did get caught clearing above their trigger level - that's expected isn't it? I think your stop is a market order triggered at a certain price. If your example shows the stop not triggering, can you please clarify it for me, I'm reading it as "every stop here was triggered and cleared"
Note the difference between
order.OrderType = "STP";? // Market order placed on price trigger
and
order.OrderType = "STP LMT"; // Limit order placed on price trigger

Best wishes,


M


On Thu, 23 Jun 2022 at 19:02, Rob Tilley Jr. <fladventurerob@...> wrote:
Does this behavior occur in live trading, or just paper trading? Per IB own docs (and every other broker I've ever used) a stop-limit "is an instruction to buy or sell limit order when the stop trigger price is attained or penetrated." The thought that this wouldn't trigger and become marooned if it jumps below is confusing to me, because there shouldn't be any condition in which that would occur if I'm understanding this issue correctly?

On Thu, Jun 23, 2022, 1:57 PM jcopp <johndcopp@...> wrote:
If you're using LIMIT stops, that's how they behave. If the market suddenly leaps over or below your stop, it's marooned. Try using a TRAIL and monitor it closely.

On Thu, Jun 23, 2022 at 10:09 AM Jenzi <jzip@...> wrote:
Just from yesterday and today.



--
+44 (0) 7528 551604?
Gulfstream Software - Winner Risk Management Awards 2010
This message is subject to :


Re: IB Routinely Misses Stops and Hidden LMTs

 

Does this behavior occur in live trading, or just paper trading? Per IB own docs (and every other broker I've ever used) a stop-limit "is an instruction to buy or sell limit order when the stop trigger price is attained or penetrated." The thought that this wouldn't trigger and become marooned if it jumps below is confusing to me, because there shouldn't be any condition in which that would occur if I'm understanding this issue correctly?


On Thu, Jun 23, 2022, 1:57 PM jcopp <johndcopp@...> wrote:
If you're using LIMIT stops, that's how they behave. If the market suddenly leaps over or below your stop, it's marooned. Try using a TRAIL and monitor it closely.

On Thu, Jun 23, 2022 at 10:09 AM Jenzi <jzip@...> wrote:
Just from yesterday and today.


Re: IB Routinely Misses Stops and Hidden LMTs

 

If you're using LIMIT stops, that's how they behave. If the market suddenly leaps over or below your stop, it's marooned. Try using a TRAIL and monitor it closely.

On Thu, Jun 23, 2022 at 10:09 AM Jenzi <jzip@...> wrote:
Just from yesterday and today.


Re: IB Routinely Misses Stops and Hidden LMTs

 

Just from yesterday and today.


Re: IB Routinely Misses Stops and Hidden LMTs

 

Do you have an example? I've used IB for years and not seen the behaviour you describe ( though I've encountered plenty of other weirdnesses)

Best wishes,


M

On Wed, 22 Jun 2022, 19:09 Jenzi, <jzip@...> wrote:
Sad, but still true.
I've seen this behaviour in paper trading, where you can actually specify the trigger method in TWS settings, and during live trading, where the stop order is getting handled by the exchange.
When the market gaps over the stop trigger point, the stop order will not get executed. The stop order will just stay there for hours, while the price is well beyond.
Absolutely no way trusting this system.


Re: IB Routinely Misses Stops and Hidden LMTs

 

Sad, but still true.
I've seen this behaviour in paper trading, where you can actually specify the trigger method in TWS settings, and during live trading, where the stop order is getting handled by the exchange.
When the market gaps over the stop trigger point, the stop order will not get executed. The stop order will just stay there for hours, while the price is well beyond.
Absolutely no way trusting this system.


Re: AttributeError: 'TestApp' object has no attribute 'nextValidOrderId'

 

LOL, now its working... how?


AttributeError: 'TestApp' object has no attribute 'nextValidOrderId'

 

from ibapi.client import EClient from ibapi.wrapper import EWrapper, iswrapper from ibapi.contract import Contract from ibapi.order import Order import threading import time ... class TestApp(EWrapper, EClient): def __init__(self): EClient.__init__(self, self) @iswrapper def nextValidId(self, orderId:int): super().nextValidId(orderId) self.nextValidOrderId = orderId def nextOrderId(self): oid = self.nextValidOrderId self.nextValidOrderId += 1 return oid ... def BracketOrder(action, quantity, limitPrice, takeProfitLimitPrice, stopLossPrice): parent = Order() parent.orderId = app.nextValidOrderId parent.action = action parent.orderType = "LMT" parent.totalQuantity = quantity parent.lmtPrice = limitPrice parent.transmit = False takeProfit = Order() takeProfit.orderId = app.nextValidOrderId takeProfit.action = "SELL" takeProfit.orderType = "LMT" takeProfit.totalQuantity = quantity takeProfit.lmtPrice = takeProfitLimitPrice takeProfit.parentId = app.nextValidOrderId takeProfit.transmit = False stopLoss = Order() stopLoss.orderId = app.nextValidOrderId stopLoss.action = "SELL" stopLoss.orderType = "STP" stopLoss.auxPrice = stopLossPrice stopLoss.totalQuantity = quantity stopLoss.parentId = app.nextValidOrderId stopLoss.transmit = True bracketOrder = [parent, takeProfit, stopLoss] return bracketOrder bracket = BracketOrder("BUY", how_much, get_price, win_price, lost_price) for o in bracket: app.placeOrder(app.nextValidOrderId, stonk(whom), o) time.sleep(1) app.nextOrderId()


I got this error:
Traceback (most recent call last):
? File "C:/Users/komp/PycharmProjects/paperbuild0.1/final8.py", line 105, in <module>
? ? bracket = BracketOrder("BUY", how_much, get_price, win_price, lost_price)
? File "C:/Users/komp/PycharmProjects/paperbuild0.1/final8.py", line 77, in BracketOrder
? ? parent.orderId = app.nextValidOrderId
AttributeError: 'TestApp' object has no attribute 'nextValidOrderId'

I admit that I'm completely surprised and exhausted. This code has been working yesterday during live session, today cannot get order Id. Could anybody fix this error and explain why this method (changed a lot of times) is so erratic? Best, G.


Re: Can I combine a bracket order with a MOC (Market on close) order - Invalid OCA handling method

 

On Sun, Jun 19, 2022 at 06:35 AM, <johannes.kreckel@...> wrote:
order.Tif = 'GTC'
Take a look at my sample code in this thread -?/g/twsapi/message/49108?to see how I have modeled the FlattenOrder to do what you are doing using the GAT order type.


Moderated Re: Fundamentals Explorer

 

¿ªÔÆÌåÓý

Ok, I got it,
Once again I am using a Delphi library that can be used in C++ Builder (no python,? C#,? Java or VC++)
so it feels a little like being on a deserted island.? And I was busy in the month gone. Thanks.

On 19/05/2022 12:44 pm, Colin B Maharaj via groups.io wrote:

I am sorry, I rushed to ask a question without a bit of research.
Not a good habit.

Thanks, I'll figure it out.

On 19/05/2022 05:22 am, Richard L King wrote:

Well, just a glance at that image shows that you've got contract data, real-time market data, and fundamentals data.

?

Armed with the API documentation, why do you need to ask this question? Please make a bit of an effort to work this out for yourself, and then if you get stuck ask a more specific question.

?

?

From: [email protected] <[email protected]> On Behalf Of Colin B Maharaj
Sent: 18 May 2022 21:02
To: [email protected]
Subject: [TWS API] Fundamentals Explorer

?

Hi all,
What API should I call to recreate one like this, it's in the TWS..

Also if I have a list of symbols, how about a minimal set of info to make a table of the following say.....

symbol, current price, low price, high price, volume, 200 dma, 50 dma etc...

?


Re: Can I combine a bracket order with a MOC (Market on close) order - Invalid OCA handling method

 

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

thanks for your tips. Actually it sounds very obviously that a MOC order can not be part of OCA group if cancelling is not always possible. I wasn't aware about that.

Now I will change my code to using?ibapi.order_condition.TimeCondition.

Also I am wondering, if it it can be done simple setting order attributes as below:

order.Tif = 'GTC'   
order.ActiveStartTime =?'20220621 15:20:00'?# Defines the start time of GTC orders., Valid format: YYYYMMDD HH:MM:SS.?

I will play a little bit around and do some paper trading next Tuesday (when NYSE) is open again.
Guess this order specifications types are only doable in NYSE.


Re: RealTimeBars for SPX

 

sorry my bad. i had initially tried for SPX then later was trying to see if SPY is working . hence when i pasted the code snippet it was SPY.?
But originally my intention was to get real time bars for SPX.
The code you had posted seems to be working. thanks alot. The mistake i had done , when i was originally trying SPX was
contract.exchange("SMART")?
contract.primaryExchance("CBOE")

the above two lines seems to be the issue, in your snippet you are setting the exhange to CBOE which seems to be helping.? ?

thanks again?


Re: Multiple Price Conditions with "OR"

 

Hi,

I use Python.. Here is what I am trying to do (I removed the imports and made the code simplified here, so that we can focus on the topic, rather than the full code)

First I create "price_condition" (only 1) and in that, they dont have a "isConjunctionConnection" property (even the docs say there is, docs is v9.72 and i am using 9.81.1). I am attaching the order_condition.py file that came with 9.81.1 and from that you can see the property is not there, but its there in another class.. But I am not sure how to use it..

After that, I create an order, then I am? appending the price_condition to the order and sending it.. This works well, but I want to add another price_condition with "OR"

Let me know if its clear.

Thanks.

price_condition = PriceCondition(triggerMethod=PriceCondition.TriggerMethodEnum.Default, conId=contract_id, exch=exchange, isMore=False, price=100)

?

order = Order()

order.action = action

order.orderType = "MKT"

order.totalQuantity = quantity

?

order.conditions.append(price_condition )


Re: Multiple Price Conditions with "OR"

 
Edited

Not sure which API language you are referring to, but the isConjunctionConnection field does exist. In the Java API is is defined in the OrderCondition super class that all specialized condition classes extend.

Below a small utility function from our framework that configures an OrderCondition of any type to be connected to the next condition in the list with OR.

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

???
public static final boolean ConjunctionAnd = true;
public static final boolean ConjunctionOr = false;

// Make this order condition connect to the next condition with "or".
public static <T extends OrderCondition> T or( final T orderCondition )
{
if ( orderCondition != null ) {
orderCondition.conjunctionConnection( ConjunctionOr );
?? ?}

?? ?return orderCondition;
}


Multiple Price Conditions with "OR"

 

Hi, Been looking around, but couldn't figure it out. So I want to buy an option but only if ONE of the conditions is true (Underlying Price "OR" Time).. Meaning if either price cosses $X "OR" if time crosses a certain time.

I am able to send an order by using the default "AND".. however I want to change "AND" to "OR" and I cant figure out how to do that! I see that in the docs, they have:

?priceCondition.isConjunctionConnection = isConjunction

However when I go into the source code, I dont see "isConjunctionConnection" anymore as part of the priceCondition Class.. Its been moved to the orderCondition Class. I am using IBAPI version 9.81.1.post1. Can anyone help me please?


Re: Can I combine a bracket order with a MOC (Market on close) order - Invalid OCA handling method

 

MOC orders have many limitations and special requirements that make them incompatible with "One Cancels All" groups, Johannes. And internally, bracket orders are basically OCA groups. Take a look at "". NASDAQ MOC orders, for example, cannot be cancelled after 15:50 EST.

Are you trying to participate in the Market on Close auction (e.g. you really need the MOC order type), or are you simply trying to close the position automatically at the end of the trading session? We successfully use bracket orders with an additional third child order that closes the position a few minutes before the market closes. Basically just a MKT type order with a time condition.

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


Can I combine a bracket order with a MOC (Market on close) order - Invalid OCA handling method

 

Hi,

I am wondering if it is possible to add? MOC order to a bracket order group?

Actually currently it doesn't work for me.

Here is what I do:

- Creating the parent order

- Creating three child orders: ProftiTaker, StopLoss and MOC

ProfitTaker and StopLoss will be created correctly, but for the MOC order I get the error:
"Invalid OCA handling method"

So my assumptions is, it is not possible - or are there specific settings to take into consideration.

Thanks
Johannes


Re: RealTimeBars for SPX

 

I'm a bit confused by your question. The code snippet is for SPY stock, but the error is for SPX index. SPY trades on a bunch of exchanges, and the SMART exchange collects data for all of them. However, the SPX index is only published by CBOE, so if that is what you're looking for, try something like this:

Contract contract = new Contract();
contract.symbol("SPX");
contract.secType("IND");
contract.currency("USD");
contract.exchange("CBOE");
m_client.reqRealTimeBars(3010, contract, 5, "TRADES", false, null);


RealTimeBars for SPX

 

i am trying t o get realTimeBars for SPX. I have the below snippet of code ,?
?Contract contract = new Contract();
contract.symbol("SPY");
contract.secType("STK");
contract.currency("USD");
contract.exchange("SMART");
contract.primaryExch("ISLAND");
m_client.reqRealTimeBars(3010, contract, 5, "TRADES", false, null);

but when executed it throws the following error?
Error. Id: 3010, Code: 420, Msg: Invalid Real-time Query:No data of type DayChart is available for the exchange 'SMART' and the security type 'Index'' and '5 secs'

I am able to fetch historical quotes for SPX , also have tried realTimeBars for other stocks/symbols. Only while trying to pull spx real time bars i am hitting this issue.?

Has any one tried this before? am i missing something??



Re: Why does my IBKR (Interactive Brokers) bot sometimes not receive data?

 

Hello again,

Without seeing the code, it's pretty much useless trying to guess this one.?
To debug it, you could place printouts before the failure point/CSV insertion and see whether it has data, whether it can write anything at all to the CSV etc. I'd work backwards through the code from the point of failure towards the functions or code that precedes it. You could also try posting a simplified version of your code so we can read it and help understand what's happening. There are some skilled coders on the forum so you may be lucky.

Best wishes,


M

On Fri, 17 Jun 2022, 22:49 Bryce Turner, <bryce.turner.axiom@...> wrote:
Hey Mark and ´³¨¹°ù²µ±ð²Ô, thank you both for replying and sorry about the delay!
Part of the problem is that I don't know how to capture possible error routes, and I'd be very grateful for any suggestions. Because of my time zone, I start my bot when the market is still closed, but it starts looking for trades soon after market opens. There are no dis/reconnection attempts reported in the terminal. I believe my code gets up to the point where it just needs to receive data (it prints something like "ready to trade" as one of the last few steps). When this problem occurs, no data at all goes into the CSV for that trading session.

I haven't seen any of those error codes in the terminal. I have enabled API logging with market data, and totally forgot about it! Thanks, I'll check the log and see what I understand from it.