[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] OFF TOPIC - PERL help requested



PureBytes Links

Trading Reference Links

Hello

I have downloaded the following script from xmlworks.com. The purpose of this scrip is to convert Intraday data exported from AB(using AFL code provided by Graham ) into a pseudo EOD format for use elsewhere(TA programs that do not support IntraDay format).


//////////==========//////////
use strict;
my $infile = shift;
my $outfile = shift;
my $ticker = shift;
open (IN,$infile) || die "Open IN failed $!";
open (OUT,">$outfile") || die "Open OUT failed $!";
my $month = 1;
my $day = 1;
my $year = 1900;
my ($date,$time,$open,$high,$low,$close,$vol);
while (<IN>) {
    chomp;
    ($ticker,$date,$time,$open,$high,$low,$close,$vol) = split /,/;
    if ($month == 2 && $day > 28) {
        $month = 3;
        $day = 1;
    }
    $month = '0' . $month if length("$month") < 2;
    $day = '0' . $day if length("$day") < 2;
    $year = '0' . $year if length("$year") < 2;
    $date = "$year$month$day";
    print OUT "$ticker,$date,$open,$high,$low,$close,$vol\n";
    $day += 1;
    if ($day == 31) {
        $month += 1;
        $day = 1;
        if ($month == 13) {
            $year += 1;
            $month =1;
        }
    }
}
close IN;
close OUT;
__END__

//////////==========//////////

The problem I am encountering is visible by seeing the data from a file converted using the above script.

TICKER,19000101,Open,High,Low,Close,Volume
3IINFOTECH,19000102,137.6000,138.0000,137.6000,138.0000,136234
3IINFOTECH,19000103,137.5000,137.6000,137.1500,137.1500,40269

The heading row contains a date instead of the heading "date". The date that should have been inserted in the first row of price data has been instead inserted where the heading "date" should have been.

I will be very very grateful if someone can kindly spare some time and help me out with this problem.

Regards


Rakesh

__._,_.___

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html




Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___