Login Page - Create Account

Support Board


Date/Time: Tue, 07 May 2024 02:11:24 +0000



Inferring trade side (bid or ask) using IQFeed data

View Count: 852

[2018-08-19 19:42:11]
nto - Posts: 6
Hi,

My team and I have been using SierraChart to visualise IQFeed data for 2 years now and we're not exactly sure about how the trade side is inferred by SierraChart's software on this data.

Note that IQFeed is not providing any field telling you the side of the trade (either ask or bid).

Note also that often last_price == bid_price or last_price == ask_price, making it easy to infer the side of the trade.

But then, there are cases where bid_price < last_price < ask_price (spread > 1 tick). And for those cases I'm not sure what to do.

Here's an example of an IQFeed data message received for FGBL (German Bund Future):

Q,BD#,162.23,5,02:01:03.095000,68,471,162.22,79,162.24,20,162.27,162.28,162.23,162.11,C,01,

Here

bid = 162.22
ask = 162.24
last = 162.23 (price of the trade)

I've been trying to reproduce SierraChart's result and have something almost working except not always.

Could you share the algorithm you use to solve this problem?

Thanks.
[2018-08-20 18:43:17]
Sierra Chart Engineering - Posts: 104368
This is explained here in the the Bid Trade and Ask Trade sections:
Numbers Bars: Definitions

One question we have, is do you use IQ Feed because you need to use it with other programs as well? Otherwise, we would recommend using the Sierra Chart Exchange Data Feed instead. However, the EUREX Bid Trade / Ask Trade section is not applicable to IQ Feed.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
Date Time Of Last Edit: 2018-08-20 18:46:50
[2018-08-20 19:50:50]
nto - Posts: 6
We need to use IQFeed because that's the data provider we're using for our automated trading system.

Here's the code I've written, trying to reproduce what's describe in the documentation you referenced:


Side side;
if (ask > 0 && last >= ask)
side = Side::ask;
else if (bid > 0 && last <= bid)
side = Side::bid;
else if (last < last_trade->price && bid < last_bid)
side = Side::bid;
else if (last > last_trade->price && ask > last_ask)
side = Side::ask;
else if ((last - bid) < (ask - last))
side = Side::bid;
else if ((ask - last) < (last - bid))
side = Side::ask;
else if (last == last_trade->price)
side = last_trade->side;
else if (last > last_trade->price)
side = Side::ask;
else if (last < last_trade->price)
side = Side::bid;


Can you spot something wrong here?

I can't seem to reproduce the output of SierraChart.
[2018-08-20 20:26:32]
nto - Posts: 6
Here's an example


1533794463147725,Q,BD#,162.23,5,02:01:03.048000,68,466,162.22,79,162.23,1,162.27,162.28,162.23,162.11,C,01,
1533794463170772,Q,BD#,162.23,5,02:01:03.048000,68,466,162.22,79,162.23,4,162.27,162.28,162.23,162.11,a,01,
1533794463201080,Q,BD#,162.23,5,02:01:03.048000,68,466,162.22,79,162.24,20,162.27,162.28,162.23,162.11,a,01,
1533794463201104,Q,BD#,162.23,5,02:01:03.095000,68,471,162.22,79,162.24,20,162.27,162.28,162.23,162.11,C,01,

First trade (received at 1533794463147725) is a BUY trade because LAST == ASK == 162.23.

But then, second trade (received at 1533794463201104) is classified as a SELL by SierraChart. I would have expected it to be classified as a BUY trade because LAST == PREVIOUS_LAST and last trade was classified as BUY.

What am I missing here?
[2018-08-28 06:41:30]
nto - Posts: 6
Hi guys, is someone reading the support board? Didn't get a reply
[2018-08-28 06:52:23]
Sierra Chart Engineering - Posts: 104368
We really cannot spend time on this now. We are very busy and the software development for the user base must take priority. We are no longer willing to get sidetracked by these requests.

The first step for us would be to compare the documentation to the code. We do not know when we could even get to that. The simple fact is we have to be honest we are declining this request. We simply cannot even keep up with our own work which we have to do for the user base.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
Date Time Of Last Edit: 2018-08-28 06:56:35
[2018-08-28 07:05:14]
nto - Posts: 6
This really is unacceptable. I give you an example where your software infers a trade side different than what is described in your documentation. This is a BUG. You are supposed to write consistent software. This is your own work, not mine.
[2018-08-28 07:44:22]
Sierra Chart Engineering - Posts: 104368
We are quite certain there is no bug. And it might be best that we just remove the documentation. The only reasonable explanation is that the implementation is more involved than documented and it takes a lot of effort to go through that especially being there are different methods of making the determination. But we know our IQ Feed processing uses the standard method we have developed.

Or there is some kind of floating-point number comparison type issue which would be unlikely in this case.

We can give you the source code for how this is done privately and then you can look at it to figure it out. But we cannot answer questions about it.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
Date Time Of Last Edit: 2018-08-28 07:45:03
[2018-08-28 08:14:57]
nto - Posts: 6
Thank you for your reply. Trade side inference is indeed not at all a trivial problem (people write actual research papers on how to infer trade sides from quote data [1]).

I don't want you to waste your time on this either. I find your solution of sharing the source code for the trade side inference absolutely perfect. If you can send me that chunk of code privately, I can reverse engineer how your software infers the trade side and reproduce SierraChart's output! Can you send it to me by mail?

Thanks again for your help.

[1] https://onlinelibrary.wiley.com/doi/pdf/10.1111/j.1540-6261.1991.tb02683.x
[2018-08-28 18:24:30]
Sierra Chart Engineering - Posts: 104368
The source code has been sent to your email address you have set on your Sierra Chart account. Let us know you received it.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account