I am new to multicast data feed processing, my question is what’s the best way to create a simple filter on the data flow.
I am writing an application to process streaming financial data, e.g., stock prices of all the stocks traded on New York Stock Exchange. The data stream looks something like this.
SJYM2 Quote: Bid=91.265000, 4 Ask=91.330000, 4
6SM2 Quote: Bid=1.105500, 23 Ask=1.105800, 5
RFM2 Quote: Bid=1.204500, 6 Ask=1.205000, 7
6SM2 Quote: Bid=1.105500, 24 Ask=1.105800, 5
6SM2 Quote: Bid=1.105500, 25 Ask=1.105800, 5
6SM2 Quote: Bid=1.105500, 26 Ask=1.105800, 5
6SM2 Quote: Bid=1.105500, 27 Ask=1.105800, 5
6SM2 Quote: Bid=1.105500, 28 Ask=1.105800, 5
GEH3-GEZ3 Quote: Bid=23.500000, 325 Ask=24.500000, 1501
GE:BF_M2-H3-Z3 Quote: Bid=-15.500000, 936 Ask=-14.000000, 16
GEM3-GEU3 Quote: Bid=7.500000, 21823 Ask=8.000000, 79
GE:DF_H3H4H5H6 Quote: Bid=-21.000000, 6 Ask=-19.000000, 4
NGG3-NGQ3 Quote: Bid=-0.162000, 2 Ask=-0.081000, 1
NGH3-NGU3 Quote: Bid=-0.185000, 3 Ask=-0.102000, 1
BZK2 Quote: Bid=123.970000, 1 Ask=124.120000, 1
BZ:C1_HO-BZ_K2 Quote: Bid=11.100000, 1 Ask=11.320000, 1
BZ:C1_RB-BZ_K2 Quote: Bid=17.060000, 1 Ask=17.310000, 1
BZM2 Quote: Bid=123.250000, 1 Ask=123.460000, 1
BZN2 Quote: Bid=122.530000, 1 Ask=122.920000, 1
CLK2-BZK2 Quote: Bid=-18.770000, 1 Ask=-18.610000, 1
BZK2 Quote: Bid=123.970000, 1 Ask=124.110000, 5
BZ:C1_HO-BZ_K2 Quote: Bid=11.110000, 1 Ask=11.320000, 1
BZ:C1_RB-BZ_K2 Quote: Bid=17.070000, 2 Ask=17.310000, 1
BZM2 Quote: Bid=123.250000, 1 Ask=123.450000, 5
BZN2 Quote: Bid=122.530000, 1 Ask=122.910000, 1
If I am only interested in BZN2, BZK2 and 6SM2 data, what’s the best way to create a simple filter to pull only those data?
Thanks.
Since the marker always goes at the first place in the string, you can split each incoming string by the space, take the first substring and compare it with a set of patterns using
strcmp().You could also use regexp here, but it’s not needed.
And the very best solution (i don’t know if it’s possible in your case) is to filter the incoming stream from the server side, i.e. choose the markers you need when you sign up for the stream.