Keyboard Shortcuts
Likes
- Twsapi
- Messages
Search
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:
-- +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:
|
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
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. |
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. |
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, On 19/05/2022 12:44 pm, Colin B Maharaj
via groups.io wrote:
|
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'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, 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.
|
Re: Multiple Price Conditions with "OR"
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; |
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:
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! |