Keyboard Shortcuts
Likes
- Twsapi
- Messages
Search
Re: Persistent reqId or orderID
If nobody gives you exact answer, my suggestion is to learn and try. The API is pretty powerful. The price you pay is that you should do your own gradual experiments. ? Suggestion for learning it: #1 Become familiar with OrderID
In C++? exemple: m_pClient->placeOrder(m_orderId++, ContractSamples::USStock(), OrderSamples::LimitOrder("SELL", stringToDecimal("1"), 50)); I read IB intent for training , using the ¡°++¡± in m_orderId++ as a way to say ¡°be sure to never reuse same ID for next order, so here we force a new one, that can be as simple as +1 of previous¡± ? also C++: m_pClient->cancelOrder(m_orderId-1, ""); Same thing with ¡°-1¡± to be understood as meaning: ?¡°here we cancel last order, could be any other, but please be sure to use a freshly brewed orderId for next ±è±ô²¹³¦±ð°¿°ù»å±ð°ù(¡).¡± Java: IB exemple use a ¡°cancelID¡± which I don¡¯t know about but seems to me more an implementation method, I don't see what else it could be aside of the Orderid you use for the ±è±ô²¹³¦±ð°¿°ù»å±ð°ù(¡). ? #2 Become familiar with the Order object #3 Read again David Walker answer. Cheers ? |
||||||||
Re: Persistent reqId or orderID
You probably might want to reread at least the section of the and make sure you understand the following concepts:
toggle quoted message
Show quoted text
Clients can request the ability to control existing or future open orders that were placed by the same clientId, all other clientIds, or even via the TWS GIU. This is done by "binding" those orders (that you you currently see with an orderId of 0) to an orderId the client can use. We find it most convenient to enable the "Use negative numbers ..." option since that nicely separates ids for orders placed by the client from "bind" orders that the client did not create but may wish to control. Order binding works even after TWS or your client restarts. You will receive openOrder callbacks with (negative) orderIds other than 0 after your client makes one or more of the open orders requests mentioned above. ´³¨¹°ù²µ±ð²Ô On Mon, Dec 26, 2022 at 03:27 AM, Sam Mills wrote:
|
||||||||
Re: Persistent reqId or orderID
Where I am now confused is how to modify an existing order using permID and not orderID. I have been modifying orders within a running instance of TWS using an Order() object, eg to change a stoploss:
Where does permID get put in here? And once TWS is closed, all of this information becomes redundant (eg- "parentId" because this is the stop loss in an OCA Buy order) - so how do I modify an order now? (I use python). Thanks. |
||||||||
Re: Persistent reqId or orderID
You are correct that there are a few responses that return no reqId and I agree with your assessment that those really don't need to be called several times in parallel. But the corresponding requests do not require reqId either. Here the request call signatures for the response example you gave:
´³¨¹°ù²µ±ð²Ô On Sun, Dec 25, 2022 at 06:39 PM, <hymagik@...> wrote:
|
||||||||
Re: Persistent reqId or orderID
Yes very useful indeed |
||||||||
'Click here to subscribe to API-specific market data packages'
Good evening all (and Happy holidays!)
I recently upgraded to IB Gateway 10.19 there's a message that says 'Click here to subscribe to API-specific market data packages', however when I click on it I'm met with an error 404 in my browser! Does anyone know what this link refers to? I couldn't find anything when I verbatim googled the message. Thanks! |
||||||||
Re: Persistent reqId or orderID
A reqId and an orderId are two quite different beasts and behave differently.
toggle quoted message
Show quoted text
reqIds are sent once to the API, and only ever once. They are used for 'requests' for data rather than for orders - i.e. to request Historical Data, or scanner data, or stream data etc. All data that is returned from each request will be stamped (in the eWrapper callback) with the reqId that you sent, so that you can match it up with your original request. You can't 'manage' a request by using the same reqId in a new command - you can only send a new request with a new reqId. reqIds do not persist between sessions. An orderId on the other hand is used to uniquely identify an order (only). It is a parameter in the placeOrder(orderId, contract, order) function, as well as of the order object. The API will return the status of the placed order via the openOrder and orderStatus callbacks, and uniquely identify these callbacks using the orderId you submitted. However (this is important to note), these callbacks only occur while the order is still active (i.e. prior to completion/cancel). You can modify an open order by sending a placeOrder with the same orderId and a modified order object (i.e. modified to whatever you want to update the order to) - this of course will return an error if you try to modify an order that has already been completed/cancelled. Once an order is completed, the user-supplied orderId disappears from the TWS API world - e.g. the completedOrder callback does not identify the order using the orderId - and you must use either the permId or the orderRef parameters of the returned order object to uniquely identify the completedOrder callbacks. The orderRef parameter you can set yourself when you first submit the order, but you will need to make sure it's unique; the permId is assigned by TWS after you place an order and can be obtained from an openOrder or orderStatus callback. OrderIds typically do not persist between sessions unless the order is sitting there unfilled (??and maybe not even then) - in any case, you should work with the permId parameter (or, if you wish, the orderRef parameter) instead. Hope that helps. Dave -----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Sam Mills Sent: Wednesday, 21 December 2022 7:31 PM To: [email protected] Subject: [TWS API] Persistent reqId or orderID Hi, is there a way to manage trades placed when TWS is closed and then reopened? I have been using reqId's to create OCA orders and then manage them whilst TWS is open. But when I close TWS and reopen TWS several days later, using the same reqId doesnt seem to work. Is there a persistent reqId that persists in between sessions? Thank you |
||||||||
Re: API error - Your API version does not support fractional size rules (during forex price extraction)
Hi Tom, Thanks for that reply...? I am making an assumption from your reply that this is the first of a list of changes that is likely to affect other currencies as well...? ?would that be correct?....? ? regards Ed On Thu, Dec 22, 2022 at 5:01 PM twoprint via <twoprint=[email protected]> wrote: Hi, |
||||||||
Re: going to have to reconsider my approach to calling reqMktData for multiple symbols how does the forum handle it please?
On Thu, Dec 22, 2022 at 07:52 PM, dent wrote:
Lol, you're so lazy apparently that it's not enough someone tell you so... but you actually need to have each and every detail of just how lazy you're being spelt out. Glad you got the answer you were looking for :-) Happy holidays. |
||||||||
Re: going to have to reconsider my approach to calling reqMktData for multiple symbols how does the forum handle it please?
¿ªÔÆÌåÓýOUTSTANDING thank you so much ´³¨¹°ù²µ±ð²Ô. The error callbacks you have encountered over time is something
that will save me a lot of time.? The data started flowing again
this morning of it's own volition BUT it DID motivate me
to go back and harden my approach. Before I was just HOPING that
all would go well :-) sheer laziness on my part. One of the
excellent things about julia is the modularity that is built into
it. I have NO excuses. Thank you for the guidance as to contract object construction, I
like that approach and will adopt it. I completely forgot that IB
returns so much in that exchange, VERY useful in the times ahead
in 2023. I get auto updates on the TWS api because I use a laptop with TWS
desktop running. I do this to keep an eye on the markets and make
sure I track the DATA flow. I also have a raspberry pi tracking
the isp just in case of problems.? This takes care of the packing
issues as I am on 10.20. I've had my own version of a data monitor running using arrays
which populate dataframes. 2023 will allow me to create a realtime
Pluto notebook which gives me control over the data representation
using tufte concepts. This whole issue was caused by my laziness and sheer luck. I've already got logging working ( took 10 minutes) and your error list has stimulated me to create an error handling function so I can standardize all levels of problem. Thanks again for 2022 and you have done an EXCELLENT job on the
forum. Happy holidays to you and all your clan. dent
On 12/22/22 12:31, ´³¨¹°ù²µ±ð²Ô Reinold via
groups.io wrote:
|
||||||||
Re: going to have to reconsider my approach to calling reqMktData for multiple symbols how does the forum handle it please?
The approach you describe sounds reasonable and seems to have worked for you for a while. But there are a few details that come to mind that make the process more robust and tolerant of changes by IBKR. Not sure whether any of these fix your problem, but I am sure they will prevent issues in the future. We have a data monitor that subscribes to all available reqMktData ticks for about 80 instruments plus 15 TickByTick streams (TickByTickLast, TickByTickBidAsk, and TickByTickMid each for five instruments) plus three Level II market book streams and is rock stable. During startup, we use to retrieve a contract object for each instrument instead of making our own contract objects. This way you get the most up-to-date instrument details and a contract object that has all fields initialized. You also get the trading hours for the next few days including short-notice changes caused by holidays or issues at the exchange. And any contract related errors (such as de-listed instruments, exchange changes, expired futures contracts, ...) are flagged well before you subscribe to market data. The loop that runs the reqMktData subscription calls needs to make sure that it does not cause API pacing violations (more than 50 requests per second). Pacing violations will cause disconnects by TWS/IBGW. For TWS/IBGW versions before V10 you have two options:
TWS/IBGW V10 have "+PACEAPI" enabled by default so this is less of an issue, but make sure the API global configuration "Reject messages above maximum allowed message rate" in TWS/IBGW is not selected. And finally, make sure you catch all error callbacks and, at a minimum, log them to aid in troubleshooting. Errors our monitor has encountered while subscribing to the various market data streams include:
There is a lot that can change without notice or go wrong. Hope this helps, ´³¨¹°ù²µ±ð²Ô |
||||||||
Re: going to have to reconsider my approach to calling reqMktData for multiple symbols how does the forum handle it please?
On Thu, Dec 22, 2022 at 03:23 PM, dent wrote:
Either am I, guess that was my point. I would post my C++ solution which works very well for my purposes but that would be inappropriate. Not to mention, at the very core, it's basically just like the example provided by the SDK. c'est la vie |
||||||||
Re: API error - Your API version does not support fractional size rules (during forex price extraction)
Hi,
IB support mentioned they changed the variable type of AUD.USD to decimal. This is the first of a long list of changes among currency pairs. This change is permanent, so I would not expect any improvement with latest / newest versions. My opinion is to try to use older versions. -- TomP |
||||||||
Older tws version availability
Hi,
I have met some troubles with the latest change in AUD.USD spot on IB. I would need to retrieve an older version of TWS to make it compatible with my third party api version. Would anyone know if some MacOS installers are available somewhere (since IB only provides current versions : stable / latest) ? Many thanks? -- TomP |
||||||||
Re: going to have to reconsider my approach to calling reqMktData for multiple symbols how does the forum handle it please?
¿ªÔÆÌåÓýI'm not expecting anything as I can't see any other way to handle it. It's just a basic awaitio loop with tagging. Been around since the late 80's nothing particularly innovative about it. I'm just making sure I didn't miss anything. From the python perspective Ewald did an AMAZING job with insync right from day one by handling the asynchio aspect for us. Good man as is Richard King and Jurgen. Happy xmas to all
On 12/22/22 09:00, buddy wrote:
|