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

[GT] SVN Commit r606 - trunk/Scripts



Author: thomas
Date: 2008-04-20 05:15:52 +0200 (Sun, 20 Apr 2008)
New Revision: 606

Modified:
   trunk/Scripts/graphic.pl
Log:
Provide missing documentation. Support alias in graphical objects.

Modified: trunk/Scripts/graphic.pl
===================================================================
--- trunk/Scripts/graphic.pl	2008-04-14 12:22:36 UTC (rev 605)
+++ trunk/Scripts/graphic.pl	2008-04-20 03:15:52 UTC (rev 606)
@@ -35,11 +35,11 @@
 		    [ --type=candle|candlevol|candlevolplace|barchart|line|none ] [ --volume ]
 		    [ --volume-height=150 ] [ --title="Daily Chart" ] \
 		    [ --width=200 ] [ --height=230 ] [ --logarithmic ] \
-		    [ additionnal graphical elements ] \
+		    [ additional graphical elements ] \
                     [ --file=conf ] [ --driver={GD|ImageMagick} ] \
 		    <code>
 
-Use "graphic.pl -man" to list all available options
+Use "graphic.pl --man" to list all available options
 
 
 =head2 Description
@@ -49,7 +49,7 @@
 
 Various options are available to control color, size and other graphic properties.
 
-=head2 ADDITIONNAL GRAPHICAL ELEMENTS
+=head2 Additional Graphical Elements
 
 =over 4
 
@@ -93,13 +93,16 @@
 =item Set-Scale(min,max,[logarithmic]) or Set-scale(auto,[logarithmic])
 
 This defines the scale for the currently selected zone (by default the last
-zone created or the main zone if no zone has been created).
+zone created or the main zone if no zone has been created). If auto scale
+is used, the scale must be set after all objects that can affect the min or
+max values have been added.
 
 =item Set-Special-Scale(min,max,[log]) or Set-Special-Scale(auto,[log])
 
 The last created object will be displayed with its own scale (and not the
 default one of the zone). The scale may be given or it may be calculated
-to fit the full zone.
+to fit the full zone. If auto scale is used, the scale must be set after 
+all objects that can affect the min or max values have been added.
 
 =item Set-Axis(tick1,tick2,tick3...)
 
@@ -149,10 +152,10 @@
 
 =back
 
-=head2 DATASOURCES
+=head2 Datasources
 
-Sometimes you need to pass datasources to the graphical objects. Here
-are the available ones.
+Sometimes you need to pass datasources to the graphical objects. The
+following are currently available.
 
 =over 4
 
@@ -166,10 +169,10 @@
 
 =back
 
-=head2 OTHER OBJECTS
+=head2 Other Objects
 
-Some datasources may be parameterized by objects. Here are the
-available objects.
+Some datasources may be parameterized by objects. The following are
+currently available.
 
 =over 4
 
@@ -181,7 +184,7 @@
 
 =back
 
-=head2 PARAMETERS
+=head2 Options
 
 =over 4
 
@@ -245,9 +248,30 @@
 
 =item --type=candle|candlevol|candlevolplace|barchart|line|none
 
-The type of graphic to plot. none causes the price not to be displayed, however, overlays
-can still be sketched in the graphic.
+The type of graphic to plot. none causes the price not to be displayed,
+however, overlays can still be sketched in the graphic.
 
+=item --volume
+
+=item --volume-height=150
+
+=item --title="Daily Chart"
+
+=item --width=200
+
+=item --height=230
+
+=item --logarithmic
+
+=item --driver=GD|ImageMagick
+
+=item --options=<key>=<value>
+
+A configuration option (typically given in the options file) in the
+form of a key=value pair. For example,
+ --option=DB::Text::format=0
+sets the format used to parse markets via the DB::Text module to 0.
+
 =item Configuration-File ( --file=conf )
 
 With this option, additional parameters are read from the
@@ -258,11 +282,18 @@
 
 =head1 Examples
 
-   --title=Stock of %c
-   --add=Switch-Zone(0)
-   --add=Curve(Indicators::SMA 200, [255,0,0])
-   --add=Curve(Indicators::SMA 38, [0,0,255])
+./graphic.pl --add="Switch-Zone(0)" \
+             --add="Curve(Indicators::SMA  38, [0,0,255])" \
+             --add="Curve(Indicators::SMA 100, [0,255,0])" \
+             --add="Curve(Indicators::SMA 200, [255,0,0])" \
+             --title=Daily history of %c
+             13000 > test.png
 
+./graphic.pl --add="Curve(Indicators::EMA 5,[255,0,0])" \
+             --add="Curve(Indicators::EMA 20,[0,0,255])" \
+             --add="BuySellArrows(SY::Generic {S::Generic::CrossOverUp {I:EMA 5} {I:EMA 20}} {S::Generic::CrossOverDown {I:EMA 5} {I:EMA 20}} )" \
+             13000 > test.png
+
 =cut
 
 my ($full, $nb_item, $start, $end, $timeframe, $max_loaded_items) =
@@ -782,6 +813,17 @@
     my ($desc, $calc, $first, $last) = @_;
     
     my $ds;
+
+    # Try aliases
+    if ($desc !~ /^(I|Indicators|SY|Systems|PortfolioEvaluation)/i) {
+	my $alias = resolve_alias($desc);
+	if (! $alias) {
+	  warn "Unknown datasource: $desc\n";
+	  return $ds;
+	}
+	$desc = $alias;
+    }
+
     if ($desc =~ /^(I|Indicators)::?/i) {
 	$ds = GT::Graphics::DataSource::SingleIndicator->new($calc, $desc);
 	$ds->set_selected_range($first, $last);