[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GT] SVN Commit r599 - trunk/Scripts
Author: thomas
Date: 2008-04-14 02:02:32 +0200 (Mon, 14 Apr 2008)
New Revision: 599
Modified:
trunk/Scripts/backtest.pl
trunk/Scripts/backtest_many.pl
trunk/Scripts/backtest_multi.pl
trunk/Scripts/display_indicator.pl
trunk/Scripts/display_signal.pl
trunk/Scripts/graphic.pl
trunk/Scripts/scan.pl
Log:
Change all scripts to use consistent options for periods.
Modified: trunk/Scripts/backtest.pl
===================================================================
--- trunk/Scripts/backtest.pl 2008-04-07 23:48:45 UTC (rev 598)
+++ trunk/Scripts/backtest.pl 2008-04-14 00:02:32 UTC (rev 599)
@@ -7,7 +7,6 @@
use lib '..';
use strict;
-use vars qw($db);
use GT::Prices;
use GT::Portfolio;
@@ -30,17 +29,19 @@
=head1 ./backtest.pl [ options ] <code>
-=head1 ./backtest.pl <system_alias> <code>
+=head1 ./backtest.pl [ options ] <system_alias> <code>
=head2 Description
Backtest will run a backtest of the system called systemname
(available as GT::Systems::<systemname>) on share of indicated code.
-You can either describe the full system with all the options, or you can
-give an alias of a system. The alias is set your configuration file with
-entries like "Aliases::<alias_name> <full_system_name>". The full
-system name is like "SY:TFS|CS:SY:TFS|CS:Stop:Fixed 4|MM:VAR".
+You can either describe the system using options, give a full system
+name or you can give a system alias. An alias is set in the
+configuration file with entries of the form
+ Aliases::<alias_name> <full_system_name>.
+An example of a full system name is
+ SY:TFS|CS:SY:TFS|CS:Stop:Fixed 4|MM:VAR.
=head2 Options
@@ -49,10 +50,65 @@
=over 4
-=item --full
+=item --full, --start=<date>, --end=<date>, --nb-item=<nr>
-Runs the backtest on the full history (it runs on two years by default)
+Determines the time interval over which to perform the backtest. In detail:
+=over
+
+=item --start=2001-1-10, --end=2002-11-17
+
+The start and end dates over which to perform the backtest.
+The date needs to be in the
+format configured in ~/.gt/options and must match the timeframe selected.
+
+=item --nb-items=100
+
+The number of periods to use in the analysis.
+
+=item --full
+
+Consider all available periods.
+
+=back
+
+The periods considered are relative to the selected time frame (i.e., if timeframe
+is "day", these indicate a date; if timeframe is "week", these indicate a week;
+etc.). In GT format, use "YYYY-MM-DD" or "YYYY-MM-DD hh:mm:ss" for days (the
+latter giving intraday data), "YYYY-WW" for weeks, "YYYY/MM" for months, and
+"YYYY" for years.
+
+The interval of periods examined is determined as follows:
+
+=over
+
+=item 1 if present, use --start and --end (otherwise default to last price)
+
+=item 1 use --nb-item (from first or last, whichever has been determined),
+if present
+
+=item 1 if --full is present, use first or last price, whichever has not yet been determined
+
+=item 1 otherwise, consider a two year interval.
+
+=back
+
+The first period determined following this procedure is chosen. If additional
+options are given, these are ignored (e.g., if --start, --end, --full are given,
+--full is ignored).
+
+=item --timeframe=1min|5min|10min|15min|30min|hour|3hour|day|week|month|year
+
+The timeframe can be any of the available modules in GT/DateTime.
+
+=item --max-loaded-items
+
+Determines the number of periods (back from the last period) that are loaded
+for a given market from the data base. Care should be taken to ensure that
+these are consistent with the performed analysis. If not enough data is
+loaded to satisfy dependencies, for example, correct results cannot be obtained.
+This option is effective only for certain data base modules and ignored otherwise.
+
=item --template="backtest.mpl"
Output is generated using the indicated HTML::Mason component.
@@ -80,14 +136,15 @@
Store the resulting portfolio in the indicated file.
-=item --timeframe="day|week|month|year"
-
-Launch the system while using the indicated timeframe.
-
=item --system="<system_name>"
use the GT::Systems::<system_name> as the source of buy/sell orders.
+=item --broker="NoCosts"
+
+Calculate commissions and annual account charge, if applicable, using
+GT::Brokers::<broker_name> as broker.
+
=item --money-management="<money_management_name>"
use the GT::MoneyManagement::<money_management_name> as money management system.
@@ -104,6 +161,8 @@
use GT::CloseStrategy::<close_strategy_name> as a close strategy.
+=item --verbose
+
=back
=head2 Examples
@@ -127,16 +186,21 @@
=cut
# Manage options
-my ($full, $verbose, $html, $display_trades, $template, $graph_file, $ofname, $broker, $system, $timeframe, $start, $end, $store_file) =
- (0, 0, 0, 0, '', '', '', '', '', 'day', '', '', '');
+my ($full, $nb_item, $start, $end, $timeframe, $max_loaded_items) =
+ (0, 0, '', '', 'day', -1);
+my ($verbose, $html, $display_trades, $template, $graph_file, $ofname, $broker, $system, $store_file) =
+ (0, 0, 0, '', '', '', '', '', '');
my (@mmname, @tfname, @csname);
-GetOptions('full!' => \$full, 'verbose!' => \$verbose, 'html!' => \$html,
+GetOptions('full!' => \$full, 'nb-item=i' => \$nb_item,
+ "start=s" => \$start, "end=s" => \$end,
+ "max-loaded-items" => \$max_loaded_items,
+ "timeframe=s" => \$timeframe,
+ 'verbose!' => \$verbose, 'html!' => \$html,
'template=s' => \$template, 'display-trades!' => \$display_trades,
'money-management=s' => \
AT
mmname, 'graph=s' => \$graph_file,
'trade-filter=s' => \
AT
tfname, 'order-factory=s' => \$ofname,
'close-strategy=s' => \
AT
csname, 'broker=s' => \$broker,
- 'system=s' => \$system, "timeframe=s" => \$timeframe,
- 'start=s' => \$start, 'end=s' => \$end, "store=s" => \$store_file);
+ 'system=s' => \$system, "store=s" => \$store_file);
if (! scalar(@mmname))
{
@@ -147,7 +211,6 @@
}
# Create the entire framework
-my $db = create_db_object();
my $pf_manager = GT::PortfolioManager->new;
my $sys_manager = GT::SystemManager->new;
@@ -204,7 +267,7 @@
$timeframe = GT::DateTime::name_to_timeframe($timeframe);
-my ($calc, $first, $last) = find_calculator($code, $timeframe, $full, $start, $end);
+my ($calc, $first, $last) = find_calculator($code, $timeframe, $full, $start, $end, $nb_item, $max_loaded_items);
# The real work happens here
my $analysis = backtest_single($pf_manager, $sys_manager, $broker, $calc, $first, $last);
Modified: trunk/Scripts/backtest_many.pl
===================================================================
--- trunk/Scripts/backtest_many.pl 2008-04-07 23:48:45 UTC (rev 598)
+++ trunk/Scripts/backtest_many.pl 2008-04-14 00:02:32 UTC (rev 599)
@@ -7,7 +7,6 @@
use lib '..';
use strict;
-use vars qw($db);
use GT::Prices;
use GT::Portfolio;
@@ -20,7 +19,7 @@
use GT::Eval;
use GT::Conf;
use GT::DateTime;
-use GT::Tools qw(:conf);
+use GT::Tools qw(:conf :timeframe);
use Getopt::Long;
GT::Conf::load();
@@ -32,10 +31,14 @@
Backtest_many will test all system listed in a system
file on all the values listed in the market file.
-The "system file" does have a special format.
+The <system file> has a special format.
+System definitions:
+
System::ADX 30 | TradeFilters::Trend 2 5 | MoneyManagement::Normal
+Abbreviations:
+
Systems = S
CloseStrategy = CS
TradeFilters = TF
@@ -46,14 +49,64 @@
=over 4
+=item --full, --start=<date>, --end=<date>, --nb-item=<nr>
+
+Determines the time interval to consider for analysis. In detail:
+
+=over
+
+=item --start=2001-1-10, --end=2002-11-17
+
+The start and end dates considered for analysis. The date needs to be in the
+format configured in ~/.gt/options and must match the timeframe selected.
+
+=item --nb-items=100
+
+The number of periods to use in the analysis.
+
=item --full
-Runs the backtest on the full history (it runs on two years by default)
+Consider all available periods.
-=item --timeframe="day|week|month|year"
+=back
-Runs the backtest using the given timeframe.
+The periods considered are relative to the selected time frame (i.e., if timeframe
+is "day", these indicate a date; if timeframe is "week", these indicate a week;
+etc.). In GT format, use "YYYY-MM-DD" or "YYYY-MM-DD hh:mm:ss" for days (the
+latter giving intraday data), "YYYY-WW" for weeks, "YYYY/MM" for months, and
+"YYYY" for years.
+The interval of periods examined is determined as follows:
+
+=over
+
+=item 1 if present, use --start and --end (otherwise default to last price)
+
+=item 1 use --nb-item (from first or last, whichever has been determined),
+if present
+
+=item 1 if --full is present, use first or last price, whichever has not yet been determined
+
+=item 1 otherwise, consider a two year interval.
+
+=back
+
+The first period determined following this procedure is chosen. If additional
+options are given, these are ignored (e.g., if --start, --end, --full are given,
+--full is ignored).
+
+=item --timeframe=1min|5min|10min|15min|30min|hour|3hour|day|week|month|year
+
+The timeframe can be any of the available modules in GT/DateTime.
+
+=item --max-loaded-items
+
+Determines the number of periods (back from the last period) that are loaded
+for a given market from the data base. Care should be taken to ensure that
+these are consistent with the performed analysis. If not enough data is
+loaded to satisfy dependencies, for example, correct results cannot be obtained.
+This option is effective only for certain data base modules and ignored otherwise.
+
=item --nbprocess=2
If you want to start two (or more) backtests in parallel (useful for machines with several CPUs for example).
@@ -80,14 +133,19 @@
=cut
# Manage options
-my ($full, $verbose, $broker, $timeframe, $start, $end, $outputdir, $set, $nbprocess) =
- (0, 0, '', '', '', '', '.', '', 1);
+my ($full, $nb_item, $start, $end, $timeframe, $max_loaded_items) =
+ (0, 0, '', '', 'day', -1);
+my ($verbose, $broker, $outputdir, $set, $nbprocess) =
+ (0, '', '', '', 1);
$outputdir = GT::Conf::get("BackTest::Directory") || '';
-GetOptions('full!' => \$full, 'verbose' => \$verbose,
- 'timeframe=s' => \$timeframe, "start=s" => \$start,
- "end=s" => \$end, 'output-directory=s' => \$outputdir,
+GetOptions('full!' => \$full, 'nb-item=i' => \$nb_item,
+ "start=s" => \$start, "end=s" => \$end,
+ "max-loaded-items" => \$max_loaded_items,
+ "timeframe=s" => \$timeframe,
+ 'verbose' => \$verbose, 'output-directory=s' => \$outputdir,
'broker=s' => \$broker, 'set=s' => \$set,
'nbprocess=s' => \$nbprocess);
+$timeframe = GT::DateTime::name_to_timeframe($timeframe);
# Checks
if (! -d $outputdir)
@@ -152,7 +210,7 @@
next;
}
my $code = $list->get($d);
- my ($calc, $first, $last) = find_calculator($code, $timeframe, $full, $start, $end);
+ my ($calc, $first, $last) = find_calculator($code, $timeframe, $full, $start, $end, $nb_item, $max_loaded_items);
# Fork a process to avoid memory consumption
foreach (@desc_systems)
Modified: trunk/Scripts/backtest_multi.pl
===================================================================
--- trunk/Scripts/backtest_multi.pl 2008-04-07 23:48:45 UTC (rev 598)
+++ trunk/Scripts/backtest_multi.pl 2008-04-14 00:02:32 UTC (rev 599)
@@ -11,7 +11,6 @@
#use lib '/tmp';
use strict;
-use vars qw($db);
use XML::Simple;
#use Data::Dumper;
@@ -26,18 +25,23 @@
use Getopt::Long;
use GT::Conf;
use GT::DateTime;
-use GT::Tools qw(:conf);
+use GT::Tools qw(:conf :timeframe);
use GT::BackTest::SpoolNew;
GT::Conf::load();
# Gestion des options
-my ($full, $start, $end, $timeframe, $outputdir, $alias) =
- (0, '', '', '', '', '');
-GetOptions('full!' => \$full, "timeframe=s" => \$timeframe,
- 'start=s' => \$start, 'end=s' => \$end,
+my ($full, $nb_item, $start, $end, $timeframe, $max_loaded_items) =
+ (0, 0, '', '', 'day', -1);
+my ($outputdir, $alias) =
+ ('', '');
+GetOptions('full!' => \$full, 'nb-item=i' => \$nb_item,
+ "start=s" => \$start, "end=s" => \$end,
+ "max-loaded-items" => \$max_loaded_items,
+ "timeframe=s" => \$timeframe,
'output-directory=s' => \$outputdir, 'alias=s' => \$alias );
+$timeframe = GT::DateTime::name_to_timeframe($timeframe);
my $init = 10000;
# read the system-description
@@ -48,8 +52,7 @@
#use Data::Dumper;
#print Dumper($data);
-# Create the Portfoliomanager and the database
-my $db = create_standard_object("DB::" . GT::Conf::get("DB::module"));
+# Create the Portfoliomanager
my $pf_manager = GT::PortfolioManager->new;
# Set up the various system managers
@@ -116,23 +119,16 @@
create_standard_object("MoneyManagement::Basic"));
$pf_manager->finalize;
-# Set up the codes
-my @codes = keys %{$data->{'code'}};
+# Set up the calculators
my @calc = ();
$cnt = 0;
-foreach my $code ( @codes ) {
- my $q = $db->get_prices($code);
- $calc[$cnt] = GT::Calculator->new($q);
+foreach my $code ( keys %{$data->{'code'}} ) {
+ my ($calc, $first, $last) = find_calculator($code, $timeframe, $full, $start, $end, $nb_item, $max_loaded_items);
+ $calc[$cnt] = $calc;
$calc[$cnt]->set_code($code);
- if ($timeframe) {
- if (! $calc[$cnt]->set_current_timeframe(GT::DateTime::name_to_timeframe($timeframe))) {
- die "Can't create � $timeframe � timeframe ...\n";
- }
- }
$cnt++;
}
-
# Now the hard part...
my $analysis = backtest_multi($pf_manager, \
AT
sys_manager, \
AT
brokers, \
AT
calc, $start, $end, $full, $init);
@@ -165,6 +161,4 @@
$bkt_spool->sync();
}
-$db->disconnect;
-
Modified: trunk/Scripts/display_indicator.pl
===================================================================
--- trunk/Scripts/display_indicator.pl 2008-04-07 23:48:45 UTC (rev 598)
+++ trunk/Scripts/display_indicator.pl 2008-04-14 00:02:32 UTC (rev 599)
@@ -30,22 +30,69 @@
=over 4
-=item --full
+=item --full, --start=<date>, --end=<date>, --nb-item=<nr>
-Runs the backtest on the full history (it runs on two years by default)
+Determines the time interval to consider for analysis. In detail:
+=over
+
+=item --start=2001-1-10, --end=2002-11-17
+
+The start and end dates considered for analysis. The date needs to be in the
+format configured in ~/.gt/options and must match the timeframe selected.
+
=item --nb-items=100
-nb-items controls how many database records are loaded.
+The number of periods to use in the analysis.
-=item --timeframe=1min|5min|10min|15min|30min|hour|3hour|Day|Week|Month|Year
+=item --full
+Consider all available periods.
+
+=back
+
+The periods considered are relative to the selected time frame (i.e., if timeframe
+is "day", these indicate a date; if timeframe is "week", these indicate a week;
+etc.). In GT format, use "YYYY-MM-DD" or "YYYY-MM-DD hh:mm:ss" for days (the
+latter giving intraday data), "YYYY-WW" for weeks, "YYYY/MM" for months, and
+"YYYY" for years.
+
+The interval of periods examined is determined as follows:
+
+=over
+
+=item 1 if present, use --start and --end (otherwise default to last price)
+
+=item 1 use --nb-item (from first or last, whichever has been determined),
+if present
+
+=item 1 if --full is present, use first or last price, whichever has not yet been determined
+
+=item 1 otherwise, consider a two year interval.
+
+=back
+
+The first period determined following this procedure is chosen. If additional
+options are given, these are ignored (e.g., if --start, --end, --full are given,
+--full is ignored).
+
+=item --timeframe=1min|5min|10min|15min|30min|hour|3hour|day|week|month|year
+
The timeframe can be any of the available modules in GT/DateTime.
=item --last-record
-Run backtest on the last period only.
+Display results for the last period only. Overrides any other options given
+to determine the interval.
+=item --max-loaded-items
+
+Determines the number of periods (back from the last period) that are loaded
+for a given market from the data base. Care should be taken to ensure that
+these are consistent with the performed analysis. If not enough data is
+loaded to satisfy dependencies, for example, correct results cannot be obtained.
+This option is effective only for certain data base modules and ignored otherwise.
+
=back
=head2 Examples
@@ -61,12 +108,22 @@
=cut
# Get all options
-my ($full, $last_record, $start, $end, $timeframe, $nb_item) =
- (0, 0, '', '', 'day', -1);
+my ($full, $nb_item, $start, $end, $timeframe, $max_loaded_items) =
+ (0, 0, '', '', 'day', -1);
+my $last_record = 0;
Getopt::Long::Configure("require_order");
-GetOptions('full!' => \$full, "last-record" => \$last_record, 'nb-item=i' => \$nb_item,
- "start=s" => \$start, "end=s" => \$end, "timeframe=s" => \$timeframe);
+GetOptions('full!' => \$full, 'nb-item=i' => \$nb_item,
+ "start=s" => \$start, "end=s" => \$end,
+ "max-loaded-items" => \$max_loaded_items,
+ "timeframe=s" => \$timeframe,
+ "last-record" => \$last_record);
$timeframe = GT::DateTime::name_to_timeframe($timeframe);
+if ($last_record) {
+ $full = 0;
+ $start = '';
+ $end = '';
+ $nb_item = 1;
+}
# Create the indicator according to the arguments
my $indicator_module = shift || pod2usage(verbose => 2);
my $code = shift || pod2usage(verbose => 2);
@@ -76,9 +133,7 @@
# Il faut cr� tout le framework
my $indicator_name = $indicator->get_name;
-my ($calc, $first, $last) = ($last_record) ?
- find_calculator($code, $timeframe, 0, '', '', 1, $nb_item) :
- find_calculator($code, $timeframe, $full, $start, $end, 200, $nb_item);
+my ($calc, $first, $last) = find_calculator($code, $timeframe, $full, $start, $end, $nb_item, $max_loaded_items);
# Au boulot
Modified: trunk/Scripts/display_signal.pl
===================================================================
--- trunk/Scripts/display_signal.pl 2008-04-07 23:48:45 UTC (rev 598)
+++ trunk/Scripts/display_signal.pl 2008-04-14 00:02:32 UTC (rev 599)
@@ -10,7 +10,6 @@
use lib '..';
use strict;
-use vars qw($db);
use GT::Prices;
use GT::Calculator;
@@ -33,18 +32,69 @@
=over 4
+=item --full, --start=<date>, --end=<date>, --nb-item=<nr>
+
+Determines the time interval to consider for analysis. In detail:
+
+=over
+
+=item --start=2001-1-10, --end=2002-11-17
+
+The start and end dates considered for analysis. The date needs to be in the
+format configured in ~/.gt/options and must match the timeframe selected.
+
+=item --nb-items=100
+
+The number of periods to use in the analysis.
+
=item --full
-Display signal results using all available data. By default, the script will only display the last 200 periods.
+Consider all available periods.
-=item --timeframe=tick|1min|5min|10min|15min|30min|hour|2hour|3hour|4hour|day|week|month|year
+=back
-timeframe can be any of the available modules in GT/DateTime.
+The periods considered are relative to the selected time frame (i.e., if timeframe
+is "day", these indicate a date; if timeframe is "week", these indicate a week;
+etc.). In GT format, use "YYYY-MM-DD" or "YYYY-MM-DD hh:mm:ss" for days (the
+latter giving intraday data), "YYYY-WW" for weeks, "YYYY/MM" for months, and
+"YYYY" for years.
-=item --start <date1> --end <date2>
+The interval of periods examined is determined as follows:
-The time interval to run the evaluation on (no defaults, see --full)
+=over
+=item 1 if present, use --start and --end (otherwise default to last price)
+
+=item 1 use --nb-item (from first or last, whichever has been determined),
+if present
+
+=item 1 if --full is present, use first or last price, whichever has not yet been determined
+
+=item 1 otherwise, consider a two year interval.
+
+=back
+
+The first period determined following this procedure is chosen. If additional
+options are given, these are ignored (e.g., if --start, --end, --full are given,
+--full is ignored).
+
+=item --timeframe=1min|5min|10min|15min|30min|hour|3hour|day|week|month|year
+
+The timeframe can be any of the available modules in GT/DateTime.
+
+=item --last-record
+
+Display results for the last period only. Overrides any other options given
+to determine the interval.
+
+=item --max-loaded-items
+
+Determines the number of periods (back from the last period) that are loaded
+for a given market from the data base. Care should be taken to ensure that
+these are consistent with the performed analysis. If not enough data is
+loaded to satisfy dependencies, for example, correct results cannot be obtained.
+This option is effective only for certain data base modules and ignored otherwise.
+
=item --change ( or -c )
show on output only those dates that signal changed
@@ -89,18 +139,23 @@
=cut
# Get all options
-my ($full, $start, $end, $tf)
- = (0, '', '', 'day');
-
-my ($change)
- = (0); # option to show only signal changes
-
+my ($change, $last_record)
+ = (0, 0);
+my ($full, $nb_item, $start, $end, $timeframe, $max_loaded_items) =
+ (0, 0, '', '', 'day', -1);
Getopt::Long::Configure('require_order');
-GetOptions('full!' => \$full, 'timeframe=s' => \$tf,
- 'start=s' => \$start, 'end=s' => \$end,
- "change!" => \$change,
- );
-my $timeframe = GT::DateTime::name_to_timeframe($tf);
+GetOptions('full!' => \$full, 'nb-item=i' => \$nb_item,
+ "start=s" => \$start, "end=s" => \$end,
+ "max-loaded-items" => \$max_loaded_items,
+ "timeframe=s" => \$timeframe,
+ "change!" => \$change, "last-record" => \$last_record);
+$timeframe = GT::DateTime::name_to_timeframe($timeframe);
+if ($last_record) {
+ $full = 0;
+ $start = '';
+ $end = '';
+ $nb_item = 1;
+}
# Create the signal according to the arguments
my $signal_module = shift || pod2usage(verbose => 1);
@@ -115,9 +170,8 @@
my $signal = create_standard_object($signal_module, @ARGV);
my $signal_name = $signal->get_name;
-my ($calc, $first, $last) = find_calculator($code, $timeframe, $full, $start, $end, 200);
+my ($calc, $first, $last) = find_calculator($code, $timeframe, $full, $start, $end, $nb_item, $max_loaded_items);
-print "\t$signal_module\n";
# Launching the signal
print "Testing signal $signal_name ...\n";
$signal->detect_interval($calc, $first, $last);
Modified: trunk/Scripts/graphic.pl
===================================================================
--- trunk/Scripts/graphic.pl 2008-04-07 23:48:45 UTC (rev 598)
+++ trunk/Scripts/graphic.pl 2008-04-14 00:02:32 UTC (rev 599)
@@ -7,7 +7,6 @@
use lib '..';
use strict;
-use vars qw($db);
use GT::Prices;
use GT::Calculator;
@@ -186,29 +185,64 @@
=over 4
-=item --timeframe
+=item --full, --start=<date>, --end=<date>, --nb-item=<nr>
-The timeframe used to plot the graphic. Defaults to daily data.
-Valid values include:
-tick|1min|5min|10min|15min|30min|hour|2hour|3hour|4hour|day|week|month|year
+Determines the time interval used to plot the graphics. In detail:
-=item --nb-item=n
+=over
-Plot n periods in the given timeframe.
+=item --start=2001-1-10, --end=2002-11-17
-=item --start=yyyy-mm-dd hh:nn:ss
+The start and end dates considered for the plot. The date needs to be in the
+format configured in ~/.gt/options and must match the timeframe selected.
-The start date used to plot the graphic.
+=item --nb-items=100
-=item --end=yyyy-mm-dd hh:nn:ss
+The number of periods to use to plot the graphics.
-The end date used to plot the graphic. This option overrides the --nb-item option.
-
=item --full
-Plot all available periods. This option overides the options --nb-item,
---start, and --end.
+Consider all available periods.
+=back
+
+The periods considered are relative to the selected time frame (i.e., if timeframe
+is "day", these indicate a date; if timeframe is "week", these indicate a week;
+etc.). In GT format, use "YYYY-MM-DD" or "YYYY-MM-DD hh:mm:ss" for days (the
+latter giving intraday data), "YYYY-WW" for weeks, "YYYY/MM" for months, and
+"YYYY" for years.
+
+The interval of periods examined is determined as follows:
+
+=over
+
+=item 1 if present, use --start and --end (otherwise default to last price)
+
+=item 1 use --nb-item (from first or last, whichever has been determined),
+if present
+
+=item 1 if --full is present, use first or last price, whichever has not yet been determined
+
+=item 1 otherwise, consider a two year interval.
+
+=back
+
+The first period determined following this procedure is chosen. If additional
+options are given, these are ignored (e.g., if --start, --end, --full are given,
+--full is ignored).
+
+=item --timeframe=1min|5min|10min|15min|30min|hour|3hour|day|week|month|year
+
+The timeframe can be any of the available modules in GT/DateTime.
+
+=item --max-loaded-items
+
+Determines the number of periods (back from the last period) that are loaded
+for a given market from the data base. Care should be taken to ensure that
+these are consistent with the performed analysis. If not enough data is
+loaded to satisfy dependencies, for example, correct results cannot be obtained.
+This option is effective only for certain data base modules and ignored otherwise.
+
=item --type=candle|candlevol|candlevolplace|barchart|line|none
The type of graphic to plot. none causes the price not to be displayed, however, overlays
@@ -231,9 +265,8 @@
=cut
-my $tf = 'day';
-my $nb_item;
-my ($start, $end) = ("", "");
+my ($full, $nb_item, $start, $end, $timeframe, $max_loaded_items) =
+ (0, 0, '', '', 'day', -1);
my ($width, $height) = ("", "200");
my $type = "candle";
my $volume = 1;
@@ -242,7 +275,6 @@
my @add;
my @options;
my $title = '';
-my $max_loaded_items = -1;
my $filename = "";
my $opt_driver = "";
my $man = 0;
@@ -262,12 +294,13 @@
}
Getopt::Long::Configure("no_pass_through");
-GetOptions("timeframe=s" => \$tf, "nb-item=i" => \$nb_item,
- "start=s" => \$start, "end=s" => \$end,
+GetOptions('full!' => \$full, 'nb-item=i' => \$nb_item,
+ "start=s" => \$start, "end=s" => \$end,
+ "max-loaded-items" => \$max_loaded_items,
+ "timeframe=s" => \$timeframe,
"width=i" => \$width, "height=i" => \$height,
"type=s" => \$type, "volume!" => \$volume,
"volume-height=s" => \$vheight,
- "max-loaded-items=i" => \$max_loaded_items,
"logarithmic!" => \$logarithmic, "add=s" => \
AT
add,
"option=s" => \
AT
options, "title=s" => \$title,
"file=s" => \$filename, "driver=s" => \$opt_driver,
@@ -280,8 +313,8 @@
pod2usage( -verbose => 2) if ($man);
my $code = shift || pod2usage(1);
-my $timeframe = GT::DateTime::name_to_timeframe($tf);
-my ($calc, $first, $last) = find_calculator($code, $timeframe, 0, $start, $end, $nb_item, $max_loaded_items);
+$timeframe = GT::DateTime::name_to_timeframe($timeframe);
+my ($calc, $first, $last) = find_calculator($code, $timeframe, $full, $start, $end, $nb_item, $max_loaded_items);
$nb_item = $last - $first + 1;
GT::Conf::default("Graphics::Driver", "GD");
Modified: trunk/Scripts/scan.pl
===================================================================
--- trunk/Scripts/scan.pl 2008-04-07 23:48:45 UTC (rev 598)
+++ trunk/Scripts/scan.pl 2008-04-14 00:02:32 UTC (rev 599)
@@ -86,25 +86,68 @@
=over 4
-=item --full (default - false)
+=item --full, --start=<date>, --end=<date>, --nb-item=<nr>
-Runs the scan with the full history (it runs with two years by default)
+Determines the time interval over which the scan is run. In detail:
-=item --verbose
+=over
-Makes scan.pl and invoked methods talkative (default - false)
+=item --start=2001-1-10, --end=2002-11-17
-=item --start=date, --end=date
+The start and end dates considered for the scan. The date needs to be in the
+format configured in ~/.gt/options and must match the timeframe selected.
-Sets the start and end dates for the scan (defaults - none)
-start and end dates should be specified consistent with timeframe
-but this conversion will be done internally provided the dates
-can be parsed (note -- with the ras hack timeframe conversion is automatic)
+=item --nb-items=100
-=item --timeframe=1min|5min|10min|15min|30min|hour|2hour|3hour|4hour|day|week|month|year
+The number of periods to use in the scan.
-Runs the scan using the given timeframe. (default - day)
+=item --full
+Runs the scan with the full history.
+
+=back
+
+The periods considered are relative to the selected time frame (i.e., if timeframe
+is "day", these indicate a date; if timeframe is "week", these indicate a week;
+etc.). In GT format, use "YYYY-MM-DD" or "YYYY-MM-DD hh:mm:ss" for days (the
+latter giving intraday data), "YYYY-WW" for weeks, "YYYY/MM" for months, and
+"YYYY" for years.
+
+The interval of periods examined is determined as follows:
+
+=over
+
+=item 1 if present, use --start and --end (otherwise default to last price)
+
+=item 1 use --nb-item (from first or last, whichever has been determined),
+if present
+
+=item 1 if --full is present, use first or last price, whichever has not yet been determined
+
+=item 1 otherwise, consider a two year interval.
+
+=back
+
+The first period determined following this procedure is chosen. If additional
+options are given, these are ignored (e.g., if --start, --end, --full are given,
+--full is ignored).
+
+=item --timeframe=1min|5min|10min|15min|30min|hour|3hour|day|week|month|year
+
+The timeframe can be any of the available modules in GT/DateTime.
+
+=item --max-loaded-items
+
+Determines the number of periods (back from the last period) that are loaded
+for a given market from the data base. Care should be taken to ensure that
+these are consistent with the performed analysis. If not enough data is
+loaded to satisfy dependencies, for example, correct results cannot be obtained.
+This option is effective only for certain data base modules and ignored otherwise.
+
+=item --verbose
+
+Makes scan.pl and invoked methods talkative (default - false)
+
=item --nbprocess=2
If you want to start two (or more) scans in parallel (useful for machines with several CPUs for example).
@@ -134,13 +177,15 @@
=cut
# Manage options
-my ($full, $verbose, $timeframe, $start, $end, $nbprocess, $html, $url) =
- (0, 0, '', '', '', 1, 0, 'http://finance.yahoo.com/l?s=%s');
-GetOptions( 'full!' => \$full,
+my ($full, $nb_item, $start, $end, $timeframe, $max_loaded_items) =
+ (0, 0, '', '', 'day', -1);
+my ($verbose, $nbprocess, $html, $url) =
+ (0, 1, 0, 'http://finance.yahoo.com/l?s=%s');
+GetOptions('full!' => \$full, 'nb-item=i' => \$nb_item,
+ "start=s" => \$start, "end=s" => \$end,
+ "max-loaded-items" => \$max_loaded_items,
+ "timeframe=s" => \$timeframe,
'verbose+' => \$verbose,
- 'timeframe=s' => \$timeframe,
- "start=s" => \$start,
- "end=s" => \$end,
'nbprocess=s' => \$nbprocess,
"html!" => \$html,
"url=s" => \$url,
@@ -412,7 +457,7 @@
}
my $code = $list->get($d);
- my ($calc, $first, $last) = find_calculator($code, $timeframe, 0, $start, $end);
+ my ($calc, $first, $last) = find_calculator($code, $timeframe, $full, $start, $end, $nb_item, $max_loaded_items);
my $i;
if ($calc->prices->has_date($date)) {