¿ªÔÆÌåÓý

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

Negative volume in tickString


 

Hi,
I was wondering if anyone has encountered this. I'm using TWS API from C# and receive the real-time trades via tickString callback. In the past using old API I didn't see this but now working with TWS 985.1h there is a situation when the value string reports negative value. It happens only during "late" hours like after 5pm EST.

Here is my code that've been working for many years in the past. Do I need to change it for the new API?
? ? ? ? public void tickString(int tickerId, int field, string value)
? ? ? ? {
? ? ? ? ? ? if (field != 48) return;
?
? ? ? ? ? ? //field 48 - our RT data
? ? ? ? ? ? // format of RTVolume=701.28;1;1348075471534;67854;701.46918464;true
? ? ? ? ? ? string[] fields = value.Split(';');
? ? ? ? ? ? if (fields.Length >= 2)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? if (double.TryParse(fields[0], out var lastPrice) && int.TryParse(fields[1], out var lastSize))
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? if (lastSize < 0)
? ? ? ? ? ? ? ? ? ? ? ? Logger.Instance.IBProviderLog(LogLevel.DEBUG,
? ? ? ? ? ? ? ? ? ? ? ? ? ? "Negative volume " + lastSize + " value string is " + value);
? ? ? ? ? ? ? ? ? ? //send to subscriber
? ? ? ? ? ? ? ? ? ? RealTimeTradeEventArgs args = new RealTimeTradeEventArgs(tickerId, (decimal)lastPrice, (decimal)lastSize);
? ? ? ? ? ? ? ? ? ? RaiseRealTimeTradeEvent?.Invoke(this, args);
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? }
Thanks in advance


 

Negative volume fields for RtVolume (TickId 48) have been around for years, not just since TWS 985.1h. They may be related to "Unreportable Trades". that are included in the data feed ( see )

I can't say for sure, but I believe we did not see negative volumes for the companion? "RTTradeVolume" (TickId 77) since it includes "Reportable Trades" only ( see )


 

JR,

Thanks for the prompt response. Strange that I've never encountered this before but maybe just didn't notice it. I guess the simplest solution would be just to ignore those negative volume messages. Would you agree?

E

On Mon, Aug 9, 2021 at 4:40 PM JR via <TwsApiOnGroupsIo=[email protected]> wrote:

Negative volume fields for RtVolume (TickId 48) have been around for years, not just since TWS 985.1h. They may be related to "Unreportable Trades". that are included in the data feed ( see )

I can't say for sure, but I believe we did not see negative volumes for the companion? "RTTradeVolume" (TickId 77) since it includes "Reportable Trades" only ( see )


 

Our code just does that, ignore ticks with negative volume. And as i said, this was put in place several years back after we did see negative volumes.

I took a quick look at the current API documentation before I sent my initial answer and realized, that our filter is actually too restrictive, though. As currently implemented it ignores RtVolume and RtTradeVolume ticks unless volume > 0. The correct filter would be volume >= 0 according to this sentence from the IB documentation:

As volume for US stocks is reported in lots, a volume of 0 reported in RTVolume will typically indicate an odd lot data point (less than 100 shares).
JR

PS. Not to make this more complicated, but other tick types do have documented cases of price or volume values of -1

From Receiving Market Data
When and are reported as -1, this indicates that there is no data currently available. Most commonly this occurs when requesting data from markets that are closed. It can also occur for infrequently trading instruments which do not have open bids or offers at that time of the request.

On Mon, Aug 9, 2021 at 09:28 AM, Edward wrote:
JR,
?
Thanks for the prompt response. Strange that I've never encountered this before but maybe just didn't notice it. I guess the simplest solution would be just to ignore those negative volume messages. Would you agree?
?
E

On Mon, Aug 9, 2021 at 4:40 PM JR via <TwsApiOnGroupsIo=[email protected]> wrote:

Negative volume fields for RtVolume (TickId 48) have been around for years, not just since TWS 985.1h. They may be related to "Unreportable Trades". that are included in the data feed ( see )

I can't say for sure, but I believe we did not see negative volumes for the companion? "RTTradeVolume" (TickId 77) since it includes "Reportable Trades" only ( see )

?


 

Thanks again,
1. I agree that ignoring it would be the right thing to do.
2. Regarding <= 0 vs < 0-? ?:) It is a kind of synchronicity. I've got your mail right when I was fixing the same - replacing <= by <
3. Just to be clear - I'm trading?US features and got that negative volume (not stocks)

Again - thanks a lot. I understand now why I missed that negative volume - we deployed?some VWAP based strategies only recently, so up to now the volume was not in use at all, while collected.

On Mon, Aug 9, 2021 at 5:53 PM JR via <TwsApiOnGroupsIo=[email protected]> wrote:
Our code just does that, ignore ticks with negative volume. And as i said, this was put in place several years back after we did see negative volumes.

I took a quick look at the current API documentation before I sent my initial answer and realized, that our filter is actually too restrictive, though. As currently implemented it ignores RtVolume and RtTradeVolume ticks unless volume > 0. The correct filter would be volume >= 0 according to this sentence from the IB documentation:

As volume for US stocks is reported in lots, a volume of 0 reported in RTVolume will typically indicate an odd lot data point (less than 100 shares).
JR

PS. Not to make this more complicated, but other tick types do have documented cases of price or volume values of -1

From Receiving Market Data
When and are reported as -1, this indicates that there is no data currently available. Most commonly this occurs when requesting data from markets that are closed. It can also occur for infrequently trading instruments which do not have open bids or offers at that time of the request.

On Mon, Aug 9, 2021 at 09:28 AM, Edward wrote:
JR,
?
Thanks for the prompt response. Strange that I've never encountered this before but maybe just didn't notice it. I guess the simplest solution would be just to ignore those negative volume messages. Would you agree?
?
E

On Mon, Aug 9, 2021 at 4:40 PM JR via <TwsApiOnGroupsIo=[email protected]> wrote:

Negative volume fields for RtVolume (TickId 48) have been around for years, not just since TWS 985.1h. They may be related to "Unreportable Trades". that are included in the data feed ( see )

I can't say for sure, but I believe we did not see negative volumes for the companion? "RTTradeVolume" (TickId 77) since it includes "Reportable Trades" only ( see )

?


 

Same here. Most of our work is with ES and VX.

We have TWS and our tools restart around 16:45 Chicago time every day. In accordance with the documentation we do receive one set of -1 values for AskPrice (Tickid 2) and BidPrice (TickId 1) since Ask/Bid values are not available between 16:00 and 17:00.

The corresponding AskSize (TickId 3) and BidSize (TickId 0) ticks have values of 0. One could argue the documentation suggests that tickSizes should be -1 in these cases as well.

JR


On Mon, Aug 9, 2021 at 09:58 AM, Edward wrote:
3. Just to be clear - I'm trading?US features and got that negative volume (not stocks)


 

We trade ES, NQ, EC, CL, EUR, NG, GC, RTY and YM in US. FTSE and DAX in Eurex and other products like HO, BRN etc. Interesting that the negative volume was discovered on ES and NQ. need to check now if we have it in others.

I concur that the negative volume happens on the break 17-18:00 EST which is 16-17:00 in Chicago. We restart our systems between 23:50 - 00:05 EST.

And could never get significant results with VX