Analyzing the crypto market with Python

in #python7 years ago

 I am currently on a trip trough Europe, and I have met some interesting individuals whom have recently realized large gains in crypto. I've decided to spend the weekend writing some code to help me learn a bit more about investing/trading in this space. As a bonus, I have also hacked together a simple trading strategy.

Requirements

What if I invested $100 in every top coin a year ago?

I would have about $140,000+ right now. That is an insanely good 14x yearly gain, most of which has been materialized in the past 2 months.   

What if I invested in 10 random coins a year ago?

Picking top coins has some survivor bias built in, so I've wondered about how the random portfolios would do (think Dr. Malkiel's Monkeys experiment). Here is an example of 15 portfolios comprised of 10 random coins, yielding $30,000 to $400,000 in returns.  Feel free to tweak the params and generate more portfolios on your own.

Which coins did the best?

Tnotebook. he variance on returns of different coins can be quite large, for example, here are returns on some top coins for the past 30 days.
To deepen my understanding of variance and correlations, I've built some interactive charts to display returns from different coins, as well as normalized returns versus an arbitrary benchmark (ie BTC).  

Please, feel free expand the size of the universe, and play with the chart interactively in your Notebok

 

Simple momentum strategy

The idea behind this strategy is simple - we want to buy the coins that are rising in value, and drop the coins that are not doing so well. I have picked the parameters haphazardly and I've avoided optimization to avoid the risk of curve-fitting.

Spec

We rebalance our portfolio weekly.Rules:

  • we can not initially buy more than 10,000 worth of coins
  • with each sell/trade, we re-calculate balance
  • no trade can be bigger than 1000 USD

Strategy:

  • if a coin goes up 30% or more in a week, buy it
  • if coin goes up 100% from last trade, sell half
  • if coin goes down by 50% in a week, sell all

Filters:

  • can't be top 10
  • must be in top 130
  • must have at least 1MM mkt cap
    The whole strategy can be succinctly described using a few helper functions.
     

Results

Before I go any further, I should mention that this strategy is very simplistic, and it suffers from serious biases/flaws. It is in my opinion not suitable for real-money trading, and I should explain why, and work on improvements for my next post.The results on trades from 2017 look promising, as the backtest of this system yields $73,815 in value (7x gain in less than 6 months).It would be good to know how does this strategy compare to buy-and-hold and random buy-and-hold strategies above. Well, it totally bombs, as we go nearly broke ($3438 of initial $10000). Maybe our strategy is only suitable for the recent market, or perhaps I have bugs in my code.
To be continued...



Source

Source code for data gathering/cleanup, analysis and the trading strategy is available here. Use at own risk (see disclaimer).

Disclaimer

This project is for educational purposes only. The code provided is not suitable for real-money trading, and comes with absolutely no warranty 

Sort:  

Brilliant post, thank you for share

Just upvote me :)
Thanks

It is great to see how different investing strategies compare with each other. We all hope to pick winners, but in a bull market even coins fairly far down the list can be lucrative!

Coin Marketplace

STEEM 0.19
TRX 0.12
JST 0.027
BTC 64828.66
ETH 3511.22
USDT 1.00
SBD 2.37