Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

urlopen ftp error #1

Open
RiekertCodes opened this issue Jul 26, 2022 · 0 comments
Open

urlopen ftp error #1

RiekertCodes opened this issue Jul 26, 2022 · 0 comments

Comments

@RiekertCodes
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant