Python script to download all NASDAQ and NYSE ticker symbols

Below is a short python script to get all NASDAQ and NYSE common stock tickers. You can then use the resulting file to get a lot of info using yahoofinance library.

#!/usr/bin/env python

import ftplib
import os
import re

# Connect to ftp.nasdaqtrader.com
ftp = ftplib.FTP('ftp.nasdaqtrader.com', 'anonymous', 'anonymous@debian.org')

# Download files nasdaqlisted.txt and otherlisted.txt from ftp.nasdaqtrader.com
for ficheiro in ["nasdaqlisted.txt", "otherlisted.txt"]:
        ftp.cwd("/SymbolDirectory")
        localfile = open(ficheiro, 'wb')
        ftp.retrbinary('RETR ' + ficheiro, localfile.write)
        localfile.close()
ftp.quit()

# Grep for common stock in nasdaqlisted.txt and otherlisted.txt
for ficheiro in ["nasdaqlisted.txt", "otherlisted.txt"]:
        localfile = open(ficheiro, 'r')
        for line in localfile:
                if re.search("Common Stock", line):
                        ticker = line.split("|")[0]
                        # Append tickers to file tickers.txt
                        open("tickers.txt","a+").write(ticker + "\n")

Satanic Route stage 6 Ponferrada to Compostela

Last entry of the Satanic route. Was supposed to be Ponferrada to Lugo, but I wanted to get home, so I decided to go all the way.
I left Ponferrada at around 1000, weather was good and the road was mostly flat. Good times were ahead, but first lets enjoy the warm up because Pedrafita was ahead, but I had almost 40 kms before facing it.

House in Cacabelos

House in Cacabelos


After Cacabelos, you pass through Trabadelo and Vega de Valcarce is the last town before going up through Pedrafita. I made a short stop in Vega de Valcarce adn asked whether to take the old road to Compostela or the N-IV and then turn left to Padornelo. Taking the N-IV adds up 5 kms to the trip, so I decided to take the old road.
Pedrafita is opened. No snow on sight.

Pedrafita is opened. No snow on sight.


Wrong big, huge fucked decesion. Should have taken the N-IV. The old road its like 3 kms uphill that never goes below 10%. That with 5kgs. in a back pack at 1400 in a sunny evening is a huge mistake.
Retablo publicity

Retablo publicity


Continue reading

Satanic Route stage 5 León to Ponferrada

So we are getting closer to Compostela, this stage takes us from León to Ponferrada. Short stage around 100 kms. IT was holiday the day I left León so there was no traffic at all. I crossed myself with the bullring of León.

Leon bullring

Leon bullring


Arriving to Astorga is quite easy, flat 45 kms, good road and many cyclist too. Now I really liked Astorga, I was never there before and I really liked it. The cathedral is really worth a visit and the Episcopal palace too.
Cathedral entrance

Cathedral entrance


Cathedral and Episcopal Palace

Cathedral and Episcopal Palace


Continue reading

Satanic route stage 4 Burgos to León

So stage four is going from Burgos to Leõn. Wake up at around 830 in the morning, have breakfast at local coffe shop close to the hotel, back to the hotel and started cycling at around 900.

Leaving Burgos

Leaving Burgos

After leaving Burgos its mostly emptiness, no traffic on N-120, most of the cars use the highway so the whole road was for me.
Emptiness ahead

Emptiness ahead

Had I known it was gonna be like this in Burgos I would have taken a train to León in Burgos. I was lucky there were clouds in the sky and temperature was around 20C. First stop I made was in Osorno, not much to see there asides from a fascist monument.
Osorno La Mayor

Osorno La Mayor

After stopping at Osorno for 15 minutes to refill the water bottles I went on towards Carrión de Los Condes, which was like 40 kms away. Flat terrain too all the way but after Carrión de Los Condes I realized terrain was not so dry, but greener. Another 40 kms until Sahagún where I decided I was gonna have lunch. Ride kept on being boring and almost without traffic, maybe one car every ten minutes or so. Anyway, there were moments were I could listen to me pedal strokes, my breathing, enjoy the Sun on my face and that was nice.

