SMF Addin Documentation
SMF Addin Documentation
Stock Market Functions Add-In Overview .......................................................................................... 2 Documentation for RCHGetElementNumber() function .................................................................... 5 Documentation for smfGetAdvFNElement() function ........................................................................ 8 Documentation for RCHGetYahooQuotes() function ....................................................................... 10 Documentation for smfGetOptionQuotes() function ......................................................................... 14 Documentation for smfGetYahooOptionQuote() function................................................................ 20 Documentation for smfGetMSNOptionQuote() function .................................................................. 22 Documentation for smfGetOXOptionQuote() function ..................................................................... 24 Documentation for smfGetOptionExpiry() function ......................................................................... 26 Documentation for RCHGetYahooHistory() function ...................................................................... 28 Documentation for smfPricesBetween() function .............................................................................. 31 Documentation for smfPricesByDates() function ............................................................................... 34 Documentation for RCHGetHTMLTable() function ........................................................................ 36 Documentation for RCHGetTableCell() function .............................................................................. 38 Documentation for RCHGetWebData() function .............................................................................. 42 Documentation for smfGetCSVFile() function................................................................................... 44 Documentation for smfGetEconData() function ................................................................................ 46 Documentation for smfGetTagContent() function ............................................................................. 48 Documentation for RCHCreateComment() function ........................................................................ 50 Documentation for smfTech() function ............................................................................................... 52 Documentation for smfStrExtr() function .......................................................................................... 54 Stock Market Functions Add-In Change Log .................................................................................... 55
How do I install the add-in? First step would be to create this directory on your computer: C:\Program Files\SMF Add-In Next, you'd download the current ZIP archive of the add-in from this group's files area into that directory and extract all of the files from the ZIP archive there. Then, you'd need to tell EXCEL to use it. In EXCEL 2002, that process is: 1. Open a new workbook 2. Use menu option > Tools > Add-Ins > Browse 3. Browse to the XLA file that was extracted from the ZIP archive and double-click on it That should be all you need to do. Note -- the reason a non-standard add-in path was used above is to ease sharing of workbooks that use the add-in. Because of how EXCEL saves UDF (User Defined Function) formula usage, sharing works best if the add-in is located in the same location on both the computer that created the workbook and the computer that is opening the workbook. If you don't use the recommended directory above, the add-in will still work, but you will have to manually update workbook links when you open any workbook created by someone who had their version of the add-in located elsewhere. Also, older versions of EXCEL treat add-in locations differently, so they may require you to manually locate the add-in when opening up a workbook created on another machine. In many cases, saving the workbook on your machine first may ease the resolution of this location problem. Here are several illustrated descriptions of how to install an EXCEL add-in: http://www.bettersolutions.com/excel/ECA723/LD023821888.htm http://www.dslimited.biz/excel_tutorials/installadd-in.html
What does the add-in do? There are five primary user-defined functions that the SMF add-in provides:
=RCHGetElementNumber() is a UDF that returns a specific data element from a specified data source (i.e. web page). For example, this formula would return the Market Capitalization amount from Yahoo's Key Statistics page for ticker "IBM": =RCHGetElementNumber("IBM", 941) More detailed documentation on the RCHGetElementNumber() function can be found here: 2.0 - RCHGetElementNumber.html
=RCHGetTableCell() is a UDF that extracts a specific data element from a specified web page. Most RCHGetElementNumber() functions are actually just an RCHGetTableCell() function with the parameters saved and assigned to an element number. For example, this formula would return the Market Capitalization amount from Yahoo's Key Statistics page for ticker "IBM": =RCHGetTableCell("http://finance.yahoo.com/q/ks?s=IBM",1,">Market Cap") More detailed documentation on the RCHGetTableCell() function can be found here: 5.1 - RCHGetTableCell.html
=RCHGetYahooQuotes() is a UDF that returns delayed stock quotes and other data from the Yahoo quotes interface. For example, this formula would return a range of data showing the last trading price, the price/sales ratio, and the price/book ratio for "IBM" and "MMM": =RCHGetYahooQuotes("IBM,MMM", "l1p5p6") More detailed documentation on the RCHGetYahooQuotes() function can be found here: 3.0 - RCHGetYahooQuotes.html
=RCHGetYahooHistory() is a UDF that returns historical stock quotes from the Yahoo historical quotes interface. For example, this formula would return a range of data containing historical quotes data from 6/1/2006 thru 6/16/2006 for "IBM": =RCHGetYahooHistory("IBM", 2006, 6, 1, 2006, 6, 16) More detailed documentation on the RCHGetYahooHistory() function can be found here: 4.0 - RCHGetYahooHistory.html
=RCHGetHTMLTable() is a UDF that is used to extract an HTML table from a web page. For example, this formula would return a range of data containing a table from
Yahoo's Key Statistics page: =RCHGetHTMLTable("http://finance.yahoo.com/q/ks?s=MMM","Market Cap (intraday)",-1,"",1) More detailed documentation on the RCHGetHTMLTable() function can be found here: 5.0 - RCHGetHTMLTable.html If you check the "Documentation" folder of the files area of the group, you'll find documentation on a number of other functions. Also, the "Links" area of the group contains links to messages with frequently asked questions and tips on using the add-in.
elementnumber = A number specifying which data element is to be retrieved for a ticker symbol. A list of element numbers and the data sources and data elements they are related to can be found in the RCHGetElementNumber-ElementDefinitions.xls workbook distributed with the add-in. errorvalue = A string or numeric value to be returned if there is an error in finding the data element. A default value of "error" is used if nothing is passed. This can prevent needing to put IF() statements in a cell to make a display or calculation of items easier to read.
Examples Example Formula Value Returned Description Tells you which version of the add-in you are using. Gives you the data source for element number 941 Gives you the element name for element number 941
element number 941 is retrieved from ("~~~~~" is the ticker symbol) =RCHGetElementNumber("IBM", 941) Market Capitalization from data source "YahooKS" for ticker "IBM" Market Capitalization from data source "MSN" for ticker "IBM"
119,670,000
=RCHGetElementNumber("IBM", 1541)
119,670,000,000
RCHGetTableCe http://finance.yahoo.com/q/ks?s=~~~ ll() function ~~ parameter 1 RCHGetTableCe ll() function parameter RCHGetTableCe ll() function parameter RCHGetTableCe ll() function parameter RCHGetTableCe ll() function parameter RCHGetTableCe ll() function parameter 0 RCHGetTableCe ll() function parameter RCHGetTableCe ll() function parameter RCHGetTableCe ll() function parameter
VALUATION MEASURES
MARKET CAP
=RCHGetElementNumber("PType",941)
Usage notes
When elements are retrieved, the source code of the web page is saved in an array within the VBA environment, then the element is extracted from that source code. It is done that way so that when a number of elements are retrieved from the same web page, the web page only needs to be retrieved once. Note that the array to save web pages is limited to 1000 pages. Anything beyond that will get an error message. The entire array can be reset by either exiting and re-entering EXCEL or by running the smfForceRecalculation macro. This macro purges all saved web pages and reacalculates all functions. ...coming later...
Find1
Find1
ErrorMsg = An optional string or numeric value to be returned if there is an error in finding the data element. A default value of "Error" is used if nothing is passed. This can prevent needing to put IF() statements in a cell to make a display or calculation of items easier to read. Type = An optional integer value to determine the type of Internet request to make. Defaults to 0. For now, other values are experimental: 0 = XMLHTTP "Get" Request 1 = IE Object Request 2 = HTMLDocument Request
To get the four most recent year-end dates from the annual financials: =smfGetAdvFNElement("MMM","A",1,">Year End Date<") =smfGetAdvFNElement("MMM","A",2,">Year End Date<") =smfGetAdvFNElement("MMM","A",3,">Year End Date<") =smfGetAdvFNElement("MMM","A",4,">Year End Date<")
To find out the number of annual periods that AdvFn has: =smfGetAdvFNElement("MMM","A",999)
Usage notes
When elements are retrieved, the source code of the web page is saved in an array within the VBA environment, then the element is extracted from that source code. It is done that way so that when a number of elements are retrieved from the same web page, the web page only needs to be retrieved once. Note that the array to save web pages is limited to 1000 pages. Anything beyond that will get an error message. The entire array can be reset by either exiting and re-entering EXCEL or by running the smfForceRecalculation macro. This macro purges all saved web pages and reacalculates all functions. ...coming later...
Cod Descripti Cod Cod Descripti Cod Descripti Cod Descripti Description e on e e on e on e on Market j1 Capitalizati on Average a2 Daily Volume 1yr t8 Target Price EPS Est. e9 Next Quarter EPS Est. e7 Current Yr EPS Est. e8 Next Year Last Trade k1 (ECN with Time) b3 Bid (ECN) Ask (ECN) Change (ECN)
Symbol
b2
Open
p5 Price/Sales
c6
10
High
p6 Price/Book
Day's Value w4 Change (ECN) After Hours c8 Change (ECN) Market j3 Cap (ECN) P/E (ECN)
Low
b4 Book Value
Exchange
P/E Ratio
Pct Chg Earnings/Sh From 52k5 are week High 50-day m3 Moving Avg Change From 50m7 day Moving Avg Pct Chg From 50m8 day Moving Avg 200-day m4 Moving Avg Change From m5 200-day Moving Avg Pct Chg From m6 200-day Moving Avg
r2
j4 EBITDA
Change & k2 Percent (ECN) Holdings v7 Value (ECN) Holdings Gain & g5 Percent (ECN) Holdings g6 Gain (ECN) Day's m2 Range (ECN)
s7 Short Ratio
Dividend/S hare
Dividend Yield
c1 Change
r1
p2
Percent Change
ExDividend Date
11
c v m j k w b
Change & Percent Volume Day's Range 52-week Low 52-week High 52-week Range Bid Option Quote Additions Cod Description e o1 p3 e3 Open interest? Type of option Expiration date Name of option
s3 Strike price n
a5 Ask Size serverid = An optional parameter to specify the country id of an alternative Yahoo Quotes server. The default is a null string, which uses the normal server. From what I've seen on Yahoo, I believe these values can be specified: Server ID Yahoo Quotes Server For ar au br ca cf cn de es fr hk in it jp Argentina Australia and New Zealand Brazil Canada French Canada China Germany Spain France Hong Kong India Italy Japan
chinese Chinese
12
kr sg uk refresh
= An optional parameter that allows automatic refreshing of quotes via the F9 key (i.e. "recalculate"). All you need to do is pass "NOW()" as the value of this parameter to activate a refresh capability. Basically, all it does is cause a change in parameter values, which makes the function recalculate. = An optional parameter that allows column headings to be generated for the returned columns of data.
headers
Examples
This would return the default data items for ticker symbol IBM: =RCHGetYahooQuotes("IBM")
This would return updated default data items for ticker symbol IBM each time F9 was pressed: =RCHGetYahooQuotes("IBM",,,NOW())
This would return default data items for ticker symbol IBM with columns headings on the returned data: =RCHGetYahooQuotes("IBM",,,,1)
An step-by-step example of creating a current quotes table can be found here. ...more to come
Usage notes
In most cases, this will need to be an array-entered formula. To array-enter a formula in EXCEL, first highlight the range of cells where you would like the returned data to appear -- the number of rows for the range should be AT LEAST the number of ticker symbols you are requesting from the function, while the number of columns for the range should be AT LEAST the number of data items you are requesting for each ticker symbol from the function. Next, enter your formula and then press Ctrl-Shift-Enter. ...more to come
13
Note that week-end and quarter-end option expirations are only available for a limited number of equities. Expiration Year = A 4-digit expiration year (e.g. "2010"). Strike Price = The desired strike price, either with or without a leading dollar sign. In addition, you can use values like "OTM1", "OTM2", "ITM1", or "ITM2" to get the first or second inthe-money or out-of-the-money strike prices (currently
14
Call/Put
only available for Yahoo and MarketWatch data sources). = A literal value of "Put" or "Call" to indicate the type of option data that is desired. Can be abbreviated to "P" or "C".
datacodelist = A list of data codes telling indicating which data elements you want retrieved. This list can either be a string concatenation of all desired data codes, a cell reference, or a range reference. Here is a table indicating the data codes available from the various data sources: Data sources Code Description % a b c e f g h i j k l o p s t u v x y z 1 2 3 4 % Change Ask Price Bid Price $ Change Bid Size Ask Size Daily Low Daily High Open Interest Contract Low Contract High Last Price Open Price Previous Close Strike Price Last Trade Time Volume Expiration Date Time/Theo. Value Option Symbol Vega Theta Rho Gamma (1) (2) (3) (4) (5) -- -- -- -Y MSN OX MW OX2 -Fast ----- -- -- -Fast Fast Fast Fast Fast -- -- -- -Fast Fast Fast Fast Fast -- -- -- -Slow Fast ---Fast Fast -- -- -- ----------Fast ----------------------- -- -- --- -- -- --- -- -- --- -- -- --- -- -- --- -- -- --- -- -- --- -- -- --- -- -- --- -- -- --- -- -- --- -- -- --- -- -- --- -- -- --- -- -- --- -- -- -Slow -Slow --
Fast Fast Fast Fast Fast -- -- -- -Slow Slow -Slow Slow -Slow Slow -Fast Fast -------
Underlying Equity Price Fast Fast Fast Fast Fast -- -- -- -Fast Fast Fast Fast Fast -- -- -- -Fast Fast ----Fast Fast Fast Fast Fast Fast Fast Fast Fast -- -- -- --
15
5 6
---
---
Fast --
---
Fast -- -- -- -Fast -- -- -- --
The difference between the "Fast" and "Slow" data items is that you can retrieve all of the "Fast" items for all of the different options in the same expiration month with a single Internet access, while the "Slow" data items require a new Internet access for each individual option for which the various items are collected. Note that all option months are retrieved by MarketWatch on a single Internet access. This can be a slower way to get the data if you only need a single expiration date, but a faster way to get the data if you need multiple expiration dates. headers = An optional parameter that allows column headings to be generated for the returned columns of data. Defaults to 0. Set to 1 if you desire a row of headers to be displayed. = An optional parameter that indicates the source you want to use for options data. Defaults to "Y". Possible values: Value "DataCode" Data Source prefix MSN 2 MSN MW OX OX2 Y 2 4 3 5 1 -MarketWatch OptionsXPress (Greeks of calls) OptionsXPress (limited Put and Call data items) Yahoo Multiple sources. If this value is passed, all datacodes will be 2-byte values, where the first byte is the "DataCode" prefix shown in this table.
source
Examples
This function invocation: =smfGetOptionQuotes("SPY Jun 2010 $100 Call,SPY Jun 2010 $110 Call","zba",1) ...returns:
Ticker Symbol
16
SPY100619C00100000 SPY100619C00110000
$7.84 $1.17
$8.02 $1.21
This function invocation: =smfGetOptionQuotes("SPY Jun 2010 $100 Call,SPY Q2 2010 $100 Call","zba",1,"MSN") ...returns:
This function invocation, when SPY was trading at $106.82: =smfGetOptionQuotes("SPY Jul 2010 ITM1 Call,SPY Jul 2010 OTM1 Call","zsba",1) ...returns:
Strike Price Bid Price Ask Price $106.00 $107.00 $4.63 $4.03 $4.73 $4.12
This function invocation: =smfGetOptionQuotes("SPY Aug 2010 $110 Call,SPY Aug 2010 $111 Call","1z2z3z4z",1,2) ...returns:
Ticker Symbol
Ticker Symbol
Ticker Symbol
Ticker Symbol
17
...which is basically returning the ticker symbols used by Yahoo (1z), MSN (2z), OptionsXpress (3z), and MarketWatch (4z).
b Option Symbols SPY Jun 2010 $100 Call SPY Jun 2010 $110 Call
a $8.02 $1.21
...where the range A3:A4 containing the ticker symbols is the green-shaded area, range B1:C1 containing the data codes ot retrieve is the yellow-shaded area, and the formula was array-entered over the blue-shaded range of B2:C4.
...more to come
Usage notes
In most cases, this will need to be an array-entered formula. To array-enter a formula in EXCEL, first highlight the range of cells where you would like the returned data to appear -- the number of rows for the range should be AT LEAST the number of ticker symbols you are requesting from the function, while the number of columns for the range should be AT LEAST the number of data items you are requesting for each ticker symbol from the function. Next, enter your formula and then press Ctrl-Shift-Enter. This function actually parses through the ticker list and data code list and does individual calls to "building block" functions like smfGetYahooOptionQuote() or smfGetMSNOptionQuote() for each data item requested. The "ITMn" and "OTMn" strike price options may not work properly where Yahoo intermixes the listings of the quarter-end and month-end option expirations on the same page. ...more to come
18
19
Expiry
The actual option expiration date if you know it (e.g. DATE(2010,6,19)). The first of the month for the option expiration month you want (e.g. DATE(2010,6,1)). The 30th or 31st day of the month-end quarter for the option expiration quarter you want (e.g. DATE(2010,6,30)). Note that only a few index ETFs have options that expire at the end of each quarter (e.g. "SPY" or "IWM").
StrikePrice = The strike price of the option for which data is to be retrieved. You have several options here: Actual Price ITMn You can pass the actual strike price you want to use (e.g. 100). You can pass a literal to indicate you want the first in-the-money option (e.g. "ITM1"), the second in-the-money option (e.g. "ITM2"), and so forth. You can pass a literal to indicate you want the first out-of-the-money option (e.g. "OTM1"), the second out-of-the-money option (e.g. "OTM2"), and so forth.
OTMn ItemID
= The itemID of the particular data item you want to retrieve for the option: Faster data items Slower data items
20
a Ask Price b Bid Price i Open Interest l Last Price s Strike Price v Volume x Expiration Date z Actual Option Symbol
c $ Change g Daily Low h Daily High j Contract Low k Contract High o Open Price p Previous Close t Last Trade Time
The difference between the "Faster" and "Slower" data items is that you can retrieve all of the "Faster" items for all of the different options in the same expiration month with a single Internet access, while the "Slower" data items require a new Internet access for each individual option for which the various items are collected. Examples
Usage notes
In general, you would use the smfGetOptionQuotes() function instead of this one. This is primarily intended as a "building block" function for that one. ...more to come
21
Expiry
The actual option expiration date if you know it (e.g. DATE(2010,6,19)). The first of the month for the option expiration month you want (e.g. DATE(2010,6,1)). The 30th or 31st day of the month-end quarter for the option expiration quarter you want (e.g. DATE(2010,6,30)). Note that only a few index ETFs have options that expire at the end of each quarter (e.g. "SPY" or "IWM").
StrikePrice = The strike price of the option for which data is to be retrieved. You have several options here: Actual Price You can pass the actual strike price you want to use (e.g. 100). ITMn You can pass a literal to indicate you want the first in-the-money option (e.g. "ITM1"), the second in-the-money option (e.g. "ITM2"), and so forth. This option is not available at this time. You can pass a literal to indicate you want the first out-of-themoney option (e.g. "OTM1"), the second out-of-the-money option (e.g. "OTM2"), and so forth. This option is not available at this time.
OTMn
ItemID
= The itemID of the particular data item you want to retrieve for the option: Faster data items Slower data items
22
% % Change a Ask Price b Bid Price c $ Change i Open Interest l Last Price s Strike Price v Volume x Expiration Date y Time Value z Actual Option Symbol
e Bid Size f Ask Size g Daily Low h Daily High o Open Price p Previous Close t Last Trade Time
The difference between the "Faster" and "Slower" data items is that you can retrieve all of the "Faster" items for all of the different options in the same expiration month with a single Internet access, while the "Slower" data items require a new Internet access for each individual option for which the various items are collected. Examples
Usage notes
In general, you would use the smfGetOptionQuotes() function instead of this one. This is primarily intended as a "building block" function for that one. ...more to come
23
Expiry
The actual option expiration date if you know it (e.g. DATE(2010,6,19)). The first of the month for the option expiration month you want (e.g. DATE(2010,6,1)). The 30th or 31st day of the month-end quarter for the option expiration quarter you want (e.g. DATE(2010,6,30)). Note that only a few index ETFs have options that expire at the end of each quarter (e.g. "SPY" or "IWM").
StrikePrice = The strike price of the option for which data is to be retrieved. ItemID = The itemID of the particular data item you want to retrieve for the option: a Ask Price b Bid Price i Open Interest l Last Price s Strike Price x Expiration Date y Theoretical Value z Actual Option Symbol
24
Usage notes
In general, you would use the smfGetOptionQuotes() function instead of this one. This is primarily intended as a "building block" function for that one. ...more to come
25
Put/Call = An optional parameter from 1 to 12 that indicates the month for which the expiration date is to be returned. Defaults to current expiration month. Expiry = An optional parameter that indicates the type of option expiration date to be returned. Defaults to "M". The following values can be passed: W Week Weekly W1 W2 M Month Q Qtr Quarter Next Weekly Next Weekly Next Weekly Next Weekly Following Weekly Monthly Monthly Quarterly Quarterly Quarterly
Monthly Monthly
26
2010-06-25 =smfGetOptionExpiry(,,"Weekly") 2010-06-25 =smfGetOptionExpiry(,,"W1") 2010-07-02 =smfGetOptionExpiry(,,"W2") 2010-07-17 =smfGetOptionExpiry(,,"M") 2010-07-17 =smfGetOptionExpiry(,,"Month") 2010-07-17 =smfGetOptionExpiry(,,"Monthly") 2010-06-30 =smfGetOptionExpiry(,,"Q") 2010-06-30 =smfGetOptionExpiry(,,"Qtr") 2010-06-30 =smfGetOptionExpiry(,,"Quarter") 2010-06-30 =smfGetOptionExpiry(,,"Quarterly") 2010-08-21 =smfGetOptionExpiry(2010,8,"M") 2010-09-18 =smfGetOptionExpiry(2010,9,"M") 2010-12-31 =smfGetOptionExpiry(2010,12,"Q") 2011-03-31 =smfGetOptionExpiry(2011,3,"Q") Usage notes
The "W2" option type will typically only be valid when the following week is the option month-end, because they have been creating the new weekly options over the weekend and that is the only time two weeklies will exist at the same time. The weekly and quarterly option expirations only exist for a few select ETFs, such as SPY and IWM. The weekly option types will ignore the year and month that are passed. ...more to come
27
Start Day = Day to use as the starting date of the historical quotes; optional; default is to fill your array-entered range. End Year = Year to use as the ending date of the historical quotes; must be four digits (e.g. 2005); optional; defaults to most recent date available. End Month = Month to use as the ending date of the historical quotes; optional; defaults to most recent date available.
End Day = Day to use as the ending date of the historical quotes; optional; defaults to most recent date available. Period = Type of data period to retrieve; optional; defaults to "d"; possible values: "d" = Daily quotes "w" = Weekly quotes (Yahoo chooses to use the first trading day of the week as the end of the period) "m" = Monthly quotes (Yahoo chooses to use the first trading day of the month as the end of the period) "v" = Dividend history ("T" is the only "Data Item" that makes a difference Date and Dividend amount are automatic) Data = A character string indicating which data items to retrieve; optional; defaults to
28
Items
"DOHLCVA"; possible values within the character string: "T" = Ticker symbol "D" = Ending date of the period "O" = Opening price of the period "H" = High price for the period "L" = Low price for the period "C" = Closing price for the period "V" = Trading volume for the period "A" = Adjusted closing price for the period
Header Line
= A binary value to indicate whether headers should be returned for the column(s) of data; optional; defaults to 1; possible values: 0 = Delete column headings 1 = Display column headings
Adjust
= A binary value to indicate whether data should be adjusted or not; optional; defaults to 0. 0 = Do not adjust data; returns the raw data as returned from Yahoo! 1 = Adjust O/H/L/C prices based on the value of the Adjusted Close and Close amounts returned from Yahoo!
Resort
= A binary value to indicate whether data should be resorted or not; optional; defaults to 0. 0 = Do not resort data; present raw data as returned from Yahoo!; newest data will be on the top rows of table. 1 = Reverse the order of data returned from Yahoo!; oldest data will be on the top rows of table.
Examples
This would return the seven default data items for ticker symbol IBM: =RCHGetYahooHistory("IBM") If you array-entered the above formula over a 10-row by 7-column range, you would get the D/O/H/L/C/V/A data items for the latest 9 days of history.
This would return a single item -- the adjusted closing price for ticker symbol IBM for January 3rd, 2007: =RCHGetYahooHistory("IBM",2007,1,3,2007,1,3,,"A",0)
29
...more to come
Usage notes
In most cases, this will need to be an array-entered formula. To array-enter a formula in EXCEL, first highlight the range of cells where you would like the returned data to appear -- the number of rows for the range should be the number of periods of data you are requesting from the function, while the number of columns for the range should be the number of data items you are requesting for each date from the function. Next, enter your formula and then press Ctrl-Shift-Enter. If the function is array-entered over a range that is larger than the amount of data available from Yahoo, the excess portion of the range will be filled with blanks. If the function is array-entered over a range that is smaller than the amount of data returned from Yahoo, the excess Yahoo data will simply be ignored. A user-defined function can only return data to a cell or a range that it has been given access to -- in this case, by the range used when array-entering the function. ...more to come
30
Examples
This would return the ten default data items for ticker symbol IBM for the past year: =smfPricesBetween("IBM",TODAY()-365,TODAY()) 31
If you array-entered the above formula over a 1-row by 10-column range, you would get the O/H/L/C/V/PC data items and dates for the various items.
If you wanted to know the 2007 YTD change for ticker "IBM", you could use: =smfPricesBetween("IBM",DATE(2007,1,1),DATE(2007,12,31)) For example, using that and =smfPricesBetween("Header") on the line above it to get the headers, here's what the results looked like:
High Date
High Price
Low Date
Low Price
Close Date
Close Price
Volume
200710-11 $121.46
200707-18 $71.46
Suppose in the above example, all I was interested in was the close prior to the starting date and the latest close of the period -- I could then have used these two formula: =smfPricesBetween("Header",,,"1008") =smfPricesBetween("IBM",DATE(2007,1,1),DATE(2007,12,31),"1008") ...which would have returned:
...more to come
Usage notes
In most cases, this will need to be an array-entered formula. To array-enter a formula in EXCEL, first highlight the range of cells where you would like the returned data to appear -- the number of rows for the range should be the number of periods of data you are requesting from the function, while the number of columns for the range should be the number of data items you are requesting for each date from the function. Next, enter your formula and then press Ctrl-Shift-Enter. In most cases, you will probably want to use cell references for the values. For example:
32
=smfPricesBetween(D17,E17,F17,"1008") ...where cell D17 contains the ticker symbol and cells E17 and F17 contain appropriate date values.
...more to come
33
Examples
=smfPricesByDates("IBM", DATE(2007,1,1)) =smfPricesByDates("IBM", "1/1/2007") =smfPricesByDates(A2, B$1:J$1) =smfPricesByDates(A2, B$1:J$1, DATE(2007,1,1)) ...more to come
Usage notes
When passing more than one date for which to retrieve data, this will need to be an arrayentered formula. To array-enter a formula in EXCEL, first highlight the range of cells where you would like the returned data to appear -- the number of rows for the range should be the number of periods of data you are requesting from the function, while the number of columns for the range should be the number of data items you are requesting for each date from the function. Next, enter your formula and then press Ctrl-Shift-Enter.
34
If a date you passed is not a valid trading date but is within the range of historical dates available from Yahoo, you will get the adjusted closing price from the most recent trading day. "#N/A" would be returned as the adjusted closing price for any date value passed that cannot be resolved -- for example, if you pass a non-date string or an empty cell, or pass a date outside of the historical range of dates available on Yahoo. This function is only available in version 2.0i or later of the add-in. ...more to come
35
Begin Direction = Number of <TABLE tags to searh for after finding the above string to find the start of the table. A negative number indicates to search backwards, positive number forwards. Find End = String to search for on web page to find end of table. If blank, the "Find Begin" parameter will be reused. = Number of </TABLE tags to searh for after finding the above string to find the end of the table. A negative number indicates to search backwards, positive number forwards.
End Direction
Usage Notes:
This function returns an array of data (the HTML table), so it needs to be array-entered. To array-enter a formula in EXCEL, first highlight the range of cells where you would like the returned data to appear -- the number of rows and columns for the range will depend on the size of the table you are retrieving and how much of that table you want to see. Next, enter your formula and then press Ctrl-Shift-Enter. What it does -- given this invocation: =RCHGetHTMLTable("http://finance.yahoo.com/q/ks?s=MMM","Market Cap (intraday)",-1,"",1) The function will: -- Retrieve HTML source of the Yahoo! Key Statistics web page. -- Search for "Market Cap (intraday)" within the source of the web page. -- Set the start of the HTML table to be the first "<TABLE" tag prior to that string (i.e. 1). -- Search for "Market Cap (intraday)" within the source of the web page. -- Set the end of the HTML table to be the first "</TABLE" tag after that string (i.e. 1). -- Return the full table specified by and including the found "<TABLE" and "</TABLE"
36
tags. Examples: =RCHGetHTMLTable("http://finance.yahoo.com/q/ks?s=MMM","PEG Ratio",-1,"",1) =RCHGetHTMLTable("http://finance.yahoo.com/q?d=t&s=IBM","Volume:",-1,"",1) =RCHGetHTMLTable("http://finance.yahoo.com/q/ao?s=IBM", "Mean Recommendation", -3, "Mean Recommendation", 1) =RCHGetHTMLTable("http://finance.yahoo.com/q/ao?s=IBM", "Mean Target", -3, "Mean Target", 1) =RCHGetHTMLTable("http://finance.yahoo.com/q/ao?s=IBM", "Three Months Ago", -4, "Three Months Ago", 1) =RCHGetHTMLTable("http://finance.yahoo.com/q/ud?s=IBM", "Research Firm", -1, "Research Firm", 1) =RCHGetHTMLTable("http://finance.yahoo.com/q/ae?s=IBM", ">Earnings Est", -2, ">Growth Est", 1)
37
Find1
Find2
Find3
Find4
Row#
EndMarker = An optional string value that marks the end of the skip aheads based on "Cell#" and "Row#". If the next found table cell ia after this point, the error message is returned. Defaults to "</BODY", but is usually set to "</TABLE" when using "Row#" to ensure that the search doesn't go outside the current table when skipping ahead by table rows. Look# = An optional number of consecutive cells to search for data in (ignoring empty
38
table cells). Rarely used. Defaults to 0. ErrorMsg = An optional value to return if the table cell cannot be found based on specified parameters. Defaults to "Error". = An optional integer value to determine the type of Internet request to make. Defaults to 0. For now, other values are experimental: 0 = XMLHTTP "Get" Request 1 = IE Object Request 2 = HTMLDocument Request 3 = XMLHTTP "Post" Request Examples
Type
To retieve the "Market Cap" value from the Yahoo! Key Statistics page for ticker symbol "MMM": =RCHGetTableCell("http://finance.yahoo.com/q/ks?s=MMM",1,"Market Cap (intraday)") ...which tells the function to retrieve the "http://finance.yahoo.com/q/ks?s=MMM" web page, look for the "Market Cap (intraday)" string on the page, then return the data in the following table cell.
...more to come
Usage notes
This is the general process the function uses to extract the data: 1. The source of the web page specified by "URL" is retrieved from the Internet. 2. A position pointer is set to 1. 3. The position pointer is advanced to the next location of the string specified by "Find1" found in the web page source. 4. If "Find2" is nonblank, the position pointer is advanced to the next location of the string specified by "Find2" found in the web page source. 5. If "Find3" is nonblank, the position pointer is advanced to the next location of the string specified by "Find3" found in the web page source. 6. If "Find4" is nonblank, the position pointer is advanced to the next location of the string specified by "Find4" found in the web page source. 7. If "Row#" is not zero, the ending position of the table is set by finding the string specified by "EndMarket". 8. If "Row#" is not zero, the position pointer is advanced the number of table rows requested, to the start of the table row. If the next row found is beyond the position set by "EndMarket", an extraction error is signaled.
39
9. The position pointer is advanced the number of table cells specified by "Cell#". If the end of the current table row is hit before the cell is found, an extraction error is signaled. 10. If "Look#" is zero, the current cell is returned. Otherwise, it looks for and returns the first non-empty cell up to the number specified by "Look#".
Basically, this works off the same extraction engine that the RCHGetElementNumber() function uses. The vast majority of data elements is defined by a line like: 941;YahooKS;Market Cap;http://finance.yahoo.com/q/ks?s=~~~~~;1;VALUATION MEASURES;MARKET CAP; ; ;0;0;0;0 That data line more or less is the same definition that this function uses. These are the relevant components: Element Number = 941 Source Name (i.e. a name assigned to a specific "URL") = "YahooKS" Element Name = "Market Cap" Web Page (i.e. "URL", with "~~~~~" as the ticker symbol) = "http://finance.yahoo.com/q/ks?s=~~~~~" # of cells to skip ahead (i.e. "Cell#") = 1 1st search string (i.e. "Find1") = "VALUATION MEASURES" 2nd search string (i.e. "Find2") = "MARKET CAP" 3rd search string (i.e. "Find3") = " " 4th search string (i.e. "Find4") = " " # of rows to skip ahead (i.e. "Row#") = 0 End of table marker (i.e. "EndMarker") = 0 # of cells to look into (i.e. "Look#") = 0 Type of Internet request to issue (i.e. "Type") = 0
This function uses the same caching technique as the RCHGetElementNumber() function, so if you are retrieving multiple elements from the same page, only one web
40
page retrieval needs to be done. The source of the web page will be saved and used for extracton of later data elements.
If someone does used this to define a number of elements on a page I haven't implemented, it should be a fairly trivial task for me to take their cell extraction data and convert them into a set of legitimate data elements for the RCHGetElementNumber() function. ...more to come
41
Position = An optional parameter that has a default value of 1, indicating either: 1. A number indicating an absolute position on the page to begin the extraction of data 2. A string to search for on the page to indicate a relative position on the page to begin the extraction of data Length = An optional parameter that has a default value of 32767 (the maximum possible value), indicating the length of the data to extract from the web page. Offset = An optional parameter that has a default value of 0, indicating the relative position to offset from parameter "Position" for extraction of data from the web page.
Examples
To retieve the first 32767 bytes of the Yahoo! Key Statistics page for ticker symbol "IHR": =RCHGetWebData("http://finance.yahoo.com/q/ks?s=IHR")
To retrieve successive data from the same web page, you could use these additional formulas: =RCHGetWebData("http://finance.yahoo.com/q/ks?s=IHR",32768,32767) =RCHGetWebData("http://finance.yahoo.com/q/ks?s=IHR",65535,32767)
...more to come
42
Usage notes
A value of "Error" is returned if the "Position" or "Length" values are invalid for the web page. However, if the "Position" is within the web page and the "Length" would cause the extraction to go outside of the web page, the "Length" is reset so the extraction only goes to the length of the web page. ...more to come
43
An alternative way to grab current quotes data from Yahoo: =smfGetCSVFile("http://download.finance.yahoo.com/d/quotes.csv?s=MMM&f=sl1d1t1 c1ohgv&e=.csv")
An alternative way to grab dividend data from Yahoo historical quotes: =smfGetCSVFile("http://ichart.finance.yahoo.com/table.csv?s=MMM&g=v&ignore=.csv ")
...more to come
Usage notes
This function returns an array of data, so it needs to be array-entered. To array-enter a formula in EXCEL, first highlight the range of cells where you would like the returned data to appear -- the number of rows and columns for the range will depend on the size of the CSV file you want parsed and how much of that CSV file you want to see. Next, enter your formula and then press Ctrl-Shift-Enter. This function is only available in version 2.0i or later of the add-in.
44
...more to come
45
Examples
46
To retrieve the daily value of the 7-Year Treasury Constant Maturity Rate for 1/2/2008: =smfGetEconData("DGS7",DATE(2008,1,2))
To retrieve the source for the 7-Year Treasury Constant Maturity Rate: =smfGetEconData("DGS7","Source")
...more to come
Usage notes
47
Find1
Find2
Find3
Find4
Convert
ErrorMsg = An optional value to return if the table cell cannot be found based on specified parameters. Defaults to "Error". Type = An optional integer value to determine the type of Internet request to make.
48
Defaults to 0. For now, other values are experimental: 0 = XMLHTTP "Get" Request 1 = IE Object Request 2 = HTMLDocument Request 3 = XMLHTTP "Post" Request Examples
To retieve the "Title" value from the Yahoo! Key Statistics page for ticker symbol "MMM": =smfGetTagContent("http://finance.yahoo.com/q/ks?s=MMM","title",1) ...which tells the function to retrieve the "http://finance.yahoo.com/q/ks?s=MMM" web page, look for the first "<title>" HTML tag on the page, then return the data within that HTML tag. In this case, it returns "MMM: Key Statistics for 3M Company Common Stock - Yahoo! Finance".
...more to come
Usage notes
This function uses the same caching technique as the RCHGetElementNumber() function, so if you are retrieving multiple elements from the same page, only one web page retrieval is done by the add-in. The source of the web page will be saved and used for extraction of later data elements. ...more to come
49
Left
50
Scale Text
= Scaling amount to apply to Choice-based height and width sizes. Defaults to 100%. = Text data to place into comment box. In most cases, you would NOT use this if you are loading an image. Defaults to "".
Return = Data to return as the value for the cell. Defaults to "Chart".
Examples
Either of these would insert a comment box containing the daily chart from Stockcharts' Gallery View for ticker "IHR": =RCHCreateComment("IHR",1,0,0,1,2,1,1,"","Chart") =RCHCreateComment("IHR",1)
This would insert a comment box containing a custom chart for ticker "HLX": =RCHCreateComment("http://stockcharts.com/csc/sc?s=HLX&p=D&yr=0&mn=6&dy=0&i=t39628903145&r=9933",99,350,360)
...more to come
Usage notes
51
MACD = Moving Average Convergence Divergence -- parm1 = period of 1st moving average, defaults to 12 -- parm2 = period of 2nd moving average, defaults to 26 -- parm3 = smoothing period for difference of the two moving averages, defaults to 9 OBV ROC RSI SMA STO = On Balance Volume -- No parameters are used = % Rate of Change -- parm1 = period, defaults to 21 = Relative Strength Index -- parm1 = period, defaults to 20 = Simple Moving Average -- parm1 = period, defaults to 50 = Stochastics -- parm1 = %K period, defaults to 14
52
parm1parm6
= Parameters to be used to create the technical analysis values. See the "indicator" list for details on each.
Examples
See the template in the files area for sample usage of each.
Usage notes
Verify values before trusting...this is a function that is under development. This function needs to be array-entered when using it to return a range of data in the workbook. In some cases, an indicator may return multiple columns of data. However, the first column contains the values for the indicator. If they exist, the other columns will contain intermediate calculations that may be of use. This function can also be used to generate single "on the fly" technical analysis values. For example: =INDEX(smfTech(RCHGetYahooHistory("MMM",,,,,,,,,,1,1,11,6),"SMA",10),11) ...would return the current 10-day simple moving average for ticker "MMM". That is:
o
smfTech(...,"SMA",10) ...generates the 10-day simple moving average on that returned historical data.
INDEX(...,11) ...gets the 11th array element returned -- which is the current day's value. That's because the Yahoo historical quotes are sorted from oldest data to newest data.
...more to come
53
End
Examples
To extract "table" out of "1table2", you would use: =smfStrExtr("1table2","1","2") ...which says to extract everything between "1" and "2".
To extract "table" out of "1table12", you would use: =smfStrExtr("1table12","1","1") ...which says to extract everything between the first "1" and the "1" following that.
...more to come?
Usage notes
54
-----------------
55
downloading of a table of data. A sample is here. 2006/09/12 2006/09/10 1.3f 1.3e Fixed RCHGetYahooQuotes() parsing -- non-double-quoted fields within comma-delimited data were dropping the last character Fixed RCHGetYahooQuotes() parsing to handle doublequoted fields within comma-delimited data Changed web page source of MSN 10-year summary of financial statement items (MSN page reformat) Obsoleted MSN financial statement data elements (MSN page reformat to use Reuters data) Added RCHCreateComment() function Added ability of RCHGetHTMLTable() function to extract rows from a table Added RCHGetTableCell() function Added RCHGetWebData() function 2006/08/17 1.3d Added sector and industry names/numbers from Yahoo Fixed a number of elements from Zacks due to web page changes Added a number of elements from Zacks due to web page changes Added annual O/H/L/C prices from Business Week (values appear inaccurate in some cases) Added a number of Valuation Ratio elements from Morningstar Added a number of Key Ratio elements from Morningstar Added the currency type and magnitude for Google Financial Statements data Added a number of calculated fields (e.g. estimates of Piotroski, Altman, MFI, Rule #1) =RCHGetElementNumber("Web Page", elementnumber) will return the URL of the web page the data element is retrieved from Removed volume adjustment option from =RCHGetYahooHistory(). Apparently, all volume is ALWAYS provided adjusted for stock splits. 2006/07/18 1.3c Added a number of Comparison Ratio elements from ----243-352 1516-1540 1542-1551 3974-4923 --------1386413868 848-876 1386913890 1389113930 1393114067 1405814398 1439914400 1500115014 ---
--13626-
56
Reuters Added a number of Market Statistics elements from Yahoo Added company name from either MSN or Yahoo Changed "P&F -- Trend" (i.e. "Bearish" or "Bullish") from StockCharts to be based on price direction instead of price objective prefix Changed RCHGetElementNumber() function to allow for a custom error value to be returned Fixed RCHGetHTMLTable() function to allow for existence of <THEAD></THEAD> table rows and empty table cells Fixed RCHGetYahooHistory() function for incorrect edit of weekly data series request Changed RCHGetYahooHistory() to allow for ascending date sorting and automatic adjustment of amounts based on the "Adjusted Close" value 2006/07/01 1.3b Added a number of mutual fund data elements from Yahoo Finance Added 10 years of annual financial statement data from AdvFN Added 5 years of quarterly financial statement data from AdvFN
-----
57