tiaa-cref quotes stopped working October 6

Mike Alexander mta at umich.edu
Sun Jan 2 19:12:45 EST 2011


--On January 1, 2011 3:28:11 PM -0500 David Reiser 
<dbreiser at earthlink.net> wrote:

>
> On Jan 1, 2011, at 2:34 PM, Richard Nelson wrote:
>
>> Pretty much says it all. There was a patch posted on this list in
>> mid-November that didn't fix things for me. Upgraded to 2.4.0 today,
>> ran gnc-fq-update which did update some things but tiaacref is still
>> not working for me. Any suggestions? Thanks!
>>
>> Richard
>
> A new version of gnucash has nothing to do with whether finance-quote
> is fixed. For that you need to ask the finance-quote maintainer to
> release a fixed version.
>
> Were you able to tell if the patch applied correctly? If you can find
> the tiaacref.pm file in your perl installation, you could replace it
> with the attached file. The attached file (just the result of the two
> patches mentioned in the finance-quote bug list discussion) has been
> working for me since mid October.
>
> Make sure you replace the right file if you have more than one
> version of perl installed.

There is another patch (actually two more patches -- I just uploaded a 
minor fix for the first one) for this module at 
<https://rt.cpan.org/Public/Bug/Display.html?id=62104>.  These patches 
add about 70 more funds to the list of funds the module can retrieve. 
Maybe these patches will become part of the distribution someday.  In 
the meantime I've attached my version to tiaacref.pm.

         Mike
 
-------------- next part --------------
#!/usr/bin/perl -w
#
#    Copyright (C) 1998, Dj Padzensky <djpadz at padz.net>
#    Copyright (C) 1998, 1999 Linas Vepstas <linas at linas.org>
#    Copyright (C) 2000, Yannick LE NY <y-le-ny at ifrance.com>
#    Copyright (C) 2000, Paul Fenwick <pjf at cpan.org>
#    Copyright (C) 2000, Brent Neal <brentn at users.sourceforge.net>
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#    02111-1307, USA
#
#
# This code derived from Padzensky's work on package Finance::YahooQuote,
# but extends its capabilites to encompas a greater number of data sources.
#
# This code was developed as part of GnuCash <http://www.gnucash.org/>

package Finance::Quote::Tiaacref;
require 5.005;
require Crypt::SSLeay;

use strict;

use vars qw($VERSION $CREF_URL $CREF_URL_INST $TIAA_URL
            %tiaacref_ids %tiaacref_locs %tiaacref_vals);

use LWP::UserAgent;
use HTTP::Request::Common;
use Carp;

$VERSION = '1.17';

# URLs of where to obtain information.
# This used to be different for the CREF and TIAA annuities, but this changed.
$CREF_URL = ("http://www.tiaa-cref.org/public/performance/retirement/data/results?");
$CREF_URL_INST = ("http://www.tiaa-cref.org/public/performance/institutional/data/results?");
#https://www3.tiaa-cref.org/ddata/DownloadData?");

sub methods { return (tiaacref=>\&tiaacref); }

sub labels { return (tiaacref => [qw/method symbol exchange name date isodate nav price/]); }

# =======================================================================
# TIAA-CREF Annuities are not listed on any exchange, unlike their mutual funds
# TIAA-CREF provides unit values via a cgi on their website. The cgi returns
# a csv file in the format 
#		bogus_symbol1,price1,date1
#		bogus_symbol2,price2,date2
#       ..etc.
# where bogus_symbol takes on the following values for the various annuities:
#
# Stock: 				CREFstok
# Money Market:				CREFmony
# Equity Index:				CREFequi
# Inf-Linked Bond:			CREFinfb
# Bond Market:				CREFbond
# Social Choice:			CREFsoci
# Global Equities:			CREFglob
# Growth:				CREFgrow
# TIAA Real Estate:			TIAAreal
# PA Stock Index:			TIAAsndx
# PA Select Stock:			TLSIX
# PA Select Growth Equity:		TLGEX
# PA Select Growth Income:		TLGIX
# PA Select Int'l Equity:		TLIEX
# PA Select Social Choice:		TLSCX
# PA Select Large Cap Value:		TLLCX
# PA Select Small Cap Equity:		TLCEX
# PA Select Real Estate:		TLREX

# TIAA-CREF Money Market:		TIAXX
# TIAA-CREF Bond Plus:			TIPBX
# TIAA-CREF High-Yield Bond:		TCHYX
# TIAA-CREF Inflation-Linked Bond:	TCILX
# TIAA-CREF Short-Term Bond:		TCSTX
# TIAA-CREF Tax-Exempt Bond:		TCTEX
# TIAA-CREF Real Estate Securities:	TCREX
# TIAA-CREF Equity Index:		TCEIX
# TIAA-CREF Growth Equity:		TIGEX
# TIAA-CREF Growth & Income:		TIGIX
# TIAA-CREF International Equity:	TIINX
# TIAA-CREF Large-Cap Value:		TCLCX
# TIAA-CREF Mid-Cap Growth:		TCMGX
# TIAA-CREF Mid-Cap Value:		TCMVX
# TIAA-CREF Small-Cap Equity:		TCSEX
# TIAA-CREF Social Choice Equity:	TCSCX
# TIAA-CREF Managed Allocation:		TIMAX

