Tuesday, February 2, 2021

Tip -- 2.1a - Using the smfUpdateDownloadTable macro

---In smf_addin@yahoogroups.com, <rharmelink@...> wrote :

I use the smfUpdateDownloadTable macro for such situations.  This would actually place values into the table, so no recalculation occurs.  When I want "fresh" values, I just rerun the macro.  Here is the documentation for the table setup from the macro's module:
  1. The upper left hand corner cell of the table needs to have a range name of "Ticker"
  2. The cells below the "Ticker" cell should be filled in with ticker symbols, one per cell
  3. The cells to the right of the "Ticker" cell should be filled with column titles
  4. The cells above the column titles need to be filled in with SMF add-in formulas or element numbers.  Use five tildas as a substitute for a ticker symbol.  For example, any of the following text strings could be used to get "Market Capitalization" from Yahoo:

    941
    RCHGetElementNumber("~~~~~", 941)
    RCHGetTableCell("http://finance.yahoo.com/q/ks?s=~~~~~",1,">Market Cap")
A recent addition to the process is that if the cell entry above a column title is an "x", that column is skipped from any update -- I use this for any calculation columns I want in the middle of my table.  In all of my workbooks, I assign the smfUpdateDownloadTable macro to a keyboard shortcut of Ctrl-Shift-J.

On 10/19/07, rjlabs <rick@...> wrote:
>
> I have a large table of =RCHGetElementNumber() that has historical
> quarterly info that I only need to update sporadically. It takes about
> 15 minutes to update (about 60 tickers x 150 fields).
>
> Is there a way I can control when those functions run and update? I
> want to be able to open the spreadsheet with perhaps stale data and
> not have it update. However I don't want to set calculation to manual
> because other parts of the workbook I want regularly calculating. (Any
> programmer guide or FAQ or embedded docs on this just point me to them.) 

Wednesday, January 6, 2021

Tip -- Using smfGetCSVFile() to grab Yahoo Historical quotes

It appears that Yahoo once again has an easy-to-grab CSV file of their historical quotes available directly via a URL. See the link below for an example, using the smfGetCSVFile() function. It does use the new EXCEL "spill" feature -- if you don't have that available, all you will see is "Date" for the function, as you would need to array-enter the function. The new "spill" feature automatically expands any array function to fill the range is has data for.

SMF-Sample-smfGetCSVFile-Yahoo-Historical-Quotes.xlsm

Tuesday, January 5, 2021

Alert -- RCHGetYahooQuotes() issue

When I wrote RCHGetYahooHistory() well over a decade ago, the default ending date was 2020-12-31 if no date information was passed.

You can either switch over and use the new smfGetYahooHistory(), or specify a different ending year (e.g. 2030) for RCHGetYahooHistory().

Friday, December 4, 2020

Alert -- Updates to Zacks Element Definitions

 Zacks recently made some changes to their quote web page, so some defined elements on smf-elements-6.txt needed to be updated.

New files on the web site: 
Best practice is to exit EXCEL when updating SMF add-in files.

Updated element definitions:

# UsageSourceElementTemplate or NotesUpdated
13869SZacksMarket CapitalizationSMF-Template-Zacks-Data.xls2020-12-04
13871SZacksCurrent Year EstimateSMF-Template-Zacks-Data.xls2020-12-04
13872SZacksEPS Last YearSMF-Template-Zacks-Data.xls2020-12-04
13891SZacksBetaSMF-Template-Zacks-Data.xls2020-12-04
13892SZacksForward P/ESMF-Template-Zacks-Data.xls2020-12-04
13896SZacksSectorSMF-Template-Zacks-Data.xls2020-12-04
 

Wednesday, November 18, 2020

Tip: Data retrieval with Python

If you're not familiar with Python, you should learn. It's a powerful programming language that can extract data from websites. And there are many code libraries for doing that retrieval. 

The Google Colaboratory website allows you to easily run Python code from the browser:

https://colab.research.google.com/notebooks/intro.ipynb#recent=true

A good introduction to retrieving Yahoo data is here:

https://medium.com/@realmistic/use-your-computer-to-make-informed-decisions-in-stock-trading-practical-introduction-part-2-832e6f67f590

For example, a program as simple as:

!pip install yfinance
import yfinance as yf
pfe = yf.Ticker('PFE')
pfe.info

