In order to extend the life of Q2001, I have written a small python script
to download selected quotes from finance.yahoo.com, format them a little
for quicken's benefit, and merge them into a cumulative quote file for
later import into quicken.
I schedule this script to run once each day in the evening and then can
import the quote file at my leisure into quicken. After importing the
quote file, I delete it so it will start over the next day.
It requires python 2.3 or better, freely available for windows, linux, the
Mac, and others from http://www.python.org.
If you want to try this script, you will need to change the 'symbols'
variable in line 9 to your ticker symbols. This variable should be
formatted as shown, with each symbol in quotes, comma separated, enclosed
in []. The 'quotefile' variable in line 14 is the cumulative import file
it builds.
Feel free to use this - I've only used it with Q2001, so I can't vouch for
other quicken versions, but as long as the quote import format didn't
change, it should work.
Paste the text below into a text editor (the #!/usr/bin... line should be
the first line) and save it as "whatever.py" or you can get it here:
http://bookex.home.comcast.net/quotes.py
John
#!/usr/bin/env python
## Retrieve stock quotes from finance.yahoo.com and format them for
## import into Quicken
import sys, os, urllib, time
## Funds/stocks we will download:
symbols = [ 'MSFT', 'IBM', 'YHOO', 'INTU',
'GOOG' ]
urlprefix = 'http://finance.yahoo.com/d/quotes.csv?s='
urlsuffix = '&f=sl1d1t1c1ohgv&e=.csv'
quotefile = 'c:/quotes.csv'
def addquotes( s ):
""" add quotes (") to the input string """
if s.startswith('"'): return s
else: return '"' + s + '"'
# import pdb; pdb.set_trace()
quotes = []
if os.path.exists( quotefile ):
qfile = file( quotefile, 'r' )
quotes = qfile.readlines()
qfile.close
urls = ''
for symbol in symbols:
urls += ( symbol + '+' )
# download the quotes from yahoo:
url = urlprefix + urls[:-1] + urlsuffix
infile = urllib.urlopen( url )
# for each line downloaded from yahoo, scan the cumulative 'quotefile'
# for the same ticker symbol and quote date. If we find one, replace the
# old quote with the newest one from yahoo:
for line in infile:
fields = line.split( ',' )
# build a line of: "symbol","price","date"
fields = [ addquotes(x) for x in fields[0:3] ]
line = ",".join( fields ) + "\n"
found = False
for qx, quot in enumerate( quotes ):
qfields = quot.rstrip('\n').split( ',' )
if qfields[0] == fields[0] and qfields[2] == fields[2]:
# replace a duplicate with an updated line:
quotes[qx] = line
found = True
break
# if we didn't find this line in the quotes.csv file, append
# it to the end:
if not found:
quotes.append( line )
infile.close()
qfile = file( quotefile, 'w+' )
qfile.writelines( quotes )
qfile.close()
print 'done'
ps,
don't leave, I'll be asking for your help....
prediction- I think you are going to become very popular between now and
April
> Good job! I have 0 programming experience. I better start experimenting
> with this now so hopefully by April when intuit cuts us lose I'll have it
> working...
>
Joe,
Thanks for the response.
Being a lurker here, I was beginning to wonder if anyone was going to try
it.
As a follow-up, I advise you to download the script from the url
( http://bookex.home.comcast.net/quotes.py ) and don't try to paste the
text from the OP into an editor.
Somewhere in the process of copy/pasting from my pc to usenet, some of the
white space characters in the script were changed - it looks like tabs
changed to blanks for example. Python doesn't like this, and when I tried
to cut/paste from the post and run it, python complained.
The copy at the url has all the white space preserved and should run
correctly.
Please reply if you have any problems
John
"Section8" <jdmo...@nospam.comcast.net> wrote in message
news:8_mdnRretY3...@comcast.com...
TIA,
Joe
"Section8" <jdmo...@nospam.comcast.net> wrote in message
news:8_mdnRretY3...@comcast.com...
Anyway, I have it updating Quicken by way of File\Import\Import Prices, I
think my problem was I had the most update to date prices to start with,, I
did a restore from a slightly older backup and that let me update from the
"quotes.csv", now I just have to make sure I'm accessing & saving the Pyton
script properly. I guess it's just a matter of some fine tuning
Thank you again!
"Section8" <jdmo...@nospam.comcast.net> wrote in message
news:8_mdnRretY3...@comcast.com...
> I assume I copied the info correctly because the quote.csv is updating
> with my quotes. How do you actually get the script to update Q2001? how &
> where do you save the new script? Do you have to rename the script with a
> PY extension and open it from Q2001?
>
>
Joe,
Sorry for the confusion.
On most systems (windows at least), the script should be named with a .py
extension so windows will automatically run it in the python interpreter -
if you double click it or put a shortcut to it on your desktop.
Quicken doesn't interact directly with the script - you import the file the
script builds into quicken.
To import the quotes into quicken, open the portfolio view in quicken (Main
menu/Investing/Portfolio view) and then go to File menu/Import/Import
prices and give it the .csv file the script creates.
This script will be most useful to you if you want to keep a daily history
of security prices in your quicken portfolio. Each day you run it, it will
add that day's prices into the quotes.csv file. If you can schedule it to
run every day, (in the windows task scheduler, or cron in linux), you won't
have to do anything to have your stock prices downloaded daily. You can
just import the csv file into quicken whenever you get around to it.
"Section8" <jdmo...@nospam.comcast.net> wrote in message
news:0_idnf08raG...@comcast.com...