line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Finance::Quote::Oslobors; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
2509
|
use strict; |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
202
|
|
4
|
5
|
|
|
5
|
|
33
|
use JSON qw( decode_json ); |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
27
|
|
5
|
5
|
|
|
5
|
|
480
|
use HTTP::Request::Common; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
386
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '1.58_01'; # TRIAL VERSION |
8
|
|
|
|
|
|
|
|
9
|
5
|
|
|
5
|
|
31
|
use vars qw( $OSLOBORS_COMPONENTS_URL ); |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
2130
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
$OSLOBORS_COMPONENTS_URL = "https://www.oslobors.no/ob/servlets/components?type=table&source=feed.omff.FUNDS&view=REALTIME&columns=ITEM%2C+PRICECHANGEPCT%2C+PRICE%2C+DATE%2C+QUOTATIONCURRENCY&filter=ITEM_SECTOR%3D%3Ds"; |
12
|
|
|
|
|
|
|
|
13
|
5
|
|
|
5
|
0
|
22
|
sub methods { return (oslobors => \&oslobors); } |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
{ |
16
|
|
|
|
|
|
|
my @labels = qw/date isodate method source currency price p_change/; |
17
|
5
|
|
|
5
|
0
|
15
|
sub labels { return (oslobors => \@labels); } |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub oslobors { |
21
|
0
|
|
|
0
|
0
|
|
my $quoter = shift; |
22
|
0
|
|
|
|
|
|
my @symbols = @_; |
23
|
0
|
|
|
|
|
|
my %funds; |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
my $ua = $quoter->user_agent; |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
my ($url, $reply, $data); |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
foreach my $symbol (@symbols) { |
30
|
0
|
|
|
|
|
|
$url = $OSLOBORS_COMPONENTS_URL . $symbol; |
31
|
0
|
|
|
|
|
|
$reply = $ua->request(GET $url); |
32
|
0
|
0
|
|
|
|
|
unless($reply->is_success) { |
33
|
0
|
|
|
|
|
|
$funds{$symbol, "success"} = 0; |
34
|
0
|
|
|
|
|
|
$funds{$symbol, "errormsg"} = "HTTP request failed"; |
35
|
|
|
|
|
|
|
} else { |
36
|
0
|
|
|
|
|
|
$data = JSON::decode_json($reply->content)->{"rows"}[0]{"values"}; |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
$quoter->store_date(\%funds, $symbol, { isodate => sprintf("%s-%s-%s", $data->{"DATE"} =~ /(\d\d\d\d)(\d\d)(\d\d)/)}); |
39
|
0
|
|
|
|
|
|
$funds{$symbol, 'method'} = 'oslobors'; |
40
|
0
|
|
|
|
|
|
$funds{$symbol, 'currency'} = $data->{"QUOTATIONCURRENCY"}; |
41
|
0
|
|
|
|
|
|
$funds{$symbol, 'success' } = 1; |
42
|
0
|
|
|
|
|
|
$funds{$symbol, 'price' } = $data->{"PRICE"}; |
43
|
0
|
|
|
|
|
|
$funds{$symbol, 'source' } = 'Finance::Quote::Oslobors'; |
44
|
0
|
|
|
|
|
|
$funds{$symbol, 'symbol' } = $symbol; |
45
|
0
|
|
|
|
|
|
$funds{$symbol, 'p_change'} = $data->{"PRICECHANGEPCT"}; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
0
|
0
|
|
|
|
|
return wantarray() ? %funds : \%funds; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 NAME |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Finance::Quote::Oslobors - Obtain fund quotes from Oslo stock exchange |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 SYNOPSIS |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
use Finance::Quote; |
61
|
|
|
|
|
|
|
$q = Finance::Quote->new; |
62
|
|
|
|
|
|
|
%fundinfo = $q->fetch("oslobors","FUND-TICKER.OSE"); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 DESCRIPTION |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
This module obtains information about mutual fund prices from |
67
|
|
|
|
|
|
|
www.oslobors.no. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 FUND TICKER SYMBOLS |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
The fund ticker symbols can be found by searching for the fund, |
72
|
|
|
|
|
|
|
and visit its page. The symbol will be visible in the URL, for |
73
|
|
|
|
|
|
|
instance OD-HORIA.OSE. The .OSE part is necessary. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
The package does not understand Oslo stock symbols. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 LABELS RETURNED |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
The module returns date, method, source, currency, price and p_change. |
80
|
|
|
|
|
|
|
The prices are updated on bank days. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 SEE ALSO |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Finance::Quote |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |