开云体育

ctrl + shift + ? for shortcuts
© 2025 Groups.io

Re: IB's New automated trading system questionnaire

 

I do not know what criteria is being used to determine who? the questionnaire applies to.? I remember no mention of the type of instrument.? It seemed like it was designed to evaluate how well your automated trading handles errors.? The concern being you might trigger some sort of market disruption (for example, Knight Capital in 2012) if your trading goes off the deep end.


Construct quote with greeks and prices

 

Trying to create a quote based on ticks coming from "reqMktData".?
Simplified code below.?
?
Question: There are two separate callbacks for option greeks and prices and both are important for my strategy but at the moment callback for prices is almost always executed before callback for greeks, so "PointStream" often receives quote with prices but without greeks. Is there an easy way to make sure that before I send final quote to the stream, its greeks are already calculated??
?
void SubscribeToPoints(Contract contract)
{
? var point = new PointModel();
? void subscribeToComs(TickOptionMessage message)
? {
? ? point.Delta = message.Delta;
? ? point.Gamma = message.Gamma;
? ? point.Theta = message.Theta;
? ? point.Vega = message.Vega;
? ? point.Sigma = message.ImpliedVolatility;
? }
? void subscribeToPrices(TickPriceMessage message)
? {
? ? switch (message.Field)
? ? {
? ? ? case PropertyEnum.BidSize: point.BidSize = message.Data; break;
? ? ? case PropertyEnum.AskSize: point.AskSize = message.Data; break;
? ? ? case PropertyEnum.BidPrice: point.Bid = message.Data; break;
? ? ? case PropertyEnum.AskPrice: point.Ask = message.Data; break;
? ? ? case PropertyEnum.LastPrice: point.Last = message.Data; break;
? ? }
? ? PointStream(point);
? }
? client.TickPrice += subscribeToPrices;
? client.TickOptionCommunication += subscribeToComs;
? client.ClientSocket.reqMktData(id, contract, string.Empty, false, false, null);
}


Re: IB's New automated trading system questionnaire

 

Hi all -
?
is the questionnaire referenced in this thread specific to class of instrument (eg futures); or does the questionnaire apply to all IBKR customers?

Thanks!


Re: Delphi and TWS

 

Yes of course we can help..... customers.? If you write to us at support, we will help get you started.? Try it.
?
?


Re: conditional order conditioned on execution of buy order only?

 

I think setting a prohibitive limit price on the parent order is also a reasonable way to effectively pause execution when this is preferred over re-submission. My guess about IBKR supporting changing good-after-time for standing orders was based on the fact that it does support changing good-till-date setting, but this setting obviously does not cause the order to pause which could make a critical difference.
?
As for cancelling the orders, one thing that would make me hesitate to prefer it over modifying is IBKR's order efficiency ratio guidelines ("OER", IB KB articles 1343/1765) where they count cancellations towards increase of inefficiency and recommend revision over re-submission. So if this happens to be an important consideration in the context of a particular trading method then cancellations are best avoided. However if modifications are used for pausing an order, two such events would be required, effectively equating in number the combination of a cancellation and a new submission. Either way, it should be noted that very frequent client-side hunting for a new limit price without execution will likely be prone to violating IB's guidelines.
?
--
Best,
DS


Re: Delphi and TWS

 

Thanks for your response.
I work mainly with Linux but also with Windows. I have Delphi 12 on Windows and Lazarus on Linux.
I have only tried connecting to TWS with Delphi, and although it does not give errors when I try to connect by telling it the host and port, I cannot connect.
I have not tried it in Lazarus for Linux. Do you have any code?
?
Greetings and thanks.


Re: Delphi and TWS

 

Thanks for your response Chucky.
I work mainly with Linux but also with Windows. I have Delphi 12 on Windows and Lazarus on Linux.
I have only tried connecting to TWS with Delphi, and although it does not give errors when I try to connect by telling it the host and port, I cannot connect.
I have not tried it in Lazarus for Linux. Do you have any code?
?
Greetings and thanks.


Re: Delphi and TWS

 

