bankroll-py / bankroll

Ingest portfolio and other data from multiple brokerages, and analyze it
MIT License
60 stars 6 forks source link

The ETF Trick: Generate a series of returns given a set of instruments #20

Closed joshvera closed 5 years ago

joshvera commented 5 years ago

Added an implementation of The ETF Trick to model a set of instruments given a dynamic set of weightings. I've updated Portfolio.ipynb with example usage.

The resulting time series reflects the value of $1 invested in a set of instruments. The series is strictly positive and can take rebalance costs, bid-ask spread costs, and missing data into account, though some work remains to extend it to those use cases.

To extend this beyond cash-settled instruments, one can also model a basket of futures as if they were a single non-expiring cash product with this method, but I think we'd need another function to handle the rolls of those futures contracts.

This idea comes from Advances in Financial Machine Learning by Marco Lopez de Prado.

joshvera commented 5 years ago

I 🍩 know what that test failure is about.