App-Chart

 view release on metacpan or  search on metacpan

devel/convert-scm.pl  view on Meta::CPAN


  foreach my $symbol (App::Chart::Database->symbols_list()) {
    if (! App::Chart::Database->symbol_is_historical ($symbol)) {
      $all_symlist->insert_symbol ($symbol);
    }
  }
}

$dbh->begin_work;
$nbh->begin_work;
$dbh->do ('PRAGMA synchronous = OFF');
$dbh->do ('PRAGMA cache_size = 20000'); # of 1.5k pages, is 30Mb

convert_prefs();

#convert_notes ('BHP.AX','BBW.AX','ERA.AX','TEL.NZ');
convert_notes (directory_files ("$ENV{HOME}/Chart/notes"));

convert_intraday ();

#convert_data ('TEL.NZ','FPA.NZ','BHP.AX','IPG.AX');

emacs/chartprog.el  view on Meta::CPAN

(defvar chartprog-latest-cache)
(defvar chartprog-symlist-alist)
(defvar chartprog-watchlist-map)
(defvar chartprog-watchlist-menu)
(defvar chartprog-quote-symbol)
(defvar chartprog-quote-changed)

(defun chartprog-exec (proc &rest args)
  "An internal part of chartprog.el.
Send the chart subprocess PROC (a symbol) with ARGS (lists,
strings, etc).  This is for an asynchronous or a no-reply message
to the subprocess.  See `chartprog-exec-synchronous' for
executing with reply."

  (unless (memq 'utf-8 (coding-system-list))
    (message "Loading mule-ucs for `utf-8' in XEmacs")
    (require 'un-define))

  ;; startup subprocess if not already running
  (unless chartprog-process
    (when (get-buffer " *chartprog subprocess*") ;; possible old buffer
      (kill-buffer " *chartprog subprocess*"))

emacs/chartprog.el  view on Meta::CPAN

                             (read (process-buffer proc))
                           (error nil))))
               (when form
                 (delete-region (point-min) (point))

                 (chartprog-debug-message "incoming " form)
                 (apply (intern (concat "chartprog-incoming-"
                                        (symbol-name (car form))))
                        (cdr form)))

               ;; no more processing after `synchronous', let the result get
               ;; back to the caller before further asynch stuff is
               ;; processed (that further stuff deferred under a timer)
               (when (eq (car form) 'synchronous)
                 (run-at-time 0.0000001 nil
                              (lambda ()
                                (chartprog-process-filter chartprog-process "")))
                 (setq form nil))

               ;; process another form, perhaps
               form)))))

(defun chartprog-process-sentinel (proc event)
  "An internal part of chartprog.el.

emacs/chartprog.el  view on Meta::CPAN

      (kill-buffer (process-buffer p)))
    ;; go back to uninitialized to force a re-read on the contents if the
    ;; subprocess is restarted, that way any additions while we were away
    ;; will appear
    (setq chartprog-completion-symbols-alist 'uninitialized)
    (setq chartprog-symlist-alist 'uninitialized)
    (setq chartprog-latest-cache (make-hash-table :test 'equal))))


;;-----------------------------------------------------------------------------
;; synchronous commands

(defvar chartprog-exec-synchronous-seq 0)
(defvar chartprog-exec-synchronous-got 0)
(defvar chartprog-exec-synchronous-result nil)

(defun chartprog-incoming-synchronous (got result)
  "An internal part of chartprog.el.
Receive synchronize number GOT from Chart subprocess."
  (setq chartprog-exec-synchronous-got got)
  (setq chartprog-exec-synchronous-result result))

(defun chartprog-exec-synchronous (proc &rest args)
  "An internal part of chartprog.el.
Call chart PROC (a symbol) with ARGS (lists, strings, etc).
Return the return value from that call, when it completes."

  (setq chartprog-exec-synchronous-seq (1+ chartprog-exec-synchronous-seq))
  (apply 'chartprog-exec 'synchronous chartprog-exec-synchronous-seq proc args)

  (while (not (= chartprog-exec-synchronous-seq
                 chartprog-exec-synchronous-got)) ;; ignore old abandoned calls
    (if (not (eq 'run (process-status chartprog-process)))
        (error "Chart subprocess died"))
    (accept-process-output chartprog-process))

  chartprog-exec-synchronous-result)


;;-----------------------------------------------------------------------------
;; incoming from subprocess

(defun chartprog-incoming-update (symbol-list)
  "An internal part of chartprog.el.
Receive advice from Chart subprocess that the symbols (strings)
in SYMBOL-LIST have updated.
Any cached data for these symbols in `chartprog-latest-cache' is