# TIAA-CREF Retirement Fund - Bond:                        TIDRX
# TIAA-CREF Retirement Fund - Bond Index:                  TBIRX
# TIAA-CREF Retirement Fund - Bond Plus:                   TCBRX
# TIAA-CREF Retirement Fund - Emerging Markets Equity:     TEMSX
# TIAA-CREF Retirement Fund - Emerging Markets Equity Index: TEQSX
# TIAA-CREF Retirement Fund - Equity Index:                TIQRX
# TIAA-CREF Retirement Fund - Growth & Income:             TRGIX
# TIAA-CREF Retirement Fund - High-Yield:                  TIHRX
# TIAA-CREF Retirement Fund - Inflation-Linked Bond:       TIKRX
# TIAA-CREF Retirement Fund - International Equity:        TRERX
# TIAA-CREF Retirement Fund - International Equity Index: TRIEX
# TIAA-CREF Retirement Fund - Large-Cap Growth:            TILRX
# TIAA-CREF Retirement Fund - Large-Cap Growth Index:      TRIRX
# TIAA-CREF Retirement Fund - Large-Cap Value:             TRLCX
# TIAA-CREF Retirement Fund - Large-Cap Value Index:       TRCVX
# TIAA-CREF Retirement Fund - Lifecycle 2010:              TCLEX
# TIAA-CREF Retirement Fund - Lifecycle 2015:              TCLIX
# TIAA-CREF Retirement Fund - Lifecycle 2020:              TCLTX
# TIAA-CREF Retirement Fund - Lifecycle 2025:              TCLFX
# TIAA-CREF Retirement Fund - Lifecycle 2030:              TCLNX
# TIAA-CREF Retirement Fund - Lifecycle 2035:              TCLRX
# TIAA-CREF Retirement Fund - Lifecycle 2040:              TCLOX
# TIAA-CREF Retirement Fund - Lifecycle 2045:              TTFRX
# TIAA-CREF Retirement Fund - Lifecycle 2050:              TLFRX
# TIAA-CREF Retirement Fund - Lifecycle Retirement Income: TLIRX
# TIAA-CREF Retirement Fund - Managed Allocation:          TITRX
# TIAA-CREF Retirement Fund - Mid-Cap Growth:              TRGMX
# TIAA-CREF Retirement Fund - Mid-Cap Value:               TRVRX
# TIAA-CREF Retirement Fund - Money Market:                TIEXX
# TIAA-CREF Retirement Fund - Real Estate Securities:      TRRSX
# TIAA-CREF Retirement Fund - S&P 500 Index:               TRSPX
# TIAA-CREF Retirement Fund - Short-Term Bond:             TISRX
# TIAA-CREF Retirement Fund - Cap Blend Index:             TRBIX
# TIAA-CREF Retirement Fund - Small-Cap Equity:            TRSEX
# TIAA-CREF Retirement Fund - Social Choice Equity:        TRSCX

# TIAA-CREF Institutional Fund - Bond:                        TIBDX     1835
# TIAA-CREF Institutional Fund - Bond Index:                  TBIIX     1837
# TIAA-CREF Institutional Fund - Bond Plus:                   TIBFX     1827
# TIAA-CREF Institutional Fund - Emerging Markets Equity:     TEMLX     1848
# TIAA-CREF Institutional Fund - Emerging Markets Equity Index: TEQLX   1849
# TIAA-CREF Institutional Fund - Enhanced International Equity Index: TFIIX 1822
# TIAA-CREF Institutional Fund - Enhanced Large-Cap Growth Index: TLIIX 1820
# TIAA-CREF Institutional Fund - Enhanced Large-Cap Value Index: TEVIX  1821
# TIAA-CREF Institutional Fund - Equity Index:                TIEIX     1833
# TIAA-CREF Institutional Fund - Growth & Income:             TIGRX     1832
# TIAA-CREF Institutional Fund - High-Yield:                  TIHYX     1826
# TIAA-CREF Institutional Fund - Inflation-Linked Bond:       TIILX     1605
# TIAA-CREF Institutional Fund - International Equity:        TIIEX     1830
# TIAA-CREF Institutional Fund - International Equity Index:  TCIEX     1615
# TIAA-CREF Institutional Fund - Large-Cap Growth:            TILGX     1824
# TIAA-CREF Institutional Fund - Large-Cap Growth Index:      TILIX     1607
# TIAA-CREF Institutional Fund - Large-Cap Value:             TRLIX     1601
# TIAA-CREF Institutional Fund - Large-Cap Value Index:       TILVX     1608
# TIAA-CREF Institutional Fund - Lifecycle 2010:              TCTIX     1810
# TIAA-CREF Institutional Fund - Lifecycle 2015:              TCNIX     1811
# TIAA-CREF Institutional Fund - Lifecycle 2020:              TCWIX     1812
# TIAA-CREF Institutional Fund - Lifecycle 2025:              TCYIX     1813
# TIAA-CREF Institutional Fund - Lifecycle 2030:              TCRIX     1814
# TIAA-CREF Institutional Fund - Lifecycle 2035:              TCIIX     1815
# TIAA-CREF Institutional Fund - Lifecycle 2040:              TCOIX     1816
# TIAA-CREF Institutional Fund - Lifecycle 2045:              TTFIX     1817
# TIAA-CREF Institutional Fund - Lifecycle 2050:              TFTIX     1818
# TIAA-CREF Institutional Fund - Lifecycle Retirement Income: TLRIX     1819
# TIAA-CREF Institutional Fund - Managed Allocation:          TIMIX     1825
# TIAA-CREF Institutional Fund - Mid-Cap Growth:              TRPWX     1602
# TIAA-CREF Institutional Fund - Mid-Cap Value:               TIMVX     1603
# TIAA-CREF Institutional Fund - Money Market:                TCIXX     1836
# TIAA-CREF Institutional Fund - Real Estate Securities:      TIREX     1604
# TIAA-CREF Institutional Fund - S&P 500 Index:               TISPX     1606
# TIAA-CREF Institutional Fund - Short-Term Bond:             TISIX     1828
# TIAA-CREF Institutional Fund - Small-Cap Blend Index:       TISBX     1612
# TIAA-CREF Institutional Fund - Small-Cap Equity:            TISEX     1634
# TIAA-CREF Institutional Fund - Social Choice Equity:        TISCX     1834
# TIAA-CREF Institutional Fund - Tax-Exempt Bond:             TITIX     1829


#
# This subroutine was written by Brent Neal <brentn at users.sourceforge.net>
# Modified to support new TIAA-CREF webpages by Kevin Foss <kfoss at maine.edu> and Brent Neal

#
# TODO:
#
# The TIAA-CREF cgi allows you to specify the exact dates for which to retrieve
# price data. That functionality could be worked into this subroutine.
# Currently, we only grab the most recent price data.
# 

