Simple stock quote grabbing with Perl

Hackszine reader 3riador wrote in to recommend a quick and easy way to grab stock quotes using Perl and the Finance::Quote CPAN module. The codebase is actively maintained and has been around for some time, having first been distributed as part of GNUCash before becoming its own project.

Paul Fenwick, one of the GNUCash developers, had this to say in an article for The Perl Journal in 2000:

If you have a reason to watch the world’s financial markets, and you know a little about perl, then you may find that the Finance::Quote package comes in handy. I personally use it to remind myself that I should never buy shares, as I have a good history of losing money on the stock exchange. However, you can use Finance::Quote to help track those tasty stock options you’ve been offered, or even to help you build dynamic artwork driven by fluctuations in the world markets.

Near as I can tell, the dynamic artwork that’s referred to is the Stock Puppets presentation which was shown at 2000s Burning Man event (can anyone confirm this?). The idea was to have large marionettes controlled directly by stock market data, some servos, Basic Stamp microcontrollers, and IBM Thinkpads pulling market data using the Finance::Quote library.

To use Finance::Quote in your own projects is a simple task. Here’s a few lines of code that will print the current price of Google shares:

#!/usr/bin/perl -w

use strict;
use Finance::Quote;

my $q = Finance::Quote->new();
my %data = $q->fetch(‘usa’, ‘GOOG’);
print $data{‘GOOG’, ‘price’} . ”
“;

The Dabbler Blog has more information on installation and basic usage, and The Perl Journal article is a good resource for those wishing to delve any deeper.

Finance::Quote Perl Library
Dabbler Blog – Fast and Simple Stock Quotes Using Perl
Finance::Quote Article In The Perl Journal
Stock Puppets

Comments are closed.

Discuss this article with the rest of the community on our Discord server!

ADVERTISEMENT

Maker Faire Bay Area 2023 - Mare Island, CA

Escape to an island of imagination + innovation as Maker Faire Bay Area returns for its 15th iteration!

Buy Tickets today! SAVE 15% and lock-in your preferred date(s).

FEEDBACK