| 1 | package Finance::QuoteHist::Generic; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # http://www.stanford.edu/dept/OOD/RESEARCH/top-ten-faq/how_do_i_find_an_historical_st.html | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # Shortcut: Use adjusted close price | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # For the mathematically inclined, one shortcut to determining the value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # after splits is to use the adjusted close price from the historical | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # quote tool. For June 2, 1997, it lists a market close price of 33.13 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # and an adjusted close price of 1.38. Divide 33.13 by 1.38 and you come | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | # up with 24.007. Multiply by 1,000 and you come pretty close to the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | # 24,000 share figure determined above. Or you could divide 1.38 by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | # 33.13, which gives you 0.041654. Divide $33,130 by 0.041654, and you | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | # get $795K, which is very close to the $808K figure above. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 5 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 5 | ▶ | use LWP::UserAgent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 5 | ▶ | use HTTP::Request; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 5 | ▶ | use Date::Manip; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 5 | Date::Manip::Date_Init("TZ=GMT"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 5 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 5 | $VERSION = '1.20'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 5 | my $CSV_XS_Class = 'Text::CSV_XS'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 5 | my $CSV_PP_Class = 'Text::CSV_PP'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 5 | my $CSV_Class = $CSV_XS_Class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 5 | ▶ | eval "use $CSV_Class"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 5 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | $CSV_Class = $CSV_PP_Class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | eval "use $CSV_Class"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | croak "Could not load either $CSV_XS_Class or $CSV_PP_Class : $@\n" if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 5 | my $HTE_CLASS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 5 | my $HTE_Class = 'HTML::TableExtract'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | sub HTML_CLASS { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | if (!$HTE_CLASS) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
HTML_CLASS: not called CC=3 SCAR=24.8
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | eval "use $HTE_Class"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | croak $@ if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | $HTE_CLASS = $HTE_Class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | $HTE_CLASS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 5 | my $Default_Target_Mode = 'quote'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 5 | my $Default_Parse_Mode = 'html'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 5 | my $Default_Granularity = 'daily'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 5 | my $Default_Vol_Pat = qr(vol|shares)i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 5 | my %Default_Labels; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 5 | $Default_Labels{quote}{$Default_Parse_Mode} = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | [qw( date open high low close ), $Default_Vol_Pat]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 5 | $Default_Labels{dividend}{$Default_Parse_Mode} = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | [qw( date div )]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 5 | $Default_Labels{'split'}{$Default_Parse_Mode} = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | [qw( date post pre )]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 5 | $Default_Labels{intraday}{$Default_Parse_Mode} = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | [qw( date time high low close ), $Default_Vol_Pat]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 5 | my @Scalar_Flags = qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | verbose | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | quiet | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | zthresh | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | quote_precision | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | attempts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | adjusted | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | has_non_adjusted | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | env_proxy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | debug | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | parse_mode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | target_mode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | granularity | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | auto_proxy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | row_filter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 5 | my $SF_pat = join('|', @Scalar_Flags); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 5 | my @Array_Flags = qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | symbols | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | lineup | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 5 | my $AF_pat = join('|', @Array_Flags); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 5 | my @Hash_Flags = qw( ua_params ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 5 | my $HF_pat = join('|', @Hash_Flags); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 5 | ▶ | my $that = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=28 SCAR=40.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 5 | ▶ | my $class = ref($that) || $that; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $that || $that
MC/DC0%0/2
ref $that || $that
ref $that
$that
Truth table33%1/3
A || B
A= ref $thatB= $that
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 5 | my(@pass, %parms, $k, $v); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 5 | ▶ | while (($k,$v) = splice(@_, 0, 2)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 28 | ▶ | if ($k eq 'start_date' || $k eq 'end_date' && $v !~ /^\s*$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
Condition83%5/6
$k eq "start_date" or $k eq "end_date" and not $v =~ /^\s*$/
$k eq "end_date" and not $v =~ /^\s*$/
MC/DC66%2/3
$k eq "start_date" or $k eq "end_date" and not $v =~ /^\s*$/
$k eq "start_date"
$k eq "end_date"
not $v =~ /^\s*$/
Truth table75%3/4
A or B and not(C)
A= $k eq "start_date"B= $k eq "end_date"C= not $v =~ /^\s*$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 10 | $parms{$k} = __PACKAGE__->date_standardize($v); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | elsif ($k =~ /^$AF_pat$/o) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 5 | ▶ | if (UNIVERSAL::isa($v, 'ARRAY')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | $parms{$k} = $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | elsif (ref $v) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | croak "$k must be passed as an array ref or single-entry string\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 5 | $parms{$k} = [$v]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | elsif ($k =~ /^$HF_pat$/o) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | if (UNIVERSAL::isa($v, 'HASH')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | $parms{$k} = $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | croak "$k must be passed as a hash ref\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | elsif ($k eq 'row_filter') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | croak "$k must be sub ref\n" unless UNIVERSAL::isa($v, 'CODE'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | $parms{$k} = $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | elsif ($k =~ /^$SF_pat$/o) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 13 | $parms{$k} = $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 5 | ▶ | $parms{end_date} ||= __PACKAGE__->date_standardize('today'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$parms{"end_date"} ||= __PACKAGE__->date_standardize("today")
MC/DC0%0/2
$parms{"end_date"} ||= __PACKAGE__->date_standardize("today")
$parms{"end_date"}
__PACKAGE__->date_standardize("today")
Truth table33%1/3
A ||= B
A= $parms{"end_date"}B= __PACKAGE__->date_standardize("today")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 5 | ▶ | $parms{symbols} or croak "Symbol list required\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 5 | my $start_date = delete $parms{start_date}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 5 | my $end_date = delete $parms{end_date}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 5 | my $symbols = delete $parms{symbols}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | # Defaults | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 5 | ▶ | $parms{zthresh} = 30 unless $parms{zthresh}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 5 | ▶ | $parms{attempts} = 3 unless $parms{attempts}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 5 | ▶ | $parms{adjusted} = 1 unless exists $parms{adjusted}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 5 | ▶ | $parms{has_non_adjusted} = 0 unless defined $parms{has_non_adjusted}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 5 | ▶ | $parms{quote_precision} = 4 unless defined $parms{quote_precision}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 5 | ▶ | $parms{auto_proxy} = 1 unless exists $parms{auto_proxy}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 5 | ▶ | $parms{debug} = 0 unless defined $parms{debug}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 5 | my $self = \%parms; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 5 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 5 | ▶ | my $ua_params = $parms{ua_params} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$parms{'ua_params'} || {}
MC/DC0%0/1
$parms{'ua_params'} || {}
$parms{'ua_params'}
Truth table50%1/2
A
A= $parms{'ua_params'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 5 | ▶ | if ($parms{env_proxy}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | $ua_params->{env_proxy} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | elsif ($parms{auto_proxy}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 5 | ▶ | $ua_params->{env_proxy} = 1 if $ENV{http_proxy}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 5 | delete $parms{env_proxy}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 5 | $self->{ua} = LWP::UserAgent->new(%$ua_params); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 5 | ▶ | if ($self->granularity !~ /^d/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 2 | $start_date = $self->snap_start_date($start_date); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 2 | $end_date = $self->snap_end_date($end_date); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 5 | $self->start_date($start_date); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 5 | $self->end_date($end_date); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 5 | $self->symbols(@$symbols); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | # These are used for constructing method names for target types. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 5 | $self->{target_order} = [qw(quote split dividend)]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 5 | grep($self->{targets}{$_} = "${_}s", @{$self->{target_order}}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 5 | $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | ### User interface stubs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 3 | ▶ | sub quotes { shift->getter(target_mode => 'quote')->() } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
quotes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 1 | ▶ | sub dividends { shift->getter(target_mode => 'dividend')->() } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dividends: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 1 | ▶ | sub splits { shift->getter(target_mode => 'split')->() } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
splits: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | sub intraday { shift->getter(target_mode => 'intraday')->() } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
intraday: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 5 | *intraday_quotes = *intraday; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | sub target_worthy { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 5 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
target_worthy: called CC=6 SCAR=22.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 5 | my %parms = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 5 | ▶ | my $target_mode = $parms{target_mode} || $self->target_mode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$parms{'target_mode'} || $self->target_mode
MC/DC0%0/2
$parms{'target_mode'} || $self->target_mode
$parms{'target_mode'}
$self->target_mode
Truth table33%1/3
A || B
A= $parms{'target_mode'}B= $self->target_mode
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 5 | ▶ | my $parse_mode = $parms{parse_mode} || $self->parse_mode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$parms{'parse_mode'} || $self->parse_mode
MC/DC0%0/2
$parms{'parse_mode'} || $self->parse_mode
$parms{'parse_mode'}
$self->parse_mode
Truth table33%1/3
A || B
A= $parms{'parse_mode'}B= $self->parse_mode
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | # forcing url_maker into a boolean role here, using a dummy symbol | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 5 | my $capable = $self->url_maker( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | %parms, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | target_mode => $target_mode, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | parse_mode => $parse_mode, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | symbol => 'waggledance', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 5 | ▶ | my $worthy = $capable && UNIVERSAL::isa($capable, 'CODE'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$capable && UNIVERSAL::isa($capable, 'CODE')
MC/DC0%0/2
$capable && UNIVERSAL::isa($capable, 'CODE')
$capable
UNIVERSAL::isa($capable, 'CODE')
Truth table33%1/3
A && B
A= $capableB= UNIVERSAL::isa($capable, 'CODE')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 5 | ▶ | if ($self->{verbose}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | print STDERR "Seeing if ", ref $self, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | " can get ($target_mode, $parse_mode) : ", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | $worthy ? "yes\n" : "no\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 5 | $worthy; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | sub granularities { qw( daily ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
granularities: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | ### Data retrieval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | sub ua { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 20 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ua: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 20 | ▶ | @_ ? $self->{ua} = shift : $self->{ua}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | sub fetch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | # HTTP::Request and LWP::UserAgent Wrangler | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 5 | ▶ | my($self, $request) = splice(@_, 0, 2); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fetch: called CC=10 SCAR=26.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 5 | ▶ | $request or croak "Request or URL required\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 5 | ▶ | if (! ref $request || ! $request->isa('HTTP::Request')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $request and $request->isa("HTTP::Request")
MC/DC0%0/2
ref $request and $request->isa("HTTP::Request")
ref $request
$request->isa("HTTP::Request")
Truth table33%1/3
A and B
A= ref $requestB= $request->isa("HTTP::Request")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 5 | $request = HTTP::Request->new(GET => $request); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 5 | my $trys = $self->{attempts}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 5 | my $response = $self->ua->request($request, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 5 | $self->{_lwp_success} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 5 | ▶ | while (! $response->is_success) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 20 | ▶ | last unless $trys; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 15 | $self->{_lwp_status} = $response->status_line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | print STDERR "Bad fetch", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | $response->is_error ? ' (' . $response->status_line . '), ' : ', ', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 15 | ▶ | "trying again...\n" if $self->{debug}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 15 | $response = $self->ua->request($request, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 15 | --$trys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 5 | $self->{_lwp_success} = $response->is_success; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 5 | ▶ | return undef unless $response->is_success; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | print STDERR 'Fetch complete. (' . length($response->content) . " chars)\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | if $self->{verbose}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | $response->content; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | sub getter { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | # closure factory to get results for a particular target_mode and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | # parse_mode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 5 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getter: called CC=3 SCAR=16.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 5 | my %parms = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 5 | ▶ | my $target_mode = $parms{target_mode} || $self->target_mode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$parms{'target_mode'} || $self->target_mode
MC/DC0%0/2
$parms{'target_mode'} || $self->target_mode
$parms{'target_mode'}
$self->target_mode
Truth table33%1/3
A || B
A= $parms{'target_mode'}B= $self->target_mode
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 5 | ▶ | my $parse_mode = $parms{parse_mode} || $self->parse_mode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$parms{'parse_mode'} || $self->parse_mode
MC/DC0%0/2
$parms{'parse_mode'} || $self->parse_mode
$parms{'parse_mode'}
$self->parse_mode
Truth table33%1/3
A || B
A= $parms{'parse_mode'}B= $self->parse_mode
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 5 | my @column_labels = $self->labels( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | %parms, target_mode => $target_mode, parse_mode => $parse_mode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 5 | my %extractors = $self->extractors( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | %parms, target_mode => $target_mode, parse_mode => $parse_mode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | # return our closure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 5 | ▶ | my @symbols = @_ ? @_ : $self->symbols; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=83 SCAR=75.4
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 5 | my @rows; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | # cache check | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | my @not_seen; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 5 | foreach my $symbol (@symbols) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 5 | my @r = $self->result_rows($target_mode, $symbol); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 5 | ▶ | if (@r) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | push(@rows, @r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 5 | push(@not_seen, $symbol); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 5 | ▶ | return @rows unless @not_seen; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 5 | my $original_target_mode = $self->target_mode; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 5 | my $original_parse_mode = $self->parse_mode; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 5 | $self->target_mode($target_mode); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 5 | $self->parse_mode($parse_mode); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 5 | my $dcol = $self->label_column('date'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 5 | my(%empty_fetch, %saw_good_rows); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 5 | my $last_data = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 5 | my $target_worthy = $self->target_worthy( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | %parms, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | target_mode => $target_mode, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | parse_mode => $parse_mode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 5 | ▶ | if (!$target_worthy) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | # make sure and empty @symbols | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | ▶ | ++$empty_fetch{$_} while $_ = pop @symbols; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 5 | SYMBOL: foreach my $s (@symbols) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 5 | my $urlmaker = $self->url_maker( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | target_mode => $target_mode, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | parse_mode => $parse_mode, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | symbol => $s, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 5 | ▶ | UNIVERSAL::isa($urlmaker, 'CODE') or croak "urlmaker not a code ref.\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 5 | my $so_far_so_good = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 5 | ▶ | URL: while (my $url = $urlmaker->()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 6 | ▶ | if ($empty_fetch{$s}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | print STDERR ref $self, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | " passing on $s ($target_mode) for now, empty fetch\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 1 | ▶ | if $self->{verbose}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 1 | last URL; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 5 | ▶ | if ($self->{verbose}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | my $uri = $url; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | ▶ | $uri = $url->uri if UNIVERSAL::isa($url, 'HTTP::Request'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | print STDERR "Processing ($s:$target_mode) $uri\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | # We're a bit more persistent with quotes. It is more suspicious | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | # if we get no quote rows, but it is nevertheless possible. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 5 | ▶ | my $trys = $target_mode eq 'quote' ? $self->{attempts} : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 5 | my $initial_trys = $trys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 5 | my($data, $rows) = ('', []); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | print STDERR "$s Trying ($target_mode) again due to no rows...\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 5 | ▶ | if $self->{verbose} && $trys != $initial_trys; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"verbose"} and $trys != $initial_trys
MC/DC0%0/2
$self->{"verbose"} and $trys != $initial_trys
$self->{"verbose"}
$trys != $initial_trys
Truth table33%1/3
A and B
A= $self->{"verbose"}B= $trys != $initial_trys
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 5 | ▶ | if (!($data = $self->{url_cache}{$url})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 5 | $data = $self->fetch($url); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 5 | ▶ | if (my $pre_parser = $self->pre_parser) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | $data = $pre_parser->( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | $data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | target_mode => $target_mode, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | parse_mode => $parse_mode, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | # make sure our url_maker hasn't sent us into a twister | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 5 | ▶ | if ($data && $data eq $last_data) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$data and $data eq $last_data
MC/DC0%0/2
$data and $data eq $last_data
$data
$data eq $last_data
Truth table33%1/3
A and B
A= $dataB= $data eq $last_data
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | print STDERR "Redundant data fetch, assuming end of URLs.\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | ▶ | if $self->{verbose}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | last URL; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 5 | ▶ | $last_data = defined $data ? $data : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 5 | $rows = $self->rows($self->parser->($data)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 5 | ▶ | last URL if $so_far_so_good && !@$rows; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$so_far_so_good and not @$rows
MC/DC0%0/2
$so_far_so_good and not @$rows
$so_far_so_good
not @$rows
Truth table33%1/3
A and not(B)
A= $so_far_so_goodB= not @$rows
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 5 | --$trys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 5 | ▶ | } while !@$rows && $trys && $self->{_lwp_success}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
not @$rows and $trys and $self->{"_lwp_success"}
not @$rows and $trys
MC/DC0%0/3
not @$rows and $trys and $self->{"_lwp_success"}
not @$rows
$trys
$self->{"_lwp_success"}
Truth table50%2/4
not(A) and B and C
A= not @$rowsB= $trysC= $self->{"_lwp_success"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 5 | $so_far_so_good = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 5 | ▶ | if ($target_mode ne 'quote' || $target_mode ne 'intraday') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$target_mode ne "quote" or $target_mode ne "intraday"
MC/DC0%0/2
$target_mode ne "quote" or $target_mode ne "intraday"
$target_mode ne "quote"
$target_mode ne "intraday"
Truth table66%2/3
A or B
A= $target_mode ne "quote"B= $target_mode ne "intraday"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | # We are not very stubborn about dividends and splits right | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | # now. This is because we cannot prove a successful negative | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | # (i.e., say there were no dividends or splits over the time | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | # period...or perhaps there were, but it is a defunct | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | # symbol...whatever...quotes should always be present unless | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | # they are defunct, which is dealt with later. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 5 | ▶ | if (!$self->{_lwp_success} || !$data) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$self->{'_lwp_success'} && $data
MC/DC0%0/2
$self->{'_lwp_success'} && $data
$self->{'_lwp_success'}
$data
Truth table33%1/3
A && B
A= $self->{'_lwp_success'}B= $data
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 5 | ++$empty_fetch{$s}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 5 | @$rows = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | ▶ | elsif ($self->{_lwp_success} && !@$rows) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"_lwp_success"} and not @$rows
MC/DC0%0/2
$self->{"_lwp_success"} and not @$rows
$self->{"_lwp_success"}
not @$rows
Truth table0%0/3
A and not(B)
A= $self->{"_lwp_success"}B= not @$rows
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | ++$empty_fetch{$s}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | # Raw cache | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 5 | $self->{url_cache}{$url} = $data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | # Extraction filters. This is an opportunity to extract rows | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | # that are not what we are looking for, but contain valuable | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | # information nevertheless. An example of this would be the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | # split and dividend rows you see in Yahoo HTML quote output. An | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | # extraction filter method should expect an array ref as an | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | # argument, representing a single row, and should return another | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | # array ref with extracted output. If there is a return value, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | # then this row will be filtered from the primary output. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 5 | my(%extractions, $ecount, $rc); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 5 | $rc = @$rows; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 5 | ▶ | if (%extractors) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | my(@filtered, $row); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | ▶ | while ($row = pop(@$rows)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | my $erow; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | foreach my $mode (sort keys %extractors) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | my $em = $extractors{$mode}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | ▶ | if ($erow = $em->($row)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | print STDERR "$s extract ($mode) got $s, ", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | ▶ | join(', ', @$erow), "\n" if $self->{verbose}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | push(@{$extractions{$mode}}, [@$erow]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | ++$ecount; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | ▶ | push(@filtered, $row) unless $erow; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | ▶ | if ($self->{verbose} && $ecount) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"verbose"} and $ecount
MC/DC0%0/2
$self->{"verbose"} and $ecount
$self->{"verbose"}
$ecount
Truth table0%0/3
A and B
A= $self->{"verbose"}B= $ecount
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | print STDERR "$s Trimmed to ",$rc - $ecount, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | " rows after $ecount extractions.\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | $rows = \@filtered; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 5 | ▶ | if (@$rows) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | # Normalization steps | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | ▶ | if ($target_mode eq 'split') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | ▶ | if (@{$rows->[0]} == 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | foreach (@$rows) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | ▶ | if ($_->[-1] =~ /split\s+(\d+):(\d+)/is) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | splice(@$_, -1, 1, $1, $2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | # Saving the rounding operations until after the adjust | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | # routine is deliberate since we don't want to be auto- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | # adjusting pre-rounded numbers. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | $self->number_normalize_rows($rows); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | # Do the same for the extraction rows, plus store the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | # extracted rows | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | foreach my $mode (keys %extractions) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | $self->target_mode($mode); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | $self->number_normalize_rows($extractions{$mode}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | $self->_target_source($mode, $s, ref $self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | $self->_store_results($mode, $s, $dcol, $extractions{$mode}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | # restore original target mode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | $self->target_mode($target_mode); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | ▶ | if ($target_mode eq 'quote' || $target_mode eq 'intraday') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$target_mode eq "quote" or $target_mode eq "intraday"
MC/DC0%0/2
$target_mode eq "quote" or $target_mode eq "intraday"
$target_mode eq "quote"
$target_mode eq "intraday"
Truth table0%0/3
A or B
A= $target_mode eq "quote"B= $target_mode eq "intraday"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | my $count = @$rows; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | ▶ | @$rows = grep($self->is_quote_row($_) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->is_quote_row($_) && $self->row_not_seen($s, $_)
MC/DC0%0/2
$self->is_quote_row($_) && $self->row_not_seen($s, $_)
$self->is_quote_row($_)
$self->row_not_seen($s, $_)
Truth table0%0/3
A && B
A= $self->is_quote_row($_)B= $self->row_not_seen($s, $_)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | $self->row_not_seen($s, $_), @$rows); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | ▶ | if ($self->{verbose}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | ▶ | if ($count == @$rows) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | print STDERR "$s Retained $count rows\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | print STDERR "$s Retained $count raw rows, trimmed to ", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | scalar @$rows, " rows due to noise\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | ▶ | if ($target_mode eq 'quote') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | # zcount is an attempt to capture null values; if there are | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | # too many we assume there is something wrong with the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | # remote data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | my $close_col = $self->label_column('close'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | my($zcount, $hcount) = (0,0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | foreach (@$rows) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | foreach (@$_) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | # Sometimes N/A appears | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | s%^\s*N/A\s*$%%; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | my $q = $_->[$close_col]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | ▶ | if (defined $q && $q =~ /\d+/) { ++$hcount } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $q and $q =~ /\d+/
MC/DC0%0/2
defined $q and $q =~ /\d+/
defined $q
$q =~ /\d+/
Truth table0%0/3
A and B
A= defined $qB= $q =~ /\d+/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | else { ++$zcount } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | ▶ | my $pct = $hcount ? 100 * $zcount / ($zcount + $hcount) : 100; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | ▶ | if (!$trys || $pct >= $self->{zthresh}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $trys or $pct >= $self->{"zthresh"}
MC/DC0%0/2
not $trys or $pct >= $self->{"zthresh"}
not $trys
$pct >= $self->{"zthresh"}
Truth table0%0/3
not(A) or B
A= not $trysB= $pct >= $self->{"zthresh"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | ▶ | ++$empty_fetch{$s} unless $saw_good_rows{$s}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | # For defunct symbols, we could conceivably get quotes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | # over a date range that contains blocks of time where the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | # ticker was actively traded, as well as blocks of time | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | # where the ticker doesn't exist. If we got good data over | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | # some of the blocks, then we take note of it so we don't | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | # toss the whole set of queries for this symbol. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | ++$saw_good_rows{$s}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | $self->precision_normalize_rows($rows) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | ▶ | if @$rows && $self->{quote_precision}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@$rows and $self->{"quote_precision"}
MC/DC0%0/2
@$rows and $self->{"quote_precision"}
@$rows
$self->{"quote_precision"}
Truth table0%0/3
A and B
A= @$rowsB= $self->{"quote_precision"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | ▶ | last URL if !$ecount && !@$rows; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$ecount or @$rows
MC/DC0%0/2
$ecount or @$rows
$ecount
@$rows
Truth table0%0/3
A or B
A= $ecountB= @$rows
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | ▶ | $self->_store_results($target_mode, $s, $dcol, $rows) if @$rows; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | $self->_target_source($target_mode, $s, ref $self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 5 | $self->_store_empty_fetches([keys %empty_fetch]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | # Check for bad fetches. If we failed on some symbols, punt them to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | # our champion class. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 5 | ▶ | if (%empty_fetch) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 5 | my @bad_symbols = $self->empty_fetches; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 5 | my @champion_classes = $self->lineup; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 5 | ▶ | while (@champion_classes && @bad_symbols) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@champion_classes and @bad_symbols
MC/DC0%0/2
@champion_classes and @bad_symbols
@champion_classes
@bad_symbols
Truth table33%1/3
A and B
A= @champion_classesB= @bad_symbols
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | print STDERR "Bad fetch for ", join(',', @bad_symbols), "\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | ▶ | if $self->{verbose} && $target_worthy; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"verbose"} and $target_worthy
MC/DC0%0/2
$self->{"verbose"} and $target_worthy
$self->{"verbose"}
$target_worthy
Truth table0%0/3
A and B
A= $self->{"verbose"}B= $target_worthy
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | my $champion = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | $self->_summon_champion(shift @champion_classes, @bad_symbols); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | ▶ | next unless $champion && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$champion and $champion->target_worthy("target_mode", $target_mode)
MC/DC0%0/2
$champion and $champion->target_worthy("target_mode", $target_mode)
$champion
$champion->target_worthy("target_mode", $target_mode)
Truth table0%0/3
A and B
A= $championB= $champion->target_worthy("target_mode", $target_mode)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | $champion->target_worthy(target_mode => $target_mode); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | ▶ | print STDERR ref $champion, ", my hero!\n" if $self->{verbose}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | # Hail Mary | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | $champion->getter(target_mode => $target_mode)->(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | # Our champion was the source for these symbols (including | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | # extracted info). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | foreach my $mode ($champion->result_modes) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | foreach my $symbol ($champion->result_symbols($mode)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | $self->_target_source($mode, $symbol, ref $champion); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | $self->_copy_results($mode, $symbol, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | $champion->results($mode, $symbol)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | @bad_symbols = $champion->empty_fetches; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 5 | ▶ | if (@bad_symbols && !$self->{quiet}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@bad_symbols and not $self->{"quiet"}
MC/DC0%0/2
@bad_symbols and not $self->{"quiet"}
@bad_symbols
not $self->{"quiet"}
Truth table33%1/3
A and not(B)
A= @bad_symbolsB= not $self->{"quiet"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 5 | print STDERR "WARNING: Could not fetch $target_mode for some symbols (",join(', ', @bad_symbols), "). Abandoning request for these symbols."; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 5 | ▶ | if ($target_mode ne 'quote') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 2 | print STDERR " Don't worry, though, we were looking for ${target_mode}s. These are less likely to exist compared to quotes."; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 5 | ▶ | if ($self->{_lwp_status}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 5 | print STDERR "\n\nLast status: $self->{_lwp_status}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 5 | print STDERR "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 5 | $self->target_mode($original_target_mode); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 5 | $self->parse_mode($original_parse_mode); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 5 | @rows = $self->result_rows($target_mode); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 5 | ▶ | if ($self->{verbose}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | print STDERR "Class ", ref $self, " returning ", scalar @rows, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | " composite rows.\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | # Return the loot. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 5 | ▶ | wantarray ? @rows : \@rows; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 5 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | sub _store_results { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | ▶ | my($self, $mode, $symbol, $dcol, $rows) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_store_results: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | foreach my $row (@$rows) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | my $date = splice(@$row, $dcol, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | $self->{results}{$mode}{$symbol}{$date} = $row; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | sub _copy_results { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | ▶ | my($self, $mode, $symbol, $results) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_copy_results: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | foreach my $date (sort keys %$results) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 0 | $self->{results}{$mode}{$symbol}{$date} = [@{$results->{$date}}]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | sub result_rows { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 10 | ▶ | my($self, $target_mode, @symbols) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
result_rows: called CC=5 SCAR=17.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 10 | ▶ | $target_mode ||= $self->target_mode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$target_mode ||= $self->target_mode
MC/DC0%0/2
$target_mode ||= $self->target_mode
$target_mode
$self->target_mode
Truth table33%1/3
A ||= B
A= $target_modeB= $self->target_mode
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 10 | ▶ | @symbols = $self->result_symbols($target_mode) unless @symbols; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 10 | my @rows; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 10 | foreach my $symbol (@symbols) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 5 | my $results = $self->results($target_mode, $symbol); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 5 | foreach my $date (sort keys %$results) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | push(@rows, [$symbol, $date, @{$results->{$date}}]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 10 | sort { $a->[1] cmp $b->[1] } @rows; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | sub _store_empty_fetches { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 5 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_store_empty_fetches: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 5 | ▶ | my $ref = shift || []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() || []
MC/DC0%0/1
shift() || []
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 5 | @$ref = sort @$ref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 5 | $self->{empty_fetches} = $ref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | sub empty_fetches { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 5 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
empty_fetches: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 5 | ▶ | return () unless $self->{empty_fetches}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 5 | @{$self->{empty_fetches}} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | ▶ | sub extractors { () } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
extractors: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | sub rows { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 5 | ▶ | my($self, $rows) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rows: called CC=17 SCAR=45.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 5 | ▶ | return wantarray ? () : [] unless $rows; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 5 | my $rc = @$rows; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 5 | ▶ | print STDERR "Got $rc raw rows\n" if $self->{verbose}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | # Load user filter if present | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 5 | my $row_filter = $self->row_filter; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | # Prep the rows | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 5 | foreach my $row (@$rows) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | ▶ | $row_filter->($row) if $row_filter; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | foreach (@$row) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | # Zap leading and trailing white space | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | ▶ | next unless defined; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | s/^\s+//; s/\s+$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | # Pass only rows with a valid date that is in range (and store the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | # processed value while we are at it) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 5 | my $target_mode = $self->target_mode; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 5 | my @date_rows; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 5 | my $dcol = $self->label_column('date'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 5 | ▶ | my $tcol = $self->label_column('time') if $target_mode eq 'intraday'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 5 | my $r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 5 | ▶ | while($r = pop @$rows) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | my $date = $r->[$dcol]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | ▶ | if ($target_mode eq 'intraday') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | my $time = splice(@$r, $tcol, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 0 | $date = join('', $date, $time); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 0 | $date = $self->date_normalize($date); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | ▶ | unless ($date) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | ▶ | print STDERR "Reject row (no date): '$r->[$dcol]'\n" if $self->{verbose}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | ▶ | next unless $self->date_in_range($date); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | $r->[$dcol] = $date; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | push(@date_rows, $r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | print STDERR "Trimmed to ", scalar @date_rows, " applicable date rows\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 5 | ▶ | if $self->{verbose} && @date_rows != $rc; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"verbose"} and @date_rows != $rc
MC/DC0%0/2
$self->{"verbose"} and @date_rows != $rc
$self->{"verbose"}
@date_rows != $rc
Truth table33%1/3
A and B
A= $self->{"verbose"}B= @date_rows != $rc
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 5 | ▶ | return wantarray ? @date_rows : \@date_rows; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | ### Adjustment triggers and manipulation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | sub adjuster { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | # In order to be an adjuster, it must first be enabled. In addition, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | # there has to be a column specified as the adjusted value. This is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | # not as generic as I would like it, but so far it's just for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | # Yahoo...it should work for any site with "adj" in the column | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | # label...this column should be the adjusted closing value. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
adjuster: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 0 | ▶ | return 0 if !$self->{adjusted}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 0 | foreach ($self->labels) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 0 | ▶ | return 1 if /adj/i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 0 | 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 0 | ▶ | sub adjusted { shift->{adjusted} ? 1 : 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
adjusted: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | ### Bulk manipulation filters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | sub date_normalize_rows { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | # Place dates into a consistent format, courtesy of Date::Manip | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 0 | ▶ | my($self, $rows, $dcol) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
date_normalize_rows: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | ▶ | $dcol = $self->label_column('date') unless defined $dcol; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | foreach my $row (@$rows) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 0 | $row->[$dcol] = $self->date_normalize($row->[$dcol]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | $rows; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | sub date_normalize { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 0 | ▶ | my($self, $date) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
date_normalize: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | ▶ | return unless $date; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 0 | my $normal_date; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 0 | ▶ | if ($self->granularity =~ /^m/ && $date =~ m{^\s*(\D+)[-/]+(\d{2,})\s*$}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->granularity =~ /^m/ and $date =~ m[^\s*(\D+)[-/]+(\d{2,})\s*$]
MC/DC0%0/2
$self->granularity =~ /^m/ and $date =~ m[^\s*(\D+)[-/]+(\d{2,})\s*$]
$self->granularity =~ /^m/
$date =~ m[^\s*(\D+)[-/]+(\d{2,})\s*$]
Truth table0%0/3
A and B
A= $self->granularity =~ /^m/B= $date =~ m[^\s*(\D+)[-/]+(\d{2,})\s*$]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 0 | my($m, $y) = ($1, $2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 0 | ▶ | $y += 1900 if length $y == 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 0 | ▶ | $normal_date = ParseDate($m =~ /^\d+$/ ? "$y/$m/01" : "$m 01 $y"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | $normal_date = ParseDate($date); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | ▶ | $normal_date or return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 0 | ▶ | return $normal_date if $self->target_mode eq 'intraday'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 0 | join('/', $self->ymd($normal_date)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | sub snap_start_date { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 2 | ▶ | my($self, $date) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
snap_start_date: called CC=5 SCAR=16.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 2 | my $g = $self->granularity; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 2 | ▶ | if ($g =~ /^(m|w)/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 2 | ▶ | if ($1 eq 'm') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 1 | my($dom) = UnixDate($date, '%d') - 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 1 | ▶ | $date = DateCalc($date, "- $dom days") if $dom; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 1 | my $dow = Date_DayOfWeek(UnixDate($date, '%m', '%d', '%Y')) - 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 1 | ▶ | $date = DateCalc($date, "- $dow days") if $dow; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 2 | $date; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | sub snap_end_date { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 2 | ▶ | my($self, $date) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
snap_end_date: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 2 | my $g = $self->granularity; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 2 | ▶ | if ($g =~ /^(m|w)/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 2 | ▶ | if ($1 eq 'm') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 1 | my($m, $y) = UnixDate($date, '%m', '%Y'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 1 | my $last = Date_DaysInMonth($m, $y); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 1 | $date = ParseDateString("$y$m$last"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 1 | my $dow = Date_DayOfWeek(UnixDate($date, '%m', '%d', '%Y')) - 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 1 | ▶ | $date = DateCalc($date, "+ " . (6 - $dow) . ' days') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | unless $dow == 6; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 2 | $date; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | sub number_normalize_rows { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | # Strip non-numeric noise from numeric fields | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 0 | ▶ | my($self, $rows, $dcol) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
number_normalize_rows: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 0 | ▶ | $dcol = $self->label_column('date') unless defined $dcol; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | # filtered rows might not have same columns | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 0 | my @cols = grep($_ != $dcol, 0 .. $#{$rows->[0]}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 0 | foreach my $row (@$rows) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 0 | s/[^\d\.]//go foreach @{$row}[@cols]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 0 | $rows; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | sub precision_normalize_rows { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | # Round off numeric fields, if requested (%.4f by default). Volume | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | # is the exception -- we just round that into an integer. This | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | # should probably only be called for 'quote' targets because it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | # knows details about where the numbers of interest reside. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 0 | ▶ | my($self, $rows) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
precision_normalize_rows: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 0 | my $target_mode = $self->target_mode; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 0 | ▶ | croak "precision_normalize invoked in '$target_mode' mode rather than 'quote' or 'intraday' mode.\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$target_mode eq "quote" or $target_mode eq "intraday"
MC/DC0%0/2
$target_mode eq "quote" or $target_mode eq "intraday"
$target_mode eq "quote"
$target_mode eq "intraday"
Truth table0%0/3
A or B
A= $target_mode eq "quote"B= $target_mode eq "intraday"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | unless $target_mode eq 'quote' || $target_mode eq 'intraday'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 0 | my @columns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 0 | ▶ | if ($target_mode ne 'intraday') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 0 | @columns = $self->label_column(qw(open high low close)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 0 | ▶ | push(@columns, $self->label_column('adj')) if $self->adjuster; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 0 | @columns = $self->label_column(qw(high low close)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | my $vol_col = $self->label_column($Default_Vol_Pat); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 0 | foreach my $row (@$rows) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | $row->[$_] = sprintf("%.$self->{quote_precision}f", $row->[$_]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 0 | foreach @columns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 0 | $row->[$vol_col] = int $row->[$vol_col]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 0 | $rows; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | ### Single row filters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | sub is_quote_row { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 0 | ▶ | my($self, $row, $dcol) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_quote_row: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 0 | ▶ | ref $row or croak "Row ref required\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | # Skip date in first field | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 0 | ▶ | $dcol = $self->label_column('date') unless defined $dcol; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 0 | foreach (0 .. $#$row) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 0 | ▶ | next if $_ == $dcol; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | 0 | ▶ | next if $row->[$_] =~ /^\s*$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 0 | ▶ | if ($row->[$_] !~ /^\s*\$*[\d\.,]+\s*$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | sub row_not_seen { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 0 | ▶ | my($self, $symbol, $row, $dcol) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
row_not_seen: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 0 | ▶ | ref $row or croak "Row ref required\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 0 | ▶ | $symbol or croak "ticker symbol required\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 0 | my $mode = $self->target_mode; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 0 | ▶ | my $res = $self->{results}{$mode} or return 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 0 | ▶ | my $mres = $res->{$symbol} or return 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 0 | ▶ | $dcol = $self->label_column('date') unless defined $dcol; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 0 | ▶ | $mres->{$row->[$dcol]} or return 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | sub date_in_range { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
date_in_range: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 0 | my $date = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 0 | ▶ | $date = $self->date_standardize($date) or return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 0 | ▶ | return 0 if $self->{start_date} && $date lt $self->{start_date}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"start_date"} and $date lt $self->{"start_date"}
MC/DC0%0/2
$self->{"start_date"} and $date lt $self->{"start_date"}
$self->{"start_date"}
$date lt $self->{"start_date"}
Truth table0%0/3
A and B
A= $self->{"start_date"}B= $date lt $self->{"start_date"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 0 | ▶ | return 0 if $self->{end_date} && $date gt $self->{end_date}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"end_date"} and $date gt $self->{"end_date"}
MC/DC0%0/2
$self->{"end_date"} and $date gt $self->{"end_date"}
$self->{"end_date"}
$date gt $self->{"end_date"}
Truth table0%0/3
A and B
A= $self->{"end_date"}B= $date gt $self->{"end_date"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | ### Label and label mapping/extraction management | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 10 | ▶ | sub default_target_mode { $Default_Target_Mode } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_target_mode: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 18 | ▶ | sub default_parse_mode { $Default_Parse_Mode } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_parse_mode: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 6 | ▶ | sub default_granularity { $Default_Granularity } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_granularity: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | sub set_label_pattern { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 28 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_label_pattern: called CC=10 SCAR=23.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 28 | my %parms = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 28 | ▶ | my $target_mode = $parms{target_mode} || $self->target_mode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$parms{'target_mode'} || $self->target_mode
MC/DC0%0/2
$parms{'target_mode'} || $self->target_mode
$parms{'target_mode'}
$self->target_mode
Truth table66%2/3
A || B
A= $parms{'target_mode'}B= $self->target_mode
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 28 | ▶ | my $parse_mode = $parms{parse_mode} || $self->parse_mode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$parms{'parse_mode'} || $self->parse_mode
MC/DC0%0/2
$parms{'parse_mode'} || $self->parse_mode
$parms{'parse_mode'}
$self->parse_mode
Truth table66%2/3
A || B
A= $parms{'parse_mode'}B= $self->parse_mode
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 28 | my $label = $parms{label}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 28 | ▶ | croak "Column label required\n" unless $label; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | 28 | ▶ | my $l2p = $self->{_label_pat}{$target_mode}{$parse_mode} ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"_label_pat"}{$target_mode}{$parse_mode} ||= {}
MC/DC100%1/1
$self->{"_label_pat"}{$target_mode}{$parse_mode} ||= {}
$self->{"_label_pat"}{$target_mode}{$parse_mode}
Truth table100%2/2
A
A= $self->{"_label_pat"}{$target_mode}{$parse_mode}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 28 | ▶ | my $p2l = $self->{_pat_label}{$target_mode}{$parse_mode} ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"_pat_label"}{$target_mode}{$parse_mode} ||= {}
MC/DC100%1/1
$self->{"_pat_label"}{$target_mode}{$parse_mode} ||= {}
$self->{"_pat_label"}{$target_mode}{$parse_mode}
Truth table100%2/2
A
A= $self->{"_pat_label"}{$target_mode}{$parse_mode}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 28 | my $pattern = $parms{pattern}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 28 | ▶ | if ($pattern) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 5 | $l2p->{$label} = $pattern; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 5 | delete $self->{label_map}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | 5 | delete $self->{pattern_map}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 28 | ▶ | my $pat = $l2p->{$label} ||= ($label =~ $Default_Vol_Pat ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$l2p->{$label} ||= $label =~ /$Default_Vol_Pat/ ? qr/\s*$label/i : qr/^\s*$label/i
MC/DC0%0/2
$l2p->{$label} ||= $label =~ /$Default_Vol_Pat/ ? qr/\s*$label/i : qr/^\s*$label/i
$l2p->{$label}
$label =~ /$Default_Vol_Pat/ ? qr/\s*$label/i : qr/^\s*$label/i
Truth table66%2/3
A ||= B
A= $l2p->{$label}B= $label =~ /$Default_Vol_Pat/ ? qr/\s*$label/i : qr/^\s*$label/i
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | qr/\s*$label/i : qr/^\s*$label/i); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 28 | ▶ | $p2l->{$pat} ||= $label; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$p2l->{$pat} ||= $label
MC/DC0%0/2
$p2l->{$pat} ||= $label
$p2l->{$pat}
$label
Truth table33%1/3
A ||= B
A= $p2l->{$pat}B= $label
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 28 | $pat; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | sub label_pattern { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 23 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
label_pattern: called CC=4 SCAR=14.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | 23 | my $target_mode = $self->target_mode; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 23 | my $parse_mode = $self->parse_mode; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 23 | my $label = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 23 | ▶ | croak "column label required\n" unless $label; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 23 | ▶ | my $l2p = $self->{_label_pat}{$target_mode}{$parse_mode} ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"_label_pat"}{$target_mode}{$parse_mode} ||= {}
MC/DC100%1/1
$self->{"_label_pat"}{$target_mode}{$parse_mode} ||= {}
$self->{"_label_pat"}{$target_mode}{$parse_mode}
Truth table100%2/2
A
A= $self->{"_label_pat"}{$target_mode}{$parse_mode}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | 23 | ▶ | my $pat = $l2p->{$label} || $self->set_label_pattern(label => $label); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$l2p->{$label} || $self->set_label_pattern('label', $label)
MC/DC0%0/2
$l2p->{$label} || $self->set_label_pattern('label', $label)
$l2p->{$label}
$self->set_label_pattern('label', $label)
Truth table33%1/3
A || B
A= $l2p->{$label}B= $self->set_label_pattern('label', $label)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 23 | $pat; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | sub label_column { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 10 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
label_column: called CC=7 SCAR=19.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 10 | my @cols; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 10 | ▶ | if (!$self->{label_map}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 9 | delete $self->{pattern_map}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | 9 | my @labels = $self->labels; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | 9 | foreach my $i (0 .. $#labels) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | 49 | $self->{label_map}{$labels[$i]} = $i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 10 | foreach (@_) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | 10 | ▶ | croak "Unknown label '$_'\n" unless exists $self->{label_map}{$_}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 10 | push(@cols, $self->{label_map}{$_}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 10 | ▶ | unless (wantarray) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | 10 | ▶ | croak "multiple columns in scalar context\n" if @cols > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 10 | return $cols[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 0 | @cols; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | sub pattern_column { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pattern_column: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | 0 | ▶ | if (!$self->{pattern_map}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 0 | my @patterns = $self->patterns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | 0 | foreach my $i (0 .. $#patterns) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | 0 | $self->{pattern_map}{$patterns[$i]} = $i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 0 | ▶ | return unless @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 0 | my $pattern = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 0 | ▶ | croak "Unknown pattern '$pattern'\n" unless $self->{_pat_map}{$pattern}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 0 | $self->{pattern_map{$pattern}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | sub pattern_map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pattern_map: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 0 | ▶ | $self->pattern_column unless $self->{pattern_map}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 0 | $self->{pattern_map}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | sub label_map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
label_map: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 0 | ▶ | $self->label_column unless $self->{label_map}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 0 | $self->{label_map}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | sub pattern_label { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pattern_label: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | 0 | my %parms = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | 0 | ▶ | my $target_mode = $parms{target_mode} || $self->target_mode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$parms{'target_mode'} || $self->target_mode
MC/DC0%0/2
$parms{'target_mode'} || $self->target_mode
$parms{'target_mode'}
$self->target_mode
Truth table0%0/3
A || B
A= $parms{'target_mode'}B= $self->target_mode
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 0 | ▶ | my $parse_mode = $parms{parse_mode} || $self->parse_mode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$parms{'parse_mode'} || $self->parse_mode
MC/DC0%0/2
$parms{'parse_mode'} || $self->parse_mode
$parms{'parse_mode'}
$self->parse_mode
Truth table0%0/3
A || B
A= $parms{'parse_mode'}B= $self->parse_mode
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | 0 | ▶ | my $pat = $parms{pattern} or croak "pattern required for label lookup\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | 0 | ▶ | my $p2l = $self->{_pat_label}{$target_mode}{$parse_mode} ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"_pat_label"}{$target_mode}{$parse_mode} ||= {}
MC/DC0%0/1
$self->{"_pat_label"}{$target_mode}{$parse_mode} ||= {}
$self->{"_pat_label"}{$target_mode}{$parse_mode}
Truth table0%0/2
A
A= $self->{"_pat_label"}{$target_mode}{$parse_mode}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | 0 | my $label = $p2l->{$pat}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | 0 | ▶ | unless (defined $label) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | 0 | delete $parms{pattern}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | 0 | $self->set_label_pattern(%parms, label => $_) foreach $self->labels; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | 0 | $label; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | sub patterns { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | 4 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
patterns: called CC=3 SCAR=12.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | 4 | my %parms = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 4 | ▶ | $parms{target_mode} ||= $self->target_mode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$parms{"target_mode"} ||= $self->target_mode
MC/DC0%0/2
$parms{"target_mode"} ||= $self->target_mode
$parms{"target_mode"}
$self->target_mode
Truth table33%1/3
A ||= B
A= $parms{"target_mode"}B= $self->target_mode
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | 4 | ▶ | $parms{parse_mode} ||= $self->parse_mode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$parms{"parse_mode"} ||= $self->parse_mode
MC/DC0%0/2
$parms{"parse_mode"} ||= $self->parse_mode
$parms{"parse_mode"}
$self->parse_mode
Truth table33%1/3
A ||= B
A= $parms{"parse_mode"}B= $self->parse_mode
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 4 | map($self->label_pattern($_), $self->labels(%parms)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | sub columns { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
columns: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | 0 | my %parms = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 0 | ▶ | $parms{target_mode} ||= $self->target_mode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$parms{"target_mode"} ||= $self->target_mode
MC/DC0%0/2
$parms{"target_mode"} ||= $self->target_mode
$parms{"target_mode"}
$self->target_mode
Truth table0%0/3
A ||= B
A= $parms{"target_mode"}B= $self->target_mode
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | 0 | ▶ | $parms{parse_mode} ||= $self->parse_mode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$parms{"parse_mode"} ||= $self->parse_mode
MC/DC0%0/2
$parms{"parse_mode"} ||= $self->parse_mode
$parms{"parse_mode"}
$self->parse_mode
Truth table0%0/3
A ||= B
A= $parms{"parse_mode"}B= $self->parse_mode
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | 0 | $self->label_column($self->labels(%parms)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | sub default_labels { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | 18 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_labels: called CC=5 SCAR=17.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | 18 | my %parms = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | 18 | ▶ | my $target_mode = $parms{target_mode} || $self->target_mode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$parms{'target_mode'} || $self->target_mode
MC/DC0%0/2
$parms{'target_mode'} || $self->target_mode
$parms{'target_mode'}
$self->target_mode
Truth table33%1/3
A || B
A= $parms{'target_mode'}B= $self->target_mode
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | 18 | my $tm = $Default_Labels{$target_mode}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | 18 | ▶ | unless ($tm) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | 0 | $tm = $Default_Labels{$self->default_target_mode}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 18 | ▶ | my $parse_mode = $parms{parse_mode} || $self->parse_mode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$parms{'parse_mode'} || $self->parse_mode
MC/DC0%0/2
$parms{'parse_mode'} || $self->parse_mode
$parms{'parse_mode'}
$self->parse_mode
Truth table33%1/3
A || B
A= $parms{'parse_mode'}B= $self->parse_mode
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | 18 | my $labels = $tm->{$parse_mode}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | 18 | ▶ | unless ($labels) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 18 | $labels = $tm->{$self->default_parse_mode}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | 18 | @$labels; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | sub labels { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | 18 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
labels: called CC=7 SCAR=20.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | 18 | my %parms = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | 18 | ▶ | my $target_mode = $parms{target_mode} || $self->target_mode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$parms{'target_mode'} || $self->target_mode
MC/DC0%0/2
$parms{'target_mode'} || $self->target_mode
$parms{'target_mode'}
$self->target_mode
Truth table66%2/3
A || B
A= $parms{'target_mode'}B= $self->target_mode
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | 18 | ▶ | my $parse_mode = $parms{parse_mode} || $self->parse_mode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$parms{'parse_mode'} || $self->parse_mode
MC/DC0%0/2
$parms{'parse_mode'} || $self->parse_mode
$parms{'parse_mode'}
$self->parse_mode
Truth table66%2/3
A || B
A= $parms{'parse_mode'}B= $self->parse_mode
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | 18 | my $tm = $self->{_labels}{$target_mode}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | 18 | ▶ | if ($parms{labels} || ! $tm->{$parse_mode}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$parms{"labels"} or not $tm->{$parse_mode}
MC/DC0%0/2
$parms{"labels"} or not $tm->{$parse_mode}
$parms{"labels"}
not $tm->{$parse_mode}
Truth table33%1/3
A or not(B)
A= $parms{"labels"}B= not $tm->{$parse_mode}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | 18 | delete $self->{label_map}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | 18 | delete $self->{pattern_map}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | 18 | ▶ | $tm->{$parse_mode} = $parms{labels} if $parms{labels}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | 18 | ▶ | my $labels = $tm->{$parse_mode} ||= [$self->default_labels( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$tm->{$parse_mode} ||= [$self->default_labels("target_mode", $target_mode, "parse_mode", $parse_mode)]
MC/DC0%0/1
$tm->{$parse_mode} ||= [$self->default_labels("target_mode", $target_mode, "parse_mode", $parse_mode)]
$tm->{$parse_mode}
Truth table50%1/2
A
A= $tm->{$parse_mode}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | target_mode => $target_mode, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | parse_mode => $parse_mode)]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | 18 | @$labels; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | sub parse_mode { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | 87 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_mode: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | 87 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | 12 | $self->{parse_mode} = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | 87 | ▶ | $self->{parse_mode} || $self->default_parse_mode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | sub target_mode { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | 98 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
target_mode: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 98 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | 10 | $self->{target_mode} = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | 98 | ▶ | $self->{target_mode} || $self->default_target_mode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | sub granularity { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | 19 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
granularity: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | 19 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | 0 | $self->{granularity} = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | 19 | ▶ | $self->{granularity} || $self->default_granularity; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | sub lineup { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | 5 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lineup: called CC=3 SCAR=13.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | 5 | ▶ | $self->{lineup} = \@_ if @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | 5 | ▶ | return unless $self->{lineup}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | 0 | @{$self->{lineup}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | ### Parser methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | sub pre_parser { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | 5 | ▶ | my($self, %parms) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pre_parser: called CC=3 SCAR=12.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | 5 | ▶ | my $parse_mode = $parms{parse_mode} || $self->parse_mode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$parms{'parse_mode'} || $self->parse_mode
MC/DC0%0/2
$parms{'parse_mode'} || $self->parse_mode
$parms{'parse_mode'}
$self->parse_mode
Truth table33%1/3
A || B
A= $parms{'parse_mode'}B= $self->parse_mode
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | 5 | my $method = "${parse_mode}_pre_parser"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | 5 | ▶ | return unless $self->can($method); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | 0 | $self->$method(%parms, parse_mode => $parse_mode); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | sub parser { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | 5 | ▶ | my($self, %parms) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parser: called CC=2 SCAR=7.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | 5 | ▶ | my $parse_mode = $parms{parse_mode} || $self->parse_mode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$parms{'parse_mode'} || $self->parse_mode
MC/DC0%0/2
$parms{'parse_mode'} || $self->parse_mode
$parms{'parse_mode'}
$self->parse_mode
Truth table33%1/3
A || B
A= $parms{'parse_mode'}B= $self->parse_mode
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | 5 | my $make_parser = "${parse_mode}_parser"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | 5 | $self->$make_parser(%parms, parse_mode => $parse_mode); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | sub html_parser { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | # HTML::TableExtract supports automatic column reordering. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
html_parser: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | 0 | my $class = HTML_CLASS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | 0 | my @labels = $self->labels(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | 0 | my @patterns = $self->patterns(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | 0 | my(%pat_map, %label_map); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | 0 | $pat_map{$patterns[$_]} = $_ foreach 0 .. $#patterns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | 0 | $label_map{$labels[$_]} = $_ foreach 0 .. $#labels; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | 0 | $self->pattern_map(\%pat_map); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | 0 | $self->label_map(\%label_map); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | 0 | ▶ | my $data = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | 0 | my $html_string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | 0 | ▶ | if (ref $data) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | 0 | local($/); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | 0 | $html_string = <$data>; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | 0 | $html_string = $data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | 0 | my %te_parms = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | headers => \@patterns, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | automap => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | 0 | ▶ | $te_parms{debug} = $self->{debug} if $self->{debug} > 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | 0 | ▶ | my $te = $class->new(%te_parms) or croak "Problem creating $class\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | 0 | $te->parse($html_string); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | 0 | $te->eof; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | 0 | my $ts = $te->first_table_found; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | 0 | ▶ | [ $ts ? $ts->rows() : ()]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | 0 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | sub csv_parser { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | # Text::CSV_XS doesn't column slice or re-order, so we do. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | 4 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
csv_parser: called CC=1 SCAR=5.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | 4 | my @patterns = $self->patterns(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | 4 | ▶ | my $data = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=22 SCAR=61.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | 4 | ▶ | return [] unless defined $data; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | 0 | ▶ | my @csv_lines = ref $data ? <$data> : split("\n", $data); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | # BOM squad (byte order mark, as csv from google tends to be) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | 0 | ▶ | if ($csv_lines[0] =~ s/^\xEF\xBB\xBF//) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | 0 | for my $i (0 .. $#csv_lines) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | 0 | utf8::decode($csv_lines[$i]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | # might be unix, windows, or mac style newlines | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | 0 | s/\s+$// foreach @csv_lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | 0 | ▶ | return [] if !@csv_lines || $csv_lines[0] =~ /(no data)|error/i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not @csv_lines or $csv_lines[0] =~ /(no data)|error/i
MC/DC0%0/2
not @csv_lines or $csv_lines[0] =~ /(no data)|error/i
not @csv_lines
$csv_lines[0] =~ /(no data)|error/i
Truth table0%0/3
not(A) or B
A= not @csv_linesB= $csv_lines[0] =~ /(no data)|error/i
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | # attempt to get rid of comments at front of csv data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | 0 | ▶ | while (@csv_lines) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | 0 | ▶ | last if $csv_lines[0] =~ /date/i || $csv_lines[0] =~ /\d+$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$csv_lines[0] =~ /date/i or $csv_lines[0] =~ /\d+$/
MC/DC0%0/2
$csv_lines[0] =~ /date/i or $csv_lines[0] =~ /\d+$/
$csv_lines[0] =~ /date/i
$csv_lines[0] =~ /\d+$/
Truth table0%0/3
A or B
A= $csv_lines[0] =~ /date/iB= $csv_lines[0] =~ /\d+$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | 0 | ▶ | print STDERR "CSV reject line: $csv_lines[0]\n" if $self->{verbose}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | 0 | shift @csv_lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | 0 | my $first_line = $csv_lines[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | 0 | ▶ | my $sep_char = $first_line =~ /date\s*(\S)/i ? $1 : ','; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | 0 | ▶ | my $cp = $CSV_Class->new({sep_char => $sep_char, binary => 1}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | or croak "Problem creating $CSV_Class\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | 0 | my @pat_slice; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | 0 | ▶ | if ($first_line =~ /date/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | # derive column detection and ordering | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | 0 | ▶ | $cp->parse($first_line) or croak ("Problem parsing (" . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | $cp->error_input . ") : " . $cp->error_diag . "\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | 0 | my @headers = $cp->fields; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | 0 | my @pats = @patterns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | 0 | my @labels = map($self->pattern_label(pattern => $_), @patterns); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | 0 | my(%pat_map, %label_map); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | 0 | HEADER: for my $i (0 .. $#headers) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | 0 | ▶ | last unless @pats; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | 0 | my $header = $headers[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | 0 | for my $pi (0 .. $#pats) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | 0 | my $pat = $pats[$pi]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | 0 | ▶ | if ($header =~ /$pat/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | 0 | my $label = $labels[$pi]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | 0 | splice(@pats, $pi, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | 0 | splice(@labels, $pi, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | 0 | $pat_map{$pat} = $i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | 0 | $label_map{$label} = $i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | 0 | next HEADER; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | 0 | shift @csv_lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | 0 | @pat_slice = map($pat_map{$_}, @patterns); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | # no header row, trust natural order and presence | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | 0 | @pat_slice = 0 .. $#patterns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | 0 | my @rows; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | 0 | foreach my $line (@csv_lines) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | 0 | ▶ | $cp->parse($line) or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | 0 | my @fields = $cp->fields; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | 0 | push(@rows, [@fields[@pat_slice]]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | 0 | \@rows; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | 4 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | ### Accessors, generators | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | sub start_date { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | 15 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
start_date: called CC=5 SCAR=16.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | 15 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | 5 | my $start_date = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | 5 | ▶ | my $clear = @_ ? shift : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | 5 | ▶ | $self->clear_cache if $clear; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | 5 | ▶ | $self->{start_date} = defined $start_date ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | $self->date_standardize($start_date) : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | 15 | $self->{start_date}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | sub end_date { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | 15 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
end_date: called CC=5 SCAR=16.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | 15 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | 5 | my $end_date = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | 5 | ▶ | my $clear = @_ ? shift : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | 5 | ▶ | $self->clear_cache if $clear; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | 5 | ▶ | $self->{end_date} = defined $end_date ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | $self->date_standardize($end_date) : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | 15 | $self->{end_date}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | sub date_standardize { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | 20 | ▶ | my($self, @dates) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
date_standardize: called CC=5 SCAR=16.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | 20 | ▶ | return unless @dates; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | 20 | foreach (@dates) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | 20 | ▶ | $_ = ParseDate($_) or Carp::confess "Could not parse date '$_'\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | 20 | s/\d\d:.*//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | 20 | ▶ | @dates > 1 ? @dates : ($dates[0]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | sub mydates { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mydates: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | 0 | $self->dates($self->{start_date}, $self->{end_date}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | sub dates { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | 0 | ▶ | my($self, $sdate, $edate) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dates: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | 0 | ▶ | $sdate && $edate or croak "Start date and end date strings required\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$sdate and $edate
MC/DC0%0/2
$sdate and $edate
$sdate
$edate
Truth table0%0/3
A and B
A= $sdateB= $edate
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | 0 | my($sd, $ed) = sort($self->date_standardize($sdate, $edate)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | 0 | my @dates; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | 0 | ▶ | push(@dates, $sd) if Date_IsWorkDay($sd); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | 0 | my $cd = $self->date_standardize(Date_NextWorkDay($sd, 1)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | 0 | ▶ | while ($cd <= $ed) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | 0 | push(@dates, $cd); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | 0 | $cd = $self->date_standardize(Date_NextWorkDay($cd)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | 0 | @dates; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | sub symbols { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | 10 | ▶ | my($self, @symbols) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
symbols: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | 10 | ▶ | if (@symbols) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | 5 | my %seen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | 5 | grep(++$seen{$_}, grep(uc $_, @symbols)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | 5 | $self->{symbols} = [sort keys %seen]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | 5 | $self->clear_cache; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | 10 | @{$self->{symbols}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | sub successors { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
successors: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | 0 | @{$self->{successors}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | sub clear_cache { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | 15 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear_cache: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | 15 | delete $self->{url_cache}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | 15 | delete $self->{results}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | 15 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | sub result_modes { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
result_modes: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | 0 | ▶ | return () unless $self->{results}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | 0 | sort keys %{$self->{results}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | sub result_symbols { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | 5 | ▶ | my($self, $target_mode) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
result_symbols: called CC=3 SCAR=14.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | 5 | ▶ | $target_mode ||= $self->target_mode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$target_mode ||= $self->target_mode
MC/DC0%0/2
$target_mode ||= $self->target_mode
$target_mode
$self->target_mode
Truth table33%1/3
A ||= B
A= $target_modeB= $self->target_mode
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | 5 | ▶ | return () unless $self->{sources}{$target_mode}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | 0 | sort keys %{$self->{results}{$target_mode}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | sub results { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | 5 | ▶ | my($self, $target_mode, $symbol) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
results: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | 5 | $self->{results}{$target_mode}{$symbol}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | 0 | ▶ | sub quote_source { shift->source(shift, 'quote') } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
quote_source: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | 0 | ▶ | sub dividend_source { shift->source(shift, 'dividend') } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dividend_source: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | 0 | ▶ | sub split_source { shift->source(shift, 'split') } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
split_source: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | 0 | ▶ | sub intraday_source { shift->source(shift, 'intraday') } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
intraday_source: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | 5 | ▶ | sub row_filter { shift->{row_filter} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
row_filter: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | sub source { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | 0 | ▶ | my($self, $symbol, $target_mode) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
source: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | 0 | ▶ | croak "Ticker symbol required\n" unless $symbol; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | 0 | ▶ | $target_mode ||= $self->target_mode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$target_mode ||= $self->target_mode
MC/DC0%0/2
$target_mode ||= $self->target_mode
$target_mode
$self->target_mode
Truth table0%0/3
A ||= B
A= $target_modeB= $self->target_mode
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | 0 | ▶ | $self->{sources}{$target_mode}{$symbol} || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | sub _target_source { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | 0 | ▶ | my($self, $target_mode, $symbol, $source) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_target_source: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | 0 | ▶ | croak "Target mode required\n" unless $target_mode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | 0 | ▶ | croak "Ticker symbol required\n" unless $symbol; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | 0 | $symbol = uc $symbol; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | 0 | ▶ | if ($source) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | 0 | $self->{sources}{$target_mode}{$symbol} = $source; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | 0 | $self->{sources}{$target_mode}{$symbol}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | ### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | sub _summon_champion { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | # Instantiate the next class in line if this class failed in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | # fetching any quotes. Make sure and pass along the remaining | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | # champions to the new champion. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | 0 | ▶ | my($self, $champion_class, @bad_symbols) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_summon_champion: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | 0 | ▶ | return undef unless ref $self->{lineup} && @{$self->{lineup}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $self->{"lineup"} and @{$self->{"lineup"};}
MC/DC0%0/2
ref $self->{"lineup"} and @{$self->{"lineup"};}
ref $self->{"lineup"}
@{$self->{"lineup"};}
Truth table0%0/3
A and B
A= ref $self->{"lineup"}B= @{$self->{"lineup"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | 0 | ▶ | print STDERR "Loading $champion_class\n" if $self->{verbose}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | 0 | eval "require $champion_class;"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | 0 | ▶ | die $@ if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | my $champion = $champion_class->new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | symbols => [@bad_symbols], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | start_date => $self->{start_date}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | end_date => $self->{end_date}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | adjusted => $self->{adjusted}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | verbose => $self->{verbose}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | 0 | lineup => [], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | 0 | $champion; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | ### Toolbox | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | 0 | ▶ | sub save_query { shift->_save_restore_query(1) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
save_query: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | 0 | ▶ | sub restore_query { shift->_save_restore_query(0) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
restore_query: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | sub _save_restore_query { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | 0 | ▶ | my($self, $save) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_save_restore_query: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | 0 | ▶ | $save = 1 unless defined $save; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | 0 | foreach (qw(parse_mode target_mode start_date end_date granularity quiet)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | 0 | my $qstr = "_query_$_"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | 0 | ▶ | if ($save) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | 0 | $self->{$qstr} = $self->{$_}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | 0 | ▶ | $self->{$_} = $self->{$qstr} if exists $self->{$qstr}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | 0 | $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | sub ymd { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | 16 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ymd: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | 16 | my @res = $_[0] =~ /^\s*(\d{4})(\d{2})(\d{2})/o; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | 16 | shift =~ /^\s*(\d{4})(\d{2})(\d{2})/o; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | sub date_iterator { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
date_iterator: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | 0 | my %parms = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | 0 | my $start_date = $parms{start_date}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | 0 | ▶ | my $end_date = $parms{end_date} || 'today'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$parms{'end_date'} || 'today'
MC/DC0%0/1
$parms{'end_date'} || 'today'
$parms{'end_date'}
Truth table0%0/2
A
A= $parms{'end_date'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | 0 | my $increment = $parms{increment}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | 0 | ▶ | my $units = $parms{units} || 'days'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$parms{'units'} || 'days'
MC/DC0%0/1
$parms{'units'} || 'days'
$parms{'units'}
Truth table0%0/2
A
A= $parms{'units'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | 0 | ▶ | $increment && $increment > 0 or croak "Increment > 0 required\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$increment and $increment > 0
MC/DC0%0/2
$increment and $increment > 0
$increment
$increment > 0
Truth table0%0/3
A and B
A= $incrementB= $increment > 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | 0 | ▶ | $start_date = ParseDate($start_date) if $start_date; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | 0 | ▶ | $end_date = ParseDate($end_date) if $end_date; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | 0 | ▶ | if ($start_date && $start_date gt $end_date) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$start_date and $start_date gt $end_date
MC/DC0%0/2
$start_date and $start_date gt $end_date
$start_date
$start_date gt $end_date
Truth table0%0/3
A and B
A= $start_dateB= $start_date gt $end_date
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | 0 | ($start_date, $end_date) = ($end_date, $start_date); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | 0 | my($low_date, $high_date); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | 0 | $high_date = $end_date; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | 0 | ▶ | return () unless $end_date; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | 0 | $low_date = DateCalc($high_date, "- $increment $units"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | 0 | ▶ | if ($start_date && $low_date lt $start_date) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$start_date and $low_date lt $start_date
MC/DC0%0/2
$start_date and $low_date lt $start_date
$start_date
$low_date lt $start_date
Truth table0%0/3
A and B
A= $start_dateB= $low_date lt $start_date
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | 0 | $low_date = $start_date; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | 0 | undef $start_date; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | 0 | undef $end_date; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | 0 | ▶ | return () if $low_date eq $high_date; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | 0 | my @date_pair = ($low_date, $high_date); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | 0 | $high_date = $low_date; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | 0 | @date_pair; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | 0 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||