Keyboard Shortcuts
Likes
- Twsapi
- Messages
Search
Re: -1 negative VOLUME in Futures BID_ASK historical request
开云体育I see the same. It looks like you only get VOLUME or BARCOUNT if you ask for TRADES. That doesn’t seem unreasonable to me. ? Richard |
Re: reqMktData callbacks are missing data with gateway 10.30 and 10.31 sporadically, works fine with 10.19 and older gateways/TWS
On Thu, Dec 19, 2024 at 10:23 PM, ajn wrote:
I just ran your sample program again, after hours w/ realtime, data_lines=75, loops=5 and everything worked OK using IBGW 10.30.1s. IDK what to say... I may try it again tomorrow since you indicate there's more likelihood of a problem during RTH. However, I'm also wondering if your network connection may have slightly degraded in the recent past? Is someone streaming HDTV while you test, lol? Are you sure you can't reproduce the problem w/ 10.19? I suppose it's possible that 10.30 has just enough extra network demand than 10.19 to make a difference but... I mention this mostly because my server has an exceptionally good connection (and I'm located close to the USA NE data center). When I look at your email headers I notice you're in Sweden, so if you're using a local computer... you might have more variation in connection quality. Just a guess since the code itself looks OK and the test results look OK. |
Re: reqMktData callbacks are missing data with gateway 10.30 and 10.31 sporadically, works fine with 10.19 and older gateways/TWS
Thank you very much!
yes, I can confirm it is there, at least it was all day for me on that very code and right now. (yet it is funky atm, see end of post) can you run it with several loops? It is often happening on the second loop or later. Does account you run has real time subscription? (see end of post, why maybe one really need subscription not 100% sure yet) ?
Using args Namespace(port=4002, global_cancel=False, file='symbols.csv', market_data_type='REALTIME', data_lines=75, loops=5)
serverVersion:187 connectionTime:b'20241219 16:56:08 EST' 1713296 Waiting... Symbols in work : 75, done symbols: 0 1714476 Waiting... Symbols in work : 75, done symbols: 1180 TIMEOUT ? ? ?reqId: 1714133, symbol: MU CANCEL ? ? ?TIMEOUT!!!! 1714504 Waiting... Symbols in work : 18, done symbols: 1264 ? ? ? ? ? ? ?Number of not done symbols: 1 reqId ? ? symbol done ?bid ? ? ask ? ? last ? ?volume ?high ? ?low ? ? last_timestamp 1714133 ? MU ? ? 0 ? ? N/A ? ? N/A ? ? 87.03 ? 904214 ?91.0 ? ?84.61 ? 2024-12-19 22:56:09 ? ? ? ? However I did notice 2 things
?
? ?
? |
Re: reqMktData callbacks are missing data with gateway 10.30 and 10.31 sporadically, works fine with 10.19 and older gateways/TWS
On Wed, Dec 18, 2024 at 12:08 AM, ajn wrote:
I presume you mean the problem will still exhibit itself. Can you confirm? Because I just ran your last sample program (w/ inconsequential changes for convenience; see attached) against a demo acct using DELAYED and it finished successfully.
Output:
|
Re: reqMktData callbacks are missing data with gateway 10.30 and 10.31 sporadically, works fine with 10.19 and older gateways/TWS
Just run a couple of more tests (using the app I posted, just changed False to True and commented cancel request). Snapshot works 100% reliable as Daniel experiences i.e. snapshot delivers all that is expected and no errors printed
self.reqMktData(orderId,?contract,?"", True,?False, [])
live data (4th argument is False) oth is the case which has the problems
self.reqMktData(orderId,?contract,?"",?False,?False, [])
It is live data is bit broken in gateway 10.30+ . We are making some progress :)
? |
Re: reqMktData callbacks are missing data with gateway 10.30 and 10.31 sporadically, works fine with 10.19 and older gateways/TWS
yes it is the same call I am making, except I am not asking for snapshot (4th argument is False) but whole set of data to be streamed to me
self.reqMktData(orderId, contract, "", False, False, [])
?
Last time I checked the difference between asking for a snapshot and streaming, snapshot was much more delayed (but that was 4-5 years ago, maybe things improved since). Still streaming or snapshot, api is promising the data, we pay for it. We should be getting it :)?
?
And even in this test. last was there, In this case bid/ask was missing. Sometimes "last_timestamp" (time of last trade) is missing, sometime high/low/volume. bit random. I believe last is present most of the time
|
Re: reqMktData callbacks are missing data with gateway 10.30 and 10.31 sporadically, works fine with 10.19 and older gateways/TWS
Hi AJ,? I connect via TWS and my TWS version is 10.30.1s, whereas the version of my CSharpAPI.dll is?10.15.2.0.? "I didn't receive all of ["bid", "ask", "last", "volume", "last_timestamp", "high", "low"]" ?I think this might be the difference. I only request snapshots every few seconds.? E.g. in C#: client.reqMktData(reqId, contractObject, string.Empty, true, false, null); As said, 50.000+ requests per day and working fine. Of?course, I only get 'the last Last' snapshot, for my app that's fine. Hope it helps, Daniel. On Thu, Dec 19, 2024 at 5:53?PM ajn via <andrei.jefremov=[email protected]> wrote:
Daniel |
Re: reqMktData callbacks are missing data with gateway 10.30 and 10.31 sporadically, works fine with 10.19 and older gateways/TWS
In the attached zip I have the app. It is now only 250 lines including all the IB connection and argument parsing. The working function are all the same as before (described earlier) I just deleted everything else. I do agree, as a standalone app it gets much more readable
?
Program_get_bid.py -f symbols.csv -m REALTIME --data-lines 75 --loops 5 --port 4001
?
As an added bonus this app can be run from anywhere, not just from python samples folder. so long your python environment has 10.30 installed
?
AJ |
Re: reqMktData callbacks are missing data with gateway 10.30 and 10.31 sporadically, works fine with 10.19 and older gateways/TWS
Thanks Daniel,
?
Just to be clear the problem is not that I am not receiving the callbacks at all. The problem is that I am receiving not entire set of? the data I expect for some of the contracts (always random which contracts will be missing some data). Sometime it is bid which is missing, sometimes ask, sometimes last etc. bit random misses. And everytime I check gateway log for the request I had issues with It is clear that that piece of data is not there (say I see that for req 123456 I get bid, ask, volume but not a last value etc.).?
?
I am 99.99% it is not the contract issue, as I am getting most of data,?
?
Moreover, today I was experimenting with unsubscribing/subscribing for data for a contract which at this point was missing data (my definition of "missing" is that after subscription I didn't receive all of ["bid", "ask", "last", "volume", "last_timestamp", "high", "low"] within 20 seconds at least once, typically one or two would be missing), and 100% of time I was receiving the data after a second subscription. So contract part is very likely fine.?
?
Possible issues:
Yes, I monitor error codes. no such errors. As for pacing, it used to be needed but SDK I believe build it in and there is an option ?setConnectOptions("+PACEAPI"), which I use for several years now on top of own pacer anyway (just ot be safe, remember first versions were glitchy). And typically pacing errors result that you don't get any data at all. which is not current case.?
?
Great stats, :) it used to be like this for me up and including gateway 10.19.?
AJ |
Re: No definition for SPX option using LocalSymbol
Yes, I mentioned that I can use TradingClass to separate monthly and weekly options. The problem is that it is supposed to be generic method that I could use to form a contract for any security type, SPX index option, QQQ stock option, ES futures option. In this case, it is not clear what I should provide in the TradingClass property.?
?
If there is a strict rule that defines how TradingClass needs to be set, e.g. symbol name + expiration type = SPXW, then I could use TradingClass instead of LocalSymbol but I haven't seen any docs describing how to set TradingClass depending on SecType. LocalSymbol does define specific format for all type of options, it is more generic, so I decided to go with it.? |
Re: No definition for SPX option using LocalSymbol
开云体育The Contract Inspector shows you the actual local symbol to use. US options and European options have different local symbol formats: you’ve tried to use the European format for a US option. ? The local symbol you need is: ? SPXW? 241218C05945000 ? which is probably in your screenshot, except it’s too small and fuzzy to read. ? Richard ? ? From: [email protected] <[email protected]> On Behalf Of Andy Sanders via groups.io
Sent: 19 December 2024 05:16 To: [email protected] Subject: [TWS API] No definition for SPX option using LocalSymbol ? Could somebody advise why I'm getting "No security definition" error for a contract with this local symbol : C SPX 20241218 5945 W ? Security: SPX index Strike: 5945 Side: Call? Expiration: 2024-12-18? Type: Weekly ? Trying to send order to buy and sell SPX index options. When I set separate contract properties such as strike, symbol, expiration, currency, and exchange, place order request returns error "ambiguous definition" because API returns the same expiration date for monthly and weekly options.? ? ? There are several ways to make contract definition for option unique, e.g. using TradingClass or LocalSymbol properties. When I try to use LocalSymbol I get error "No security definition found" ? Example of local symbol that I used : C SPX 20241218 5945 W Format mentioned in the docs : ? ? |
Re: reqMktData callbacks are missing data with gateway 10.30 and 10.31 sporadically, works fine with 10.19 and older gateways/TWS
Hi AJN.? First off: note that `Contract.primaryExch` is not the same as `Contract.Exchange`. You might be constructing invalid Contract objects.? About reqMktData: just for fun I checked my code and out and yesterday I made 54.000 calls to it, all received a callback except few, like ~50, because of the reason #2 mentioned below.? Possible issues: 1: make sure you comply with the max 50 requests per second pacing violation. I don't know if you'll receive an error message if that's your case. 2: error code 10197 "No market data during competing session": if you're pulling reqMktData and at the same time visualizing the data in TWS, you might get this error and hence not receive an eWrapper callback.? Note I'm in C# API 10.15.2.0 - no capacity to test on another version at?the moment. Hope it helps.? On Wed, Dec 18, 2024 at 9:09?PM ajn via <andrei.jefremov=[email protected]> wrote:
--
Daniel |
Re: reqMktData callbacks are missing data with gateway 10.30 and 10.31 sporadically, works fine with 10.19 and older gateways/TWS
On Wed, Dec 18, 2024 at 08:09 PM, ajn wrote:
Pull it out and make it stand alone. Get rid of ALL SUPERFLUOUS things like colorization constants... or no one will want to help you. |
Re: No definition for SPX option using LocalSymbol
For SPX OPT you have to set up `Contract.TradingClass` as `SPX` for monthlies?and `SPXW` for daily/weekly?expiration. Do not define `LocalSymbol`. For naked SPX options, just do `Symbol`, `SecType`, `Exchange`, `Currency`, `TradingClass`, `Strike`, `Right` and `LastTradeDateOrContractMonth`. Good luck, Daniel. On Thu, Dec 19, 2024 at 6:16?AM Andy Sanders via <arteinvolo=[email protected]> wrote:
--
Daniel |
No definition for SPX option using LocalSymbol
Could somebody advise why I'm getting "No security definition" error for a contract with this local symbol : C SPX 20241218 5945 W
?
Security: SPX index
Strike: 5945
Side: Call?
Expiration: 2024-12-18?
Type: Weekly
?
Trying to send order to buy and sell SPX index options. When I set separate contract properties such as strike, symbol, expiration, currency, and exchange, place order request returns error "ambiguous definition" because API returns the same expiration date for monthly and weekly options.?
?
?
There are several ways to make contract definition for option unique, e.g. using TradingClass or LocalSymbol properties. When I try to use LocalSymbol I get error "No security definition found"
?
Example of local symbol that I used : C SPX 20241218 5945 W
Format mentioned in the docs : ?
?
|
Re: reqMktData callbacks are missing data with gateway 10.30 and 10.31 sporadically, works fine with 10.19 and older gateways/TWS
I created a second version where I removed all code which is not absolutely necessary It is roughly 150 line of code which one easily sees comparing Program.py from samples to Program_get_bid.py. As per first post: The file is part of \samples\Python\Testbed?extract provided python.zip in that folder Then, run (or even better run from debugger and step)
Program_get_bid.py -f symbols.csv -m REALTIME --data-lines 75 --loops 5 --port 4001 ?
There is 3 new functions left. Main entry , runs the test in the loop
?
Actual code subscribing to data. making sure the datalines limit is not exceeded. And knowing that Subscription is expensive I typically run 65% of line limit. I.e. for test accounts where I have only 100 lines I would run 65 max. So we never run into "max data lines limit reached" error.?
?
monitor_not_done is called after each subscription and stops new subscribtions once we reach the limit or (finalize = True) simply waits until all subscriptions returned the data or Timed out.
?
The wrappers are easier described by comparison to Program.py the original test app. Really all wrappers do is saving incoming data
?
and there is unsubscribing bit which is driven by wrappers (here on example of error), if all data is present the cancel is called and sets "sentCancelMktData" which gives signal to test loop that one received all the data
?
That is pretty much it.?
?
|
Re: reqMktData callbacks are missing data with gateway 10.30 and 10.31 sporadically, works fine with 10.19 and older gateways/TWS
I have implemented reqContractDetails and start constructing contract using conId I received.
so instead of this Like this ?
It made no difference, unfortunately. still not receiving some data
|