...will allow access to all of this data:

{'52WeekChange': 0.025267482,
 'SandP52WeekChange': 0.16119564,
 'address1': '235 East 42nd Street',
 'algorithm': None,
 'annualHoldingsTurnover': None,
 'annualReportExpenseRatio': None,
 'ask': 36.55,
 'askSize': 4000,
 'averageDailyVolume10Day': 82095557,
 'averageVolume': 31018400,
 'averageVolume10days': 82095557,
 'beta': 0.641488,
 'beta3Year': None,
 'bid': 36.52,
 'bidSize': 1800,
 'bookValue': 11.744,
 'category': None,
 'circulatingSupply': None,
 'city': 'New York',
 'companyOfficers': [],
 'country': 'United States',
 'currency': 'USD',
 'dateShortInterest': 1604016000,
 'dayHigh': 37.42,
 'dayLow': 36.3,
 'dividendRate': 1.52,
 'dividendYield': 0.0422,
 'earningsQuarterlyGrowth': -0.714,
 'enterpriseToEbitda': 13.11,
 'enterpriseToRevenue': 5.206,
 'enterpriseValue': 253279617024,
 'exDividendDate': 1604534400,
 'exchange': 'NYQ',
 'exchangeTimezoneName': 'America/New_York',
 'exchangeTimezoneShortName': 'EST',
 'expireDate': None,
 'fiftyDayAverage': 35.149593,
 'fiftyTwoWeekHigh': 39.83871,
 'fiftyTwoWeekLow': 26.451612,
 'fiveYearAverageReturn': None,
 'fiveYearAvgDividendYield': 3.62,
 'floatShares': 5548891741,
 'forwardEps': 2.84,
 'forwardPE': 12.788733,
 'fromCurrency': None,
 'fullTimeEmployees': 88300,
 'fundFamily': None,
 'fundInceptionDate': None,
 'gmtOffSetMilliseconds': '-18000000',
 'heldPercentInsiders': 0.00046999997,
 'heldPercentInstitutions': 0.70032,
 'industry': 'Drug Manufacturers—General',
 'isEsgPopulated': False,
 'lastCapGain': None,
 'lastDividendDate': 1604534400,
 'lastDividendValue': 0.36053,
 'lastFiscalYearEnd': 1577750400,
 'lastMarket': None,
 'lastSplitDate': 1605571200,
 'lastSplitFactor': '1054:1000',
 'legalType': None,
 'logo_url': 'https://logo.clearbit.com/pfizer.com',
 'longBusinessSummary': 'Pfizer Inc. develops, manufactures, and sells healthcare products worldwide. It offers medicines and vaccines in various therapeutic areas, including cardiovascular metabolic and pain under the Eliquis, Chantix/Champix, and Premarin family brands; biologics, small molecules, immunotherapies, and biosimilars under the Ibrance, Sutent, Xtandi, Xalkori, Inlyta, Braftovi + Mektovi brands; and sterile injectable and anti-infective medicines under the Sulperazon, Medrol, Vfend, and Zithromax brands. The company also provides medicines and vaccines in various therapeutic areas, such as pneumococcal disease, meningococcal disease, and tick-borne encephalitis under the Prevnar 13/Prevenar 13 (pediatric/adult), FSME-IMMUN, Nimenrix, and Trumenba brands; biosimilars for chronic immune and inflammatory diseases under the Xeljanz, Enbrel, Inflectra, and Eucrisa brands; and amyloidosis, hemophilia, and endocrine diseases under the Vyndaqel/Vyndamax, BeneFIX, Genotropin, and Refacto AF/Xyntha brands. In addition, the company is involved in the contract manufacturing business. It serves wholesalers, retailers, hospitals, clinics, government agencies, pharmacies, and individual provider offices, as well as disease control and prevention centers. The company has collaboration and/or co-promotion agreements with Bristol-Myers Squibb Company and Astellas Pharma US, Inc.; a licensing agreement with Akcea Therapeutics, Inc; a strategic alliance with Verily Life Sciences LLC; collaboration agreements with Merck KGaA and Valneva SE; a clinical trial collaboration and supply agreement with IDEAYA Biosciences, Inc.; a material transfer and collaboration agreement with BioNTech SE; a clinical supply collaboration with Jiangsu Alphamab Biopharmaceuticals Co., Ltd; a research collaboration and license agreement with BioInvent International AB; and a multi-target drug discovery collaboration with Sosei Group Corporation. Pfizer Inc. was founded in 1849 and is headquartered in New York, New York.',
 'longName': 'Pfizer Inc.',
 'market': 'us_market',
 'marketCap': 201881092096,
 'maxAge': 1,
 'maxSupply': None,
 'messageBoardId': 'finmb_162270',
 'morningStarOverallRating': None,
 'morningStarRiskRating': None,
 'mostRecentQuarter': 1601164800,
 'navPrice': None,
 'netIncomeToCommon': 8686000128,
 'nextFiscalYearEnd': 1640908800,
 'open': 36.93,
 'openInterest': None,
 'payoutRatio': 0.96769994,
 'pegRatio': -12.73,
 'phone': '212 733 2323',
 'previousClose': 36.04,
 'priceHint': 2,
 'priceToBook': 3.092643,
 'priceToSalesTrailing12Months': 4.1497483,
 'profitMargins': 0.17854,
 'quoteType': 'EQUITY',
 'regularMarketDayHigh': 37.42,
 'regularMarketDayLow': 36.3,
 'regularMarketOpen': 36.93,
 'regularMarketPreviousClose': 36.04,
 'regularMarketPrice': 36.93,
 'regularMarketVolume': 62576363,
 'revenueQuarterlyGrowth': None,
 'sector': 'Healthcare',
 'sharesOutstanding': 5558400000,
 'sharesPercentSharesOut': 0.0083,
 'sharesShort': 45925049,
 'sharesShortPreviousMonthDate': 1601424000,
 'sharesShortPriorMonth': 45163995,
 'shortName': 'Pfizer, Inc.',
 'shortPercentOfFloat': 0.0083,
 'shortRatio': 1.93,
 'startDate': None,
 'state': 'NY',
 'strikePrice': None,
 'symbol': 'PFE',
 'threeYearAverageReturn': None,
 'toCurrency': None,
 'totalAssets': None,
 'tradeable': False,
 'trailingAnnualDividendRate': 1.5,
 'trailingAnnualDividendYield': 0.041620422,
 'trailingEps': 1.538,
 'trailingPE': 23.615084,
 'twoHundredDayAverage': 34.76005,
 'volume': 62576363,
 'volume24Hr': None,
 'volumeAllCurrencies': None,
 'website': 'http://www.pfizer.com',
 'yield': None,
 'ytdReturn': None,
 'zip': '10017'}

 

