Keyboard Shortcuts
Likes
- Twsapi
- Messages
Search
Re: Could this happen: stp and trail in oca group both getting triggered?
I think it is not guaranteed even with the block option of the ocatype flag. It can execute two orders of the OCA at the exact same time. Check? ? "Please note that because the OCA procedure is an automated process, there is no guarantee that requested cancellations and modifications will reach the specific exchange before an order has been executed." El lun, 21 ago 2023 a las 18:11, ´³¨¹°ù²µ±ð²Ô Reinold via (<TwsApiOnGroupsIo=[email protected]>) escribi¨®: We just had a different post where OCA overfill protection was discussed, Raoul. When you create the OCA group, do you set the attribute for each order or do you let IBKR use a default? |
Re: Could this happen: stp and trail in oca group both getting triggered?
We just had a different post where OCA overfill protection was discussed, Raoul. When you create the OCA group, do you set the attribute for each order or do you let IBKR use a default?
toggle quoted message
Show quoted text
Chances are, that your OCA was of type 3 (see table at the bottom of the chapter) which does not protect against overfill. So you might need to set ocaType 1 or type 2 for your orders explicitly. ´³¨¹°ù²µ±ð²Ô On Mon, Aug 21, 2023 at 10:51 AM, Raoul Suurmeijer wrote:
|
Could this happen: stp and trail in oca group both getting triggered?
Hello all, Just minutes ago, something strange happened in my algo trading. My algo always submits orders as an oca order. Parent being a limit order, connected are 3 child orders: stp, trail and mkt with time control. The trail is set much wider than the stp but I want to limit the max loss with the fixed stp. In the call back after placing the MNQ order, size 1, I can clearly see all the order id's being used, all child orders in the same oca group. Everything perfect as expected and I am positioned +1 MNQ. The positions goes green, and the trail is going along. At some point the stp and trail are at the same level. Then price drops and hits that level. You would expect that either of the two (stp or trail) to get executed and not the others. But afterwards I am left with -1 MNQ position. In the logging I see callbacks for executed orders for both the stp and trail causing a double closing sell. Again, all the order id's match with the initial orders as part of the same parent. Is this behavior to be expected when using both a stp and trail in the same oca group and are at the same price level? If so, my algo should probably change stp level as soon as trail gets to the same level. Or remove it from the oca group (if that's possible). Thanks in advance for sharing your insights and own experience, greetings, Raoul |
Re: Can I place orders asyncronously like this without causing issues with the twsapi?
I am not familiar enough with Python but a couple of things maybe be generic |
Can I place orders asyncronously like this without causing issues with the twsapi?
I want to check if this is possible. I am using the following code which queries a price using certain conditions from an api, the prices are returned to me asynchronously. I want to place the order as soon as the query has been returned from the api. I put the app.placeorder into the async loop as shown below.
I am worried that I will place to orders at the exact same time and the order id's will get messed up. Is there a way around this or does twsapi automatically mitigate this? |
(Paid) Need a bot written in c# (with code) to place option trades based on criteria
I would like to have a bot that can place complex option strategies along with profit taker and stop loss orders. I would want to have it place?trades based on specific times, volatility, margin and maybe technicals. If a fully developed solution is not available, I am fine if the application is able to get account particulars, place trades and provides extensibility to build strategies on my own.? You can reach out to me at lvsniper@... Thanks |
Re: C++ TWS API w/ Cmake
I would like to use pytorch because I trained my models in python using pytorch, and are all serialized to .pt files. Just would be easiest if I could get pytorch working in C++ so I can load the the .pt files using their load functionality rather than using ONNX or something. And yes, I like the extra ability to configure everything. I really have next to no experience using Cmake for reference.?
|
Re: C++ TWS API w/ Cmake
Yes. You're very welcome. Just bear in mind that the process will be a little different for you since you're on Windows. For example, in order for me to get my stack ready I only needed to download the TWS API and the rest was set up using I also don't know if WIndows supports genuine symbolic links so you may have to copy more stuff around than otherwise necessary. In addition, you'll need to fiddle w/ the target_link_libraries for your specific needs. The bullet-points I mentioned should be most, if not everything, you need to "wrap your mind around" though. -Good luck |
Re: Is it possible to place order at 15:59 or 16:00 and get a fill?
Juergen, your concern is certainly valid, I just meant to show how some limitations can be worked around. Admittedly, while LOC/MOC orders have their strong advantages and constitute perhaps some 30-40% of my own volumes, and about twice that amount of my orders use oca groups and/or bracket/pair-trading modes allowing to almost completely avoid real-time trading, when recommending them I kind of tend to overlook the fact that my process involves routinely pre-programming orders to avoid overfills with tightly timed cancellations and activations. In the end of the day (pun not pre-programmed), the choice of placing orders into the auctions or simulating them with timed activations during regular trading is a problem of concrete implementation's design, and both approaches have their merits, some of which go beyond mere technical discussion.
-- Best, DS |
Re: WAP value provided by 'realtimeBar' vs. that shown in the TWS quote panel
Thanks Gordon for your detailed response.. I went off to test a few more things. Thought I post it here as it might be useful for others:
1) Getting VWAP from subscription of "reqRealTimeBars" (updates every 5 secs) depends on when you subscribe. Not sure how exactly it's calculated but the first VWAP value is always the closing price of the first 5 sec bar after the subscription was made and ofcourse the subsequent vwap calcs are made of the first value, i.e. this value can be very different than what you see on TWS charts. 2) The VWAP value on TWS chart remains consistent regardless of the candle size you choose (1 minute, 5min, 15min, hourly, daily) 3) VWAP value coming from the subscription of "reqHistoricalData" with "KeepUpToDate=true" is closer to the what's shown in TWS charts. 4) As you mentioned, volume and HLC price between different vendors maybe slightly different, but with TWS API all data comes from TWS, that's why the fixed difference between VWAP values of TWS and it's API?(when using "reqHistoricalData" with "KeepUpToDate=true"), even of a few cents, does not make sense to me. I imagine IB software engg. may have an answer to this but I will leave it be. For now, since I have been using the 5 sec bars and wanting to avoid any new tick based subscriptions, I calculate vwap locally. As you pointed out, because of the aggregated data provided, the calc is not precise but serves my purpose. |
Re: C++ TWS API w/ Cmake
BTW, besides the symbolic links, here are the changes I needed to make to their CMakeLists.txt:
Hope this helps a little. |
Re: C++ TWS API w/ Cmake
On Fri, Aug 18, 2023 at 02:57 PM, blydon12@... wrote:
I think you're probably making a mountain out of a molehill. As Gordon suggests CMake offers a ton of options and LibTorch needs that power since it can be configured to use disparate and exotic hardware. Otherwise you're better off (IMHO) just using Python and opencv + scikit or something. But, if you decided to stick with LibTorch there must be a reason. And that reason, presumably, is you want the extra ability to configure everything. It shouldn't be that hard to merge your stuff in though. Especially if you're willing to take some [temporary?] shortcuts. Gordon's suggestion to experiment on a small project is definitely spot on. I don't actually see why you can't experiment with your own TWS application though... just use the minimal CMakeLists.txt provided by LibTorch and leverage the following:
Then do your regular: I had the TWS sample going in short order and so I'm sure you'll be up and running in no time flat. |
Re: Is it possible to place order at 15:59 or 16:00 and get a fill?
There are three ocaType options and only one of them allows MOC/MOO orders in the group. So I guess my concern is 67% valid :-) We don't use OCA groups a lot but when we do, (more) guaranteed overfill protection is key so that we tend to use type 1 ("with block"). As you said, the two "with block" types reject MOC/MOO orders in the group but I guess the overfill risk for type 3 OCAs can be mitigated if triggers for the orders in the OCA are "far enough" apart. In other words, even in crazy market situation no two orders in the group would be eligible at the same time. ´³¨¹°ù²µ±ð²Ô On Thu, Aug 17, 2023 at 08:16 AM, ds-avatar wrote:
|
Re: Gateway loses historical market data every day
You might want to check this post and the topic for more information about the various market data connection messages. I don't want to repeat that post but here some thoughts:
toggle quoted message
Show quoted text
´³¨¹°ù²µ±ð²Ô ?
On Fri, Aug 18, 2023 at 02:26 AM, Matthias Kurz wrote:
Ok, thanks. Today I observed that it behaves like described. But yesterday it did not reactivate. The yesterdays client log contains this two times: |
Re: C++ TWS API w/ Cmake
Yes Out of scope of this forum |
Re: C++ TWS API w/ Cmake
Ya I don't want to use Cmake if I don't have to. Especially, since I already have a fairly large project I built without it, which correctly implements the TWS C++ API. So, my problem is probably more suited towards a PyTorch forum to see how to link without Cmake.
Thanks anyways, Brendan |
Re: C++ TWS API w/ Cmake
About Cmake: unfortunately allows to specify tons of option at generation time.
You should look at linker error message and guess what could make Cmake happy. Cmake is only a "makefile" generator (or Solution generator) , in VS it make it compatible with nmake (MS implementation of make) Once done your are free to modify the makefile (or the project file) but be careful that all your modification will be overwritten the next time Cmake run (which can be automatic as part of consistency check done during make 'thanks' to Cmake invocation during make) Be carefull also about any Release version opf lib supplied by thrid party and invocation of nmake in Debug mode Look to me you need first to master Cmake.? Take a small project like a ziplib to experiment it. Sorry to not be more helpful, wasn't a specific issue I ran trough |
Re: Gateway loses historical market data every day
I can only speculate. ? |
Re: C++ TWS API w/ Cmake
I've tried that section briefly to no avail, perhaps I will have to try again. I could try just mirroring the template project that link populates and copy the includes and linkers to my current TWS Project. It's really a linking issue I am having with PyTorch. Knowing exactly which libraries to build, etc. If I knew that, which, to my knowledge, they do not seem to outline explicitly, I believe I could figure out how to get the build into my project. Building a whole new project for the TWS C++ API in Cmake seems like overkill. It may be necessary though because PyTorch has detailed information on building this way, and they plan to only support this going forward.
|