ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  FinanceChart convertDailyToQuarterlyData() method
Posted by s2s on Apr-15-2011 13:11
Hi ASE Chart Support,

We have been using ChartDirector (Perl version) for quite a while, we are recently working
on a Financ Chart project which requires calculation for quarterly data. ChartDirector does
not provide a method something like convertDailyToQuarterlyData().

Our data source is daily data, the convertDailyToWeeklyData(),
convertDailyToMonthlyData() and convertDailyToYearlyData() methods work perfectly but
how can we aggregate data quarterly?

Is there any workaround? Can you advice?

Thanks.

  Re: FinanceChart convertDailyToQuarterlyData() method
Posted by Peter Kwan on Apr-15-2011 17:37
Hi s2s,

Actually, the convertDailyToWeeklyData, convertDailyToMonthlyData and convertDailyToYearlyData are not part of ChartDirector, but are part of the sample code that demonstrates how to use ChartDirector. You may freely modify the sample code to fit your own needs.

For the conversion to quarterly data, I have just written the following code:

sub convertDailyToQuarterlyData
{
    #get monthly delimiters
    my $delimiters = new ArrayMath($timeStamps)->selectStartOfMonth()->result();

    #remove all delimiters that are not at Jan, Apr, Jul, Oct
    for (my $i = 0; $i < scalar(@$delimiters); ++$i) {
         if ($delimiters->[$i] != $perlchartdir::NoValue) {
             if ((int(perlchartdir::getChartYMD($delimiters->[$i]) / 100) % 100) % 3 != 1) {
                 $delimiters->[$i] = $perlchartdir::NoValue;
             }
         }
    }

    #now aggregate based on the quarterly delimiters
    aggregateData(new ArrayMath($delimiters));
}

Hope this can help.

Regards
Peter Kwan