line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Finance::StockAccount::Acquisition; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
4
|
|
|
|
|
|
|
|
5
|
8
|
|
|
8
|
|
541
|
use strict; |
|
8
|
|
|
|
|
19
|
|
|
8
|
|
|
|
|
281
|
|
6
|
8
|
|
|
8
|
|
35
|
use warnings; |
|
8
|
|
|
|
|
8
|
|
|
8
|
|
|
|
|
174
|
|
7
|
|
|
|
|
|
|
|
8
|
8
|
|
|
8
|
|
29
|
use Carp; |
|
8
|
|
|
|
|
9
|
|
|
8
|
|
|
|
|
467
|
|
9
|
|
|
|
|
|
|
|
10
|
8
|
|
|
8
|
|
388
|
use Finance::StockAccount::AccountTransaction; |
|
8
|
|
|
|
|
21
|
|
|
8
|
|
|
|
|
4423
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
1505
|
|
|
1505
|
0
|
1588
|
my ($class, $at, $shares) = @_; |
15
|
1505
|
|
|
|
|
4348
|
my $self = { |
16
|
|
|
|
|
|
|
at => undef, |
17
|
|
|
|
|
|
|
shares => 0, |
18
|
|
|
|
|
|
|
cashEffect => 0, |
19
|
|
|
|
|
|
|
commission => 0, |
20
|
|
|
|
|
|
|
regulatoryFees => 0, |
21
|
|
|
|
|
|
|
otherFees => 0, |
22
|
|
|
|
|
|
|
}; |
23
|
1505
|
|
|
|
|
2719
|
bless($self, $class); |
24
|
1505
|
|
|
|
|
1988
|
$self->init($at, $shares); |
25
|
1505
|
|
|
|
|
2612
|
return $self; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub at { |
29
|
3010
|
|
|
3010
|
0
|
2767
|
my ($self, $at) = @_; |
30
|
3010
|
100
|
|
|
|
3644
|
if ($at) { |
31
|
1505
|
50
|
33
|
|
|
4345
|
if (ref($at) and ($at->buy() or $at->short())) { |
|
|
|
33
|
|
|
|
|
32
|
1505
|
|
|
|
|
1519
|
$self->{at} = $at; |
33
|
1505
|
|
|
|
|
1341
|
return 1; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
else { |
36
|
0
|
|
|
|
|
0
|
confess "Acquisition requires a valid AccountTransaction object of type buy or short."; |
37
|
0
|
|
|
|
|
0
|
return 0; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
else { |
41
|
1505
|
|
|
|
|
1902
|
return $self->{at}; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
2150
|
|
|
2150
|
0
|
3851
|
sub cashEffect { return shift->{cashEffect}; } |
46
|
1505
|
|
|
1505
|
0
|
2692
|
sub commission { return shift->{commission}; } |
47
|
1504
|
|
|
1504
|
0
|
2410
|
sub regulatoryFees { return shift->{regulatoryFees}; } |
48
|
1504
|
|
|
1504
|
0
|
2315
|
sub otherFees { return shift->{otherFees}; } |
49
|
1504
|
|
|
1504
|
0
|
2802
|
sub shares { return shift->{shares}; } |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub tm { |
52
|
7918
|
|
|
7918
|
0
|
5908
|
my $self = shift; |
53
|
7918
|
|
|
|
|
6958
|
my $at = $self->{at}; |
54
|
7918
|
|
|
|
|
11745
|
return $at->tm(); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub proportion { |
58
|
1505
|
|
|
1505
|
0
|
1197
|
my $self = shift; |
59
|
1505
|
|
|
|
|
1375
|
my $shares = $self->{shares}; |
60
|
1505
|
|
|
|
|
1288
|
my $at = $self->{at}; |
61
|
1505
|
|
|
|
|
2775
|
my $quantity = $at->quantity(); |
62
|
1505
|
|
|
|
|
2362
|
return $shares / $quantity; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub compute { |
66
|
1505
|
|
|
1505
|
0
|
1268
|
my $self = shift; |
67
|
1505
|
|
|
|
|
2005
|
my $proportion = $self->proportion(); |
68
|
1505
|
|
|
|
|
1887
|
my $at = $self->at(); |
69
|
1505
|
|
|
|
|
2613
|
$self->{cashEffect} = $at->cashEffect() * $proportion; |
70
|
1505
|
|
|
|
|
2804
|
$self->{commission} = $at->commission() * $proportion; |
71
|
1505
|
|
|
|
|
2602
|
$self->{regulatoryFees} = $at->regulatoryFees() * $proportion; |
72
|
1505
|
|
|
|
|
2452
|
$self->{otherFees} = $at->otherFees() * $proportion; |
73
|
1505
|
|
|
|
|
1545
|
return 1; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub init { |
77
|
1505
|
|
|
1505
|
0
|
1499
|
my ($self, $at, $shares) = @_; |
78
|
1505
|
50
|
33
|
|
|
4727
|
if (!($at and $shares)) { |
79
|
0
|
|
|
|
|
0
|
confess "Acquisition->new constructor requires \$at (AccountTransaction) and shares count parameters.\n"; |
80
|
|
|
|
|
|
|
} |
81
|
1505
|
50
|
33
|
|
|
8060
|
if ($shares =~ /^[0-9]+$/ and $shares > 0) { |
82
|
1505
|
|
|
|
|
2398
|
$self->at($at); |
83
|
1505
|
|
|
|
|
2114
|
$self->{shares} = $shares; |
84
|
1505
|
|
|
|
|
1920
|
$self->compute(); |
85
|
1505
|
|
|
|
|
1442
|
return 1; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
else { |
88
|
0
|
|
|
|
|
0
|
confess "Acquisition::Init requires numeric positive shares value, got $shares.\n"; |
89
|
0
|
|
|
|
|
0
|
return 0; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub lineFormatValues { |
94
|
93
|
|
|
93
|
0
|
66
|
my $self = shift; |
95
|
93
|
|
|
|
|
113
|
my $at = $self->{at}; |
96
|
93
|
|
|
|
|
170
|
my $lineFormatValues = $at->lineFormatValues(); |
97
|
93
|
|
|
|
|
120
|
$lineFormatValues->[3] = $self->{shares}; |
98
|
93
|
|
|
|
|
92
|
$lineFormatValues->[5] = $self->{commission}; |
99
|
93
|
|
|
|
|
112
|
$lineFormatValues->[6] = $self->{regulatoryFees} + $self->{otherFees}; |
100
|
93
|
|
|
|
|
87
|
$lineFormatValues->[7] = $self->{cashEffect}; |
101
|
93
|
|
|
|
|
1211
|
return $lineFormatValues; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub lineFormatString { |
105
|
93
|
|
|
93
|
0
|
69
|
my $self = shift; |
106
|
93
|
|
|
|
|
192
|
return sprintf(Finance::StockAccount::Transaction->lineFormatPattern(), @{$self->lineFormatValues()}); |
|
93
|
|
|
|
|
117
|
|
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1; |