sub tiaacref
{
    my $quoter = shift;
    if (! %tiaacref_ids ) {  #build a name hash for the annuities (once only)
    	$tiaacref_ids{"CREFstok"} = "CREF Stock";
    	$tiaacref_ids{"CREFmony"} = "CREF Money Market";
    	$tiaacref_ids{"CREFequi"} = "CREF Equity Index";
    	$tiaacref_ids{"CREFinfb"} = "CREF Inflation-Linked Bond";
    	$tiaacref_ids{"CREFbond"} = "CREF Bond Market";
    	$tiaacref_ids{"CREFsoci"} = "CREF Social Choice";
    	$tiaacref_ids{"CREFglob"} = "CREF Global Equities";
    	$tiaacref_ids{"CREFgrow"} = "CREF Growth";
    	$tiaacref_ids{"TIAAreal"} = "TIAA Real Estate";
    	$tiaacref_ids{"TIAAsndx"} = "TIAA Teachers Personal Annuity Stock Index";
        $tiaacref_ids{"TLSIX"} = "TIAA Personal Annuity Select Stock Index";
        $tiaacref_ids{"TLGEX"} = "TIAA Personal Annuity Select Growth Equity";
        $tiaacref_ids{"TLGIX"} = "TIAA Personal Annuity Select Growth & Income";
        $tiaacref_ids{"TLIEX"} = "TIAA Personal Annuity Select International Equity";
        $tiaacref_ids{"TLSCX"} = "TIAA Personal Annuity Select Social Choice Equity";
        $tiaacref_ids{"TLLCX"} = "TIAA Personal Annuity Select Large Cap Value";
        $tiaacref_ids{"TLCEX"} = "TIAA Personal Annuity Select Small Cap Equity";
        $tiaacref_ids{"TLREX"} = "TIAA Personal Annuity Select Real Estate Securities";

	# Money Market
	$tiaacref_ids{"TIAXX"} = "TIAA-CREF Money Market";

	# Bonds
	$tiaacref_ids{"TIPBX"} = "TIAA-CREF Bond Plus";
	$tiaacref_ids{"TCHYX"} = "TIAA-CREF High-Yield Bond";
	$tiaacref_ids{"TCILX"} = "TIAA-CREF Inflation-Linked Bond";
	$tiaacref_ids{"TCSTX"} = "TIAA-CREF Short-Term Bond";
	$tiaacref_ids{"TCTEX"} = "TIAA-CREF Tax-Exempt Bond";

	# Real Estate
	$tiaacref_ids{"TCREX"} = "TIAA-CREF Real Estate Securities";

	# Equities
	$tiaacref_ids{"TCEIX"} = "TIAA-CREF Equity Index";
	$tiaacref_ids{"TIGEX"} = "TIAA-CREF Growth Equity";
	$tiaacref_ids{"TIGIX"} = "TIAA-CREF Growth & Income";
	$tiaacref_ids{"TIINX"} = "TIAA-CREF International Equity";
	$tiaacref_ids{"TCLCX"} = "TIAA-CREF Large-Cap Value";
	$tiaacref_ids{"TCMGX"} = "TIAA-CREF Mid-Cap Growth";
	$tiaacref_ids{"TCMVX"} = "TIAA-CREF Mid-Cap Value";
	$tiaacref_ids{"TCSEX"} = "TIAA-CREF Small-Cap Equity";
	$tiaacref_ids{"TCSCX"} = "TIAA-CREF Social Choice Equity";

	$tiaacref_ids{"TIMAX"} = "TIAA-CREF Managed Allocation";
	
        # Retirement class funds
        $tiaacref_ids{"TIDRX"} = "Retirement Fund - Bond";
        $tiaacref_ids{"TBIRX"} = "Retirement Fund - Bond Index";
        $tiaacref_ids{"TCBRX"} = "Retirement Fund - Bond Plus";
        $tiaacref_ids{"TEMSX"} = "Retirement Fund - Emerging Markets Equity";
        $tiaacref_ids{"TEQSX"} = "Retirement Fund - Emerging Markets Equity Index";
        $tiaacref_ids{"TIQRX"} = "Retirement Fund - Equity Index";
        $tiaacref_ids{"TRGIX"} = "Retirement Fund - Growth & Income";
        $tiaacref_ids{"TIHRX"} = "Retirement Fund - High-Yield";
        $tiaacref_ids{"TIKRX"} = "Retirement Fund - Inflation-Linked Bond";
        $tiaacref_ids{"TRERX"} = "Retirement Fund - International Equity";
        $tiaacref_ids{"TRIEX"} = "Retirement Fund - International Equity Index";
        $tiaacref_ids{"TILRX"} = "Retirement Fund - Large-Cap Growth";
        $tiaacref_ids{"TRIRX"} = "Retirement Fund - Large-Cap Growth Index";
        $tiaacref_ids{"TRLCX"} = "Retirement Fund - Large-Cap Value";
        $tiaacref_ids{"TRCVX"} = "Retirement Fund - Large-Cap Value Index";
        $tiaacref_ids{"TCLEX"} = "Retirement Fund - Lifecycle 2010";
        $tiaacref_ids{"TCLIX"} = "Retirement Fund - Lifecycle 2015";
        $tiaacref_ids{"TCLTX"} = "Retirement Fund - Lifecycle 2020";
        $tiaacref_ids{"TCLFX"} = "Retirement Fund - Lifecycle 2025";
        $tiaacref_ids{"TCLNX"} = "Retirement Fund - Lifecycle 2030";
        $tiaacref_ids{"TCLRX"} = "Retirement Fund - Lifecycle 2035";
        $tiaacref_ids{"TCLOX"} = "Retirement Fund - Lifecycle 2040";
        $tiaacref_ids{"TTFRX"} = "Retirement Fund - Lifecycle 2045";
        $tiaacref_ids{"TLFRX"} = "Retirement Fund - Lifecycle 2050";
        $tiaacref_ids{"TLIRX"} = "Retirement Fund - Lifecycle Retirement Income";
        $tiaacref_ids{"TITRX"} = "Retirement Fund - Managed Allocation";
        $tiaacref_ids{"TRGMX"} = "Retirement Fund - Mid-Cap Growth";
        $tiaacref_ids{"TRVRX"} = "Retirement Fund - Mid-Cap Value";
        $tiaacref_ids{"TIEXX"} = "Retirement Fund - Money Market";
        $tiaacref_ids{"TRRSX"} = "Retirement Fund - Real Estate Securities";
        $tiaacref_ids{"TRSPX"} = "Retirement Fund - S&P 500 Index";
        $tiaacref_ids{"TISRX"} = "Retirement Fund - Short-Term Bond";
        $tiaacref_ids{"TRBIX"} = "Retirement Fund - Small-Cap Blend Index";
        $tiaacref_ids{"TRSEX"} = "Retirement Fund - Small-Cap Equity";
        $tiaacref_ids{"TRSCX"} = "Retirement Fund - Social Choice Equity";
        
        #Institutional class funds
        $tiaacref_ids{"TIBDX"} = "Institutional Fund - Bond";
        $tiaacref_ids{"TBIIX"} = "Institutional Fund - Bond Index";
        $tiaacref_ids{"TIBFX"} = "Institutional Fund - Bond Plus";
        $tiaacref_ids{"TEMLX"} = "Institutional Fund - Emerging Markets Equity";
        $tiaacref_ids{"TEQLX"} = "Institutional Fund - Emerging Markets Equity Index";
        $tiaacref_ids{"TFIIX"} = "Institutional Fund - Enhanced International Equity Index";
        $tiaacref_ids{"TLIIX"} = "Institutional Fund - Enhanced Large-Cap Growth Index";
        $tiaacref_ids{"TEVIX"} = "Institutional Fund - Enhanced Large-Cap Value Index";
        $tiaacref_ids{"TIEIX"} = "Institutional Fund - Equity Index";
        $tiaacref_ids{"TIGRX"} = "Institutional Fund - Growth & Income";
        $tiaacref_ids{"TIHYX"} = "Institutional Fund - High-Yield";
        $tiaacref_ids{"TIILX"} = "Institutional Fund - Inflation-Linked Bond";
        $tiaacref_ids{"TIIEX"} = "Institutional Fund - International Equity";
        $tiaacref_ids{"TCIEX"} = "Institutional Fund - International Equity Index";
        $tiaacref_ids{"TILGX"} = "Institutional Fund - Large-Cap Growth";
        $tiaacref_ids{"TILIX"} = "Institutional Fund - Large-Cap Growth Index";
        $tiaacref_ids{"TRLIX"} = "Institutional Fund - Large-Cap Value";
        $tiaacref_ids{"TILVX"} = "Institutional Fund - Large-Cap Value Index";
        $tiaacref_ids{"TCTIX"} = "Institutional Fund - Lifecycle 2010";
        $tiaacref_ids{"TCNIX"} = "Institutional Fund - Lifecycle 2015";
        $tiaacref_ids{"TCWIX"} = "Institutional Fund - Lifecycle 2020";
        $tiaacref_ids{"TCYIX"} = "Institutional Fund - Lifecycle 2025";
        $tiaacref_ids{"TCRIX"} = "Institutional Fund - Lifecycle 2030";
        $tiaacref_ids{"TCIIX"} = "Institutional Fund - Lifecycle 2035";
        $tiaacref_ids{"TCOIX"} = "Institutional Fund - Lifecycle 2040";
        $tiaacref_ids{"TTFIX"} = "Institutional Fund - Lifecycle 2045";
        $tiaacref_ids{"TFTIX"} = "Institutional Fund - Lifecycle 2050";
        $tiaacref_ids{"TLRIX"} = "Institutional Fund - Lifecycle Retirement Income";
        $tiaacref_ids{"TIMIX"} = "Institutional Fund - Managed Allocation";
        $tiaacref_ids{"TRPWX"} = "Institutional Fund - Mid-Cap Growth";
        $tiaacref_ids{"TIMVX"} = "Institutional Fund - Mid-Cap Value";
        $tiaacref_ids{"TCIXX"} = "Institutional Fund - Money Market";
        $tiaacref_ids{"TIREX"} = "Institutional Fund - Real Estate Securities";
        $tiaacref_ids{"TISPX"} = "Institutional Fund - S&P 500 Index";
        $tiaacref_ids{"TISIX"} = "Institutional Fund - Short-Term Bond";
        $tiaacref_ids{"TISBX"} = "Institutional Fund - Small-Cap Blend Index";
        $tiaacref_ids{"TISEX"} = "Institutional Fund - Small-Cap Equity";
        $tiaacref_ids{"TISCX"} = "Institutional Fund - Social Choice Equity";
        $tiaacref_ids{"TITIX"} = "Institutional Fund - Tax-Exempt Bond";
    }
    
    if (! %tiaacref_vals) {
        $tiaacref_vals{"CREFstok"} = "1001";
	$tiaacref_vals{"CREFmony"} = "1008";
	$tiaacref_vals{"CREFequi"} = "1004";
	$tiaacref_vals{"CREFinfb"} = "1007";
	$tiaacref_vals{"CREFbond"} = "1006";
	$tiaacref_vals{"CREFsoci"} = "1005";
	$tiaacref_vals{"CREFglob"} = "1002";
	$tiaacref_vals{"CREFgrow"} = "1003";
	$tiaacref_vals{"TIAAreal"} = "1009";
	$tiaacref_vals{"TIAAsndx"} = "1010";
	$tiaacref_vals{"TLSIX"}    = "1011";
	$tiaacref_vals{"TLGEX"}    = "1012";
	$tiaacref_vals{"TLGIX"}    = "1013";
	$tiaacref_vals{"TLIEX"}    = "1014";
	$tiaacref_vals{"TLSCX"}    = "1015";
	$tiaacref_vals{"TLLCX"}    = "1016";
	$tiaacref_vals{"TLCEX"}    = "1017";
	$tiaacref_vals{"TLREX"}    = "1018";

	$tiaacref_vals{"TIAXX"} = "76";

        $tiaacref_vals{"TIPBX"} = "75";
        $tiaacref_vals{"TCHYX"} = "82";
        $tiaacref_vals{"TCILX"} = "90";
        $tiaacref_vals{"TCSTX"} = "81";
        $tiaacref_vals{"TCTEX"} = "80";

        $tiaacref_vals{"TCREX"} = "89";

        $tiaacref_vals{"TCEIX"} = "84";
        $tiaacref_vals{"TIGEX"} = "72";
        $tiaacref_vals{"TIGIX"} = "73";
        $tiaacref_vals{"TIINX"} = "71";
        $tiaacref_vals{"TCLCX"} = "85";
        $tiaacref_vals{"TCMGX"} = "86";
        $tiaacref_vals{"TCMVX"} = "87";
        $tiaacref_vals{"TCSEX"} = "88";
        $tiaacref_vals{"TCSCX"} = "83";

        $tiaacref_vals{"TIMAX"} = "74";
        
        $tiaacref_vals{"TIDRX"} = "1641";
        $tiaacref_vals{"TBIRX"} = "1660";
        $tiaacref_vals{"TCBRX"} = "1638";
        $tiaacref_vals{"TEMSX"} = "1671";
        $tiaacref_vals{"TEQSX"} = "1672";
        $tiaacref_vals{"TIQRX"} = "1643";
        $tiaacref_vals{"TRGIX"} = "1616";
        $tiaacref_vals{"TIHRX"} = "1637";
        $tiaacref_vals{"TIKRX"} = "1640";
        $tiaacref_vals{"TRERX"} = "1618";
        $tiaacref_vals{"TRIEX"} = "1632";
        $tiaacref_vals{"TILRX"} = "1635";
        $tiaacref_vals{"TRIRX"} = "1624";
        $tiaacref_vals{"TRLCX"} = "1619";
        $tiaacref_vals{"TRCVX"} = "1625";
        $tiaacref_vals{"TCLEX"} = "1650";
        $tiaacref_vals{"TCLIX"} = "1651";
        $tiaacref_vals{"TCLTX"} = "1652";
        $tiaacref_vals{"TCLFX"} = "1653";
        $tiaacref_vals{"TCLNX"} = "1654";
        $tiaacref_vals{"TCLRX"} = "1655";
        $tiaacref_vals{"TCLOX"} = "1656";
        $tiaacref_vals{"TTFRX"} = "1657";
        $tiaacref_vals{"TLFRX"} = "1658";
        $tiaacref_vals{"TLIRX"} = "1659";
        $tiaacref_vals{"TITRX"} = "1636";
        $tiaacref_vals{"TRGMX"} = "1620";
        $tiaacref_vals{"TRVRX"} = "1621";
        $tiaacref_vals{"TIEXX"} = "1642";
        $tiaacref_vals{"TRRSX"} = "1622";
        $tiaacref_vals{"TRSPX"} = "1623";
        $tiaacref_vals{"TISRX"} = "1639";
        $tiaacref_vals{"TRBIX"} = "1629";
        $tiaacref_vals{"TRSEX"} = "1633";
        $tiaacref_vals{"TRSCX"} = "1617";
        
        $tiaacref_vals{"TIBDX"} = "1835";
        $tiaacref_vals{"TBIIX"} = "1837";
        $tiaacref_vals{"TIBFX"} = "1827";
        $tiaacref_vals{"TEMLX"} = "1848";
        $tiaacref_vals{"TEQLX"} = "1849";
        $tiaacref_vals{"TFIIX"} = "1822";
        $tiaacref_vals{"TLIIX"} = "1820";
        $tiaacref_vals{"TEVIX"} = "1821";
        $tiaacref_vals{"TIEIX"} = "1833";
        $tiaacref_vals{"TIGRX"} = "1832";
        $tiaacref_vals{"TIHYX"} = "1826";
        $tiaacref_vals{"TIILX"} = "1605";
        $tiaacref_vals{"TIIEX"} = "1830";
        $tiaacref_vals{"TCIEX"} = "1615";
        $tiaacref_vals{"TILGX"} = "1824";
        $tiaacref_vals{"TILIX"} = "1607";
        $tiaacref_vals{"TRLIX"} = "1601";
        $tiaacref_vals{"TILVX"} = "1608";
        $tiaacref_vals{"TCTIX"} = "1810";
        $tiaacref_vals{"TCNIX"} = "1811";
        $tiaacref_vals{"TCWIX"} = "1812";
        $tiaacref_vals{"TCYIX"} = "1813";
        $tiaacref_vals{"TCRIX"} = "1814";
        $tiaacref_vals{"TCIIX"} = "1815";
        $tiaacref_vals{"TCOIX"} = "1816";
        $tiaacref_vals{"TTFIX"} = "1817";
        $tiaacref_vals{"TFTIX"} = "1818";
        $tiaacref_vals{"TLRIX"} = "1819";
        $tiaacref_vals{"TIMIX"} = "1825";
        $tiaacref_vals{"TRPWX"} = "1602";
        $tiaacref_vals{"TIMVX"} = "1603";
        $tiaacref_vals{"TCIXX"} = "1836";
        $tiaacref_vals{"TIREX"} = "1604";
        $tiaacref_vals{"TISPX"} = "1606";
        $tiaacref_vals{"TISIX"} = "1828";
        $tiaacref_vals{"TISBX"} = "1612";
        $tiaacref_vals{"TISEX"} = "1634";
        $tiaacref_vals{"TISCX"} = "1834";
        $tiaacref_vals{"TITIX"} = "1829";
    }
    
#The location doesn't matter anymore. 
#I'm leaving this data structure in place in case it changes again
#FBN 23/JAN/04
    
    if (! %tiaacref_locs) {
        $tiaacref_locs{"CREFstok"} = 1;
        $tiaacref_locs{"CREFmony"} = 1;
        $tiaacref_locs{"CREFequi"} = 1;
        $tiaacref_locs{"CREFinfb"} = 1;
        $tiaacref_locs{"CREFbond"} = 1;
        $tiaacref_locs{"CREFsoci"} = 1;
        $tiaacref_locs{"CREFglob"} = 1;
        $tiaacref_locs{"CREFgrow"} = 1;
        $tiaacref_locs{"TIAAreal"} = 1;
        $tiaacref_locs{"TIAAsndx"} = 1;
        $tiaacref_locs{"TLSIX"}    = 1;
        $tiaacref_locs{"TLGEX"}    = 1;
        $tiaacref_locs{"TLGIX"}    = 1;
        $tiaacref_locs{"TLIEX"}    = 1;
        $tiaacref_locs{"TLSCX"}    = 1;
        $tiaacref_locs{"TLLCX"}    = 1;
        $tiaacref_locs{"TLCEX"}    = 1;
        $tiaacref_locs{"TLREX"}    = 1;

	$tiaacref_locs{"TIAXX"} = 1;

        $tiaacref_locs{"TIPBX"} = 1;
        $tiaacref_locs{"TCHYX"} = 1;
        $tiaacref_locs{"TCILX"} = 1;
        $tiaacref_locs{"TCSTX"} = 1;
        $tiaacref_locs{"TCTEX"} = 1;

        $tiaacref_locs{"TCREX"} = 1;

        $tiaacref_locs{"TCEIX"} = 1;
        $tiaacref_locs{"TIGEX"} = 1;
        $tiaacref_locs{"TIGIX"} = 1;
        $tiaacref_locs{"TIINX"} = 1;
        $tiaacref_locs{"TCLCX"} = 1;
        $tiaacref_locs{"TCMGX"} = 1;
        $tiaacref_locs{"TCMVX"} = 1;
        $tiaacref_locs{"TCSEX"} = 1;
        $tiaacref_locs{"TCSCX"} = 1;

        $tiaacref_locs{"TIMAX"} = 1;
        
        $tiaacref_locs{"TIDRX"} = 1;
        $tiaacref_locs{"TBIRX"} = 1;
        $tiaacref_locs{"TCBRX"} = 1;
        $tiaacref_locs{"TEMSX"} = 1;
        $tiaacref_locs{"TEQSX"} = 1;
        $tiaacref_locs{"TIQRX"} = 1;
        $tiaacref_locs{"TRGIX"} = 1;
        $tiaacref_locs{"TIHRX"} = 1;
        $tiaacref_locs{"TIKRX"} = 1;
        $tiaacref_locs{"TRERX"} = 1;
        $tiaacref_locs{"TRIEX"} = 1;
        $tiaacref_locs{"TILRX"} = 1;
        $tiaacref_locs{"TRIRX"} = 1;
        $tiaacref_locs{"TRLCX"} = 1;
        $tiaacref_locs{"TRCVX"} = 1;
        $tiaacref_locs{"TCLEX"} = 1;
        $tiaacref_locs{"TCLIX"} = 1;
        $tiaacref_locs{"TCLTX"} = 1;
        $tiaacref_locs{"TCLFX"} = 1;
        $tiaacref_locs{"TCLNX"} = 1;
        $tiaacref_locs{"TCLRX"} = 1;
        $tiaacref_locs{"TCLOX"} = 1;
        $tiaacref_locs{"TTFRX"} = 1;
        $tiaacref_locs{"TLFRX"} = 1;
        $tiaacref_locs{"TLIRX"} = 1;
        $tiaacref_locs{"TITRX"} = 1;
        $tiaacref_locs{"TRGMX"} = 1;
        $tiaacref_locs{"TRVRX"} = 1;
        $tiaacref_locs{"TIEXX"} = 1;
        $tiaacref_locs{"TRRSX"} = 1;
        $tiaacref_locs{"TRSPX"} = 1;
        $tiaacref_locs{"TISRX"} = 1;
        $tiaacref_locs{"TRBIX"} = 1;
        $tiaacref_locs{"TRSEX"} = 1;
        $tiaacref_locs{"TRSCX"} = 1;
        
        $tiaacref_locs{"TIBDX"} = 3;
        $tiaacref_locs{"TBIIX"} = 3;
        $tiaacref_locs{"TIBFX"} = 3;
        $tiaacref_locs{"TEMLX"} = 3;
        $tiaacref_locs{"TEQLX"} = 3;
        $tiaacref_locs{"TFIIX"} = 3;
        $tiaacref_locs{"TLIIX"} = 3;
        $tiaacref_locs{"TEVIX"} = 3;
        $tiaacref_locs{"TIEIX"} = 3;
        $tiaacref_locs{"TIGRX"} = 3;
        $tiaacref_locs{"TIHYX"} = 3;
        $tiaacref_locs{"TIILX"} = 3;
        $tiaacref_locs{"TIIEX"} = 3;
        $tiaacref_locs{"TCIEX"} = 3;
        $tiaacref_locs{"TILGX"} = 3;
        $tiaacref_locs{"TILIX"} = 3;
        $tiaacref_locs{"TRLIX"} = 3;
        $tiaacref_locs{"TILVX"} = 3;
        $tiaacref_locs{"TCTIX"} = 3;
        $tiaacref_locs{"TCNIX"} = 3;
        $tiaacref_locs{"TCWIX"} = 3;
        $tiaacref_locs{"TCYIX"} = 3;
        $tiaacref_locs{"TCRIX"} = 3;
        $tiaacref_locs{"TCIIX"} = 3;
        $tiaacref_locs{"TCOIX"} = 3;
        $tiaacref_locs{"TTFIX"} = 3;
        $tiaacref_locs{"TFTIX"} = 3;
        $tiaacref_locs{"TLRIX"} = 3;
        $tiaacref_locs{"TIMIX"} = 3;
        $tiaacref_locs{"TRPWX"} = 3;
        $tiaacref_locs{"TIMVX"} = 3;
        $tiaacref_locs{"TCIXX"} = 3;
        $tiaacref_locs{"TIREX"} = 3;
        $tiaacref_locs{"TISPX"} = 3;
        $tiaacref_locs{"TISIX"} = 3;
        $tiaacref_locs{"TISBX"} = 3;
        $tiaacref_locs{"TISEX"} = 3;
        $tiaacref_locs{"TISCX"} = 3;
        $tiaacref_locs{"TITIX"} = 3;
    }
    my(@funds) = @_;
    return unless @funds;
    my(@line);		#holds the return from parse_csv
    my(%info);
    my(%check);		#holds success value if data returned	
    my($ua,$urlc,$urlci,$urlt);   #useragent and target urls
    my($cntc,$cntci,$cntt); #counters for each of the two url containers
    my($reply,$qdata);		#the reply from TIAA-CREF's cgi and a buffer for the data
    my $cbResult = 'cbResults=';
    my $cbResulti = 'cbResults=';

    $urlc  = $CREF_URL;
    $urlc .= "page=input&numdays=2&sqlorder=asc&dldformat=1&submit.x=29&submit.y=7";
    $urlci  = $CREF_URL_INST;
    $urlci .= "page=input&numdays=2&sqlorder=asc&dldformat=1&submit.x=29&submit.y=7";

    $urlt = $TIAA_URL;
#Initialize counters for the two types of URL. If either counter is zero, then
# that URL will not be retrieved. This is less technically clever than testing
#the URL string itself with m/yes/, but its faster.
    $cntc = 0;
    $cntci = 0;
    $cntt = 0;
    foreach my $fund (@funds) {
	if ($tiaacref_ids{$fund}) {
        	if ($tiaacref_locs{$fund} == 1) {
			$cntc++;
			$urlc .= "&fundid" . $tiaacref_vals{$fund} . "=" . $tiaacref_vals{$fund};
			$cbResult .= ($cntc > 1) ? ( "%2C" . $tiaacref_vals{$fund}) : ($tiaacref_vals{$fund})
		} elsif ($tiaacref_locs{$fund} == 3) {
			$cntci++;
			$urlci .= "&fundid" . $tiaacref_vals{$fund} . "=" . $tiaacref_vals{$fund};
			$cbResulti .= ($cntci > 1) ? ( "%2C" . $tiaacref_vals{$fund}) : ($tiaacref_vals{$fund})
		} else {
 			$urlt .= $fund . "=yes&";
			$cntt++;
		}
		$check{$fund} = 0;
	} else {
		$info{$fund,"success"} = 0;
		$info{$fund,"errormsg"} = "Bad symbol";
	}
    }
    $urlc .=  "&$cbResult";
    $urlci .=  "&$cbResulti";
    $urlt .=  "selected=1";
    $qdata ="";

    $ua = $quoter->user_agent;
    if ($cntc) {
    	$reply = $ua->request(GET $urlc);
        if ($reply ->is_success) {
            $qdata .= $reply->content;
	}
    }
    if ($cntci) {
    	$reply = $ua->request(GET $urlci);
        if ($reply ->is_success) {
            $qdata .= $reply->content;
	}
    }
    if ($cntt) {
        $reply = $ua->request(GET $urlt);
        if ($reply ->is_success) {
            $qdata .= $reply->content;
	}
    }

    if (length($qdata)) {
       foreach (split(/<br .>/,$qdata) ){
	   next unless m/.+,.+/;
	   s/[\r\n]+//g;
	   s/^ +//g;
	   s/ +$//g;
           @line = $quoter->parse_csv($_);
	       
           if (exists $check{$line[0]}) {   #did we ask for this data?
		  $info{$line[0],"symbol"} = $line[0]; #in case the caller needs this in the hash
         	  $info{$line[0],"exchange"} = "TIAA-CREF";
         	  $info{$line[0],"name"} = $tiaacref_ids{$line[0]};
		  $quoter->store_date(\%info, $line[0], {usdate => $line[2]});
         	  $info{$line[0],"nav"} =  $line[1];	
		  $info{$line[0],"price"} = $info{$line[0],"nav"};
	 	  $info{$line[0],"success"} = 1; #this contains good data, 
                                                 #beyond a reasonable doubt
                  $info{$line[0],"currency"} = "USD";
		  $info{$line[0],"method"} = "tiaacref";
		  $info{$line[0],"exchange"} = "TIAA-CREF";
	 	  $check{$line[0]} = 1;
	  } else {
	  	$info{$line[0],"success"} = 0;
	  	$info{$line[0],"errormsg"} = "Bad data returned";
	  }
       }
    } else {
	foreach $_ (@funds) {
		$info{$_,"success"} = 0;
		$info{$_,"errormsg"} = "HTTP error";
	} # foreach
	
    } #if $length(qdata) else
    
    
    #now check to make sure a value was returned for every symbol asked for
    foreach my $k (keys %check) {
    	if ($check{$k} == 0) {
    		$info{$k,"success"} = 0;
    		$info{$k,"errormsg"} = "No data returned";
    	}
    }

    return %info if wantarray;
    return \%info;
}

