Chapter 2 NASDAQ ITCH Data

I get the following error when I try to run the codes for chapter 2, processing Nasdaq ITCH data:

Start of Messages
3:02:31.647283 8,265,631

Start of System Hours
4:00:00.000203 8,265,632

error Traceback (most recent call last)
in
10
11 record = data.read(message_size - 1)
—> 12 message = message_fields[message_type]._make(unpack(fstring[message_type], record))
13 messages[message_type].append(message)
14

error: unpack requires a buffer of 18 bytes

How can I solve this problem, and what is the problem exactly?

Hi,
How did you pass the download part?
I didn’t even got the downloads part starting.

Hi,
I actually used the following code, I found the same issue somewhere I do not know anymore, the problem was something with an update from Nasdaq side, so this code should fix it:

FTP_URL = ‘ftp://emi.nasdaq.com/ITCH/Nasdaq ITCH/’
SOURCE_FILE = ‘10302019.NASDAQ_ITCH50.gz’

1 Like

Hi @MAB
May be you can try this :

def unpack_helper(fmt, data):
    size = calcsize(fmt)
    if (len(data) < size):
        record = (data+data[0:calcsize(fmt)-len(data)]).decode('latin1').encode('utf-8')
        return unpack(fmt, record[:size])
    return unpack(fmt, data[:size])

And

message = message_fields[message_type]._make(unpack_helper(fstring[message_type], record))