cvxgrp/cvxportfolio

questions / thoughts on examples folder

Opened this issue · 2 comments

quant5 commented

I made a PR with a small refactor to two of the examples.
#87

I have some questions / thoughts:

  • for multiperiod_tcost.py
    • why is there a hard-coded zero-out of the portfolio on 4/20/23? Should the backtester have an end_time of 4/20/23 then?
    • if you set an initial h, initial_value becomes unnecessary / overridden, it may be worth noting this in the docs
    • drawdowns are positive numbers - it's more conventional to plot them as negative (e.g., underwater). I'd actually suggest flipping the sign of the drawdowns series when it's calculated.
  • hello_world.py - I didn't refactor this as it seems really expensive for a "hello world" - making 500 yfinance calls / filling one's hard drive with data. Suggest paring down to perhaps the example in the readme?
enzbus commented

Ok you're right, I was experimenting with the examples when working on the covariance forecast, it scales nicely to hundreds of names. (The data doesn't take much space BTW, each stock takes 500k-1Mb, so less than 300Mb in total). The multiperiod example shows the effect of imposing constraints at time (if you know ahead of time that you have to be all cash on a given day, it plans and optimizes on tcost). This also showcases some new api elements (it wasn't possible in 0.0.X, now the policies in backtest are aware of the trading calendar). If you want you could also help me translate the old examples (in https://github.com/cvxgrp/cvxportfolio/tree/0.0.X ) for the new API. They should become much more terse, one of my goals has been to move logic that was built there into the library itself.

quant5 commented

Sounds great - I'll take a crack at (1) making new examples more user-friendly and explanatory and (2) refactoring old examples.