NAME
Finance::GeniusTrader::Portfolio - A portfolio
DESCRIPTION
A Portfolio is used to keep track of orders. It can calculate a performance and give useful statistics about what you've done (average trade gain/loss, percentage of winning/losing trades, max draw down, ...).
my $p = Finance::GeniusTrader::Portfolio->new;
-
Create a portfolio object without any open positions and without any pendings orders (ie an empty portfolio).
$p->add_order($order)
-
Add $order to the list of pending orders.
$p->discard_order($order)
-
Discard the order. Usually that means that it hasn't been executed or that it has been cancelled.
$p->new_position($code, $source, $date)
-
Create a new open position in the portfolio.
$p->apply_order_on_position($position, $order, $price, $date)
-
Add the given order to the position and modify the money available in the portfolio accordingly.
$p->close_position($pos)
-
Move the position from the list of open positions to the historic list. Update the cash with the marged gain.
$p->apply_pending_orders($calc, $i, $source, $pf_manager, [ $cb ])
-
Check the pending order for the value indicated by $calc, try to execute them on the day $i. It restricts itself to the orders coming from the indicated source. You can pass an optionnal callback for managing specially the position_opened callback. Not giving this arg and leaving to its default value is usually ok.
$p->apply_pending_orders_on_position($position, $calc, $i)
-
Apply all pending orders on the position, this does include the stop.
$p->update_position_evaluation($position, $calc, $i)
-
Update the evaluation of the position with data of day $i.
$p->store_evaluation($date)
-
Store the cash level and the evaluation of the portfolio for the indicated date.
$p->current_cash()
-
Returns the sum of cash available (may return a negative value if "effet de levier" is used).
$p->current_evaluation()
-
Returns the evaluation of all the open positions in the portfolio.
$p->current_marged_gains()
-
Returns the sum of gains (or losses if the number is negative) made with marged positions.
$p->current_marged_investment()
-
Returns the sum of gains (or losses if the number is negative) made with marged positions.
my($cash, $evaluation, $gains) = $p->get_historic_evaluation($date)
-
Return the historic information (cash and portfolio evaluation) about the portfolio.
$p->has_historic_evaluation($date)
-
Returns true if an evaluation of the portfolio exists for the given date.
$p->list_pending_orders([$source])
-
Returns the list of orders that are pending and that have been submitted by the corresponding source. If source argument is missing (or undef), returns all the pending orders.
$p->list_open_positions([$source])
-
Returns the list of positions that are open and that have been submitted by the corresponding source. If source argument is missing (or undef), returns all the open positions.
$p->get_position($code, $source)
-
Return the position (if any) corresponding to $code and $source. This assumes that only one such position exists.
$p->list_history_positions($code, $source)
-
Return the list of historical positions corresponding to $code and $source.
$p->set_initial_value()
-
Set the amount of money available initially on the portfolio.
$p->set_broker($broker)
-
Defines which broker to use for the calculation of order commissions and annual account charge.
$p->get_order_cost($order)
-
Apply all broker rules and return the amount ask by the broker for the given order.
$p->real_global_analysis()
$p->real_analysis_by_code($code)
-
Analyzes the evolution of the portfolio. Either globally or for each share individually.
Real analysis uses just the information provided. For a global analysis, it needs an initial value for the portfolio.
The informations calculated are :
- global gain/loss (sum & percentage) - number of winning trades - number of loosing trades - average loss (percentage) - average gain (percentage) - max gain in single trade (percentage) - max loss in single trade (percentage) - max global gain - max global loss - max draw down (biggest cumulated loss after a new high) (percentage)