Interactive Brokers (IB) Volume Incorrect

I'm working on integrating Norgate EOD with realtime data. I was first looking to use IB for realtime, but as I've seen others point out the volume seems to be wrong. I believe this is an IB issue, not an Amibroker issue, but not sure. For example, here is a screenshot of a SPY 5 minute chart from Trader Workstation (top), and Ami using IB realtime (bottom).

image

This makes the realtime data useless, for me, as I use volume to some extent. In any case, I just wanted to check if maybe I missed some way to correct this before discarding IB for realtime and looking elsewhere. Thanks.

Have you tried refreshing the data @foosballer? Or tried any other symbols?

IB definitely reports volume differently than Norgate. Generally 100x difference because of IB reports in 100's. But Norgate also reports volume and price on certain futures in a legacy format, using old contract specifications that don't agree with the current day contract specs for silver and copper, which makes no sense at all (they should revise the legacy data to correspond with the current specs).

Anyway, the volume difference in the screenshots you posted could easily be the 100x volume multiplier (because TWS can show volume differently than the real-time data feed that they send!), but perhaps you also have different intervals. You didn't include the time axis or anything that would show me that you're using the same time frame for each chart.

In order solve the 100x challenge, I now use a naming convention for by AB DBs. I include the data source in the filename. I use two functions: one tells me the data source, and the other multiplies the volume by 100 if the source is IB or MetaStock. Of course this assumes you have only one data provider per DB. If you mix them this code won't work properly.

function DB()
{
	// Returns a string with the data provider. Assumes that the DB filename includes the quoted text below.
	// 20210525
	DatabaseName = GetDatabaseName();
	if( 	 StrFind( DatabaseName, "IBKR" ) ) 		Output = "IBKR";
	else if( StrFind( DatabaseName, "Norgate" ) ) 	Output = "Norgate";
	else if( StrFind( DatabaseName, "Yahoo" ) ) 	Output = "Yahoo";
	else if( StrFind( DatabaseName, "IQFeed" ) ) 	Output = "IQFeed";
	else if( StrFind( DatabaseName, "Polygon" ) ) 	Output = "Polygon";
    else if( StrFind( DatabaseName, "MetaStock" ) ) Output = "MetaStock";
	else Output = "";
	return Output;
}

function VolMult()
{
	// Volume multiplier may be needed because some data sources report volume that needs to be multiplied by 100.
	// 20200717
	switch( DB() )
	{
		case "IBKR":			
		case "MetaStock":		
			Output = V * 100;
			break;
		default:
			Output = V; 
			break;
	}
	return Output;
}

I hope this helps.

2 Likes

@vmonkey Yes and Yes. All symbols have the issue. The realtime data has the issue, and the backfill data has the issue, even after refreshing.

@PeterD They were both 5 minute. That would be great if one just needs to multiply 100. Going back to check if that's the case...

@PeterD You are right, it is close to 100x. For whatever reason it does not match exactly with the charts from IB, but close.

I also noticed that the total Volume presented in the Realtime Quote window is higher than the sum of all bar volume for the day. The realtime quote total volume seems to be more accurate than the volume on the chart. My understanding is that the data plugin provides this field separately, explaining why it can be different. As I type this the total day volume for tesla, after multiplying by 100x is off by 500K on the chart, but spot on in the Realtime Quote window.

Unfortunately, as far as I'm aware the realtime info is not available to AFL.

Okay, maybe what I'll do is use the Realtime info from IB's daily OHLCV feed, since that seems accurate enough, and combine it with Norgate for realtime updated EOD without the intraday backfill.

See also AFL Function Reference - GETRTDATA

@PeterD Thank you! Seems there is always a way with AmiBroker. I've come to think of it more like a build chain / framework like Visual Studio than an Application. Cheers.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.