line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Finance::Symbology; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
21079
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
38
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
36
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
661
|
use Finance::Symbology::Convention::CQS; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
36
|
|
7
|
1
|
|
|
1
|
|
714
|
use Finance::Symbology::Convention::CMS; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
41
|
|
8
|
1
|
|
|
1
|
|
746
|
use Finance::Symbology::Convention::Fidessa; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
36
|
|
9
|
1
|
|
|
1
|
|
692
|
use Finance::Symbology::Convention::NASDAQ::Integrated; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
66
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
BEGIN { |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
866
|
our $VERSION = 0.4; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub new { |
19
|
1
|
|
|
1
|
0
|
47
|
my ($class, $info) = @_; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $self = { |
22
|
|
|
|
|
|
|
Check => { |
23
|
11
|
|
|
11
|
|
14
|
CQS => sub { my $x = shift; return Finance::Symbology::Convention::CQS->check($x); }, |
|
11
|
|
|
|
|
50
|
|
24
|
7
|
|
|
7
|
|
9
|
CMS => sub { my $x = shift; return Finance::Symbology::Convention::CMS->check($x); }, |
|
7
|
|
|
|
|
34
|
|
25
|
7
|
|
|
7
|
|
12
|
FIDESSA => sub { my $x = shift; return Finance::Symbology::Convention::Fidessa->check($x); }, |
|
7
|
|
|
|
|
33
|
|
26
|
7
|
|
|
7
|
|
11
|
NASINTEGRATED => sub { my $x = shift; return Finance::Symbology::Convention::NASDAQ::Integrated->check($x); } |
|
7
|
|
|
|
|
31
|
|
27
|
|
|
|
|
|
|
}, |
28
|
|
|
|
|
|
|
Convert => { |
29
|
3
|
|
|
3
|
|
6
|
CQS => sub { my $x = shift; return Finance::Symbology::Convention::CQS->convert($x); }, |
|
3
|
|
|
|
|
14
|
|
30
|
7
|
|
|
7
|
|
10
|
CMS => sub { my $x = shift; return Finance::Symbology::Convention::CMS->convert($x); }, |
|
7
|
|
|
|
|
30
|
|
31
|
3
|
|
|
3
|
|
6
|
FIDESSA => sub { my $x = shift; return Finance::Symbology::Convention::Fidessa->convert($x); }, |
|
3
|
|
|
|
|
14
|
|
32
|
3
|
|
|
3
|
|
6
|
NASINTEGRATED => sub { my $x = shift; return Finance::Symbology::Convention::NASDAQ::Integrated->convert($x); } |
|
3
|
|
|
|
|
14
|
|
33
|
|
|
|
|
|
|
} |
34
|
1
|
|
|
|
|
38
|
}; |
35
|
|
|
|
|
|
|
|
36
|
1
|
|
|
|
|
4
|
bless ($self, $class); |
37
|
1
|
|
|
|
|
10
|
return $self; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub what { |
41
|
4
|
|
|
4
|
1
|
1659
|
my ($self, $symbol) = @_; |
42
|
|
|
|
|
|
|
|
43
|
4
|
|
|
|
|
7
|
my $returnObj; |
44
|
|
|
|
|
|
|
|
45
|
4
|
|
|
|
|
14
|
$returnObj->{CQS} = $self->{Check}{CQS}->($symbol); |
46
|
4
|
100
|
|
|
|
18
|
delete $returnObj->{CQS} unless defined $returnObj->{CQS}; |
47
|
|
|
|
|
|
|
|
48
|
4
|
|
|
|
|
14
|
$returnObj->{CMS} = $self->{Check}{CMS}->($symbol); |
49
|
4
|
100
|
|
|
|
16
|
delete $returnObj->{CMS} unless defined $returnObj->{CMS}; |
50
|
|
|
|
|
|
|
|
51
|
4
|
|
|
|
|
14
|
$returnObj->{FIDESSA} = $self->{Check}{FIDESSA}->($symbol); |
52
|
4
|
100
|
|
|
|
16
|
delete $returnObj->{FIDESSA} unless defined $returnObj->{FIDESSA}; |
53
|
|
|
|
|
|
|
|
54
|
4
|
|
|
|
|
12
|
$returnObj->{NASINTEGRATED} = $self->{Check}{NASINTEGRATED}->($symbol); |
55
|
4
|
100
|
|
|
|
18
|
delete $returnObj->{NASINTEGRATED} unless defined $returnObj->{NASINTEGRATED}; |
56
|
|
|
|
|
|
|
|
57
|
4
|
|
|
|
|
13
|
return $returnObj; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub convert { |
61
|
13
|
|
|
13
|
1
|
5574
|
my ($self, $symbols, $from, $to) = @_; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
13
|
100
|
|
|
|
34
|
if (ref $symbols eq 'ARRAY') { |
65
|
1
|
|
|
|
|
2
|
my @convertedsymbols; |
66
|
1
|
|
|
|
|
3
|
for my $symbol (@{$symbols}){ |
|
1
|
|
|
|
|
3
|
|
67
|
4
|
50
|
|
|
|
18
|
if ($symbol =~ m/^[A-Z]+$/) { |
68
|
0
|
|
|
|
|
0
|
push @convertedsymbols, $symbol; |
69
|
|
|
|
|
|
|
} else { |
70
|
4
|
|
|
|
|
13
|
my $fromobj = $self->{Check}{uc($from)}->($symbol); |
71
|
4
|
50
|
|
|
|
17
|
return "Invalid format for $from \($symbol\)" unless defined $fromobj; |
72
|
4
|
|
|
|
|
13
|
my $toobj = $self->{Convert}{uc($to)}->($fromobj); |
73
|
4
|
|
|
|
|
14
|
push @convertedsymbols, $toobj; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} |
76
|
1
|
|
|
|
|
6
|
return @convertedsymbols; |
77
|
|
|
|
|
|
|
} else { |
78
|
12
|
50
|
|
|
|
47
|
if ($symbols =~ m/^[A-Z]+$/) { |
79
|
0
|
|
|
|
|
0
|
return $symbols; |
80
|
|
|
|
|
|
|
} else { |
81
|
12
|
|
|
|
|
38
|
my $fromobj = $self->{Check}{uc($from)}->($symbols); |
82
|
12
|
50
|
|
|
|
47
|
return "Invalid format for $from \($symbols\)" unless defined $fromobj; |
83
|
12
|
|
|
|
|
39
|
my $toobj = $self->{Convert}{uc($to)}->($fromobj); |
84
|
12
|
|
|
|
|
53
|
return $toobj; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=pod |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 NAME |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Finance::Symbology - Common US Stock market convention swapper / tester |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 SYNOPSIS |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
use Finance::Symbology; |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
my $converter = Finance::Symbology->new(); |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
my $symbols = [ 'AAPL WI', 'C PR', 'TEST A' ]; |
108
|
|
|
|
|
|
|
my $symbol = 'TEST A'; |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
# Valid convention options CMS, CQS, NASINTEGRATED, Fidessa |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
my $converted_symbols = $converter->convert($symbols, 'CMS', 'CQS' ); |
113
|
|
|
|
|
|
|
my $converted_symbol = $converter->convert($symbol, 'CMS', 'CQS' ); |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
my $what_is = $converter->what($symbol); |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 DESCRIPTION |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Finance::Symbology is a module that can convert valid symbol syntaxes across |
121
|
|
|
|
|
|
|
popular formats from the US Domestic markets. Converter can also test symbols |
122
|
|
|
|
|
|
|
to provide information about it, such as type, class, and underyling symbol |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 USAGE |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head2 convert(symbol(s), FROM, TO) |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Converts a symbol from a convetion to another convention also works with lists |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Example: |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
$converter->convert('AAPL PR', 'CMS', 'CQS'); |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
output: AAPLp |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
$converter->convert(['AAPL PR', 'C PRA'], 'CMS', 'CQS'); |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
output: ['AAPLp', 'CpA']; |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head2 what(symbol) |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Tests a symbol of any convention and breaks down its convention if valid |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Example: |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
$converter->what('AAPLp'); |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
output: |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
'CQS' => { |
153
|
|
|
|
|
|
|
'symbol' => 'AAPL', |
154
|
|
|
|
|
|
|
'suffix' => 'p', |
155
|
|
|
|
|
|
|
'type' => 'Preferred' |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head1 Author |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
George Tsafas |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 Support |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
elb0w on irc.freenode.net #perl |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=cut |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
__END__ |