Skip Menu |

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

Report information
The Basics
Id: 48228
Status: open
Priority: 0/
Queue: Finance-Quote

People
Owner: eco [...] ecocode.net
Requestors: nagy.attila.gabor [...] gmail.com
Cc:
AdminCc:

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



Subject: Proposed new module: bamosz
I'd like to propose this module to get included in Finance::Quote. I wrote it a few years ago, and using it since then on daily basis, updated to work with 1.16. This modules makes it possible to get daily quotes for every fund sold in Hungary. Data is acquired from Bamosz (Association of Hungarian Investment Fund and Asset Management Companies).
Subject: Bamosz.pm
#!/usr/bin/perl -w package Finance::Quote::Bamosz; require 5.005; use strict; use LWP::UserAgent; use HTML::TableExtract; use HTTP::Request::Common; use vars qw/$VERSION $BAMOSZ_FUNDS_URL/; $VERSION = '1.00'; $BAMOSZ_FUNDS_URL = "http://bamosz.econet.hu/index1.php"; sub methods { return ( bamosz => \&bamosz, europe => \&bamosz); } { my @labels = qw /name date nav method/; sub labels { return (bamosz => \@labels, europe => \@labels); } } sub bamosz { my $quoter = shift; my @funds = @_; return unless @funds; my $ua = $quoter->user_agent; my %info; my $response = $ua->request(GET $BAMOSZ_FUNDS_URL); if ($response->is_success) { #my $te = new HTML::TableExtract( headers => [qw/Alap "Nettó eszközérték" Dátum Árfolyam "Hozam<br>3 hó" "Hozam<br>6 hó" "Hozam<br>12" hó/]); my $te = new HTML::TableExtract( headers => [qw/Alap Dátum Árfolyam/]); $te->parse($response->content); my %found_funds; foreach my $ts ($te->table_states) { foreach my $row ($ts->rows) { my $name = $$row[0]; $name = _translate_name($name); $found_funds{$name, "name"} = $$row[0]; $found_funds{$name, "nav"} = $$row[2]; $found_funds{$name, "date"} = $$row[1]; } } foreach my $fund (@funds) { my $fund_id = _translate_name($fund); if (defined ($found_funds{$fund_id, "name"})) { my $name = $found_funds{$fund_id, "name"}; my $nav = $found_funds{$fund_id, "nav"}; my $date = $found_funds{$fund_id, "date"}; # Leave only digits and comma in the prize field $nav =~ s/[^\d,]//g; $nav =~ tr/,/./; # Convert date into US format mm/dd/year $date =~ /(\d{4})\.(\d{2})\.(\d{2})/; $date = $2."/".$3."/".$1; # Strip leading and trailing whitespace from name $name =~ s/^\s*(.*?)\s*$/$1/; $info{$fund, "symbol"} = $fund_id; $info{$fund, "name"} = $name; $info{$fund, "nav"} = $nav; $info{$fund, "date"} = $date; $info{$fund, "currency"} = "HUF"; $info{$fund, "method"} = "bamosz"; $info{$fund, "success"} = 1; } else { $info{$fund, "success"} = 0; $info{$fund, "errormsg"} = "Not found"; } } } else { foreach my $fund (@funds) { $info{$fund, "success"} = 0; $info{$fund, "errormsg"} = "HTTP error"; } } return wantarray() ? %info : \%info; } sub _translate_name { my $name = shift; $name =~ tr/áíûõüöúóéÁÍÛÕÜÖÚÓÉ/aiuououoeaiuououoe/; $name =~ tr/a-z/A-Z/; $name =~ s/[^\w\d]//g; return $name; } 1; =head1 NAME Finance::Quote::Bamosz - Obtain hungarian fund prices from bamosz.econet.hu =head1 SYNOPSYS use Finance::Quote; $q = Finance::Quote->new; %stockinfo = $q->fetch("bamosz","BUDAPEST I"); =head1 DESCRIPTION This modul obtains information from the Association of Fund Management Companies in Hungay (BAMOSZ) http://bamosz.econet.hu. Information returned by this module is governed by BAMOSZ's terms and conditions. =head1 LABELS RETURNED The following labels are returned by Finance::Quote::Bamosz: name, symbol, date, price, nav =head1 NOTE Since there aren't any common symbols for these funds, as symbol the modul returns the translated name of the fund. All whitespaces, and non word or non digit caracters are removed, and special hungarian characters are translated to them ascii pairs. For example, the symbol of the fund named "K&H Aranykosár" will be "KHARANYKOSAR". When retrieving information trough fetch, one could use both formats or anything else, that could be translated to the same value as used on the website. =head1 SEE ALSO BAMOSZ http://www.bamosz.hu, http://bamosz.econet.hu =cut
Hi ! Thank you for your submission! Would you mind submitting a test file also ? Only modules with tests do hit CPAN releases ;) Also, please send me your exact name ( Then you'll be included in the hall of fame ;) ) Tell me if you need some help... regards -- Erik
Subject: Re: [rt.cpan.org #48228] Proposed new module: bamosz
Date: Mon, 27 Jul 2009 15:57:02 +0200
To: bug-Finance-Quote [...] rt.cpan.org
From: Attila Nagy <nagy.attila.gabor [...] gmail.com>
On Mon, Jul 27, 2009 at 3:54 PM, Erik Colson via RT<bug-Finance-Quote@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=48228 > > > Thank you for your submission! > Would you mind submitting a test file also ? Only modules with tests do > hit CPAN releases ;)
Ok, could you give me some example of the required test files? In a few days I'll put one together then. Show quoted text
> Also, please send me your exact name ( Then you'll be included in the > hall of fame ;) )
It's Nagy Attila Gábor :) -- Nagy Attila Gabor
Subject: Re: [rt.cpan.org #48228] Proposed new module: bamosz
Date: Thu, 30 Jul 2009 08:21:58 +0200
To: Nagy Attila Gábor via RT <bug-Finance-Quote [...] rt.cpan.org>
From: Erik Colson <eco [...] ecocode.net>
Hi Nagy! On Mon, Jul 27, 2009 at 09:57:22AM -0400, Nagy Attila Gábor via RT wrote: Show quoted text
> Ok, could you give me some example of the required test files? In a > few days I'll put one together then.
You can take a look at the t/ directory in the repo. There's one test file for each module. The results of the master development branch tests is located here: http://www.ecocode.net/files/fq/fq-testreport.html Show quoted text
> > Also, please send me your exact name ( Then you'll be included in the > > hall of fame ;) )
> > It's Nagy Attila Gábor
Ok, I'll add it in the code Thank you for your work! -- erik