Difference between revisions of "Install the Example Quote Source"
m (→Introduction) |
|||
(11 intermediate revisions by one other user not shown) | |||
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]] (below) that gets quotes from the [http://code.google.com/p/yahoo-finance-managed/wiki/YahooFinanceAPIs Yahoo! Finance API] and imports them into MS Money. Because the [[wikipedia:API | API]] used in the example does not return column headers to identify the fields in the [http://en.wikipedia.org/wiki/Comma-separated_values .csv] file, the example also includes an accompanying example schema file, [[#QuoteCSVSchema.csv]] below. |
− | + | QuoteCSV.py is a very simple [http://en.wikipedia.org/wiki/Python_script python script]. Python is the name of a high level computer scripting language and an [http://en.wikipedia.org/wiki/Interpreter_%28computing%29 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]] below. | |
+ | |||
+ | <blockquote>Testers: This is an advanced topic. This documentation can be improved. Please register on this wiki and fix any simple errors, or leave a note in the discussion tab for more complex issues.</blockquote> | ||
<h4>Instructions</h4> | <h4>Instructions</h4> | ||
− | * If necessary, download and install python. See [[#Installing Python]]. | + | * If necessary, download and install python and required python libraries. 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. | + | * 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. | * 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 ''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. | * Click the ''New'' button to start a new quote source. | ||
− | * Enter the fields according to the settings in [#YahooExtQuoteCSV Section] below. | + | * 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. | * Click ''Ok'' to save the settings and close the dialog. Observe that the new source is displayed in the ''Quote Source'' selector. | ||
− | * Hit Update | + | * Hit ''Update Now'' to launch the method and update the quotes. Observe a few windows flash open and close, and then the updated quotes and Total Value. Notice how fast it is -- only 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, which uses the same call for each symbol individually. |
<h4>Troubleshooting a.k.a. Debugging</h4> | <h4>Troubleshooting a.k.a. Debugging</h4> | ||
Line 23: | Line 25: | ||
* 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. | * 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 | + | External source settings are stored in ''PalOMoney.ini.'' PalOMoney saves PalOMoney.ini in the same folder as each Money file you open. |
− | * 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. | + | * 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 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. | * 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 | + | ** If there is no file, make sure you have permission to write to the python folder. |
** Make sure your internet connection is working. | ** Make sure your internet connection is working. | ||
− | ** Check and compare PalOMoney.ini [#MoneyPal | + | ** 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 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. | ** 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. | ** Hit ''View Logs'' on the Portfolio View window, and see what if anything has been recently written. | ||
+ | ** Look for common pitfalls. For example, the command interpreter requires that ''arguments'' that contain spaces or special characters (e.g., '&') be surrounded by double quotes. The following special characters require quotation marks: & < > [ ] { } ^ = ; ! ' + , ` ~ [white space] | ||
− | * Is the | + | * Is the QuoteCSVpy.csv output file Ok, but nothing has changed in the Portfolio View window? This might be correct behavior. 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'' | + | ** Hit ''View Logs'' and examine the recently written log files for clues. |
* Report a support issue on the [https://www.palomoney.com/forum/ Support Forum] or [https://www.palomoney.com/support/ Support Ticket System]. | * Report a support issue on the [https://www.palomoney.com/forum/ Support Forum] or [https://www.palomoney.com/support/ Support Ticket System]. | ||
Line 44: | Line 47: | ||
<h4>PalOMoney.ini with Example</h4> | <h4>PalOMoney.ini with Example</h4> | ||
− | Ini files store configuration in a human readable format. Ini files consist of <nowiki>[sections]</nowiki> enclosed in square brackets. Each section contains one or more | + | 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. |
+ | |||
+ | Ini files store configuration in a human readable format. Ini files consist of <nowiki>[sections]</nowiki> 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 its Value. Section and Key names are case insensitive, so "Settings" matches "settings". | ||
+ | |||
+ | Quote sources are stored in the <nowiki>[Quote Sources]</nowiki> 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. | ||
− | + | <h5>AlphaVantage Replaces Yahoo</h5> | |
+ | <b>Note:</b> As of the beginning of November, 2017, the Yahoo Finance APIs used below stopped working. See [[AlphaVantage Quote Source]]. Because of this, PalOMoney was updated to version 1.0.8, and MoneyPal was also updated to support AlphaVantage, and AlphaVantage.CSV has become the new default quote source. | ||
<h5>Quote Sources Section</h5> | <h5>Quote Sources Section</h5> | ||
<nowiki>[Quote Sources] | <nowiki>[Quote Sources] | ||
+ | AlphaVantage.CSV=AlphaVantage.CSV Section | ||
Finance.Yahoo.CSV=Finance.Yahoo.CSV Section | Finance.Yahoo.CSV=Finance.Yahoo.CSV Section | ||
Finance.Yahoo.YQL.XML=Finance.Yahoo.YQL.XML Section | Finance.Yahoo.YQL.XML=Finance.Yahoo.YQL.XML Section | ||
Line 56: | Line 65: | ||
YahooExtQuoteCSV=YahooExtQuoteCSV Section</nowiki> | YahooExtQuoteCSV=YahooExtQuoteCSV Section</nowiki> | ||
− | In this example, we see that the external source named "YahooExtQuoteCSV" stores its settings in the | + | In this example, we see that the external source named "YahooExtQuoteCSV" stores its settings in the [[#YahooExtQuoteCSV Section]. |
<h5>YahooExtQuoteCSV Section</h5> | <h5>YahooExtQuoteCSV Section</h5> | ||
Line 78: | Line 87: | ||
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. | 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. | ||
+ | |||
+ | * Notice that the ''AddOn'' is the python interpreter, not the script. The example script path and name is the first ''argument'' given to the python interpreter in the ''URL Template.'' Here this argument does not need quotes because it does not contain spaces or special characters. | ||
+ | |||
+ | * Notice that the second argument is quoted because it contains the '&' special character. | ||
<h5>MoneyPal Section</h5> | <h5>MoneyPal Section</h5> | ||
− | Open PalOMoney.ini in your MS Money folder, and find and compare [ | + | Open PalOMoney.ini in your MS Money folder, and find and compare <nowiki>[MoneyPal]</nowiki> section with the example below. It contains the ''Last External Launch'' and ''Last Launch'' keys. |
<nowiki>[MoneyPal] | <nowiki>[MoneyPal] | ||
Line 89: | Line 102: | ||
Debug Level=0 </nowiki> | Debug Level=0 </nowiki> | ||
+ | You can open a [[wikipedia:Command Prompt|Command Prompt]] window, copy, and paste these two lines directly at the command prompt, press Enter, and observe what happens. The Command Prompt window will stay open after each command has finished, so you can read whatever messages the commands produce. | ||
<h4>QuoteCSV.py</h4> | <h4>QuoteCSV.py</h4> | ||
Line 122: | Line 136: | ||
<h4>Installing Python</h4> | <h4>Installing Python</h4> | ||
− | 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 [http://www.python.org 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. | + | Windows does not include a python interpreter, but you can download and install one for free. [http://en.wikipedia.org/wiki/Python_%28programming_language%29 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 [http://www.python.org 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. |
Latest revision as of 23:15, 6 November 2017
Contents
Introduction
PalOMoney includes an example external quote source, #QuoteCSV.py (below) that gets quotes from the Yahoo! Finance API and imports them into MS Money. Because the 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 below.
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 below.
Testers: This is an advanced topic. This documentation can be improved. Please register on this wiki and fix any simple errors, or leave a note in the discussion tab for more complex issues.
Instructions
- If necessary, download and install python and required python libraries. 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 the updated quotes and Total Value. Notice how fast it is -- only 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, which 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.
- 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, 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.
- Look for common pitfalls. For example, the command interpreter requires that arguments that contain spaces or special characters (e.g., '&') be surrounded by double quotes. The following special characters require quotation marks: & < > [ ] { } ^ = ; ! ' + , ` ~ [white space]
- Is the QuoteCSVpy.csv output file Ok, but nothing has changed in the Portfolio View window? This might be correct behavior. 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 and examine the recently written log files for clues.
- Report a support issue on the Support Forum or Support Ticket System.
PalOMoney.ini with Example
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.
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 its Value. Section and Key names are case insensitive, so "Settings" matches "settings".
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.
AlphaVantage Replaces Yahoo
Note: As of the beginning of November, 2017, the Yahoo Finance APIs used below stopped working. See AlphaVantage Quote Source. Because of this, PalOMoney was updated to version 1.0.8, and MoneyPal was also updated to support AlphaVantage, and AlphaVantage.CSV has become the new default quote source.
Quote Sources Section
[Quote Sources] AlphaVantage.CSV=AlphaVantage.CSV Section 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.
- Notice that the AddOn is the python interpreter, not the script. The example script path and name is the first argument given to the python interpreter in the URL Template. Here this argument does not need quotes because it does not contain spaces or special characters.
- Notice that the second argument is quoted because it contains the '&' special character.
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
You can open a Command Prompt window, copy, and paste these two lines directly at the command prompt, press Enter, and observe what happens. The Command Prompt window will stay open after each command has finished, so you can read whatever messages the commands produce.
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.