1;

=head1 NAME

Finance::Quote::Tiaacref	- Obtain quote from TIAA-CREF.

=head1 SYNOPSIS

    use Finance::Quote;

    $q = Finance::Quote->new;

    %stockinfo = $q->fetch("tiaacref","TIAAreal");

=head1 DESCRIPTION

This module obtains information about TIAA-CREF managed funds.

The following symbols can be used:

    Stock: 				CREFstok
    Money Market:			CREFmony
    Equity Index:			CREFequi
    Inf-Linked Bond:			CREFinfb
    Bond Market:			CREFbond
    Social Choice:			CREFsoci
    Global Equities:			CREFglob
    Growth:				CREFgrow
    TIAA Real Estate:			TIAAreal

    PA Stock Index:			TIAAsndx
    PA Select Stock:			TLSIX
    PA Select Growth Equity:		TLGEX
    PA Select Growth Income:		TLGIX
    PA Select Int'l Equity:		TLIEX
    PA Select Social Choice:		TLSCX
    PA Select Large Cap Value:		TLLCX
    PA Select Small Cap Equity:		TLCEX
    PA Select Real Estate:		TLREX

    TIAA-CREF Money Market:             TIAXX
    TIAA-CREF Bond Plus:                TIPBX
    TIAA-CREF High-Yield Bond:          TCHYX
    TIAA-CREF Inflation-Linked Bond:    TCILX
    TIAA-CREF Short-Term Bond:          TCSTX
    TIAA-CREF Tax-Exempt Bond:          TCTEX
    TIAA-CREF Real Estate Securities:   TCREX
    TIAA-CREF Equity Index:             TCEIX
    TIAA-CREF Growth Equity:            TIGEX
    TIAA-CREF Growth & Income:          TIGIX
    TIAA-CREF International Equity:     TIINX
    TIAA-CREF Large-Cap Value:          TCLCX
    TIAA-CREF Mid-Cap Growth:           TCMGX
    TIAA-CREF Mid-Cap Value:            TCMVX
    TIAA-CREF Small-Cap Equity:         TCSEX
    TIAA-CREF Social Choice Equity:     TCSCX
    TIAA-CREF Managed Allocation:       TIMAX

    TIAA-CREF Retirement Fund - Bond:                   TIDRX
    TIAA-CREF Retirement Fund - Bond Index:             TBIRX
    TIAA-CREF Retirement Fund - Bond Plus:              TCBRX
    TIAA-CREF Retirement Fund - Emerging Markets Equity: TEMSX
    TIAA-CREF Retirement Fund - Emerging Markets Equity Index: TEQSX
    TIAA-CREF Retirement Fund - Equity Index:           TIQRX
    TIAA-CREF Retirement Fund - Growth & Income:        TRGIX
    TIAA-CREF Retirement Fund - High-Yield:             TIHRX
    TIAA-CREF Retirement Fund - Inflation-Linked Bond:  TIKRX
    TIAA-CREF Retirement Fund - International Equity:   TRERX
    TIAA-CREF Retirement Fund - International Equity Index: TRIEX
    TIAA-CREF Retirement Fund - Large-Cap Growth:       TILRX
    TIAA-CREF Retirement Fund - Large-Cap Growth Index: TRIRX
    TIAA-CREF Retirement Fund - Large-Cap Value:        TRLCX
    TIAA-CREF Retirement Fund - Large-Cap Value Index:  TRCVX
    TIAA-CREF Retirement Fund - Lifecycle 2010:         TCLEX
    TIAA-CREF Retirement Fund - Lifecycle 2015:         TCLIX
    TIAA-CREF Retirement Fund - Lifecycle 2020:         TCLTX
    TIAA-CREF Retirement Fund - Lifecycle 2025:         TCLFX
    TIAA-CREF Retirement Fund - Lifecycle 2030:         TCLNX
    TIAA-CREF Retirement Fund - Lifecycle 2035:         TCLRX
    TIAA-CREF Retirement Fund - Lifecycle 2040:         TCLOX
    TIAA-CREF Retirement Fund - Lifecycle 2045:         TTFRX
    TIAA-CREF Retirement Fund - Lifecycle 2050:         LFRX
    TIAA-CREF Retirement Fund - Lifecycle Retirement Income: TLIRX
    TIAA-CREF Retirement Fund - Managed Allocation:     TITRX
    TIAA-CREF Retirement Fund - Mid-Cap Growth:         TRGMX
    TIAA-CREF Retirement Fund - Mid-Cap Value:          TRVRX
    TIAA-CREF Retirement Fund - Money Market:           TIEXX
    TIAA-CREF Retirement Fund - Real Estate Securities: TRRSX
    TIAA-CREF Retirement Fund - S&P 500 Index:          TRSPX
    TIAA-CREF Retirement Fund - Short-Term Bond:        TISRX
    TIAA-CREF Retirement Fund - Cap Blend Index:        TRBIX
    TIAA-CREF Retirement Fund - Small-Cap Equity:       TRSEX
    TIAA-CREF Retirement Fund - Social Choice Equity:   TRSCX

    TIAA-CREF Institutional Fund - Bond:                TIBDX
    TIAA-CREF Institutional Fund - Bond Index:          TBIIX
    TIAA-CREF Institutional Fund - Bond Plus:           TIBFX
    TIAA-CREF Institutional Fund - Emerging Markets Equity: TEMLX
    TIAA-CREF Institutional Fund - Emerging Markets Equity Index: TEQLX
    TIAA-CREF Institutional Fund - Enhanced International Equity Index: TFIIX
    TIAA-CREF Institutional Fund - Enhanced Large-Cap Growth Index: TLIIX
    TIAA-CREF Institutional Fund - Enhanced Large-Cap Value Index: TEVIX
    TIAA-CREF Institutional Fund - Equity Index:        TIEIX
    TIAA-CREF Institutional Fund - Growth & Income:     TIGRX
    TIAA-CREF Institutional Fund - High-Yield:          TIHYX
    TIAA-CREF Institutional Fund - Inflation-Linked Bond: TIILX
    TIAA-CREF Institutional Fund - International Equity: TIIEX
    TIAA-CREF Institutional Fund - International Equity Index: TCIEX
    TIAA-CREF Institutional Fund - Large-Cap Growth:    TILGX
    TIAA-CREF Institutional Fund - Large-Cap Growth Index: TILIX
    TIAA-CREF Institutional Fund - Large-Cap Value:     TRLIX
    TIAA-CREF Institutional Fund - Large-Cap Value Index: TILVX
    TIAA-CREF Institutional Fund - Lifecycle 2010:      TCTIX
    TIAA-CREF Institutional Fund - Lifecycle 2015:      TCNIX
    TIAA-CREF Institutional Fund - Lifecycle 2020:      TCWIX
    TIAA-CREF Institutional Fund - Lifecycle 2025:      TCYIX
    TIAA-CREF Institutional Fund - Lifecycle 2030:      TCRIX
    TIAA-CREF Institutional Fund - Lifecycle 2035:      TCIIX
    TIAA-CREF Institutional Fund - Lifecycle 2040:      TCOIX
    TIAA-CREF Institutional Fund - Lifecycle 2045:      TTFIX
    TIAA-CREF Institutional Fund - Lifecycle 2050:      TFTIX
    TIAA-CREF Institutional Fund - Lifecycle Retirement Income: TLRIX
    TIAA-CREF Institutional Fund - Managed Allocation:  TIMIX
    TIAA-CREF Institutional Fund - Mid-Cap Growth:      TRPWX
    TIAA-CREF Institutional Fund - Mid-Cap Value:       TIMVX
    TIAA-CREF Institutional Fund - Money Market:        TCIXX
    TIAA-CREF Institutional Fund - Real Estate Securities: TIREX
    TIAA-CREF Institutional Fund - S&P 500 Index:       TISPX
    TIAA-CREF Institutional Fund - Short-Term Bond:     TISIX
    TIAA-CREF Institutional Fund - Small-Cap Blend Index: TISBX
    TIAA-CREF Institutional Fund - Small-Cap Equity:    TISEX
    TIAA-CREF Institutional Fund - Social Choice Equity: TISCX
    TIAA-CREF Institutional Fund - Tax-Exempt Bond:     TITIX


This module is loaded by default on a Finance::Quote object.  It's
also possible to load it explicitly by passing "Tiaacref" in to the
argument argument list of Finance::Quote->new().

Information returned by this module is governed by TIAA-CREF's terms
and conditions.

=head1 LABELS RETURNED

The following labels may be returned by Finance::Quote::Tiaacref:
symbol, exchange, name, date, nav, price.

=head1 SEE ALSO

TIAA-CREF, http://www.tiaa-cref.org/

=cut


More information about the gnucash-user mailing list