Skip to content

Instantly share code, notes, and snippets.

@keedi
Last active December 23, 2015 23:29
Show Gist options
  • Save keedi/6710221 to your computer and use it in GitHub Desktop.
Save keedi/6710221 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
#
# http://cafe.naver.com/perlstudy/2148
#
use v5.14;
use utf8;
use strict;
use warnings;
use Finance::QuoteHist::Yahoo;
local $| = 1;
die "Usage: $0 <stock file>\n" unless @ARGV == 1;
my $file = shift;
open my $fh, $file or die "cannot open $file file: $!\n";
while ( my $stock = <$fh> ) {
chomp $stock;
my $q = Finance::QuoteHist::Yahoo->new(
symbols => $stock,
start_date => '01/01/1960',
end_date => 'today',
);
for my $row ( $q->quotes ) {
my ( $symbol, $date, $open, $high, $low, $close, $volume, $adj ) = @$row;
say "$date $open $high $low $close $volume $adj";
}
}
close $fh;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment