Build a Robo-Advisor with Python (From Scratch). Automate your financial and investment decisions

Build a Robo-Advisor with Python (From Scratch). Automate your financial and investment decisions

Build a Robo-Advisor with Python (From Scratch). Automate your financial and investment decisions
Автор: Michalka Alex, Reider Rob
Дата выхода: 2025
Издательство: Manning Publications Co.
Количество страниц: 335
Размер файла: 3,2 МБ
Тип файла: PDF
Добавил: codelibs
 Проверить на вирусы  Дополнительные материалы 

Build a Robo-Advisor with Python....1

brief contents....5

contents....7

preface....12

acknowledgments....13

about this book....14

Who should read this book....14

How this book is organized: A roadmap....14

About the code....15

liveBook discussion forum....16

about the authors....17

about the cover illustration....18

Part 1 Basic tools and building blocks....19

1 The rise of robo-advisors....21

1.1 What are robo-advisors?....21

1.1.1 Key features of robo-advisors....22

1.1.2 Comparison of robo-advisors....23

1.1.3 Things robo-advisors don't do....23

1.2 Advantages of robo-advisors....24

1.2.1 Low fees....24

1.2.2 Tax savings....24

1.2.3 Avoiding behavioral biases....25

1.2.4 Saving time....26

1.3 Example: Social Security benefits....26

1.4 Python and robo-advising....28

1.5 Who might be interested in learning about robo-advising?....29

Summary....30

2 An introduction to portfolio construction....31

2.1 A simple example with three assets....32

2.2 Computing a portfolio's expected return and standard deviation....33

2.3 An illustration with random weights....36

2.4 Introducing a risk-free asset....39

2.5 Risk tolerance....41

Appendix....45

No risk-free rate....45

Adding a risk-free rate....47

Summary....48

3 Estimating expected returns and covariances....49

3.1 Estimating expected returns....50

3.1.1 Historical averages....50

3.1.2 CAPM....52

3.1.3 Adjusting historical returns for changes in valuation....57

3.1.4 Capital market assumptions from asset managers....63

3.2 Estimating variances and covariances....63

3.2.1 Using historical returns....63

3.2.2 GARCH models....65

3.2.3 Other approaches....68

3.2.4 Subjective estimates....68

Summary....70

4 ETFs: The building blocks of robo-portfolios....71

4.1 ETF basics....72

4.1.1 ETF strategies....72

4.1.2 ETF pricing: Theory....72

4.1.3 ETF pricing: Reality....74

4.1.4 Costs of ETF investing....75

4.2 ETFs vs. mutual funds....75

4.2.1 Tradability....76

4.2.2 Costs and minimums....77

4.2.3 Tax efficiency....77

4.2.4 The verdict on mutual funds vs. ETFs....78

4.3 Total cost of ownership....79

4.3.1 Cost components....79

4.4 Beyond standard indices....80

4.4.1 Smart beta....81

4.4.2 Socially responsible investing....82

Summary....84

Part 2 Financial planning tools....85

5 Monte Carlo simulations....87

5.1 Simulating returns in Python....89

5.2 Arithmetic vs. geometric average returns....92

5.3 Simple vs. continuously compounded returns....94

5.4 Geometric Brownian motion....95

5.5 Estimating the probability of success....96

5.6 Dynamic strategies....98

5.7 Inflation risk....100

5.8 Fat tails....105

5.9 Historical simulations and booststrapping....106

5.10 Longevity risk....108

5.11 Flexibility of Monte Carlo simulations....111

Appendix....112

Summary....112

6 Financial planning using reinforcement learning....114

6.1 A goals-based investing example....115

6.2 An introduction to reinforcement learning....115

6.2.1 Solution using dynamic programming....118

6.2.2 Solution using Q-learning....123

6.3 Utility function approach....126

6.3.1 Understanding utility functions....126

6.3.2 Optimal spending using utility functions....128

6.4 Longevity risk....132

6.5 Other extensions....134

Summary....135

7 Measuring and evaluating returns....136

7.1 Time-weighted vs. dollar-weighted returns....137

7.1.1 Time-weighted returns....138

7.1.2 Dollar-weighted returns....138

7.2 Risk-adjusted returns....140

7.2.1 Sharpe ratio....140

7.2.2 Alpha....142

7.2.3 Evaluating an ESG fund's performance....143

7.2.4 Which is better, alpha or Sharpe ratio?....145

Summary....146

8 Asset location....148

8.1 A simple example....149

8.2 The tax efficiency of various assets....153

8.3 Adding a Roth account....155

8.3.1 A simple example with three types of accounts....156

8.3.2 An example with optimization....157

8.4 Additional considerations....159

Summary....160

9 Tax-efficient withdrawal strategies....161

9.1 The intuition behind tax-efficient strategies....161

9.1.1 Principle 1: Deplete less tax-efficient accounts first....161

9.1.2 Principle 2: Keep tax brackets stable over time....162

9.2 Examples of sequencing strategies....163

9.2.1 Starting assumptions....163

9.2.2 Tax-sequencing code....164

9.2.3 Strategy 1: IRA first....167

9.2.4 Strategy 2: Taxable first....168

9.2.5 Strategy 3: Fill lower tax brackets....169

9.2.6 Strategy 4: Roth conversions....171

9.3 Additional complications....172

9.3.1 Required minimum distributions....173

9.3.2 Inheritance....174

9.3.3 Capital gains taxes....175

9.3.4 State taxes....178

9.3.5 Putting it all together....179

Summary....179

Part 3 Portfolio construction....181

