Skip Menu |

This queue is for tickets about the Finance-Quote CPAN distribution.

Report information
The Basics
Id: 124978
Status: new
Priority: 0/
Queue: Finance-Quote

People
Owner: Nobody in particular
Requestors: diego.marcolungo [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: New module for morningstar.it
From: diego.marcolungo [...] gmail.com
Hi, I use KMyMoney for may personal finance and F::Q for updating prices of my mutual funds. I receive data from http://www.morningstar.it/ I wrote a module for that site. I am happy to share it - Diego Marcolungo
Subject: MorningstarIT.pm
#!/usr/bin/perl package Finance::Quote::MorningstarIT; require 5.005; use warnings; use strict; use HTTP::Request::Common; use HTML::TableExtract; use feature 'say'; use vars qw{ $MORNINGSTAR_IT_FUNDS_URL }; $MORNINGSTAR_IT_FUNDS_URL = "http://www.morningstar.it/it/funds/snapshot/snapshot.aspx?id="; sub methods { return ( morningstarit => \&morningstarit ); } { my @labels = qw/name isin date isodate nav last currency p_change cap source method type/; sub labels { return (morningstar => \@labels); } } sub morningstarit { my $quoter = shift; my @symbols = @_; # my $te = HTML::TableExtract->new( headers => [qw(Sintesi)], gridmap => 1 ); my $te = HTML::TableExtract->new( depth => 0, count => 6 ); my $teName = HTML::TableExtract->new( depth => 0, count => 3 ); my %info; foreach my $symbol (@symbols) { my $url = $MORNINGSTAR_IT_FUNDS_URL . $symbol; my $reply = $quoter->user_agent->request(GET $url); unless ($reply->is_success) { $info{ $symbol, "success" } = 0; $info{ $symbol, "errmsg" } = join ' ', $reply->code, $reply->message; } else { $te->parse($reply->decoded_content); #~ say $te->tables_report([1]); my $sintesi_table = $te->table(0, 6); my $nav_row = $sintesi_table->row(1); my @date = split /\n/, @$nav_row[0]; my @currency_value = split /\240/, @$nav_row[2]; $info{ $symbol, "last" } = $currency_value[1]; $info{ $symbol, "nav" } = $currency_value[1]; $info{ $symbol, "currency" } = $currency_value[0]; $quoter->store_date(\%info, $symbol, {eurodate => $date[1]} ); my $pchange_row = $sintesi_table->row(2); $info{ $symbol, "p_change" } = @$pchange_row[2]; my $isin_row = $sintesi_table->row(5); $info{ $symbol, 'isin' } = @$isin_row[2]; my $share_class_size_row = $sintesi_table->row(7); my @share_class_size = split /\240/, @$share_class_size_row[2]; $info{ $symbol, 'cap' } = $share_class_size[1]; $teName->parse($reply->decoded_content); my $name_row = $teName->table(0, 3)->row(0); $info{ $symbol, 'name' } = @$name_row[0]; $info{ $symbol, 'source' } = 'Finance::Quote::MorningstarIT'; $info{ $symbol, 'method' } = 'morningstar_it_funds'; $info{ $symbol, "type" } = "fund"; $info{ $symbol, "success" } = 1; } } return wantarray ? %info : \%info; } 1;