Keyboard Shortcuts
Likes
- Twsapi
- Messages
Search
No realized profit and loss for Forex ?
Hi,
if i execute m_pClient->reqPnLSingle(...) for the forex pairs i get 0.0 as pnl even if there were trades executed with a result different from 0. Why is that ? does this have something to do with virtual FX positions ? If i do exact the same for a stock i can get the correct pnl. |
Re: Level2 data falls behind actual market
Yes |
Re: Order entry time via the API?
I don't know how. Generally manual and automated are not very easy to run simultaneously. Trend is to add Manual capabilities UI directly on your automate so that your automate DB can store info |
Re: Order entry time via the API?
Thanks for the reply.
My application is listening for the openOrder callback, but I was expecting to see an order creation/submit time field on the order itself. For example, my application may not be running when an order is submitted manually via TWS, it is then not possible to find out via the API later what time it was submitted. |
Re: Pairs trading: Parent vs Child order placement
That is how are supposed to work. All orders in the bracket match the parent order quantity as the as long as the parent order exists. IBKR says:
toggle quoted message
Show quoted text
When you place the bracket order, IBKR adjusts quantities for all attached child orders to match the parent order (desired) quantity. Once the parent order starts filling, IBKR automatically adjusts quantities for all child orders to match the actual filled quantity of the parent until the parent order is considered filled (partially or completely) and becomes inactive. I say "all child orders" since you are not limited just to a profit taker and stop loss order and you can attach additional child orders to the parent in the bracket. One that comes to mind is a "close position at the end of the session" order that sells the position at some point should neither profit nor loss orders have not triggered yet. ´³¨¹°ù²µ±ð²ÔOn Mon, Aug 14, 2023 at 07:05 AM, HenryE wrote:
|
Re: Pairs trading: Parent vs Child order placement
Thanks for the explanation of the different order types and the example. Building on your example, I've tried to construct a similar tree of orders by linking parent and child limit orders for the same contract using the parentId attribute:
Here's a visual representation of the order tree I aimed for: sell 100 @ $20 ? |___ sell 125 @ $25 ? ? |___ buy 75 @ $15? However, I've encountered an issue. Even though the orders are submitted to TWS and appear as described in the tree, once they are eventually "transmitted" in the UI, all child order quantities get changed to 100 units (the same value as the parent). Is there a specific setting or option within the TWS or IBKR API that might be causing this change in order quantities? I'm trying to ensure that the child order quantities remain as defined.
Semi-unrelated but it seems like another possible limitation in the TWS API is that you can only attach one hedge order per parent order. At least this appears to be the case via the UI, still need to write a proper code based test case for this. |
Re: Level2 data falls behind actual market
On Sat, Aug 12, 2023 at 02:01 PM, ebtrader wrote:
Not THIS Buddy! Please, I'm begging you, at least try dumping the data to a file first and watching it with . If you don't have tail, find it... in the WSL or install cygwin. The test should be easy as pie, don't overthink it, just comment/ifdef out the SQL insert and replace it with a file append. Unless your computer has floppies with a 10Mbit network (i.e. ancient) everything should keep up. Then tune the db as previously suggested. You haven't mentioned any kind of real-time computation happening on the CPU or GPU so the process is basically all network and disk I/O bound. If you need to upgrade anything it will be the network and/or disk first, and only then the [CG]PU; assuming you want to keep the data. Be reasonable! With interest rates this high who can afford unnecessary capex? |
Re: Level2 data falls behind actual market
My buddy ran it with a laptop that has an Nvidia 2 series GeForce and it worked fine without falling behind.? I will upgrade my machine and then it should work. On Thu, Aug 10, 2023 at 4:56 PM ebtrader via <jsiddique=[email protected]> wrote:
|
Re: Having trouble submitting ZT (2 yr treas) futures orders thru API.
On Fri, Aug 11, 2023 at 06:33 PM, Lou Dudka wrote:
Sweet. On Fri, Aug 11, 2023 at 06:33 PM, Lou Dudka wrote:
You'll have to let me know the secret. Although, I admit it will probably never sink in for me :-) |
Re: Having trouble submitting ZT (2 yr treas) futures orders thru API.
Hi buddy,
Thanks for the TWSAPI e-mail, I appreciate your concern and interest.? Didn't want to send a private reply to you and get your company upset at you.? Kudos to your new avatar. Yeah, the 10.19 TWS went slick as snot, probably the easiest upgrade I ever did! The ZT trades went thru just fine in the new API.? The problem is upgrading my XLS's. I'm so backleveled with my current API it'd take a ton of work to get my xls/App up to date.? I've touched just about every VBA module the IB supplied in the sample API.? I'm far more interested in trading than writing code ...? I use a separate XLS for each instrument (yeah, I know, I can already hear the naysayers ...) - one of the main reasons being it serves as a database and I have an absolutely phenomenal history of each to run "what-ifs" against.? I'm a retired Head Data Base Admin from a major international car company, so yes, I do understand databases.? Sometimes simpler is better ...? Everything is self-contained and runs like the wind.? I've learned to live with the vagaries of XLS (as Richard has rightfully pointed out on numerous occasions) and it works just fine for me. I have a work-around for the ZT trades (90% of which DO go thru) so I'm OK. Thanks, as always, Lou Dudka |
Re: Is it possible to place order at 15:59 or 16:00 and get a fill?
If you need to exit at end of day with the highest execution chance and arguably the most liquid price, the best order type to use is MOC (Marketable On Close). These orders pile into the closing auction event that usually gets 5-15% of liquidity for the entire day, i.e. about an hour worth of regular trading packed into a single event.?Additionally MOC orders remove the hassle of tracking the exact time of market close which can be different on certain dates. This will save you a lot of efforts and troubles, which will very likely hit you if you are contemplating placing marketable orders into after-hours trading where poor liquidity can be destructive to any reasonably good trading strategy. Placing regular-hours orders a few minutes or seconds before market close is generally much safer but offers little to no benefits compared to a MOC order. But this all is rather an aspect of strategy than technology, so it's not directly relevant in this discussion group. For a MOC order, use OrderType = "MOC" and Tif = "DAY".
-- Best, DS |
Order entry time via the API?
Just started working on an application using the API. My app is listening on the callbacks for reqCompletedOrders and?reqAllOpenOrders
I can see order/contract/status details but I can't find a field for order entry/creation time. I have checked the documentation and can't see it. Does anybody know how to retrieve this? Andy |
Re: Error when requesting 20 years of price data for specific ticker [CHTR]
If I rephrase your concern I understand it as: why different tickers with exactly same exchanges behave differently on historical request ? |
Re: Level2 data falls behind actual market
Outside RTH it stays in sync no issues.? Only during RTH is the issue. On Wed, Aug 9, 2023 at 7:13 PM Gordon Eldest via <hymagik=[email protected]> wrote:
|
Re: VIX Futures trading
Interesting chain, I trade VX futures daily, Jurgen is correct 5 cents is the min price increment as per CBOE restrictions, the min bid-ask spread is therefore 5 cents.
toggle quoted message
Show quoted text
Some pointed out that the VIX calendar spread has 1 cent min price increment, this is true, but it is also true that the bid-ask spread there tends to be 10 cents +, so it more economical to buy and sell each future individually, also there is a lot more liquidity, than buying/selling the spread outright. Is it useful to know that the mini-VIX contract, VXM, does have a 1 cent price variation, tighter spread, and decent liquidity if you are small enough. Finally, I would echo this comment: if you're not REALLY sure of what you're doing and the risks involved, stay away from VX futures and all derived products. |
Re: g++ command for including the proper libraries
Thanks Gordon and Jurgen. I figured out the problem. My mingw64 compiler was using a target architecture of x64, but the TwsSocketClient.dll was built using a x86 or 32-bit architecture. The reason I have chose to go this route is I like using visual studio code rather than visual studio because I find it clunky and I like working from the command line. Makes me feel good about myself. However, all it took in the end was opening up the TestCppClient.sln in Visual Studio and running main.cpp using win32 and magically a command window appeared trying to connect to TWS. It's as if someone recommended that all along...Lol. But, now I think I know the problem for g++, and which library to link. So, I will be installing a mingw32 version with a C++ compiler. I will post the full .bat file I come up that hopefully works based on everyone's recommendations and my own meddling for correctly linking the TwsSocketClient.dll to my project with the proper Client Class inheriting from EWrapper. Hopefully, it could help someone facing the same issues.
Thanks again, Brendan? |
Re: Error when requesting 20 years of price data for specific ticker [CHTR]
Great catch from @ds-avatar: the dates are indeed different (so the difference in the last pair of screenshots are not meaningfull.
So this morning, I run my code but using ISLAND for CHTR. And it worked on the first trial (without my workaround of opening a chart with share prices for CHTR) - see below. Here is a puzzling part: @´³¨¹°ù²µ±ð²Ô Reinold allerted me to the following: "In general, a smart-routed historical data requests will require subscriptions to all exchanges on which a instrument trades". So I got the "validExchanges" info for the contracts I was using to ask for price data. See below that after each set of price data, there is now a "CONTRACT DETAILS" section. Note that for CHRW and CSX (two other Nasdaq-listed stocks) the "Valid Exchanges" are exactly the same as for CHTR. So not sure why the issue happens only with CHTR (and not the other Nasdaq names in my test list). Tomorrow I will run the code with "SMART"? for CHTR and see if the error happens again and report back. Thank you all for the help so far. |