10 Optimization and portfolio construction....183

10.1 Convex optimization in Python....184

10.1.1 Basics of optimization....184

10.1.2 Convexity....186

10.1.3 Python libraries for optimization....189

10.2 Mean-variance optimization....191

10.2.1 The basic problem....191

10.2.2 Adding more constraints....192

10.3 Optimization-based asset allocation....194

10.3.1 Minimal constraints....195

10.3.2 Enforcing diversification....200

10.3.3 Creating an efficient frontier....205

10.3.4 Building an ESG portfolio....206

Summary....207

11 Asset allocation by risk: Introduction to risk parity....209

11.1 Decomposing portfolio risk....210

11.1.1 Risk contributions....210

11.1.2 Risk concentration in a ``diversified'' portfolio....210

11.1.3 Risk parity as an optimal portfolio....211

11.2 Calculating risk-parity weights....213

11.2.1 Naive risk parity....213

11.2.2 General risk parity....213

11.2.3 Weighted risk parity....214

11.2.4 Hierarchical risk parity....218

11.3 Implementation of risk-parity portfolios....229

11.3.1 Applying leverage....230

Summary....231

12 The Black-Litterman model....232

12.1 Equilibrium returns....232

12.1.1 Reverse optimization....233

12.1.2 Understanding equilibrium....235

12.2 Conditional probability and Bayes' rule....236

12.3 Incorporating investor views....238

12.3.1 Expected returns as random variables....238

12.3.2 Expressing views....239

12.3.3 Updating equilibrium returns....240

12.3.4 Assumptions and parameters....241

12.4 Examples....242

12.4.1 Example: Sector selection....242

12.4.2 Example: Global allocation with cryptocurrencies....246

Summary....249

Part 4 Portfolio management....251

13 Rebalancing: Tracking a target portfolio....253

13.1 Rebalancing basics....253

13.1.1 The need for rebalancing....254

13.1.2 Downsides of rebalancing....255

13.1.3 Dividends and deposits....255

13.2 Simple rebalancing strategies....257

13.2.1 Fixed-interval rebalancing....257

13.2.2 Threshold-based rebalancing....257

13.2.3 Other considerations....258

13.2.4 Final thoughts....261

13.3 Optimizing rebalancing....261

13.3.1 Variables....261

13.3.2 Inputs....262

13.3.3 Formulating the problem....269

13.3.4 Running an example....271

13.4 Comparing rebalancing approaches....273

13.4.1 Implementing rebalancers....274

13.4.2 Building the backtester....279

13.4.3 Running backtests....286

13.4.4 Evaluating results....287

Summary....290

14 Tax-loss harvesting: Improving after-tax returns....291

14.1 The economics of tax-loss harvesting....292

14.1.1 Tax deferral....292

14.1.2 Rate conversion....294

14.1.3 When harvesting doesn't help....295

14.2 The wash-sale rule....295

14.2.1 Wash-sale basics....295

14.2.2 Wash sales with Python....299

14.3 Deciding when to harvest....311

14.3.1 Trading costs....311

14.3.2 Opportunity cost....312

14.3.3 End-to-end evaluation....317

14.4 Testing a TLH strategy....322

14.4.1 Backtester modifications....322

14.4.2 Choosing ETFs....323

Summary....323

index....324

Automated digital financial advisors—also called robo-advisors—manage billions of dollars in assets. Follow the step-by-step instructions in this hands-on guide, and you’ll learn to build your robo-advisor capable of managing a real investing strategy.

In Build a Robo-Advisor with Python (From Scratch) you’ll learn how to:

  • Measure returns and estimate the benefits of robo-advisors
  • Use Monte Carlo simulations to build and test financial planning tools
  • Construct diversified, efficient portfolios using optimization and other methods
  • Implement and evaluate rebalancing methods to track a target portfolio over time
  • Decrease taxes through tax-loss harvesting and optimized withdrawal sequencing
  • Use reinforcement learning to find the optimal investment path up to, and after, retirement

Automated “robo-advisors” are commonplace in financial services, thanks to their ability to give high-quality investment advice at a fraction of the cost of human advisors. Build a Robo-Advisor with Python (From Scratch) teaches you to develop one of these powerful, flexible tools using popular and free Python libraries. You’ll master practical Python skills in demand in financial services, and financial planning skills that will help you take the best care of your money. All examples are accompanied by working Python code, and are easy to adjust for investors anywhere in the world.

About the technology

Millions of investors use robo-advisors as an alternative to human financial advisors. In this one-of-a-kind guide, you’ll learn how to build one of your own. Your robo-advisor will assist you with all aspects of financial planning, including saving for retirement, creating a diversified portfolio, and decreasing your tax bill. And along the way, you’ll learn a lot about Python and finance!

About the book

Build a Robo-Advisor with Python (From Scratch) guides you step-by-step, feature-by-feature as you create a robo-advisor from the ground up. As you go, you’ll dive into techniques like reinforcement learning, convex optimization, and Monte Carlo methods that you can apply even outside the field of FinTech. When you finish, your powerful assistant will be able to create optimal asset allocations, rebalance investments while minimizing taxes, and more.

What's inside

  • Advanced portfolio construction techniques
  • Tax-loss harvesting, sequencing of retirement withdrawals, and asset location
  • Financial planning using AI and Monte Carlo simulations
  • Rebalancing methods to track a portfolio over time

About the reader

Accessible to anyone with a basic knowledge of Python and finance—no special skills required.


Похожее:

Список отзывов:

Нет отзывов к книге.