[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GT] SVN Commit r633 - branches/exp/Scripts
Author: thomas
Date: 2008-06-11 07:24:45 +0200 (Wed, 11 Jun 2008)
New Revision: 633
Modified:
branches/exp/Scripts/backtest.pl
branches/exp/Scripts/display_signal.pl
Log:
Add option --tight as in display_indicator.pl to print signal
and backtest information in a more concise format.
Modified: branches/exp/Scripts/backtest.pl
===================================================================
--- branches/exp/Scripts/backtest.pl 2008-06-11 05:15:33 UTC (rev 632)
+++ branches/exp/Scripts/backtest.pl 2008-06-11 05:24:45 UTC (rev 633)
@@ -151,6 +151,10 @@
Output is generated in html
+=item --tight
+
+Outputs only the positions in concise format.
+
=item --graph=<filename>
Generate a PNG graph of your portfolio value over the time of the backtest and
@@ -230,15 +234,15 @@
(0, 0, '', '', 'day', -1);
my $man = 0;
my @options;
-my ($verbose, $html, $display_trades, $template, $graph_file, $ofname, $broker, $system, $store_file, $outputdir, $set) =
- (0, 0, 0, '', '', '', '', '', '', '', '');
+my ($verbose, $html, $display_trades, $template, $graph_file, $ofname, $broker, $system, $store_file, $outputdir, $set, $tight) =
+ (0, 0, 0, '', '', '', '', '', '', '', '', 0);
my (@mmname, @tfname, @csname);
$outputdir = GT::Conf::get("BackTest::Directory") || '';
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,
+ 'verbose!' => \$verbose, 'html!' => \$html, 'tight!' => \$tight,
'template=s' => \$template, 'display-trades!' => \$display_trades,
'output-directory=s' => \$outputdir, 'set=s' => \$set,
'money-management=s' => \
AT
mmname, 'graph=s' => \$graph_file,
@@ -435,12 +439,18 @@
}
else
{
+ unless ($tight) {
print "## Analysis of " . $sys_manager->get_name . "|" .
$pf_manager->get_name . "\n";
GT::Report::Portfolio($analysis->{'portfolio'}, $verbose);
print "## Global analysis (full portfolio always invested)\n";
GT::Report::PortfolioAnalysis($analysis->{'real'}, $verbose);
print "\n";
+ } else {
+ print "Analysis of " . $sys_manager->get_name . "|" .
+ $pf_manager->get_name . "\n";
+ GT::Report::PortfolioShort($analysis->{'portfolio'});
+ }
}
$db->disconnect;
Modified: branches/exp/Scripts/display_signal.pl
===================================================================
--- branches/exp/Scripts/display_signal.pl 2008-06-11 05:15:33 UTC (rev 632)
+++ branches/exp/Scripts/display_signal.pl 2008-06-11 05:24:45 UTC (rev 633)
@@ -100,6 +100,10 @@
show on output only those dates that signal changed
+=item --tight
+
+Displays indicator values in concise tabular format.
+
=item --options=<key>=<value>
A configuration option (typically given in the options file) in the
@@ -146,8 +150,8 @@
=cut
# Get all options
-my ($change, $last_record)
- = (0, 0);
+my ($change, $last_record, $tight)
+ = (0, 0, 0);
my ($full, $nb_item, $start, $end, $timeframe, $max_loaded_items) =
(0, 0, '', '', 'day', -1);
my $man = 0;
@@ -157,7 +161,7 @@
"start=s" => \$start, "end=s" => \$end,
"max-loaded-items" => \$max_loaded_items,
"timeframe=s" => \$timeframe,
- "change!" => \$change, "last-record" => \$last_record,
+ "change!" => \$change, "last-record" => \$last_record, "tight!" => \$tight,
"option=s" => \
AT
options, "help!" => \$man);
$timeframe = GT::DateTime::name_to_timeframe($timeframe);
@@ -200,9 +204,20 @@
print "Testing signal $signal_name ...\n";
$signal->detect_interval($calc, $first, $last);
+if ( $tight ) {
+ printf "[%s] =", "Date";
+ for(my $n = 0; $n < $signal->get_nb_values; $n++)
+ {
+ my $name = $signal->get_name($n);
+ printf "\t%s", $name;
+ }
+ printf "\n";
+}
+
my $prior_state = undef;
for(my $i = $first; $i <= $last; $i++)
{
+ unless ( $tight ) {
for(my $n = 0; $n < $signal->get_nb_values; $n++)
{
my $name = $signal->get_name($n);
@@ -222,12 +237,60 @@
if ( $prior_state != $state ) {
printf "%-20s[%s] = %s\n", $name, $calc->prices->at($i)->[$DATE],
($state ? 'yes' : 'no');
- }
+ }
}
$prior_state = $state;
}
}
}
+ } else {
+ # --tight
+ if ( ! $change ) {
+ printf "[%s] =", $calc->prices->at($i)->[$DATE];
+ for(my $n = 0; $n < $signal->get_nb_values; $n++) {
+ my $name = $signal->get_name($n);
+
+ if ($calc->signals->is_available($name, $i)) {
+ printf "\t%s", ($calc->signals->get($name, $i) ? 'yes' : 'no');
+ }
+ }
+ printf "\n";
+ } else {
+ my $name = $signal->get_name(0);
+ if ($calc->signals->is_available($name, $i)) {
+ # show only changes from prior
+ my $state = $calc->signals->get($name, $i);
+ if ( ! defined ( $prior_state ) ) {
+
+ printf "[%s] =", $calc->prices->at($i)->[$DATE];
+ for(my $n = 0; $n < $signal->get_nb_values; $n++) {
+ $name = $signal->get_name($n);
+ my $val = $calc->signals->get($name, $i);
+
+ if ($calc->signals->is_available($name, $i)) {
+ printf "\t%s", ($val ? 'yes' : 'no');
+ }
+ }
+ printf "\n";
+ } else {
+ if ( $prior_state != $state ) {
+
+ printf "[%s] =", $calc->prices->at($i)->[$DATE];
+ for(my $n = 0; $n < $signal->get_nb_values; $n++) {
+ $name = $signal->get_name($n);
+ my $val = $calc->signals->get($name, $i);
+
+ if ($calc->signals->is_available($name, $i)) {
+ printf "\t%s", ($val ? 'yes' : 'no');
+ }
+ }
+ printf "\n";
+ }
+ }
+ $prior_state = $state;
+ }
+ }
+ }
}
$db->disconnect;