Tuesday, October 20, 2020

Alert -- Issue with smfGetGuruFocusItem()

 Unfortunately, GuruFocus has changed the way HTML class labels are used on their web page, and those were the labels that the function uses as search terms. I made some simple changes that fixed many, but there were also many that they didn't make the same changes to, so then those broke. It seems like any fix I make to the current algorithm to fix one extraction breaks some other extraction.

It looks like they've also changed a few line item labels.

...Later...

I made a compromise and abandoned the old search tags, now keying off the TTM item. That was the way I originally did it, but there were issues with companies that didn't have enough quarterly items. But I'd rather have it work for everything else and not those than not work for anything.

It looks like the things I'm getting an outright "Error" on are a result of the line item simply not existing for the company.

Because I am a subscriber, I never use this function. The smfGetGuruFocusCSVItem() function is much faster at data retrieval and more comprehensive. 

Here is an interim XLA file until I decide what more I want to do, if anything.

Updated XLA file

You should exit EXCEL before updating the XLA file.

Tuesday, September 29, 2020

Alert -- Updates to Zacks Element Definitions

 Zacks recently made some changes to their quote web page, so some defined elements on smf-elements-6.txt needed to be updated.

New files on the web site: 
Best practice is to exit EXCEL when updating SMF add-in files.

Updated element definitions:

#UsageSourceElementTemplate or NotesUpdated
844SZacksStock Style, ValueSMF-Template-Zacks-Data.xls2020-09-20
845SZacksStock Style, GrowthSMF-Template-Zacks-Data.xls2020-09-20
846SZacksStock Style, MomentumSMF-Template-Zacks-Data.xls2020-09-20
847SZacksStock Style, VGMSMF-Template-Zacks-Data.xls2020-09-20
848SZacksZacks RankSMF-Template-Zacks-Data.xls2020-09-20