emacs/chartprog.el  view on Meta::CPAN

the Chart subprocess when 'uninitialized.")

(defun chartprog-completion-symbols-alist (&optional dummy)
  "An internal part of chartprog.el.
Return an alist of Chart symbols for completing read.
Currently there's nothing in the `cdr's, it's just
\((SYMBOL) (SYMBOL) ...)."
  (when (eq 'uninitialized chartprog-completion-symbols-alist)
    (chartprog-with-temp-message "Receiving database symbols ..."
      (setq chartprog-completion-symbols-alist
            (chartprog-exec-synchronous 'get-completion-symbols))))
  chartprog-completion-symbols-alist)

(defun chartprog-incoming-completion-symbols-update ()
  "An internal part of chartprog.el.
Receive advice from Chart subprocess that completion symbols have changed."
  (setq chartprog-completion-symbols-alist 'uninitialized))

(defun chartprog-symbol-completion-handler (str pred action)
  "An internal part of chartprog.el.
Chart symbol (string) completion handler, for `completing-read'."

emacs/chartprog.el  view on Meta::CPAN

Call function `chartprog-symlist-alist' instead of using this
variable directly.  The function gets the list from the Chart
subprocess when `uninitialized'.")

(defun chartprog-symlist-alist ()
  "An internal part of chartprog.el.
Return the variable `chartprog-symlist-alist', initializing it if
necessary."
  (when (eq 'uninitialized chartprog-symlist-alist)
    (chartprog-with-temp-message "Receiving symlist info ..."
      (chartprog-exec-synchronous 'get-symlist-alist)))
  chartprog-symlist-alist)

(defun chartprog-incoming-symlist-alist (alist)
  "An internal part of chartprog.el.
Receive the `chartprog-symlist-alist' data from Chart subprocess."
  (setq chartprog-symlist-alist alist)

  ;; freshen watchlist mode-line symlist name, if any
  (when (get-buffer "*chartprog-watchlist*")
    (with-current-buffer "*chartprog-watchlist*"

emacs/chartprog.el  view on Meta::CPAN

This function is designed for use from variable
`bookmark-make-record-function' as a tie-in to bookmark.el.

The bookmark records the symlist displayed.  This is done with
the symlist key, so if the name is edited in chart then it will
still be found.  The bookmark name is the symlist name at the
time the bookmark is set, it won't update.

Line and column of point are not recorded since the watchlist
contents are not available until chart has started and been
queried, which is done asynchronously."

  (list
   ;; symlist name as bookmark name
   (or (car (chartprog-symlist-find
             chartprog-watchlist-current-symlist))
       (symbol-name chartprog-watchlist-current-symlist))

   (cons 'symlist   chartprog-watchlist-current-symlist)
   '(handler      . chartprog-watchlist-bookmark-jump)))

emacs/chartprog.el  view on Meta::CPAN

  (interactive (list (chartprog-completing-read-symbol (thing-at-point
                                                        'chart-symbol))))
  (message "Fetching ...")
  (setq chartprog-quote-symbol symbol)
  (setq chartprog-quote-changed t)
  (chartprog-exec 'request-explicit (list symbol))

  (while chartprog-quote-symbol
    (when chartprog-quote-changed
      (setq chartprog-quote-changed nil)
      (let* ((elem (chartprog-exec-synchronous 'quote-one symbol))
             (face (nth 2 elem)))
        (message "%s" (propertize (cadr elem) 'face face))
        (redisplay t)
        (when (not (eq face 'chartprog-in-progress))
          (setq chartprog-quote-symbol nil))))
    (if chartprog-quote-symbol
        (accept-process-output))))

;;;###autoload
(defun chart-quote-at-point ()

emacs/chartprog.el  view on Meta::CPAN

              (cons symbol (aref chartprog-latest-record-calls 0)))))
  (unless field
    (setq field 'last))
  (let ((latest (gethash symbol chartprog-latest-cache)))
    (when (or (not latest)
              (plist-get latest 'dirty))
      ;; ses.el likes to run with inhibit-quit (to force atomic updates),
      ;; but accept-process-output doesn't like that.  with-local-quit here
      ;; will bail out, probably returning nil.
      (with-local-quit
        (setq latest (chartprog-exec-synchronous 'get-latest-record symbol))
        (puthash symbol latest chartprog-latest-cache)))

    (let ((value (plist-get latest field)))
      (when (and value
                 (memq field '(bid offer open high low last change)))
        (let ((factor (- (or scale 0) (plist-get latest 'decimals))))
          (if (/= 0 factor)
              (setq value (* value (expt (if (< factor 0) 10.0 10)
                                         factor))))))
      value)))

emacs/chartprog.el  view on Meta::CPAN

      (accept-process-output)

      (dolist (symbol symbol-list)
        (unless (eq (chart-latest symbol 'face) 'chartprog-in-progress)
          (setq symbol-list (remove symbol symbol-list))
          (chartprog-debug-message "ses-refresh got " symbol))))))

;;-----------------------------------------------------------------------------

;; LocalWords: Customizations eg ie watchlist symlist symlists initializing
;; LocalWords: hscrolled hscrolling UTF minibuffer tooltip cl synchronize
;; LocalWords: col init chartprog

(provide 'chartprog)

;;; chartprog.el ends here

lib/App/Chart/EmacsMain.pm  view on Meta::CPAN

}

# send the symbols in symlist $key
sub emacs_command_get_symlist {
  my ($key) = @_;
  require App::Chart::Gtk2::Symlist;
  my $symlist = App::Chart::Gtk2::Symlist->new_from_key ($key);
  emacs_write (symbol('symlist-list'), symbol($key), $symlist->symbol_listref);
}

sub emacs_command_synchronize {
  my ($n) = @_;
  emacs_write (symbol('synchronize', $n));
}

sub emacs_command_synchronous {
  my ($seq, $func, @args) = @_;
  if (DEBUG) { print "  synchronous to $func\n"; }
  emacs_write (symbol('synchronous'), $seq,
               call_command ([$func, @args]));
}

sub emacs_command_noop {
}


#-----------------------------------------------------------------------------
# symlist manipulations

lib/App/Chart/EmacsMain.pm  view on Meta::CPAN

           symbol('source'),     $latest->{'source'},
           symbol('face'),       latest_to_face($latest),
         ];
}


#-----------------------------------------------------------------------------
# spreadsheet support

# return when SYMBOL-LIST has been downloaded
# (define-public (emacs-command-request-symbols-synchronous symbol-list)
#   (call-with-current-continuation
#    (lambda (cont)
#      (define (callback this-symbol-list)
#        (set! this-symbol-list (remove latest-in-progress? this-symbol-list))
#        (set! symbol-list (lset-difference string=?
# 					  symbol-list this-symbol-list))
#        (if (null? symbol-list)
# 	   (begin
# 	     (notify-disconnect 'latest-update callback)
# 	     (cont #f))))



( run in 0.237 second using v1.01-cache-2.11-cpan-0d8aa00de5b )