At Sahagún I made a long stop (about an hour). Needed to eat something asides from energy bars after around 150 kms. Not much to see in Sahagún either, but you could certainly see the increase in the amount of pilgrims heading to Compostela. So after Sahagún I went to Leó, which was like 50 kms away. At this time I was really eager to arrive to Le&oacunte;n. Theres a cross were you leave N-120 to take N-601. I made another stop in Matallana de Madrigal to buy some water, but got back on the road really fast because there were thunderstorms and I didnt wanted to get wet. And after a flat and mostly boring stage I arrived to León at around 1930.

Almost 8 hours later

Almost 8 hours later

Well deserved bath at the hotel and quick dinner at a local bar (typical spanich look). I was back at the hotel before 2200 to see another MasterChef episode.
Dried spanish bull

Dried spanish bull

Tomorrow was gonna be another day.

Strava file here.

Satanic route stage 3 Gasteiz to Burgos

So stage 3 says good bye to Euskal Herria and hello to Castile. Wake up early in Gasteiz and after a quick breakfast I was heading to Miranda de Ebro through Treviño, which is inside Euskal Herria even when it belongs to Castile. After getting lost through Gasteiz and asking the locals how to head to Treviño I had to face Zaldiaran. No big deal, easy and short port I even had time to ask another cyclist how to head to Treviño. “Straight ahead” he said.

Short visit to Mendizorroza exiting Gasteiz

Mendizorroza stadium. Home of Deportivo Alaves

Mendizorroza stadium. Home of Deportivo Alaves

After arriving to Treviño the direction to Miranda de Ebro is clearly indicated. Nothing worth seeing in Treviñ, or at least I didn’t saw anything. After around an hour of cycling we arrive to Miranda de Ebro. Almost no traffic around the road. Easy route so far.

Miranda de Ebro arrival.

Entering Miranda de Ebro

Entering Miranda de Ebro

In Miranda I stopped to rest, inflate the bike and buy some food for the kms ahead. On the out of Miranda de Ebro we need to climb La Ventilla, another easy port which takes us to La Rioja.

Nice views from the top of La Ventilla.

Nice views from the top of La Ventilla.

Flat land ahead and we head to Tirgo in our direction towards Belorado. We stopped in Tirgo to refill the water bottles and I was able to chat a little with the locals. Looked to me like there’s not a lot to do at Tirgo asides from working the vineyards.

Locals at Tirgo protecting from the Sun.

Locals at Tirgo protecting from the Sun.

As of now there was little traffic on the road, which was something really nice. So we leave Tirgo heading to Belorado. Mostly flat terrain now, a little boring too. This is expected as Castile is famous for its flat places. On my way to Belorado I took the wrong road and was heading to Santo Domingo de La Calzada, luckily I went back about 5 kms and took the right road. I arrived at Belorado at around 1430.

Entrance to Belorado

Entrance to Belorado

Lunch time

Lunch time

So after lunch I ride again to Burgos. Burgos is around 60 kms away from Belorado and its mostly flat except for La Pedraja. Easy port, but there is a lot of traffic on the road. Many trucks use it to go from Logroño to Burgos.

La Pedraja, done too.

La Pedraja, done too.


On your way to Burgos, you pass close to Atapuerca archeological site.
Atapuerca archeological site.

Atapuerca archeological site.


And after passing through an industrial site we arrive to Burgos.
Mio Cid

Mio Cid


Hotel was pretty close so after a well deserved shower I went out for a walk and found this place called Bar El Patillas. Really authentic place, two beers and a couple of photos.
Bar El Patillas

Bar El Patillas

This ain't Mc'Donalds

This ain’t Mc’Donalds


I went out for dinner and found that the river Arlanzón flooded the city some years ago.
River grew this much

River grew this much


It was a rainy night and there was not much going on so I went back to the hotel to catch some well deserved rest.

Strava file here. Part from Gasteiz to Miranda de Ebro is missing. For some weird reason Garmin misbehaved and I had to start it again.