whittlem / pycryptobot

Python Crypto Bot (PyCryptoBot)
Apache License 2.0
1.97k stars 738 forks source link

Portfolio Optimization by Calculating Sharpe Ratio and Auto-Rebalancing Portfolio #336

Closed i3creations closed 3 years ago

i3creations commented 3 years ago

Describe the solution you'd like As a trader, I would like my portfolio automatically re-balance how much is invested in each position so that I can maximize profitability and reduce risk.

Describe alternatives you've considered Currently manually re-balancing my portfolio using the Sharpe ratio similar to the article found here: Finding top crypto portfolios with Tensorflow and Matrix calculus

Additional context I have started to modify the code from aforementioned article to utilize the Coinbase Pro API here.

I imagine the process would be:

  1. On interval (time) trigger portfolio optimization
  2. Fetch from Coinbase Pro all portfolios with coin investments
  3. For each coin, fetch historical data
  4. Calculate Sharpe ratio for entire portfolio(s)
  5. Based on Sharpe ratio, transfer/move amounts from/to investments to match percentages

Requirements:

whittlem commented 3 years ago

This is interesting but sounds like a completely new application, probably similar to my Coinbase Pro Portfolio Tracker.

I don't think this can be implemented in the bot itself for a few reasons.

  1. The bot should only have the API keys for the portfolio it is working with (adding APi keys for all portfolios may run the risk of mistakes)

  2. I don't want users to have to enable the Transfer permission on their API keys. It puts them at a lot of risk if the keys get lost or stolen. With that turned on their entire portfolio can be drained. At least if someone's API keys get lost now all that can be done is trading within the account itself.

Thanks for the feature request and I do like it but maybe a separate project. If you would like me to help you with this I'm more than willing to help but it doesn't fit well into this project.

i3creations commented 3 years ago

Agreed. I imagine it would run as a separate "optimizer" bot. How would you like to proceed as a separate project? It appears another developer is interested as well (see Telegraph chats dated 2021-06-16).