Like most people, I'm more than annoyed with the Intuit "sunset" policy that prevents Quicken users from downloading data after a few years of use.
I recently installed TurboTax, and was appalled to find that it had a bug that causes it to crash. Several other people have experienced the same crash. Last year, two family members lost all their data during TurboTax crashes.
So, I'm not big on buying more software from Intuit, but I do want to keep getting stock quotes, at least until GNUcash (which has massive dependency issues on OSX) or jgnash or Grisbi get far enough along.
I found several scripts that do most of the job, but decided I'd just make my own. Feel free to use it if you'd like. No warranty, use at your own risk. It works for me.
It's written to use zsh and tested on OSX 10.3.9. It will probably work on most Unix platforms with zsh-like shell environments - it doesn't use any particularly unique zsh components.
It's meant to be used from the command line. You could pretty easily trigger it from a cron job, to get the quotes on a regular basis. The name of each qif file is unique (it has the date and time in the name).
Before you use it, you should make a file called ~/stocknames that contains the symbols for the stocks you want to download. Save this script and run it from the command line, for example:
$ ./getstockquotes
You can give it one or two dates, if you want to retrieve historical data. If you don't give any dates, you get the current data.
Copy the text below into a blank file. Save the file as getstockquotes, then set the execute bit by typing chmod u+x getstockquotes
Here it is:
#!/bin/zsh
#
# getstockquotes < startdate enddate >
# Gets stock quotes from yahoo finance and saves them in a qif file.
#
# version 1.0 2007-02-11
#
# The stock symbols you want to download should
# be put in a file called ~/stocknames
#
USAGE='getstockquotes < startdate < enddate > >
date format=yyyymmdd
The resulting file, quotes_xxx.qif or table_xxx.qif
can be imported into programs that understand qif files'
# If you specified a date or two, get historical data.
now=`date +%Y%m%d%H%M%S`
if < $# -gt 2 >; then
echo $USAGE
echo Too many parameters.
exit
elif < ! -r ~/stocknames >; then
echo $USAGE
echo ~/stocknames is not readable
exit
elif < $# -gt 0 >; then
if < "$1" = "-h" >; then
echo $USAGE
exit
fi
# Massage the given dates into the form yahoo wants them
start=$1
# If you only give one date, the end date is assumed to be the current date.
if < $# -eq 1 >; then
end=`date +%Y%m%d`
else
end=$2
fi
startyear=`echo $start|cut -c1-4`
sm=`echo $start|cut -c5-6`
# Yahoo months are numbered from zero, not one
let startmonth=$sm-1
startday=`echo $start|cut -c7-8`
endyear=`echo $end|cut -c1-4`
sm=`echo $end|cut -c5-6`
let endmonth=$sm-1
endday=`echo $end|cut -c7-8`
# Quicken wants DOS line endings (hex 0D0A)
# so we put a ^M (0D, \r) just before the Unix line ending (0A).
echo "!Type:Prices\r" > table_$now.qif
# Yahoo won't give multiple quotes for historical data
Re: Script to download stock quotes and history Feb 18, 2007 01:25 pm
re: "Uncle Foobar"'s naive comment
I won't waste my time pulling out a half-dozen links from people who have lost all their data after doing a TurboTax update this year. At least one of them had a backup copy on another (apparently connected) disk, and lost that copy, too.
You might want to look in to a problem more closely before writing demeaning comments about others.
Personally, I print all my interim results to a .pdf. TT is less likely to find and delete a .pdf.
But your comment also has nothing to do with this thread. Hopefully, others will provide feedback on the topic.
Script to download stock quotes and history: Like most people, I'm more than annoyed with the Intuit "sunset" policy that...
I apologize but I am a novice with scripts. Can someone give me the instructions on how I can load & execute this script? I have "lost" some historical pricing beyond 5 years and need to get the info reloaded in an automated fashion.
Would appreciate any advice/suggestions or alternative approaches.
Re: Script to download stock quotes and history: re: "Uncle Foobar"'s naive commentI won't waste my time pulling out...
I tried this script and got the error:
sbin/getstockquotes:33: parse error near `;'
I tried the stocknames with each stock separated by a semicolon and with each stock on a separate line.
I used stock sympbols from Yahoo eg: BSN.TO and REI-UN.TO
Has anybody got this script working ?
Cheers
Re: Script to download stock quotes and history: Hi Fuzzy_1 I think that some of the characters got...
Thanks msienkiewicz,
I downloaded the file and it works great.
Now if we could get mutual funds working.
I can get quotes of canadian mutal funds from an excel spreadsheet using a Web Query which gets the data from MSN Money. the query is <http://moneycentral.msn.com/investor/external/excel/quotes.asp?SYMBOL=CA:PHN150;CA:CHO100> to get two quotes. Can you creat a QIF file from an excel spreadsheet? or can this query be used in the aformentioned script?
Re: Script to download stock quotes and history: Thanks msienkiewicz,
I downloaded the file and it works great.
Now if...
The format for a stock quote QIF file is simple, you should be able to create it from an Excel spreadsheet. I use a Google spreadsheet to track company stock funds in my retirement account and export a CSV file that I use to import the prices into Quicken.
You would modify the sheet so that the 1st line says
"!Type:Prices" and the following lines contain
Stock Symbol, Price, Date (and optionally High, Low,Volume) Then the last line of the sheet should have '^' in the first column. If you export to CSV (comma delimited values) the file should have the right format to import to Quicken. After exporting you may need to open the file in a text editor and make sure that the last column is '^' followed by a carriage return.
Since you said the 'getstockquote' script worked fine, you should have an example of the QIF format. Also see in the Quicken manual, chapter 15, under "Importing a price file into Quicken".
Script to download stock quotes and history Mar 17, 2008 06:49 pm
This post is about: Quicken Mac 2008
Does anyone have a tweak for this script that will ignore errors due to bad ticker symbols in the file "stocknames"?
I track LOTS of securities (bonds and the like) in Quicken and I have to use dummy symbols to keep the manually-entered security price history straight. Additionally, stocks are regularly delisted and the symbols disappear.
These ultimately end up in "stocknames" and it causes big time errors in the output file. I've attached a file that results, for instance, from the non-existent symbol, ABYNY.