FRENESDE

Managing a portfolio

To manage several assets, you think in target weights: for example 40% in an equity ETF, 40% in a bond ETF, 20% in gold. self.order_target_percent(data=d, target=0.40) adjusts the position in d so that it weighs 40% of the total value.
The order works out the difference by itself: if the asset weighs 30%, it buys what is missing; if it weighs 50%, it sells the excess; target=0 closes the position. There are also order_target_size (in units) and order_target_value (in amount).
The calculation uses the price known at decision time, but execution happens at the next open: the weight obtained is therefore only approximate. Keep a small cash buffer, otherwise an order may be refused (Margin status).
Order of operations: send the sells first, then the buys. Sells free up cash; if the buys go first, the broker may refuse them for lack of cash.

Examples

Key terms

Target weight
Desired share of an asset in the portfolio value
order_target_percent
Order that adjusts a position towards a target percentage
Concentration
Situation where one asset weighs too much in the portfolio
Portfolio value
Cash plus the value of all positions
Take the mission on Doji Academy

← Back to the index