Skip to content

urlopen ftp error #1

@RiekertCodes

Description

@RiekertCodes

Good day,
Im trying to run this code to download the order messages , but I run into this error "URLError: <urlopen error ftp error: TimeoutError(10060, 'A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond', None, 10060, None)>"
Heres my code I used
`
import numpy as np
import pandas as pd
from collections import Counter
from datetime import timedelta
from pathlib import Path
import gzip
import shutil
from pathlib import Path
from urllib.request import urlretrieve
import urllib.parse
FTP_URL = 'ftp://emi.nasdaq.com/ITCH/Nasdaq_ITCH/'
SOURCE_FILE = '01302019.NASDAQ_ITCH50.gz'
data_path = Path('data')
itch_store=str(data_path/'itch.h5')
order_book_store = data_path/'order_book.h5'

def may_be_download(url):
"""Download & unzip ITCH data if not yet available"""
filename = data_path / url.split('/')[-1]
if not data_path.exists():
print('Creating directory')
data_path.mkdir()
if not filename.exists():
print('Downloading...', url)
urlretrieve(url, filename)
unzipped = data_path / (filename.stem + '.bin')
if not (data_path / unzipped).exists():
print('Unzipping to', unzipped)
with gzip.open(str(filename), 'rb') as f_in:
with open(unzipped, 'wb') as f_out:
shutil.copyfileobj(f_in, f_out)
return unzipped

file_name = may_be_download(urllib.parse.urljoin(FTP_URL, SOURCE_FILE))
date = file_name.name.split('.')[0]
`
Any help would be appreciated to fix this

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions