Keyboard Shortcuts
Likes
- Twsapi
- Messages
Search
Re: Pairs trading: Parent vs Child order placement
Thank you very much both.
With trial and error, I found that Transmit=False is of no use in this case, as I need the orders transmitted; the child order got blocked in the current format as not on the same contract. I did not manage to use?hedgeType='P', hedgeParams=f'ratio = {self.ratio}', it seems like whatever I put in hedgeParam(s?) I get an "invalid ratio" error in return. How would I place these conditional orders manually, that's an excellent question and I honestly don't know. Algos seem interesting and I would love to do some profiling with them at a later stage, but these are not available for testing on paper money as I understand, so no use at this time for me. Execution Conditions seem to offer every possible condition, except the condition of another order getting executed, or maybe I am missing something. Combo orders might be closest to what I am looking for, but I spent a few hours on it thus far without understanding the concept.. Apparently I need to define a "BAG" contract like "AAPL, AMZN", put an action "BUY"/"SELL" and a ratio on each leg, and then append both legs to a?contract.comboLegs object. What is not clear at all from? is what to do next with this contract.comboLegs object? According to??I need to define an order with the orderComboLegs properties in there, but it suggests that this order must also have an action, and orderType e.g. "LMT", a quantity and/or a limit price? what does that mean? the quantity of what? the limit price of what exactly?
Also how does the guaranteed flag work? if I need both legs or nothing, I should simply not mention it? |
Re: TWS order has reqId=0; how to cancel it from API?
¿ªÔÆÌåÓýThanks for the reply. I found the root cause of this.
I used ¡®reqAllOpenOrders¡¯ instead of ¡®reqOpenOrders¡¯ and that does not receive the ¡®orderBound¡¯ callback. The confusing thing is that it seems that only on new orders that were submitted in TWS after a last API call to ¡®reqOpenOrders¡¯ the orderId is 0 when you retrieve via ¡®reqAllOpenOrders¡¯ later. On orders that were submitted before a last call to ¡®reqOpenOrders¡¯, even when you retrieve them via ¡®reqAllOpenOrders¡¯ later, still a valid (negative) orderId is returned.? The API doc indeed only mentions the orderBound callback for ¡®reqOpenOrders¡¯ and says to use ¡®reqAllOpenOrders¡¯ to ¡®obtain those orders created via the API regardless of client application¡¯. So while it does retrieve orders from TWS also, their orderId will be zero if not bound prior. Bart On Mar 27, 2022, 1:28 PM -0700, ´³¨¹°ù²µ±ð²Ô Reinold via groups.io <TwsApiOnGroupsIo@...>, wrote:
|
Re: Pairs trading: Parent vs Child order placement
A few quick thoughts, John:
|
Re: Pairs trading: Parent vs Child order placement
Actually regarding the missing parent order, I believe I need to add transmit =False on the child order too,
unlike the example given in? It then appears to work, at least it populated the orders correctly as conditionals in TWS, but then it give me the button "Transmit" and it seems like the orders are just parked there waiting for me to manually click "Transmit" ? |
Pairs trading: Parent vs Child order placement
Hello Group,
Currently implementing mean reverting pairs trading (e.g. long SLV, short SSLN), would like to have the second leg order conditional on the execution of the first leg order. Tried an approach similar to the??hedging one (with hedgeType='P'), but I get the below "missing parent order" error despite giving it a few seconds between the two.
Then I tried to attach the order?? , which is essentially a regular order with the parentId specified, but then it gives me the absurd:
then once that one is completed, trigger another one which deals with the hedging leg asap, on another contract/instrument. Should I track the order execution via?execDetails? or is there a simpler way to attach them that works? Thanks, Jonathan |
Re: Install TWS or IB gateway on Ubuntu and ARM64 bit processor
I last tried to do this a year ago on a Raspberry Pi 4B (4GB) running Ubuntu 21.04 64 bit. Andy |
TWS API GUI
Hello All, I have a C# application working for years. I am considering using the GUI features to see if I can plot / create my own charts. Is that possible? Does anyone have experience doing / attempting this? I am considering using 1-2 symbols to create custom charts using?tick data. Cheers, TraderAPI |
Re: TWS order has reqId=0; how to cancel it from API?
What does it mean when you say "I can see this order in the API"? The section of the API reference describes the various options you have When client 0 calls or? ? callbacks will provide mappings of permIds to orderIds client 0 can use to manipulate orders that were placed by other clients or manually in TWS. You can configure TWS such that negative orderIds are used to better separate these orders them from orders your API client places. For this to work, orders must be "open" from the TWS point of view. I am not sure whether simulated orders with status "pre-submitted" are considered "open" for the purpose of order binding, but you should be able to quickly try and and see whether you get an ?callback. ´³¨¹°ù²µ±ð²Ô |
TWS order has reqId=0; how to cancel it from API?
I have a manual order placed in TWS.
I can see this order in the API (my API client is set to clientID=0). It shows as: order=Order(permId=390120308, action='BUY', totalQuantity=10.0, orderType='STP LMT', lmtPrice=25.0, auxPrice=24.5, tif='GTC', ocaType=3, displaySize=2147483647, rule80A='0', trailStopPrice=24.5, openClose='', volatilityType=0, deltaNeutralOrderType='None', deltaNeutralOpenClose='?', referencePriceType=0, account='XXXX', clearingIntent='IB', adjustedOrderType='None', cashQty=0.0, dontUseAutoPriceForHedge=True) Now I want to cancel this order from the API. When I pass this order to cancelOrder(order), the following error shows: Error 10147, reqId 0: OrderId 0 that needs to be cancelled is not found. Indeed, while there is a permId, order.clientId and order.reqId are 0. How can I cancel this order? Note: this order has status pre-submitted on TWS because it is a stop limit order for a CBOE combo order position, and thus it is held by IB until the stop triggers as stop limit is not natively supported by CBOE. |
Re: Install TWS or IB gateway on Ubuntu and ARM64 bit processor
Hello
Have you found a way to make it work? I tried different distros and always got to the same point of being unable to install IB Gateway. I installed IB Gateway in a Debian VM and copied the resulting folder but it didn't work either, not even installing Oracle's JDK1.8.0_321. |
Locked
Re: Paid engagement for python script
Please folks if you want to follow up on this request, reply directly to the poster. I'm locking this topic now. Richard King Moderator |
Locked
Re: Paid engagement for python script
¿ªÔÆÌåÓýHey Matt- I¡¯m interested in this project as well. ?I¡¯m currently managing a multi strategy long/short portfolio via IBApi overseeing 7 figures in assets, much of it being outside funds. ?Let me know if you need other qualifications or if you¡¯d like a price estimate. Thanks, Mike On Mar 26, 2022, at 3:29 PM, mfleharty@... wrote:
|
Locked
Re: Paid engagement for python script
¿ªÔÆÌåÓýYou may want to check first if IB lets you submit orders that are so far away from market price. I believe they have a limit on accepting limit orders that are too far away from current bid/ask depending on the instrument type and exchange.?
If your trigger is to be based on the underlying reaching a certain price, you could handle it via a conditional order in the script so then you don¡¯t need an external flag. rgds, Bart On Mar 26, 2022, 12:43 PM -0700, RobDawg35 via groups.io <rob.sandberg26@...>, wrote:
On Sat, Mar 26, 2022 at 3:29 PM <mfleharty@...> wrote:
|
Locked
Re: Paid engagement for python script
I can do this? Let me know, Rob? On Sat, Mar 26, 2022 at 3:29 PM <mfleharty@...> wrote:
|
Locked
Paid engagement for python script
Hi,?
I'm writing to see if anyone is interested in 1) a paid engagement to develop a python script, functionality described below; and 2) spending the time to help me understand the logic behind the python script execution.? ??
?
Desired functionality:? When a new order is placed, that order will be either extremely above or below the current bid/ask spread, and the order is being used simply as a flag.??
For example, a limit buy order for 1 share of MSFT at $100 is submitted.? At that point, I'd like the python script to:?
1) detect that the order has been submitted;
2) cancel the order;
3) submit an option call order for symbol MSFT at a strike price that is just OTM, at the soonest expiration date.? ?
4) Exit strategy: detect when an order on the opposite side has been submitted (for example, sell 1 share of MSFT at $500)
4a) delete the sell order
4b) if the call order has been filled, exit the option position
?
The opposite of the above scenario needs to work as well, with a sell order and puts.?
?
Additionally, I'd ask the programmer to allot 4hrs to explain the execution of the code and allow for questions in order for me to understand the script, so that I can maintain/modify going forward.? I do have programming experience, but it is in classic ASP.? ??
?
Sample script execution (assume current price of MSFT stock is $300, and assume current date is 3/28/2022):
1) outside of the python script, a limit buy order is submitted for 1 share of MSFT at $100/share
2) the python script deletes this order
3) python script submits an order for 1 MSFT Call option at the Ask, with a strike price of $302.5, expiring on 4/1/2022
4) outside of the python script, a limit sell order is submitted for 1 share of MSFT at $500/share
5) the python script deletes this order
6) python script exits or cancels the existing/open call position at the Bid price
7) python script submits an order for 1 MSFT option Put at the Bid, with a strike price of $297.5 expiring on 4/1/2022
8) At 3:55 PM EST, the python script closes all positions.??
?
Notes:??
1)??Soonest expiration date must account for weeklies, for example M/W/F in the case of SPY.?
2)? Stock symbol must be variable.??
3)? I believe Symbol + Order Type (buy/sell) can be used as a flag.? The order price will not be static, therefore I don't think it can be used as part of the flag.??
?
Please email?mfleharty@...?if interested.? Thanks in advance.
Matt |