GT::PortfolioManager - Manages a portfolio


A PortfolioManager is an entity interacting between a Portfolio, a Trading System, money management rules and trade filters.

When it comes to starting a new position (ie submitting an order to start a position), the money management system comes in again to decide how much to put on the trade.

Filters can be applied to accept/refuse trades proposed by the various trading systems.

my $manager = GT::PortfolioManager->new($portfolio)

Create a new portfolio manager that implements a money management strategy.


Change the portfolio managed.


Returns the managed portfolio.

$order = $manager->buy_market_price($calc, $source)
$order = $manager->buy_limited_price($calc, $source, $price)
$order = $manager->buy_conditional($calc, $source, $price [, $price2])
$order = $manager->virtual_buy_at_open($calc, $source)
$order = $manager->virtual_buy_at_high($calc, $source)
$order = $manager->virtual_buy_at_low($calc, $source)
$order = $manager->virtual_buy_at_close($calc, $source)
$order = $manager->virtual_buy_at_signal($calc, $source)
$order = $manager->sell_market_price($calc, $source)
$order = $manager->sell_limited_price($calc, $source, $price)
$order = $manager->sell_conditional($calc, $source, $price [, $price2])
$order = $manager->virtual_sell_at_open($calc, $source)
$order = $manager->virtual_sell_at_high($calc, $source)
$order = $manager->virtual_sell_at_low($calc, $source)
$order = $manager->virtual_sell_at_close($calc, $source)
$order = $manager->virtual_sell_at_signal($calc, $source)

Those functions are used to create orders that may be modified and submitted later.

$manager->set_order_partial($order, $ratio)

When you want to close a position, you may want to not close it fully. With this function, you indicate how much of the initial position you want to close.

$manager->discard_all_orders($calc, $source)

Discards all orders concerning this share and this source.

$manager->submit_order($order, $i, $calc)
$manager->submit_order_in_position($position, $order, $i, $calc)

Submit the prepared order, either an order that will start a new position or as an order that will modify an existing position.


Use a money management rule and remove all money management rules currently used.

$manager->decide_quantity($order, $i, $calc)

Apply the various money management rules and decide the size of the position.


Finalize the setup of the manager. Calculate its name. You can get its name afterward using $manager->get_name.


Return the name of the system.


Setup the portfolio manager according to the name, it will create the corresponding money management rules.