line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Finance::StockAccount::Stock; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
4
|
|
|
|
|
|
|
|
5
|
10
|
|
|
10
|
|
39
|
use strict; |
|
10
|
|
|
|
|
13
|
|
|
10
|
|
|
|
|
300
|
|
6
|
10
|
|
|
10
|
|
32
|
use warnings; |
|
10
|
|
|
|
|
9
|
|
|
10
|
|
|
|
|
3534
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
276
|
|
|
276
|
0
|
530
|
my ($class, $init) = @_; |
10
|
276
|
|
|
|
|
569
|
my $self = { |
11
|
|
|
|
|
|
|
symbol => undef, |
12
|
|
|
|
|
|
|
exchange => undef, |
13
|
|
|
|
|
|
|
}; |
14
|
276
|
|
|
|
|
458
|
bless($self, $class); |
15
|
276
|
100
|
|
|
|
410
|
$init and $self->set($init); |
16
|
276
|
|
|
|
|
497
|
return $self; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub set { |
20
|
1
|
|
|
1
|
0
|
23
|
my ($self, $init) = @_; |
21
|
1
|
|
|
|
|
4
|
for my $key (keys %$init) { |
22
|
1
|
50
|
|
|
|
3
|
if (exists($self->{$key})) { |
23
|
1
|
|
|
|
|
1
|
$self->{$key} = $init->{$key}; |
24
|
1
|
|
|
|
|
2
|
return 1; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
else { |
27
|
0
|
|
|
|
|
0
|
warn "Tried to set $key in Finance::StockAccount::Stock object, but that's not a known key.\n"; |
28
|
0
|
|
|
|
|
0
|
return 0; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub symbol { |
34
|
1634
|
|
|
1634
|
0
|
1466
|
my ($self, $symbol) = @_; |
35
|
1634
|
100
|
|
|
|
2006
|
if ($symbol) { |
36
|
275
|
|
|
|
|
401
|
$self->{symbol} = $symbol; |
37
|
275
|
|
|
|
|
564
|
return 1; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
else { |
40
|
1359
|
|
|
|
|
3155
|
return $self->{symbol}; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub exchange { |
45
|
534
|
|
|
534
|
0
|
419
|
my ($self, $exchange) = @_; |
46
|
534
|
50
|
|
|
|
587
|
if ($exchange) { |
47
|
0
|
|
|
|
|
0
|
$self->{exchange} = $exchange; |
48
|
0
|
|
|
|
|
0
|
return 1; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
else { |
51
|
534
|
|
|
|
|
971
|
return $self->{exchange}; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub same { |
56
|
266
|
|
|
266
|
0
|
238
|
my ($self, $stock) = @_; |
57
|
266
|
|
|
|
|
332
|
my $symbol = $self->symbol(); |
58
|
266
|
50
|
33
|
|
|
570
|
if ($symbol and $symbol eq $stock->symbol()) { |
59
|
266
|
|
|
|
|
335
|
my $exchange = $self->exchange(); |
60
|
266
|
50
|
33
|
|
|
538
|
if ($exchange or $stock->exchange()) { |
61
|
0
|
0
|
|
|
|
0
|
if ($exchange eq $stock->exchange()) { |
62
|
0
|
|
|
|
|
0
|
return 1; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
else { |
65
|
0
|
|
|
|
|
0
|
return 0; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
} |
68
|
266
|
|
|
|
|
650
|
return 1; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
else { |
71
|
0
|
|
|
|
|
0
|
return 0; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub hashKey { |
76
|
257
|
|
|
257
|
0
|
231
|
my $self = shift; |
77
|
257
|
|
|
|
|
287
|
my $symbol = $self->{symbol}; |
78
|
257
|
|
|
|
|
224
|
my $exchange = $self->{exchange}; |
79
|
257
|
50
|
33
|
|
|
829
|
if ($symbol and $exchange) { |
|
|
50
|
|
|
|
|
|
80
|
0
|
|
|
|
|
0
|
return "$symbol:$exchange"; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
elsif ($symbol) { |
83
|
257
|
|
|
|
|
535
|
return $symbol; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
else { |
86
|
0
|
|
|
|
|
|
warn "Cannot generate hash key when stock symbol not set.\n"; |
87
|
0
|
|
|
|
|
|
return undef; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
__END__ |