use strict;
use warnings;
my $symbol;
my $series;
my $open;
my $high;
my $low;
my $close;
my $last;
my $prevclose;
my $tottrdqty;
my $tottrdval;
my $timestamp;
my @files;
my $file;
my $broker = Win32::OLE->new('Broker.Application');
$broker->LoadDatabase( "D:\\AmiBroker\\EOD" );
chdir "E:\\NSEdata\\raw";
@files=<cm06NOV2012*.csv>;
foreach $file(@files)
{
print "Procesing file $file\n";
open(IFILE,"<",$file);
while (<IFILE>)
{
($symbol,$series,$open,$high,$low,$close,$last,$prevclose,$tottrdqty,$tottrdval,$timestamp) = split(',',$_);
if ($series eq "EQ")
{
print "Symbol $symbol with series $series found...\n";
my $stock = $broker->stocks->add($symbol) or die "Adding stock errored out";
my $quote = $stock->quotations->add($timestamp) or die "Adding quote errored out";
$quote->{open} = $open;
$quote->{high} = $high;
$quote->{low} = $low;
$quote->{close} = $close;
$quote->{volume} = $tottrdqty;
$quote->{aux1} = $last;
$quote->{aux2} = $prevclose;
}
}
close IFILE;
$broker->SaveDatabase;
}
$broker->Quit;