or if that page is down then from the wayback machine
The author considers it obsolete, but the code may still be of interest for ideas on showing a quote in the mode line, updating periodically, and optional price change triggers.
The web sites used by the two builtin retrieval methods have changed. Money Quick Quotes has gone away, and Quicken now merely redirects to Yahoo Finance.
The following code got prices from the Yahoo Finance (http://finance.yahoo.com) CSV query. Alas Yahoo has discontinued that interface. (As of Jan 2019 it has two forms of JSON, one with cookies and one without, both needing parsing and some truncating of decimals due to floating point.)
(defun my-stock-quote-yahoo (ticker) "Download a stock price using Yahoo Finance (CSV format)." (require 'url) (with-temp-buffer (let (url-show-status) ;; url prior to about 2002 leaves some headers as invisible ;; text when reading http/1.1 chunked, workaround that by ;; retrieving and matching the stock code (url-insert-file-contents ;; s=FOO is the stock, f=sl1 asks for stock and last price (concat "http://quote.yahoo.com/d?f=sl1&s=" ticker)) (set-buffer-modified-p nil)) ;; yahoo gives "N/A" for an unknown ticker, which comes out as 0 ;; from string-to-number, maybe throwing an error would be better (goto-char (point-min)) (re-search-forward (concat (regexp-quote ticker) "\",\\(.+\\)")) (string-to-number (match-string 1)))) (custom-add-option 'stock-quote-data-functions 'my-stock-quote-yahoo)
(setq stock-quote-data-functions '(my-stock-quote-yahoo))
global-mode-string setup doesn’t seem quite right if that variable is
nil. If you’re using
customize-variable stock-quote-in-modeline then you might need
(setq global-mode-string (list ""))