Difference between revisions of "Install the Example Quote Source"
m (→Introduction) |
(→Introduction) |
||
Line 1: | Line 1: | ||
==== Introduction ==== | ==== Introduction ==== | ||
− | PalOMoney includes an example external quote source, [[#QuoteCSV.py]] that gets quotes from Yahoo Finance and imports them into MS Money. | + | PalOMoney includes an example external quote source, [[#QuoteCSV.py]] that gets quotes from Yahoo Finance and imports them into MS Money. Because the Yahoo Finance API used in the example does not return column headers to identify the fields in the .csv file, the example also includes an accompanying example schema file, [[#QuoteCSVSchema.csv]]. |
− | + | QuoteCSV.py is a very simple ''python script.'' Python is the name of a high level computer scripting language and an ''interpreter'' program that executes the script. You might have a python interpreter already installed to use python solutions for updating MS Money quotes and bank statements, etc. If not, see [[#Installing Python]]. | |
<h4>Instructions</h4> | <h4>Instructions</h4> |
Revision as of 01:45, 25 January 2013
Contents
Introduction
PalOMoney includes an example external quote source, #QuoteCSV.py that gets quotes from Yahoo Finance and imports them into MS Money. Because the Yahoo Finance API used in the example does not return column headers to identify the fields in the .csv file, the example also includes an accompanying example schema file, #QuoteCSVSchema.csv.
QuoteCSV.py is a very simple python script. Python is the name of a high level computer scripting language and an interpreter program that executes the script. You might have a python interpreter already installed to use python solutions for updating MS Money quotes and bank statements, etc. If not, see #Installing Python.
Instructions
- If necessary, download and install python. See #Installing Python.
- Locate and copy QuoteCSV.py and QuoteCSVSchema.csv in the Program Files PalOMoney folder to your python folder (or elsewhere). Please try to keep the original files intact and in place should you need them in the future.
- Launch PalOMoney, and open a Money file. We will install the external quote source into this file's folder for use by all Money files in that folder.
- Click the Quote Sources button labeled "..." to the right of the Quote Source selector to open the Quote Sources dialog.
- Click the New button to start a new quote source.
- Enter the fields according to the settings in [#YahooExtQuoteCSV Section] below.
- Click Ok to save the settings and close the dialog. Observe that the new source is displayed in the Quote Source selector.
- Hit Update now to launch the method and update the quotes. Observe a few windows flash open and close, and then its done. Notice how fast it is -- about a second. This method is fast because it batches symbols together and calls the Yahoo API only once per batch, unlike the internal method that uses the same call for each symbol individually.
Troubleshooting a.k.a. Debugging
Too bad Siri doesn't work, otherwise we would just ask her to Fix it, Siri.
Try figure out what is going wrong. If you can't, that is a support issue that you should report on the Support Forum or Support Ticket System.
- Did a message dialog appear? PalOMoney has built in sanity checking for some common problems. If you get a dialog message, there's usually a simple problem with what you entered.
External source settings are stored in PalOMoney.ini. PalOMoney saves PalOMoney.ini in the same folder as each Money file you open. This means that if you are working with several Money files in different folders, you will have to install external quote sources in each folder. If you move your Money file, you can also move your PalOMoney.ini file as well to preserve the PalOMoney settings.
- To troubleshoot, locate and open PalOMoney.ini and verify that the settings at the end of the file match those in [#PalOMoney.ini with Example] below.
- Did any windows appear? If not, PalOMoney didn't launch the quote source. There could be a problem with your command interpreter. Check your Windows configuration.
- Did the method write its output file (QuoteCSVpy.csv)? Open the folder specified in the Output control, and see if the file exists, and open it with NotePad and look for some quote data.
- If there is no file, or no quotes, make sure you have permission to write to the python folder.
- Make sure your internet connection is working.
- Check and compare PalOMoney.ini [#MoneyPal section] below.
- Try pasting the URL portion of the Last External Launch command line into your browser address bar. You should see, or download, a .csv file with the desired quotes.
- Try pasting entire Last External Launch command line into a command prompt window in the python folder. It should create the output file.
- Hit View Logs on the Portfolio View window, and see what if anything has been recently written.
- Is the output file (QuoteCSVpy.csv) ok, but nothing changed? Keep in mind that PalOMoney does not update quotes that already have the same price. It should not create an new online quote if there is a correct online or manual quote already.
- Hit View Logs on the Portfolio View window, and see what if anything has been recently written.
- Report a support issue on the Support Forum or Support Ticket System.
PalOMoney.ini with Example
Ini files store configuration in a human readable format. Ini files consist of [sections] enclosed in square brackets. Each section contains one or more key=value pairs, stored one per line, with an equals sign separating the key and the value. Section names and keys are case insensitive, so "Settings" matches "settings".
The quote sources are stored in the [Quote Sources] section. The internal quote sources are listed first, followed by any installed external quote sources. The key is the name you have given the quote source. The value is the name of the section header containing the settings for that source.
Quote Sources Section
[Quote Sources] Finance.Yahoo.CSV=Finance.Yahoo.CSV Section Finance.Yahoo.YQL.XML=Finance.Yahoo.YQL.XML Section File.CSV=File.CSV Section File.YQL.XML=File.YQL.XML Section YahooExtQuoteCSV=YahooExtQuoteCSV Section
In this example, we see that the external source named "YahooExtQuoteCSV" stores its settings in the "YahooExtQuoteCSV Section."
YahooExtQuoteCSV Section
External quote sources are typically found the end of the PalOMoney.ini file. Here, we see the [YahooExtQuoteCSV Section].
[YahooExtQuoteCSV Section] Name=YahooExtQuoteCSV AddOn=c:\python27\python Output File=c:\python27\QuoteCSVpy.csv Output Format=0 Header Schema=0 Schema=c:\python27\QuoteCSVSchema.csv URL Template=c:\python27\QuoteCSV.py "http://finance.yahoo.com/d/quotes.csv?s=%s+&f=sl1d1t1" Request Tickers=20 Tickers in Output=1 Real Time=1 Historical=0 Login ID= Password=
The key values closely but not exactly correspond to the labels in the Quote Sources dialog. Put another way, every setting in the dialog is stored in this section.
MoneyPal Section
Open PalOMoney.ini in your MS Money folder, and find and compare [#MoneyPal section] with the example below. It contains the Last External Launch and Last Launch keys.
[MoneyPal] Last Launch="C:\Program Files\PalOMoney.com\PalOMoney\MoneyPal.exe" C:\Finance\k2008s.mny -s2 -fc:\python27\QuoteCSVpy.csv -cc:\python27\QuoteCSVSchema.csv Last External Launch=c:\python27\python c:\python27\QuoteCSV.py "http://finance.yahoo.com/d/quotes.csv?s=AAPL+GOOG+PSX+COH&f=sl1d1t1" c:\python27\QuoteCSVpy.csv Quotes Updated=2013/01/24 11:26 Debug Level=0
QuoteCSV.py
<code> import os, urllib2, sys argv = sys.argv if __name__=="__main__": if len(argv) < 3: print "Usage:",argv[0], "YahooURLSpec OutputFileName" if len(argv) > 0: print "1:", argv[1] if len(argv) > 1: print "2:", argv[2] sys.exit() #url = "http://finance.yahoo.com/d/quotes.csv?s=%s&f=nl1d1t1" % argv[1] url = argv[1] csv = urllib2.urlopen(url).read() f = file(argv[2],"w") f.write(csv) f.close() </code>
QuoteCSVSchema.csv
Of course, it is trivial to modify QuoteCSV.py to include the header line, but then we wouldn't have an example of a schema file to give you. Testers in particular should test using the separate schema file.
Ticker, Close, Date, Time
Installing Python
Windows does not include a python interpreter, but you can download and install one for free. Python comes in a multitude of versions, and the latest version is of course improved, but it does not work with older python scripts. The safest bet is to install version 2.7.3, which you can get at Python.org. Because the command interpreter is frequently used to execute python scripts, it is handy to install python just on your C drive root, say at C:\python27. You will also have to download and install python libraries (e.g., os and urllib is used by the example) to extend python's functionality.