GT::Graphics::Object::Positions

This graphical object displays all positions in a portfolio on a graph if the order date coincides with the graph time span.

the default buy orders color is Graphic::Positions::BuyColor which defaults to 62 % green intensity if not set in .gt/options

the default sell orders color is Graphic::Positions::SellColor which defaults to 62 % red intensity if not set in .gt/options

the marker color is always adjusted to be a transparent version of the color specified (and will likely alter the transparency attribute if it is already set)

if a 6th argument is supplied via Positions->new method and it is "true" (in perl not zero or something other than "") then a horizontal line will be drawn from the opening of the position (or start date) to the end date. price lines are not drawn for closed positions since the price points will likely differ. the line color will be based on the type of position, green for long, red for short.


SYNOPSIS

my $pf = GT::Portfolio->create_from_file("./my_portfolio);

$all_trades = GT::Graphics::Object::Positions->new($calc, $zone, \ $pf, $first, $last, "enable priceline");

NB: $calc, $zone, required by GT::Graphics::Object::<object>->new() which Positions.pm inherits. see Object.pm.

$graphic->add_object($all_trades);

  where $calc will yield the security symbol ($code) being processed
        $portfolio contains the portfolio data
        $first, $last are the dates of interest


EXAMPLES: script code

    (from ras hack of Samal Chandrans' portgraph.pl)
    my $pf = GT::Portfolio->create_from_file($pfname);
    my $all_trades = GT::Graphics::Object::Positions->new(
     $calc, $zone, $pf, $first, $last, "plotline");
    $graphic->add_object($all_trades);
    
    (from ras hack of backtest.pl)
      my $positions = GT::Graphics::Object::Positions->new(
       $calc, $zone, $analysis->{'portfolio'}, $first, $last, "show priceline");
      $positions->set_special_scale($scale_p);
      $graphic->add_object($positions);


BUGS, NOTES, LIMITATIONS

no testing with widths other than the default width

i selected width of 24 because it was large enough for my old tired eyes to see on an otherwise cluttered graph but not so large as to obliterate the adjacent candle sticks

no testing with non-closed short positions. manage_portfolio doesn't seem to support them (or am i missing something) so i've been unable to easily mechanize an test/evaluation portfolio with them.