It works perfectly well on Lazarus.?
Tested in both MacOS and Linux versions of Lazarus.? Even comes with a sample app built in Lazarus.? So, quit saying bad things about my work.


Re: conditional order conditioned on execution of buy order only?

 

?
p.s. two relevant threads:
?
?/g/twsapi/topic/88826062#msg48954?-- how to pause execution
?
?/g/twsapi/topic/6097221#msg38757-- Can I create a condition to toggle a Limit order between ACTIVE and PAUSED states...
?


Re: conditional order conditioned on execution of buy order only?

 

?
DS,
?
From looking through relevant posts, and doing some experimenting, I can see only two ways to "pause" a limit order via the TWS API:
?
  1. cancel the order, the submit it again to "resume" the order, or

  2. modify the limit price to prevent the order from filling, then modify it again to "resume" the order.
?
It looks like the only parameters of a standing limit order that can be changed may be the quantity, the price, and the time in force.
?
In particular, modifying or removing a time condition (whether attached to the order when created, or added later) doesn't seem to be supported. ?Nor does modifying or removing a goodAfterTime.
?
At least, this is the best explanation given what I've read and the results of things I've tried. ?I'd be happy to find out this is not the case.
?
-Neal


Re: Delphi and TWS

 

Are you trying to use Ross Hemminway's library? If so I bought a license and could not make it work for me either. But I run solely on Linux these days and tried to implement it with Lazarus so I never tried it on Delphi. If youre working on implementing your own socket connection with the wire protocol I might be able to get you started.
?


Wire Protocol

 

I am not a professional programmer. I write code for my own use, which is usually, because of my age, in pascal. That said I obviously needed to understand the wire protocol and was surprised to learn support was almost non-existent. I studied the C++ API and used wire shark to learn the necessary message format to right the code I needed to support the type of trading I do. It works quite well and is fast.
?
The warnings I've seen on the board about getting out of sync and hopelessly unable to recover without a restart are unfounded. Why would anyone suggest that,? when the API itself is simply converting you requests to the wire protocol and decoding the incoming wire protocol messages to a human readable format. The ability to recover is what you make of it in your code.
?
While studying the C++ code I was amazed at how poorly the code is maintained. Its like a Swiss army knife trying to do everything under the sun until it becomes buggy. Look at EClient::placeOrder. Its amazing how many if else statements are being executed based upon what protocol version you might be using. And if you just happen to be using a certain version the bug raises its ugly head. This API should be paired with the TWS workstation release and your code should refuse to connect if you update the workstation and try to connect with client software written with an older version.
?
I wanted to share my knowledge of using the wire protocol directly but Ive seen posts that this isn't the forum to do that, and since I have been unable to find a forum on the net that handles this I'm left with the decision of creating one myself.
?
If there are others who have interest in that please respond. Thanks and I hope that I haven't offended anyone with this post.
?


Re: reqContractDetails() does not get a callback if secType = "OPT"

 

Working fine here on TWS 10.30, including on non-RTH.?

Try not doing this — I definitely?don't:

optContract.multiplier = ""
optContract.conId = 0


image.png
[...]

On Mon, Jan 13, 2025 at 8:19?AM 闯ü谤驳别苍 Reinold via <TwsApiOnGroupsIo=Reinold.org@groups.io> wrote:

Worked for me just now, so your problem is not related to trading hours. I received 2,404 contracts within 10 to 12 seconds.

Maybe you need to check your setup or get a "second opinion" by using a different client. Richard's screen shot was from his very handy "Contract Inspector" tool that you can . Maybe start with that.

闯ü谤驳别苍

?

On Mon, Jan 13, 2025 at 12:18 AM, Stephan Gueorguiev wrote:
OK, I think the issue is trying this outside of trading hours like on a Sunday - this weekday morning it seems to work as expected.? Weird as I'd have thought looking up option contracts should not need live market data but it appears that's not the case.? It just so happened I tried the smaller chain first this AM which is why it worked rather than the chain size.



--
Daniel


Re: reqContractDetails() does not get a callback if secType = "OPT"

 

