Suggest you try different dataset from nasdaq because the dataset you picked is rather limited in message types and so it crashes and burns.
Data output should look something like using data from 08/22/2014:
[A, 7832, 0, 34383145181253, 9138132, S, 100, WLL, 810000]
[F, 7845, 0, 34383145198745, 9138133, S, 100, WMW, 268800, NITE]
[F, 7845, 0, 34383145201499, 9138134, S, 100, WMW, 268800, ATDF]
[F, 7845, 0, 34383145204380, 9138135, S, 100, WMW, 268800, CANT]
[F, 7845, 0, 34383145207174, 9138136, S, 100, WMW, 268800, TRIM]
[D, 7845, 0, 34383145238037, 8467825]
[D, 7845, 0, 34383145240887, 8467826]
[U, 7845, 0, 34383145288744, 8780722, 9138137, 500, 210300
To interpret the time stamp (col4) divide by 1 million and use the function
=TEXT(E6236/86400000,"hh:mm:ss.000") in excel to view it in milliseconds For example 34383145288744 becomes 09:33:03.145
Missing case for when the field is 2 bytes in length and is an integer. This is why you get non printable characters. Code currently treats it like a char.
Missing case for the time stamp. Code currently treats as 4 bytes Int. So it only treats 4 bytes not 6 leaving a much smaller number!
So switch statement should look something like:
switch ((Integer) fieldArray.get(0)) {
case 1:
value = (String) getChar(arr);
break;
case 2:
value = (String) getInt(arr);
break;
case 3:
value = (String) getString(arr, (Integer) fieldArray.get(1));
break;
case 4:
value = (String) getLong(arr);
break;
case 5: //for 2 byte integer
value = (String) getShort(arr);
break;
case 6: // for timestamp
value = (String) getArbitrayLengthNumber(arr);
break;
public Object getShort(byte[] payload) {
return Integer.toString(ByteBuffer.wrap(payload).getShort());
}
public Object getArbitrayLengthNumber(byte[] payload) {
long value = 0;
for (int i = 0; i < payload.length; i++)
{
value = (value << 8) + (payload[i] & 0xff);
}
return Long.toString(value);
}
Problems in your yaml file:
Missing message "N" which is the Retail Price Improvement indicator Section 4.7 You need this because the datasets are before it was discontinued. Program crashes and burns.
For message type ="K" you are missing the field tracking Number
The additional corrections to the yaml file are as follows (it's ok to leave the decimal changes out and it will run. )
formats:
- MessageType : [1,1]ok
- Timestamp : [2,6] should be integer length 6
- StockLocate : [1,2] should be integer length 2
- TrackingNumber : [1,2] should be integer length 2
- Stock : [3,8] ok
- Shares : [2,4] ok
- Price : [2,4] length is 4 but has 4 decimal places
- BuySellIndicator : [1,1]ok
- OrderReferenceNumber : [4,8]ok
- MatchNumber : [4,8]ok
- Attribution : [3,4]ok
- CanceledShares : [2,4]ok
- CrossPrice : [2,4] length is 4 but has 4 decimal places
- CrossShares : [4,8]ok
- CrossType : [1,1]ok
- CurrentReferencePrice : [2,4] length is 4, but has 4 decimal places
- EventCode : [1,1] ok
- ExecutedShares : [2,4] ok
- ExecutionPrice : [2,4] length is 4, but has 4 decimal places
- FarPrice : [2,4] length is 4, but has 4 decimal places
- FinancialStatusIndicator : [1,1]ok
- Imbalance : [4,8]ok
- ImbalanceDirection : [1,1]ok
- MPID : [3,4]ok
- MarketCatagory : [1,1]ok
- MarketMakerMode : [1,1]ok
- MarketParticipantState : [1,1]ok
- NearPrice : [2,4]length is 4, but has 4 decimal places
- NewOrderReferenceNumber : [4,8]ok
- OriginalOrderReferenceNumber : [4,8]ok
- PairedShares : [4,8]ok
- PriceVariationIndicator : [1,1]ok
- PrimaryMarketMaker : [1,1]ok
- Printable : [1,1]ok
- Reason : [3,4]ok
- RegSHOAction : [1,1]ok
- Reserved : [1,1]ok
- RoundLotSize : [2,4]ok
- RoundLotsOnly : [1,1]ok
- TradingState : [1,1]ok
- IssueClassification : [1,1]ok
- IssueSubType : [1,2]incorrect alpha two bytes length
- Authenticity : [1,1]ok
- SSThresholdIndicator : [1,1]ok
- IPOFlag : [1,1]ok
- LULD : [1,1]ok
- ETPFlag : [1,1]ok
- ETPFactor : [1,4]incorrect integer 4 bytes length
- InverseIndicator : [1,1]ok
- LocateCode : [1,2]incorrect integer 2 bytes length
- Level1 : [3,8]length is 8, but has 8 decimal places
- Level2 : [3,8]length is 8, but has 8 decimal places
- Level3 : [3,8]length is 8, but has 8 decimal places
- BreachedLevel : [1,1]ok
- IPOQuotRelTime : [1,4]incorrect integer 4 bytes length
- IPOQuotRelQual : [1,1]ok
- IPOPrice : [1,4] integer length is 4, but has 4 decimal places