Next: Concept Index, Previous: Internationalization, Up: Top [Index]
http://www.gnu.org/software/emacs/
chartprog.el shows the Chart watchlist and gets quotes within Emacs (see The Emacs Editor in The Emacs Editor). It’s designed for Emacs 21 and higher, and also works with XEmacs 21 if you have the UTF-8 coding system (see below).
The Debian package has the following setups already. Otherwise, the best way to use chartprog.el is with autoloads for the commands. chartprog-loaddefs.el is a small file which sets this up. Add the following to your .emacs file (see The Init File ~/.emacs in The Emacs Editor),
(require 'chartprog-loaddefs)
The build system currently doesn’t install chartprog.el into
site-lisp, so you should copy it and chartprog-loaddefs.el to
somewhere in your load-path
(see Libraries of Lisp
Code for Emacs in The Emacs Editor).
M-x chart-watchlist displays the Favourites list in a buffer. Key a adds a symbol. C-k and C-y kill and yank symbols. g refreshes the quotes. L selects a different list (like the Alerts list). The usual C-h m mode help shows other key bindings.
Chart communicates changes to the lists between the Emacs display and a running Chart GUI. So if you have both open then changes in one are reflected in the other a moment later.
M-x chart-quote displays a quote for a given symbol in the message area. It prompts for the symbol with default a symbol at point. Tab completion is available (see Completion in The Emacs Editor) using the database symbols, favourites list, and previously requested symbols.
M-x chart-quote-at-point displays a quote for the symbol at point, without prompting.
The language, date formats, etc, follow the Chart locale selection described in Internationalization. Emacs M-x set-language-environment and other Emacs setups don’t influence the display.
UTF-8 is used in Emacs, the same as in the Gtk GUI display. This is easiest to implement, and should mean whatever is seen in the GUI can be seen in Emacs.
If you use an Asian locale then you probably know Emacs 21 has limited support for Asian parts of UTF-8. The typical symptom is ‘\207’, ‘\221’ etc in the display. Install the MULE-UCS package to add to the builtin characters: http://www.m17n.org
If you use XEmacs 21 you probably know it has no builtin UTF-8. To run
chartprog.el
you must get one of the add-ons providing that. MULE-UCS
is recommended (http://www.m17n.org), and chartprog.el
will
attempt to load it automatically.
Return the latest price for symbol (a string) from Chart. If there’s no
information available (an unknown stock, not online, nothing cached, etc) the
return is nil
.
(chart-latest "F") ⇒ 19.55
field is a lisp symbol for what data to return. The default is
last
which is the last traded price. The fields are
name string or nil bid offer \ prices or nil open high low last change / quote-date last-date string like "2012-12-31", or nil quote-time last-time string like "16:59:59", or nil volume number or nil note string or nil
Which fields actually have data depends on the data source. name
is
the stock or commodity name as a string, or nil
if not available.
Dates and times are in the timezone of the symbol. note
is a string
with extra notes, such as ex-dividend or limit up, or nil
if no other
notes.
(chart-latest "F" 'volume) ⇒ 10492900
scale (an integer) is how many places to move the decimal point down. For example if SCALE is 2 then price 1.23 is returned as 123. This is good for working in cents when quotes are in dollars, etc.
chart-latest
doesn’t download new quotes but just returns existing
data.
A call (thing-at-point 'chart-symbol)
gives the Chart symbol at point
(see Examining Buffer Contents in GNU Emacs Lisp Reference Manual). Note that you must (require
'chartprog)
before using this, it’s not autoloaded.
chart-latest
above can be used in SES (see Simple Emacs
Spreadsheet in Simple Emacs
Spreadsheet) expressions to include prices in a portfolio etc. See
emacs/example.ses in the Chart sources for a sample spreadsheet doing
this.
Since chart-latest
doesn’t download new data an
M-x ses-recalculate-all just shows existing downloaded quotes
(see Cell formulas in SES: Simple
Emacs Spreadsheet).
M-x chart-ses-refresh does a combination ses-recalculate-all
and
download of Chart prices used. A first recalculate records calls to
chart-latest
for which prices are used in the spreadsheet, they’re
downloaded, then a second recalculate applies the new data. (Further rounds
of download and recalculate are done as necessary if conditionals in
expressions use yet more symbols.)
Next: Concept Index, Previous: Internationalization, Up: Top [Index]
Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2014, 2015, 2016, 2017 Kevin Ryde
Chart 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 3, or (at your option) any later version.