Worked for me just now, so your problem is not related to trading hours. I received 2,404 contracts within 10 to 12 seconds.

Maybe you need to check your setup or get a "second opinion" by using a different client. Richard's screen shot was from his very handy "Contract Inspector" tool that you can . Maybe start with that.

闯ü谤驳别苍

?

On Mon, Jan 13, 2025 at 12:18 AM, Stephan Gueorguiev wrote:

OK, I think the issue is trying this outside of trading hours like on a Sunday - this weekday morning it seems to work as expected.? Weird as I'd have thought looking up option contracts should not need live market data but it appears that's not the case.? It just so happened I tried the smaller chain first this AM which is why it worked rather than the chain size.


Re: reqContractDetails() does not get a callback if secType = "OPT"

 

OK, I think the issue is trying this outside of trading hours like on a Sunday - this weekday morning it seems to work as expected.? Weird as I'd have thought looking up option contracts should not need live market data but it appears that's not the case.? It just so happened I tried the smaller chain first this AM which is why it worked rather than the chain size.


Re: reqContractDetails() does not get a callback if secType = "OPT"

 

Thanks Richard, appreciate you looking.
From your screenshot, it doesn't look like this is running via the gateway, or is it?
?
The API messages for the first of my calls are:
?
Whereas for the second call they are (and then it hangs):
?
?
?
So it's definitely not getting a call back rather than something in my code.
?
Actually, I've just tried another ticker given the v. large option chain on AAPL you report.? If the ticker is a smaller chain, say LPRO, then it does work as expected.? Surely this is a bug though?? Just hanging without a call back for 60s if the chain is too big?? Should I be reporting it or is it considered normal operation?
?
?


Re: reqContractDetails() does not get a callback if secType = "OPT"

 

开云体育

Your request for the AAPL options actually returns 2482 contract details. The whole lot is returned within a second or two. You should be able to easily verify this from the API log.

?

See attached screenshot.

?

I can’t speculate as to why your code doesn’t receive them, but the fault is certainly not in the IBKR API code.

?

Richard


Re: reqHistoricalTicks() & batching vs. reqTickByTick() vs. reqHistoricalData(), Backtesting vs. Realtime execution

 

Yes agreed it does appear that the sequence they arrive is correct as long as it's maintained. Good idea tagging them with a serial number.... I'm gonna add that for good measure.
?
?
-----
?
Side note (just because I'm looking at it) in case helpful for anyone, here's a chart of NQ with the prices from each source. Similar but not identical, where bento seems to have higher price resolution and ibkr sorta averages ticks.
?


Re: reqHistoricalTicks() & batching vs. reqTickByTick() vs. reqHistoricalData(), Backtesting vs. Realtime execution

 

Just a note that the price I mentioned was for trade ticks only. The bid/ask and book ticks are more.


reqContractDetails() does not get a callback if secType = "OPT"

 

I had some old code I haven't run for a few years, which used to successfully retrieve an option chain.? I've been trying to update it but for the life of me I can't get hold of an option chain through reqContractDetails() with code which used to work.
?
I've updated to IB Gateway 10.33 and also a python client implementing API 10.30.01.
?
I can call reqContractDetails
?
contract = Contract()
contract.symbol = "AAPL"
contract.secType = "STK"
contract.currency = "USD"
contract.exchange = "SMART"
reqContractDetails(1, contract)
?
This works perfectly and I retrieve the details just fine.
?
If however I then do:
optContract = Contract()
optContract.symbol = "AAPL"
optContract.currency = "USD"
optContract.exchange = "SMART"
optContract.secType = "OPT"
optContract.multiplier = ""
optContract.conId = 0
reqContractDetails(2, optContract)
?
Then the contractDetails() callback never gets called, or at least within my 60 second timeout.? I have tried with "" for exchange and multiplier - no dice.
?
I can see how if I'm not properly defining a request for the option then it won't find it - but then I'd expect a "security not found" type message - whereas this is more like as soon as the contract type is set to OPT the callback never takes place.
?
Any ideas?? Is it possible that I'm doing this on a Sunday and it will work during regular trading hours?
?
Thanks in advance,
S.?