liveBook · Manning

Policy

As explained in Build a Robo-Advisor with Python (From Scratch)

A policy is a rule or mapping that specifies which action an agent should take for each state.

A policy maps each state to an action. In goals-based investing, it tells an investor how much wealth to allocate to stocks versus a risk-free bond for a given wealth level and time. The objective is to maximize cumulative reward, defined here by meeting a financial goal over the planning horizon. section 6.2

The policy is state-dependent rather than a fixed glide path. With state (W, t), an optimal action can change when wealth differs even at the same date: an investor ahead of the goal can reduce stock exposure, while one behind it may need greater risk exposure. section 6.2.1

Two methods produce a policy from modeled investment choices:

  • Dynamic programming computes expected values backward from the goal date, then records the action with the highest expected value at every wealth-time state in A(W,t). section 6.2.1
  • Q-learning estimates Q(W,t,a), the value of each state-action pair, through many simulated episodes; choosing the action with the largest Q value yields the learned policy. section 6.2.2

Goal-based stock allocation

For a $1 million starting portfolio aiming to double in 10 years, the dynamic-programming policy begins with an 85% stock allocation. Along a medium-return wealth path, stock allocation declines; near the goal date, enough wealth can make a risk-free-bond allocation sufficient. section 6.2.1

Figure 6.4 Asset allocations for the three paths of wealth
figure

Compare the policy’s stock allocations across good, medium, and bad wealth paths to see why time alone does not determine the action. section 6.2.1

How Build a Robo-Advisor with Python (From Scratch) covers it

How deep it goes
Works through dynamic-programming and Q-learning policy construction, including value functions, state-action values, updates, and simulated episodes.
Examples
Uses a $1 million, 10-year wealth-doubling goal and good, medium, and bad wealth paths to compare allocations.
What you can do after
Build it from scratch by computing state-dependent asset allocations with dynamic programming or learning them through Q-learning episodes.
How it connects
Connects policies to reinforcement learning, states, actions, rewards, value functions, dynamic programming, Q-learning, and glide paths.

Also explained in

Compare how 13 books explain policy →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build a Robo-Advisor with Python (From Scratch). The section links point to the parts of the book it draws on.