view release on metacpan or search on metacpan
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
t/WatchlistDialog.t
t/WatchlistModel.t
t/Yahoo.t
unused/CommSec.pm
unused/Float.pm
unused/NZX-old.pm
unused/t-tradingroom.pl
unused/TradingRoom.pm
unused/Yahoo-v7.pm
unused/YahooOld.pm
xt/0-desktop-file-validate.t
xt/0-exe-shebang.t
xt/0-file-is-part-of.t
xt/0-META-read.t
xt/0-no-debug-left-on.t
xt/0-Test-CheckChanges.t
xt/0-Test-DistManifest.t
xt/0-Test-Pod.t
xt/0-Test-YAML-Meta.t
xt/1-Test-Synopsis.t
xtools/my-check-copyright-years.sh
SHA256 511ac10e3e1d51fd09680e8cc7f1e3de6594eb49d70876a0c2eddb012eae0b6a unused/NZX-old.pm
SHA256 2f4abf10405bbe15c6140f17f0875f6054febb63b0e78027d985858ad1eda47c unused/TradingRoom.pm
SHA256 f304640458c3eba63d09250b7a6a2c42566442573adfe69888208c59c313423c unused/Yahoo-v7.pm
SHA256 1f78114bbd088579d2ec58d4221908a9d2a50ec0b8228b3b884fcc7f478fa180 unused/YahooOld.pm
SHA256 fca4a298c6567e289bfb6d385ebf9c1e749ea84160c383d3d2debc8a832346ea unused/t-tradingroom.pl
SHA256 ef75312e02ddcfed7095de7eecebc6b7b863d56acd9b64142737ab7a5edb57e3 xt/0-META-read.t
SHA256 d1a5584b94be4ea06efcf8b8446f060ac11cda4d4a4ec02e03b54f2ee2008848 xt/0-Test-CheckChanges.t
SHA256 be42622f3841d04240cb1284e6b30e1af81cb0fcb56d29e853c70af656653488 xt/0-Test-DistManifest.t
SHA256 48b441e0c335e93946d913897e342662387788833229c5ba5fac57f0ff3d567c xt/0-Test-Pod.t
SHA256 d33b48c1986680cd934565250bd9e3879674dfe6aad69b1717ed76354a29ff44 xt/0-Test-YAML-Meta.t
SHA256 3bf4a1d420b60e022b3ebf10b9e369e5d03f393308f2da95cba663ddcab3d67e xt/0-desktop-file-validate.t
SHA256 2a45215859688affb1efc824fa060f3d73b8b6287d9010aef98c4bd308f82491 xt/0-exe-shebang.t
SHA256 75a73148514fad2715873d1e02a6fa8e3b9cc43f7aff97aaffac9721c086a319 xt/0-file-is-part-of.t
SHA256 7d9eacc605d8cb575b2869790e4b90d71dea6a97547c725825a49e1db036dee4 xt/0-no-debug-left-on.t
SHA256 358b4c096b2f0ddf3a292ad07cb82ad865255d2e2d34a4765aa0efec429da1f1 xt/1-Test-Synopsis.t
SHA256 479a5a0436204528727a74e5257b1c5c6adbebd65b21b6817a196b4e159e7549 xtools/my-check-copyright-years.sh
SHA256 e1a132f2761adf019b76629f466c23a4b151f6f9764951ae99f31c408cb38023 xtools/my-check-file-part-of.sh
SHA256 5d5bed5cd3332e9d386b2e6175f2e6fad1e87b33f263836327935bb44a1d999b xtools/my-check-spelling.sh
SHA256 0a4726b4ae47a369753e2b3c1b88e84c67f8554d529935a13fa78f1e0c727462 xtools/my-deb.sh
SHA256 02d7e3c4bd8846b27dbeeb736ce4386015b0cacc1917a03d12e9db15417acc62 xtools/my-diff-prev.sh
SHA256 0c9535621e35a944f06353ea646eff232edacb9faeb43b0b60d2642c6ffb535b xtools/my-kwalitee.sh
doc/chart.texi view on Meta::CPAN
x1*y1 + ... + xN*yN
b = -------------------
x1^2 + ... xN^2
@end example
@end ifnottex
A least squares fit is ``best'' under certain mathematical assumptions:
basically that the data points were a straight line to which normally
distributed random amounts (positive or negative) have been added. Of course
an underlying straight line is unlikely in market price data, or in economics
generally, and in particular any cyclical component invalidates the
assumptions. Even so the algorithm is quite widely used because it offers an
objective basis for fitting a line.
@cindex Linear regression slope indicator
@cindex Regression coefficient
@cindex Coefficient, regression
@anchor{Linear Regression Slope}
@subsection Slope
The slope of the linear regression line, the @math{b} above, is sometimes
lib/App/Chart.pm view on Meta::CPAN
foreach my $elem (@source_help_list) {
if ($elem->[0]->match ($symbol)) {
return $elem->[1];
}
}
return undef;
}
sub setup_source_help {
my ($pred, $node) = @_;
require App::Chart::Sympred;
App::Chart::Sympred::validate ($pred);
# newer get higher priority
unshift @source_help_list, [ $pred, $node ];
}
#------------------------------------------------------------------------------
sub hms_to_seconds {
my ($hour, $minute, $seconds) = @_;
return $hour * 60*60 + $minute * 60 + ($seconds || 0);
lib/App/Chart/Download.pm view on Meta::CPAN
# including returning Thursday all through the weekend.
# =head1 DATABASE FUNCTIONS
#
# =over 4
#
# =item C<< App::Chart::Download::write_daily_group ($hashref) >>
#
# C<$hashref> is daily share price data. Write it to the database. The
# fields of C<$hashref> are as follows. They are variously crunched to
# normalize and validate before being written to the database.
#
# =over
#
# =item C<data>
#
# Arrayref containing hashref records with fields
#
# symbol string
# open price
# high price
lib/App/Chart/DownloadHandler.pm view on Meta::CPAN
#------------------------------------------------------------------------------
our @handler_list = ();
sub new {
my ($class, %self) = @_;
$self{'pred'} or croak __PACKAGE__,": missing pred";
$self{'proc'} or croak __PACKAGE__,": missing proc";
App::Chart::Sympred::validate ($self{'pred'});
my $self = bless \%self, $class;
push @handler_list, $self;
$self{'name'} ||= do {
my ($package,$filename,$line) = caller();
"$package:" . Glib::filename_to_unicode($filename) . ":$line" };
# highest priority first and 'stable' above for order added for equals
@handler_list
lib/App/Chart/Gtk2/Ex/ListOfListsModel.pm view on Meta::CPAN
return [ $self->{'stamp'}, $sub_index, $minfo, undef ];
}
return undef;
}
# gtk_tree_model_get_path
#
sub GET_PATH {
my ($self, $iter) = @_;
if (DEBUG >= 2) { print "ListOfListsModel get_path\n"; }
my ($index, $minfo) = _iter_validate ($self, $iter);
if (defined $minfo) {
my $mnum = $minfo->{'mnum'};
return Gtk2::TreePath->new_from_indices ($mnum, $index);
} else {
return Gtk2::TreePath->new_from_indices ($index);
}
}
# gtk_tree_model_get_value
#
sub GET_VALUE {
my ($self, $iter, $col) = @_;
if (DEBUG >= 2) { print "ListOfListsModel get_value\n";
print " iter=",$iter->[0],",",$iter->[1],",",
defined $iter->[2] ? $iter->[2] : 'undef',
" col=$col\n"; }
my ($index, $minfo) = _iter_validate ($self, $iter);
my $list_model_n_columns = $self->{'list_model_n_columns'};
my $model;
if ($col < $list_model_n_columns) {
# columns of list_model
$model = $self->{'list_model'} || return undef;
if ($minfo) {
# $iter is a submodel row
$index = $minfo->{'mnum'};
}
lib/App/Chart/Gtk2/Ex/ListOfListsModel.pm view on Meta::CPAN
return undef;
};
return $model->get_value ($subiter, $col);
}
# gtk_tree_model_iter_next
#
sub ITER_NEXT {
my ($self, $iter) = @_;
if (DEBUG >= 2) { print "ListOfListsModel iter_next\n"; }
my ($index, $minfo) = _iter_validate ($self, $iter);
$index++;
if ($minfo) {
# next in submodel
my $model = $minfo->{'model'} || return undef;
if ($index < $model->iter_n_children(undef)) {
return [ $self->{'stamp'}, $index, $minfo, undef ];
}
} else {
lib/App/Chart/Gtk2/Ex/ListOfListsModel.pm view on Meta::CPAN
#
sub ITER_N_CHILDREN {
my ($self, $iter) = @_;
if (DEBUG) { print "ListOfListsModel iter_n_children\n"; }
if (! defined $iter) {
# asking about top-levels
if (DEBUG) { print " toplevel has ",scalar @{$self->{'mlist'}},"\n"; }
return scalar @{$self->{'mlist'}};
}
my ($index, $minfo) = _iter_validate ($self, $iter);
if ($minfo) {
# asking about under submodel
if (DEBUG) { print " nothing under submodel rows\n"; }
return 0;
} else {
# asking about under toplevel row
$minfo = $self->{'mlist'}->[$index] || return 0;
my $model = $minfo->{'model'} || return 0;
if (DEBUG) { print " model row has",$model->iter_n_children(undef),"\n"; }
lib/App/Chart/Gtk2/Ex/ListOfListsModel.pm view on Meta::CPAN
#
sub ITER_NTH_CHILD {
my ($self, $iter, $n) = @_;
if (DEBUG) { print "ListOfListsModel iter_nth_child",
" index=",$iter?$iter->[1]:'<iter undef>',
" minfo=",($iter&&$iter->[2])||'undef',
" child n=$n\n"; }
my $mlist = $self->{'mlist'};
if (defined $iter) {
my ($index, $minfo) = _iter_validate ($self, $iter);
if (! $minfo) {
# $n'th row of model under toplevel $index
if ($minfo = $mlist->[$index]) {
if (my $model = $minfo->{'model'}) {
if ($n < $model->iter_n_children(undef)) {
if (DEBUG) { print " yes, submodel $model row $n\n"; }
return [ $self->{'stamp'}, $n, $minfo, undef ];
}
}
}
lib/App/Chart/Gtk2/Ex/ListOfListsModel.pm view on Meta::CPAN
if (DEBUG) { print " no\n"; }
return undef;
}
# gtk_tree_model_iter_parent
#
sub ITER_PARENT {
my ($self, $iter) = @_;
if (DEBUG) { print "ListOfListsModel iter_parent\n"; }
my ($index, $minfo) = _iter_validate ($self, $iter);
if (defined $minfo) {
if (DEBUG) { print " yes, up to toplevel ",$minfo->{'mnum'},"\n"; }
return [ $self->{'stamp'}, $minfo->{'mnum'}, undef, undef ];
}
if (DEBUG) { print " no\n"; }
return undef;
}
# gtk_tree_model_ref_node
# gtk_tree_model_unref_node
#------------------------------------------------------------------------------
# our iters
# return ($mnum, $minfo), with $minfo undef on toplevel rows
sub _iter_validate {
my ($self, $iter) = @_;
if ($iter->[0] != $self->{'stamp'}) {
croak "iter is not for this ", ref($self),
" (stamp ", $iter->[0], " want ", $self->{'stamp'}, ")\n";
}
return ($iter->[1], $iter->[2]);
}
sub _top_index_to_iterobj {
my ($self, $mnum) = @_;
return Gtk2::TreeIter->new_from_arrayref ([ $self->{'stamp'}, $mnum, undef, undef ]);
}
sub _sub_index_to_iterobj {
my ($self, $minfo, $index) = @_;
return Gtk2::TreeIter->new_from_arrayref ([ $self->{'stamp'}, $index, $minfo, undef]);
}
sub _iterobj_validate {
my ($self, $iterobj) = @_;
if (! defined $iterobj) {
croak 'iter is undef';
}
my $iter = Gtk2::TreeIter->to_arrayref ($self->{'stamp'});
return ($iter->[1], $iter->[2]);
}
#------------------------------------------------------------------------------
lib/App/Chart/Gtk2/Ex/ListOfListsModel.pm view on Meta::CPAN
}
sub _Xpend {
my ($self, $parent_iterobj, $method) = @_;
my ($model, $minfo, $subiter);
if (! defined $parent_iterobj) {
# append to toplevel
$model = $self->{'list_model'};
$subiter = $model->$method;
} else {
my $index;
($index, $minfo) = _iterobj_validate ($parent_iterobj);
if ($minfo) { croak 'cannot append under sub-row'; }
# append to submodel, ie. under a toplevel row
$minfo = $self->{'mlist'}->[$index] || croak 'no such row (bad iter)';
$model = $minfo->{'model'};
$subiter = $model->$method;
}
if (! $subiter) { return undef; }
my ($index) = $model->get_path($subiter)->get_indices;
return Gtk2::TreeIter->new_from_arrayref ([ $self->{'stamp'}, $index, $minfo, undef]);
}
# gtk_tree_store_is_ancestor
sub is_ancestor {
my ($self, $parent_iterobj, $child_iterobj) = @_;
my ($parent_index, $parent_minfo) = _iterobj_validate ($parent_iterobj);
if ($parent_minfo) { return 0; } # a submodel row
my ($child_index, $child_minfo) = _iterobj_validate ($child_iterobj);
return defined $child_minfo; # only if a submodel row
}
# gtk_tree_store_iter_depth
sub iter_depth {
my ($self, $iterobj) = @_;
my ($index, $minfo) = _iterobj_validate ($iterobj);
return $minfo ? 2 : 1;
}
# gtk_tree_store_clear
sub clear {
my ($self) = @_;
my $list_model = $self->{'list_model'} || return;
$list_model->clear;
}
lib/App/Chart/Gtk2/Ex/ListOfListsModel.pm view on Meta::CPAN
if (defined $minfo) {
return List::Util::first {$_ == $minfo} @{$self->{'mlist'}}
&& $index < $minfo->{'model'}->iter_n_children(undef);
} else {
return $index < scalar @{$self->{'mlist'}};
}
}
sub remove {
my ($self, $iterobj) = @_;
my ($index, $minfo) = _iterobj_validate ($iterobj);
my $model = $minfo ? $minfo->{'model'} : $self->{'list_model'};
my $subiter = $model->iter_nth_child (undef, $index)
|| croak 'no such row (bad iter)';
if ($model->remove ($subiter)) {
# more rows
$iterobj->set([$self->{'stamp'}, $index+1, $minfo, undef]);
return 1;
} else {
$iterobj->set([0,0,undef,undef]); # zap
return 0;
}
}
# gtk_tree_store_reorder
# Gtk2::TreeStore reorder() taking multiple args
sub reorder {
my ($self, $iterobj, @order) = @_;
if ($iterobj) {
my ($index, $minfo) = _iterobj_validate ($iterobj);
if ($minfo) {
croak 'nothing under sub-row';
}
$minfo = $self->{'mlist'}->[$index] || croak 'iter out of range';
my $model = $minfo->{'model'} || croak 'no submodel';
$model->reorder (@order);
} else {
# toplevel
$self->{'list_model'}->reorder (@order);
lib/App/Chart/Gtk2/Ex/TreeRowPosition.pm view on Meta::CPAN
Current path in the model.
=item C<key-column> (integer, default -1)
Column number of row key data. The default -1 means no key column.
=back
C<notify> signals are emitted for C<path> and/or C<type> when model row
changes alter those values, in the usual way. A notify handler must not
insert, delete or reorder model rows because doing so may invalidate the
path and/or iter objects passed to further handlers on the model.
=head1 SIGNALS
=over 4
=item C<key-extract>, called (treerowpos, model, path, iter)
Callback to extract a key from a row. When set it's called
lib/App/Chart/Gtk2/RawDialog.pm view on Meta::CPAN
sql => { select => 'ex_date, record_date, pay_date, amount, imputation, type, qualifier, note',
from => 'dividend',
order_by => 'ex_date DESC',
where => 'symbol=?',
bind_values => [ '' ],
},
treeview => $treeview,
fields => [ { name => 'ex_date',
header_markup => __('Ex'),
x_absolute => $date_width_editable,
validation => \&validate_date,
# renderer => 'date',
},
{ name => 'record_date',
header_markup => __('Record'),
x_absolute => $date_width_editable,
validation => \&validate_date,
# renderer => 'date',
},
{ name => 'pay_date',
header_markup => __('Pay'),
x_absolute => $date_width_editable,
validation => \&validate_date,
# renderer => 'date',
},
{ name => 'amount',
header_markup => __('Amount'),
align => 'right',
x_absolute => 8 * $digit_width,
validation => \&validate_number,
},
{ name => 'imputation',
header_markup => __('Imputation'),
align => 'right',
x_absolute => 8 * $digit_width,
validation => \&validate_number,
},
{ name => 'type',
header_markup => __('Type'),
x_absolute => 6 * $em,
},
{ name => 'qualifier',
header_markup => __('Qualifier'),
x_absolute => 6 * $em,
},
{ name => 'note',
lib/App/Chart/Gtk2/RawDialog.pm view on Meta::CPAN
sql => { select => 'date, new, old, note',
from => 'split',
order_by => 'date DESC',
where => 'symbol=?',
bind_values => [ '' ],
},
treeview => $treeview,
fields => [ { name => 'date',
header_markup => __('Date'),
x_absolute => $date_width_editable,
validation => \&validate_date,
# renderer => 'date',
},
{ name => 'new',
header_markup => __('New'),
align => 'right',
x_absolute => 3 * $digit_width,
validation => \&validate_number,
},
{ name => 'old',
header_markup => __('Old'),
align => 'right',
x_absolute => 3 * $digit_width,
validation => \&validate_number,
},
{ name => 'note',
header_markup => __('Note'),
x_absolute => 10 * $em,
},
],
});
_datasheet_init ($self, $vbox, $datasheet);
$vbox->{'insert_defaults'} = \&_splits_insert_defaults;
}
lib/App/Chart/Gtk2/RawDialog.pm view on Meta::CPAN
x_absolute => 4 * $em,
},
{ name => 'error',
header_markup => __('Error'),
x_absolute => 10 * $em,
},
{ name => 'fetch_timestamp',
header_markup => __('Fetch Timestamp'),
x_absolute => (length('2009-03-09 22:01:31+00:00')
* $digit_width),
validation => \&validate_integer,
},
{ name => 'url',
header_markup => __('URL'),
x_absolute => 10 * $em,
},
{ name => 'etag',
header_markup => __('ETag'),
x_absolute => 10 * $em,
},
{ name => 'last_modified',
lib/App/Chart/Gtk2/RawDialog.pm view on Meta::CPAN
},
treeview => $treeview,
fields => [
{ name => 'id',
header_markup => __('Id'),
x_absolute => 3 * $em,
},
{ name => 'date1',
header_markup => __('Date1'),
x_absolute => $date_width_editable,
validation => \&validate_date,
# renderer => 'date',
},
{ name => 'price1',
header_markup => __('Price1'),
x_absolute => 15 * $digit_width,
validation => \&validate_number,
},
{ name => 'date2',
header_markup => __('Date2'),
x_absolute => $date_width_editable,
validation => \&validate_date,
# renderer => 'date',
},
{ name => 'price2',
header_markup => __('Price2'),
x_absolute => 15 * $digit_width,
validation => \&validate_number,
},
{ name => 'horizontal',
header_markup => __('Horizontal'),
# validation => \&validate_boolean,
},
],
});
_datasheet_init ($self, $scrolled, $datasheet);
$scrolled->{'insert_defaults'} = \&_lines_insert_defaults;
}
sub _lines_insert_defaults {
my ($self, $pagewidget) = @_;
my $datasheet = $pagewidget->{'datasheet'};
my $num = $datasheet->{'column_name_to_number_mapping'};
lib/App/Chart/Gtk2/RawDialog.pm view on Meta::CPAN
},
treeview => $treeview,
fields => [
{ name => 'id',
header_markup => __('Id'),
x_absolute => 3 * $em,
},
{ name => 'price1',
header_markup => __('Price1'),
x_absolute => 15 * $digit_width,
validation => \&validate_number,
},
{ name => 'above',
header_markup => __('Above'),
# validation => \&validate_boolean,
},
],
});
_datasheet_init ($self, $scrolled, $datasheet);
}
sub _datasheet_init {
my ($self, $pagewidget, $datasheet) = @_;
lib/App/Chart/Gtk2/RawDialog.pm view on Meta::CPAN
}
# 'activate' signal on the Gtk2::Entry widget
sub _do_entry_activate {
my ($entry) = @_;
my $self = $entry->get_toplevel;
$self->set_symbol ($entry->get_text);
}
# return true if $str is a valid ISO format date like 2008-05-27
sub validate_date {
my ($str) = @_;
return ($str =~ /^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$/);
}
# return true if $str is a valid number
sub validate_number {
my ($str) = @_;
return ($str =~ /^[0-9]*(.[0-9]*)?$/);
}
# return true if $str is a valid number
sub validate_integer {
my ($str) = @_;
return ($str =~ /^[0-9]*$/);
}
sub popup {
my ($class, $symbol, $parent) = @_;
if (! defined $symbol) { $symbol = ''; }
require App::Chart::Gtk2::Ex::ToplevelBits;
return App::Chart::Gtk2::Ex::ToplevelBits::popup
($class,
lib/App/Chart/Gtk2/SeriesModel.pm view on Meta::CPAN
use constant { COL_DATE => 0,
COL_OPEN => 1,
COL_HIGH => 2,
COL_LOW => 3,
COL_CLOSE => 4,
COL_VOLUME => 5,
COL_OPENINT => 6,
NUM_COLUMNS => 7 };
sub _validate_iter {
my ($self, $iter) = @_;
if (! defined $iter) { return; }
if ($iter->[0] != $self->{'stamp'}) {
croak "iter is not for this ".ref($self)." (id ",
$iter->[0]," want ",$self->{'stamp'},")\n";
}
}
sub INIT_INSTANCE {
my ($self) = @_;
lib/App/Chart/Gtk2/SeriesModel.pm view on Meta::CPAN
my ($self, $path) = @_;
$path->get_depth == 1 or return undef;
my ($n) = $path->get_indices;
return [ $self->{'stamp'}, $n, undef, undef ];
}
# gtk_tree_model_get_path
#
sub GET_PATH {
my ($self, $iter) = @_;
_validate_iter ($self, $iter);
my $n = $iter->[1];
return Gtk2::TreePath->new_from_indices ($n);
}
sub data {
my ($self) = @_;
if (exists $self->{'data'}) { return $self->{'data'}; }
my $symbol = $self->{'symbol'};
if (! defined $symbol) { return ($self->{'data'} = []); }
lib/App/Chart/Gtk2/SeriesModel.pm view on Meta::CPAN
# gtk_tree_model_get_value
#
my %col_to_array = (COL_OPEN, 'opens',
COL_HIGH, 'highs',
COL_LOW, 'lows',
COL_CLOSE, 'closes',
COL_VOLUME, 'volumes',
COL_OPENINT, 'openints');
sub GET_VALUE {
my ($self, $iter, $col) = @_;
_validate_iter ($self, $iter);
my $n = $iter->[1];
### GET_VALUE: "$n,$col"
if ($n < 0) { return ''; }
my $series = $self->{'series'};
if (! $series) { return ''; }
if ($col == 0) {
return $series->timebase->to_iso ($n);
}
lib/App/Chart/Gtk2/SeriesModel.pm view on Meta::CPAN
return $series->values_array->[$n];
}
my $array = $col_to_array{$col} // return '';
return $series->array($array)->[$n];
}
# gtk_tree_model_iter_next
#
sub ITER_NEXT {
my ($self, $iter) = @_;
_validate_iter ($self, $iter);
my $n = $iter->[1] + 1;
if ($n >= $self->length) {
# past last record
return undef;
}
return [ $self->{'stamp'}, $n, undef, undef ];
}
# gtk_tree_model_iter_children
#
sub ITER_CHILDREN {
my ($self, $iter) = @_;
_validate_iter ($self, $iter);
if ($iter) {
# no children of any nodes
return undef;
} else {
# $iter==NULL means first toplevel
return [ $self->{'stamp'}, 0, undef, undef ];
}
}
# gtk_tree_model_iter_has_child
# Note Gtk2 prior to 1.183 demands numeric return (zero or non-zero).
#
use constant ITER_HAS_CHILD => 0;
# gtk_tree_model_iter_n_children
#
sub ITER_N_CHILDREN {
my ($self, $iter) = @_;
_validate_iter ($self, $iter);
if ($iter) {
# nothing under actual rows
return 0;
} else {
# $iter==NULL asks about toplevel
return $self->length;
}
}
# gtk_tree_model_iter_nth_child
#
sub ITER_NTH_CHILD {
my ($self, $iter, $n) = @_;
_validate_iter ($self, $iter);
if ($iter) {
# nothing unde actual rows
return undef;
} else {
# $iter==NULL means nth toplevel
if ($n < 0 || $n >= $self->length) {
# out of range
return undef;
}
return [ $self->{'stamp'}, $n, undef, undef ];
}
}
# gtk_tree_model_iter_parent
#
sub ITER_PARENT {
my ($self, $iter) = @_;
_validate_iter ($self, $iter);
return undef;
}
my @field_name = qw(date open high low close volume openint);
sub set_value {
(@_ == 4) or croak 'SeriesModel::set_value(): wrong number of arguments';
my ($self, $iterobj, $col, $value) = @_;
my $iter = $iterobj->to_arrayref ($self->{'stamp'});
### set_value: "$self $iter, $col, $value"
_validate_iter ($self, $iter);
my $n = $iter->[1];
my $series = $self->{'series'};
if (! $series->isa ('App::Chart::Series::Database')) {
croak "Can only change Database series";
}
my $symbol = $series->symbol || croak "No symbol in series";
my $date = $series->timebase->to_iso ($n);
my $field = $field_name[$col];
lib/App/Chart/IntradayHandler.pm view on Meta::CPAN
use App::Chart;
# uncomment this to run the ### lines
#use Smart::Comments;
our @handler_list = ();
sub new {
my $class = shift;
my $self = bless ({ @_ }, $class);
App::Chart::Sympred::validate ($self->{'pred'});
push @handler_list, $self;
@handler_list = sort { $a->{'name'} cmp $b->{'name'} } @handler_list;
return $self;
}
sub handlers_for_symbol {
my ($class, $symbol) = @_;
App::Chart::symbol_setups ($symbol);
return grep { $_->{'pred'}->match($symbol) } @handler_list;
}
lib/App/Chart/LatestHandler.pm view on Meta::CPAN
use App::Chart::Sympred;
# uncomment this to run the ### lines
# use Smart::Comments;
our @handler_list = ();
sub new {
my $class = shift;
my $self = bless ({ @_ }, $class);
App::Chart::Sympred::validate ($self->{'pred'});
push @handler_list, $self;
# highest priority first, and 'stable' for order added among equal
use sort 'stable'; # lexical in 5.10
@handler_list = sort { ($b->{'priority'} || 0) <=> ($a->{'priority'} || 0) }
@handler_list;
return $self;
}
sub handler_for_symbol {
if (@_ != 2) { croak "wrong number of arguments"; }
lib/App/Chart/Suffix/MLC.pm view on Meta::CPAN
next if (ymd_is_weekend ($year, $month, $day));
$date = App::Chart::ymd_to_iso ($year, $month, $day);
push @data, { symbol => $fund . ',' . $product . '.MLC',
date => $date,
close => $price };
}
return $h;
}
sub validate_symbol {
my ($symbol) = @_;
if ($symbol !~ /,/) {
print __x("MLC: invalid symbol, should be \"Fund,Product.MLC\": {symbol}\n",
symbol => $symbol);
return 0;
}
return 1;
}
lib/App/Chart/Suffix/MLC.pm view on Meta::CPAN
App::Chart::LatestHandler->new
(pred => $pred,
proc => \&latest,
max_symbols => 1,
available_tdate => \&available_tdate);
sub latest {
my ($symbol_list) = @_;
my $symbol = $symbol_list->[0];
if (! validate_symbol ($symbol)) { return; }
my $avail_tdate = available_tdate();
my $url = url_func ($symbol, $avail_tdate-3, $avail_tdate+1);
my $resp = App::Chart::Download->get ($url);
App::Chart::Download::write_latest_group (parse ($symbol, $resp));
}
#-----------------------------------------------------------------------------
# generic helpers
lib/App/Chart/Sympred.pm view on Meta::CPAN
package App::Chart::Sympred;
use 5.005;
use strict;
use warnings;
use Carp;
use Scalar::Util;
use List::Util;
use App::Chart;
sub validate {
my ($obj) = @_;
if (! (Scalar::Util::blessed ($obj) && $obj->isa (__PACKAGE__))) {
croak 'Not a symbol predicate: ' . ($obj||'undef');
}
}
#------------------------------------------------------------------------------
package App::Chart::Sympred::Equal;
lib/App/Chart/Sympred.pm view on Meta::CPAN
#------------------------------------------------------------------------------
package App::Chart::Sympred::Any;
use strict;
use warnings;
use base 'App::Chart::Sympred';
sub new {
my ($class, @preds) = @_;
foreach my $pred (@preds) { App::Chart::Sympred::validate ($pred); }
return bless { preds => \@preds }, $class;
}
sub add {
my ($self, @newpreds) = @_;
foreach my $pred (@newpreds) { App::Chart::Sympred::validate ($pred); }
push @{$self->{'preds'}}, @newpreds;
}
sub match {
my ($self, $symbol) = @_;
return List::Util::first { $_->match($symbol) } @{$self->{'preds'}};
}
1;
__END__
lib/App/Chart/Sympred.pm view on Meta::CPAN
=over
=item C<< $sympred->match ($symbol) >>
Return true if C<$symbol> is matched by the C<$sympred> object.
=item C<< $sympred->add ($pred,...) >>
Add additional predicates to a C<App::Chart::Sympred::Any> object.
=item C<< App::Chart::Sympred::validate ($obj) >>
Check that C<$obj> is a C<App::Chart::Sympred> object, throw an error if not.
=back
=head1 HOME PAGE
L<http://user42.tuxfamily.org/chart/index.html>
=head1 LICENCE
lib/App/Chart/TZ.pm view on Meta::CPAN
#------------------------------------------------------------------------------
# sub new {
# my ($class, $name, @choices) = @_;
# return $class->SUPER::new (name => $name,
# choose => \@choices,
# defer => 1);
# }
sub validate {
my ($obj) = @_;
(Scalar::Util::blessed ($obj) && $obj->isa (__PACKAGE__))
or croak 'Not a '.__PACKAGE__.' object';
}
#------------------------------------------------------------------------------
{
my $local_TZ = $ENV{'TZ'}; # its value at startup
use constant::defer loco => sub {
lib/App/Chart/TZ.pm view on Meta::CPAN
Stock and commodity symbols have an associated timezones, setup by their
handler code and then looked up here.
=head1 FUNCTIONS
=over 4
=cut
=item App::Chart::TZ::validate ($obj)
Check that C<$obj> is a C<App::Chart::TZ> object, throw an error if
not.
=item C<< App::Chart::TZ->loco >>
Return a timezone object representing the local timezone (which means
leaving C<TZ> at its initial setting).
=item C<< App::Chart::TZ->chicago >>
lib/App/Chart/Weblink.pm view on Meta::CPAN
# uncomment this to run the ### lines
#use Smart::Comments;
our @weblinks_list = ();
sub new {
my ($class, %self) = @_;
my $self = bless \%self, $class;
require App::Chart::Sympred;
App::Chart::Sympred::validate ($self->{'pred'});
if (! ($self->{'url'} || $self->{'proc'})) {
croak "Missing weblink url or proc\n";
}
if (! $self->{'name'}) {
croak "Missing weblink name";
}
push @weblinks_list, $self;
@weblinks_list = sort { $a->{'name'} cmp $b->{'name'} } @weblinks_list;
return $self;
lib/App/Chart/doc/chart.html view on Meta::CPAN
x1*y1 + ... + xN*yN
b = -------------------
x1^2 + ... xN^2
</pre></div>
<p>A least squares fit is “best” under certain mathematical assumptions:
basically that the data points were a straight line to which normally
distributed random amounts (positive or negative) have been added. Of course
an underlying straight line is unlikely in market price data, or in economics
generally, and in particular any cyclical component invalidates the
assumptions. Even so the algorithm is quite widely used because it offers an
objective basis for fitting a line.
</p>
<a class="index-entry-id" id="index-Linear-regression-slope-indicator"></a>
<a class="index-entry-id" id="index-Regression-coefficient"></a>
<a class="index-entry-id" id="index-Coefficient_002c-regression"></a>
<a class="anchor" id="Linear-Regression-Slope"></a><ul class="mini-toc">
<li><a href="#Slope" accesskey="1">Slope</a></li>
<li><a href="#Standard-Error" accesskey="2">Standard Error</a></li>
<li><a href="#Additional-Resources-11" accesskey="3">Additional Resources</a></li>
misc/t-raw.pl view on Meta::CPAN
my $datasheet_def
= { dbh => $dbh,
sql => { select => "date, new, old, note",
from => "split",
order_by => "date"
},
vbox => $vbox,
fields => [ { name => 'date',
x_percent => 35,
# validation => sub { &validate_first_name(@_); }
},
{ name => 'new',
align => 'right',
x_percent => 35
},
{ name => 'old',
align => 'right',
x_percent => 30,
},
{ name => 'note',
align => 'right',
x_percent => 30,
},
],
};
sub validate_date {
my ($str) = @_;
return ($str =~ /^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$/);
}
$datasheet_def
= { dbh => $dbh,
sql => { select => 'ex_date, record_date, pay_date, amount, imputation, qualifier, note',
from => 'dividend',
order_by => 'ex_date',
where => 'symbol=?',
bind_values => [ 'BHP.AX' ],
},
vbox => $vbox,
fields => [ { name => 'ex_date',
# renderer => 'date',
validation => \&validate_date,
},
{ name => 'record_date',
# renderer => 'date',
validation => \&validate_date,
},
{ name => 'pay_date',
# renderer => 'date',
validation => \&validate_date,
},
{ name => 'amount',
align => 'right',
# x_percent => 35
},
{ name => 'imputation',
align => 'right',
# x_percent => 30,
},
{ name => 'qualifier',
misc/t-raw.pl view on Meta::CPAN
= { dbh => App::Chart::DBI->instance,
sql => { select => 'date, open, high, low, close, volume, openint',
from => 'daily',
order_by => 'date',
where => 'symbol=?',
bind_values => [ 'BHP.AX' ],
},
vbox => $vbox,
# treeview => $treeview,
fields => [ { name => 'date',
validation => \&validate_date,
x_absolute => 9 * $em,
},
{ name => 'open',
align => 'right',
x_absolute => 9 * $em,
},
{ name => 'high',
align => 'right',
x_absolute => 9 * $em,
},
misc/t-raw.pl view on Meta::CPAN
# sql => { select => 'date, open, high, low, close, volume, openint',
# from => 'daily',
# order_by => 'date DESC',
# where => 'symbol=?',
# bind_values => [ '' ],
# },
# treeview => $treeview,
# fields => [ { name => 'date',
# header_markup => __('Date'),
# x_absolute => $date_width,
# validation => \&validate_date,
# },
# { name => 'open',
# header_markup => __('Open'),
# align => 'right',
# x_absolute => 9 * $digit_width,
# validation => \&validate_number,
# },
# { name => 'high',
# header_markup => __('High'),
# align => 'right',
# x_absolute => 9 * $digit_width,
# validation => \&validate_number,
# },
# { name => 'low',
# header_markup => __('Low'),
# align => 'right',
# x_absolute => 9 * $digit_width,
# validation => \&validate_number,
# },
# { name => 'close',
# header_markup => __('Close'),
# align => 'right',
# x_absolute => 9 * $digit_width,
# validation => \&validate_number,
# },
# { name => 'volume',
# header_markup => __('Volume'),
# align => 'right',
# x_absolute => 10 * $digit_width,
# validation => \&validate_number,
# },
# { name => 'openint',
# header_markup => __('Open Int'),
# align => 'right',
# x_absolute => 8 * $digit_width,
# validation => \&validate_number,
# },
# ],
# });
# $scrolled->{'datasheet'} = $datasheet;
# push @{$self->{'datasheets'}}, $datasheet;
#
# foreach my $column ($treeview->get_columns) {
# $column->set (sizing => 'fixed',
# resizable => 1);
# foreach my $renderer ($column->get_cell_renderers) {
t/Sympred.t view on Meta::CPAN
use MyTestHelpers;
BEGIN { MyTestHelpers::nowarnings() }
require App::Chart::Sympred;
#-----------------------------------------------------------------------------
# Suffix
{
my $pred = App::Chart::Sympred::Suffix->new ('.Z');
App::Chart::Sympred::validate ($pred);
ok (! $pred->match (''));
ok (! $pred->match ('Z'));
ok (! $pred->match ('.'));
ok ($pred->match ('.Z'));
ok ($pred->match ('FOO.Z'));
ok (!$pred->match ('.ZZ'));
ok (!$pred->match ('FOO'));
ok (!$pred->match ('^FOO'));
}
t/Sympred.t view on Meta::CPAN
ok (! $pred->match ('tsp.FQ'));
ok ($pred->match ('C.tsp.FQ'));
ok (! $pred->match ('^FQ'));
}
#-----------------------------------------------------------------------------
# Prefix
{
my $pred = App::Chart::Sympred::Prefix->new ('^Z');
App::Chart::Sympred::validate ($pred);
ok (! $pred->match (''));
ok (! $pred->match ('Z'));
ok (! $pred->match ('^'));
ok ($pred->match ('^Z'));
ok ($pred->match ('^ZZ'));
ok ($pred->match ('^ZZZ'));
ok (!$pred->match ('Z^Z'));
}
{
my $a = App::Chart::Sympred::Prefix->new ('^A');
my $b = App::Chart::Sympred::Suffix->new ('.B');
my $pred = App::Chart::Sympred::Any->new ($a, $b);
App::Chart::Sympred::validate ($pred);
ok (! $pred->match (''));
ok (! $pred->match ('Z'));
ok (! $pred->match ('.'));
ok ($pred->match ('.B'));
ok ($pred->match ('FOO.B'));
ok ($pred->match ('^A'));
ok ($pred->match ('^AA'));
ok (!$pred->match ('FOO'));
ok (!$pred->match ('B.A'));
ok (!$pred->match ('B.^A'));
xt/0-desktop-file-validate.t view on Meta::CPAN
#!/usr/bin/perl -w
# Copyright 2011, 2012, 2023 Kevin Ryde
# 0-desktop-file-validate.t is shared by several distributions.
#
# 0-desktop-file-validate.t 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.
#
# 0-desktop-file-validate.t 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 file. If not, see <http://www.gnu.org/licenses/>.
BEGIN { require 5 }
use strict;
use File::Spec;
xt/0-desktop-file-validate.t view on Meta::CPAN
use strict;
use Carp;
use Test::More;
use ExtUtils::Manifest;
sub skip_reason {
### skip_reason() ...
eval { require IPC::Run; 1 }
or return 'IPC::Run not available';
### try desktop-file-validate ...
if (IPC::Run::run (['desktop-file-validate','--help'],
'<', File::Spec->devnull,
'>', \my $output,
'2>&1')) {
return undef;
}
my $skip = "desktop-file-validate program not available";
return $skip;
}
sub desktop_file_validate {
my ($filename) = @_;
my $output;
if (IPC::Run::run(['desktop-file-validate',
'--no-warn-deprecated',
$filename],
'>', \$output,
'2>&1')) {
return undef;
}
return "desktop-file-validate error\n$output";
}
sub check_all_desktop_files {
### check_all_desktop_files() ...
SKIP: {
my $skip = skip_reason();
if (defined $skip) {
skip $skip, 1;
}
my $manifest = ExtUtils::Manifest::maniread();
my @filenames = grep /\.desktop$/, keys %$manifest;
### @filenames
my $bad = 0;
foreach my $filename (@filenames) {
my $reason = desktop_file_validate($filename);
if (defined $reason) {
diag "$filename: $reason";
$bad++;
}
}
is ($bad, 0, 'desktop-file-validate failures');
}
}
}
use Test::More tests => 1;
Test::DesktopFile::Validate::check_all_desktop_files();
exit 0;
__END__
# my $devnull = File::Spec->devnull;
# my $wait = do {
# local *STDOUT;
# local *STDERR;
# if (! open STDOUT, ">$devnull") {
# die "Oops, cannot open $devnull: $!";
# }
# if (! open STDERR, ">$devnull") {
# die "Oops, cannot open $devnull: $!";
# }
# system 'desktop-file-validate --help';
# };
#
# if ($wait == 0) {
# return undef;
# }
# return 'desktop-file-validate program not available';