Keyboard Shortcuts
Likes
- Twsapi
- Messages
Search
Re: Parent/Child orders with different TotalQuantity not working
I have the same problem - for a long time. I believed this is by design and therefore stopped using the native parent/child order from TWS. I implemented almost all order types myself and only use mark order, stop order and limit order from TWS.?
|
Re: Parent/Child orders with different TotalQuantity not working
It seems this was brought up here too. |
Parent/Child orders with different TotalQuantity not working
I am facing the issue that I can not create a child order to an parent order using different quantities. ? For example: ? Parent order: 4901383488: 117,0,0: LMT SELL 1.000000@... DAY Child order: 4901387616: 118,0,0: TRAIL SELL 49.000000@... DAY ? When sending it to TWS the? total quantity of the child order will be set to 1 (the value from the parent order). ? This was already a question on this topic here: /g/twsapi/topic/94355322?p=%2C%2C%2C20%2C0%2C0%2C0%3A%3A%2C%2C%2C0%2C0%2C0%2C94355322#?
? Is somebody else facing the same issue? ? THX |
Re: TWAP VWAP price request
You can run the calculation on more than one ticket on real-time data at the same time.? What is the time interval for the twap i.e. every 5 minutes? On Sat, Aug 26, 2023 at 11:58 PM John <serorjb@...> wrote: Hello, |
TWAP VWAP price request
Hello,
Is there a way to ask for a stock price snapshot, giving the twap or vwap of stock X between time Y and Z? I am asking for snapshots as I need to query 600US stocks within a minute several minutes per hour, I can't afford subscribing, or querying/waiting for historical bars. Looking at the list of supported ticks, I assume that it's not possible, but please do let me know I'd love to be proved wrong. Also specific ticks requests require subscriptions so I would need to subscribe/unsubscribe and that likely wouldn't work. One way would be to have 600 continuous live reaMktData streams,? and compute my own twap locally, I'd need to buy extra lines for that. Thanks, Jonathan? |
Re: VIX Futures trading
For me it is more cost effective to order the first leg at the bid for a buy or ask for a sell, and then hedge it with the second leg accordingly if I am executed.
There is a risk that you're unhedged for a short while between the execution of the two orders, and suffer some slippage, you should try and study carefully historical data (and queue position if you can) to get the best assessment of this impact on your strategy performance. Imho the way vix calendar spreads are priced, I am confident the only people making money trading them are market makers actually hedging themselves with an inventory of individual contracts, and looking at the volumes, clearly there isn't much money to be made there anyways. I'd recommend staying away from vix spreads, and also from weekly vix futures while we're at it, totally illiquid. |
Is it possible to split a takeprofit into 2 parts, limit first, then whatever remains into a market order 5 mins later?
I have the following bracket order,
I wish to change my takeprofit into 2 parts and leave the rest of it intact, I want to do a LIT, LMT or darkice, order at 200 dollars. Then if it doesn't fill within 5 mins, I want to push the rest into a market or MIT order at 200. But if it happens at 3:30-3:34, the close at time should cover it and it should just market exit at 3:35. So something like this,
Is something like this possible with ib/twsapi? |
Re: VIX Futures trading
On Thu, Aug 10, 2023 at 01:45 PM, John wrote:
h future individually, also there is a lot more liquidity, than buying/selling the spread outright.I think that the bid-ask spread during regular trading hours is more like 4-6 cents and not 10. its still quite expensive since 10 cents equals full spread on both individual legs. Based on your personal experience how much does it cost to trade a spread using individual legs as opposed to spreads. I am aware this isnt a TWS API question so forgive if I broke some rule here. |
Re: Performance optimization when exporting data to excel
Well, weight in the fact that I am not a fan of Excel for handling fast pace data. (and here you deal with 'ticks' which is rated 2nd fastest data set of the API) Maybe other members have better experience. |
Re: Level2 data falls behind actual market
csv solved the problem. You were absolutely correct and saved me a boat load of money.? Much appreciated.? You are my new buddy! On Tue, Aug 22, 2023 at 6:55 PM ebtrader via <jsiddique=[email protected]> wrote:
|
Performance optimization when exporting data to excel
? I have a stock scanner project where I am working with TWS C# API to get data based on certain price parameters.
the data gets callbacked in several methods which I then am using with EPPlus to open and update my excel file. the data comes back in the following order 1st loop (request stock symbols from API) using?reqScannerSubscription for each symbol we have another loop to get contract details from API, (2nd loop) using reqcontractdetails for each contract we request market data from API (3rd loop) using reqMktdata for each market data we store as variable (4th loop) The callbacks from tickprice ticksize etc... each method is a public virtual void method for loop 2-4 we are opening and editing an excel file with epplus ? ? using (var package = new ExcelPackage(pathtofile)) ? ? { ? ? ? ? // edit excel file with the data callback from API ? ? ? ? ? ? package.Save(); ? ? } Instead of opening and saving the excel file in each method, which costs about 5 seconds? for each iteration? 1) I could instead pass the variables to the last method in a array and then do it there. 2) I could use `LoadFromCollection` of Epplus instead of calling each cell, currently I am calling each cell like so ? ? worksheet.Cells[row, 1].Value = mycelldata; where row is sheet.Dimension.End.Row + 1 3) I could use sql database instead of using excel, (keep in mind I don't plan on having large databases (less then 50,000 entries) has anyone had any experience on my 3 previous methods or would like to suggest something new to speed up performance?? |
Re: Level2 data falls behind actual market
Using tail it is matching up with current market pricing in the after hours.? I will let you know if it works during regular market hours. On Tue, Aug 22, 2023 at 6:35 PM ebtrader via <jsiddique=[email protected]> wrote:
|
Re: Level2 data falls behind actual market
I will try this file append.? I have an SSD drive.? No computations are happening. ? On Sat, Aug 12, 2023 at 1:25 PM buddy <spy@...> wrote:
|
Linking an automatically exercised option to an underlying position
Hi all,
I'm looking to implement an options strategy which will BUY/SELL back options on expiration date to exit the position and avoid automatic exercising, however to build in redundancy for options which do get exercised through either technical issues on expiration day (WiFi down, application issues), or low-liquidity environments, it would be ideal to link a trade/position back to the exercised option through a field such as a permId. Due to my setup (and seemingly not able to distinguish position by client id), the resultant position in the underlying would be mixed with other existing positions in that security. Ideally the `Trade.log` or `Trade.fills` (ib_insync) class variables for the option would recieve additional executions/logs to capture that it was exercised, but I don't believe it does this? Any help on how others handle this case would be greatly appreciated! Many thanks, Aidan |
Re: MidPrice algo syntax, and other algo syntax
Bump.
From the FIX API, it appears that it requires the use of?MIDPX as order type instead of LMT / MKT. That being said it is not documented anywhere in the TWS API. Has anyone used it successfully? Also how to know which exchange is it accepted with? I understand it only applies to US stocks. |
Re: Can I place orders asyncronously like this without causing issues with the twsapi?
That sounds like a standard answer from a tier 1 support person. I would consider the counterpoints.. It's true there's a global interpreter lock, which may be in Python 3. It's also true that async code is single threaded, but in this circumstance you still need to be careful where you await. Finally, neither you nor IB mentioned anything about how many different instances of this program you may be running... if it's more than one you could certainly have a problem. So again, since you haven't provided a picture of the whole system, there's no great point in speculation. Of course testing is worthwhile, but static code analysis and formal verification are different beasts altogether. And, this is why I simply said "You might have problems but I won't conjecture on their likelihood." I know my reply was somewhat esoteric. Therefore, to make up for that a tiny bit, I'd suggest that you use the "+= 1" idiom instead of adding constants to your order ID. In addition, you'll want to learn about different methods of doing an atomic increment in Python as well as how to leverage critical sections. You should be able to significantly "future proof" your code when and if necessary with those two things. Still, these are all Python related (and concurrent programming) issues in general which the API can't address for you. Although I greatly enjoy the subject, it's a bit off-topic for this email group. |
Re: Gateway loses historical market data every day
Ok, thanks! I need some time to process that. @Gordon Eldest No it wasn't exactly 300.
?
|
Re: Can I place orders asyncronously like this without causing issues with the twsapi?
I contacted IB, they told me the following: Concurrency assumes that two task may overlap each other in execution. In python GIL(Global Interpreter Lock) prevents multiple threads from accessing the same python object. Only one thread can hold the GIL at a time and one thread must wait for another thread to release the GIL before running. If i understand everything right - your code will run one thread that will asynchronously place bracket orders.In this case this task is still single-threaded but asynchronous and you should not encounter any issues with order id's if they are incremented during the execution of run_loop(). So anyway, I tested my code yesterday on paper like 20 times and it seems to work fine, I checked there were no order id clashes. I also made another version where there was a second queue inside the function for the orders themselves, meaning if 2 api calls for price came back at the same time, the orders will be queued up, but it works exactly the same as the first version I described. Will try it again on paper today. |
Re: Can I place orders asyncronously like this without causing issues with the twsapi?
On Sun, Aug 20, 2023 at 10:26 AM, omgwtfsalty@... wrote:
You might have problems but I won't conjecture on their likelihood. They may not be exactly as you've described either, but there's no way to know much more from just a snippet of code. Details of the rest of the system need to be provided and considered... e.g. is this running in wsgi? On Sun, Aug 20, 2023 at 10:26 AM, omgwtfsalty@... wrote:
Yes... of course. Potential solutions, however, have much more to do with Python and concurrent programming in general than they do with the IBKR API. Check out my profile and follow the link to MIT's 6.031 class if you want to learn more about those topics. There's also a video by David Beasley in my profile... it's really great! But before you check those out, I suggest you sit through the 1986 videos of SICP and work through the book at the same time.... it's a masterpiece IMHO. On Sun, Aug 20, 2023 at 10:26 AM, omgwtfsalty@... wrote:
Not really, this kind of thing is the responsibility of the end user. With a little work I'm sure you'll be able to come with something. Good luck! |
Re: Could this happen: stp and trail in oca group both getting triggered?
Thats is great information again ´³¨¹°ù²µ±ð²Ô! I remember the post you are referring but I never really paid attention or understood the risc of overfilling, assuming the default behavior of oca would be sufficient.? Thanks again, and will certainly add this OcaType to my oca orders. Probably setting it to 1. Thanks again for your much appreciated help, greetings, Raoul. On Mon, Aug 21, 2023, 18:11 ´³¨¹°ù²µ±ð²Ô Reinold via <TwsApiOnGroupsIo=[email protected]> wrote: 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? |