# Analyzing the crypto market with Python

in python •  last year

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.

## 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?

The 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 notebook.

## 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 Order:
·  last year

You should havea look at www.bittwenty.com.

It's a crypto currency index fund of the top 20 crypto. The index have a monthly revison, you will probably enjoy the information ;)

·  last year

This took me several days but I was able to calculate the top performers by market cap over the last year. small cap crushed it!!

Thank you for your insight on portfolio management!
Best,
Isaac

·
·  last year

Really interesting.

·
·
·  last year

Certainly!

For someone not understanding how blockchain technology works, this might seem like navel-gazing and building a "useless tool" and investing in "useless coins", just for the sake of it.

Where does the value come from, right?

For someone understanding what blockchain innovation means, it shows how 'permisionless innovation' is also coming to the world of finance.

·
·
·
·  last year

Where does the value come from? Haha! I love that one.

I think nowadays people that ask me that question I'll ask them where does the value of money that government print and can print as much as they like, where does the value of this enchanted paper comes from?

It's so good to be part of this cryptocurrency revolution. It's so freeing.

·
·
·  last year

Thanks @teamsteem, let's keep pooling the wealth of knowledge together!

·
·  last year

This is by far one of the best analysis posts out there for the cryptocurrency community. Right on brother time to execute your random coin strategy. Even if the market tanks in the long term this is typical buffet style buy and hold, absent the inside info and the massive leverage haha

·
·  last year

I'm gonna have a go at this!!

·
·  last year

Hey Isaac! Awesome presentation here and very good insight. Lately, I had been thinking there has to be a sweet spot for coin market cap and it looks like it is clearly 10-100mm. May I ask where you got your data? I'd love to take a look at this myself? Thanks!

·
·
·  last year

Sure thing I used the historical snapshots on Coinmarketcap.com and then went to work crunching it if different ways to get the results I wanted.

·
·  last year

That looks very nice, something I've been thinking of doing with market cap info from coinmarketcap. Have you finished the spreadsheet. Any chance we can take a look at the whole sheet. Thank You!

·
·
·  last year

I could email it if you want a copy. This is what I am doing full time now having turned down my job out of college. So I need to find fair ways to get compensated for the work I do hope you understand. If anyone wants to send 1 SP or SBD with their email in the memo I would be happy to email them my sheets of excel research.
Best,
Isaac

·
·  last year

I agree - small cap crushes it. Well done @furion on a great post.

This post got me thinking What happens if you invest \$1000 into crypto and leave it for 1 year? It's easy enough to find out. I'd love to hear others thoughts on their top choices over the next 365 days.

·
·  last year

Nice, you are right and the small cap coins still do. If you have the data can simulate it with crystal ball, and lets see.

Regards

·
·  last year

How can I increase your picture so I can see details I just see a small pic but it's not large enough for me to look at details. Thanks.

·
·
·  last year

I am not sure on the esteem app is one way it show up better so you can read it

·
·  last year

very very interesting. when you invest, do you normally buy and hold or do you trade? if you trade, do you use any anomaly detection algorithm that classifies the detected anomaly into a buy or sell signal? Great stuff - keep your posts coming Isaac

·  last year

thanks for the post,

I have been doing similar experiments. This momentum strategy can work as long as there is inward capital flow. which we could expect for a while because people are still learning about block chain.

yes the experiment of top coins with "survivor bias" does not mean anything. but random portfolios are very interesting and tells us some things..

I did paper trade a momentum strategy for 3 weeks.

1st week high cap coins did well. low cap was around -10%
2nd week all the portfolios generated more than 50%
3rd week which was just 1 week before until today, (I also do rebalancing during tuesdays) low caps profited around 10%, high caps were around -5%.

which means yes low caps can return more.

I was thinking about publishing results and live trade it some day. as far as I know I can share my own positions and that would not constitute as trading advise. I got 30x and 6x in my experiements with different cap sizes.

lastly, I would be also very interested to see how the "buy low, sell high" strategy works.

·
·  last year

Interesting strategy findings. I'd love to learn more. But just a simple strategy of buying and holding seems to prove a really good return in a year for those who don't have the time to stay on top of trading. I really like the back history comparisons of what could have been if you had done BLANK.

·  last year

This is a very interesting project. Developing trading strategies is a lot of work, especially back-testing, thanks for posting your findings.

In your last two charts, it definitely looks like Steem is the only coin that hasn't gone totally parabolic yet; it's sitting at the BTC line. I hope that means there's plenty of room for it to run.

·  last year

Your strategies seem to be following the trends. It would be interesting to test 'buy the dip' strategies, eg:

### Strat 1

Filter: Top 30 coin over last 26 weeks (i.e. quality)
Action: Sell when price rises 20% above average price movement of all other quality coins.
Buy when price falls 20% below average price movement of all other quality coins.

### Strat 2:

Filter: Randomly choose 20 coins from top 100
Action: Same as strat 1 (to test difference)

·
·  last year

I think trading volumes for the top 100 alt coins whether they are gainers or losers give a good indication of potential. I agree with you

·  last year

Every strategy is going to work in the market that you made a strategy for, now once the market changes you will have to develop a ​strategy for that market, it is never ending circle.

·
·  last year

Indeed. I think the trick is in building a portfolio of robust strategies that can adhere to different market conditions.

·
·
·  last year

So you're actually talking about some sort of AI portfolio :)

·
·
·
·  last year

It is an interesting idea and it is already being done by many investors in other markets and possibly in crypto as well. But it is really a neverending cycle of upgrades and adjustments.

·  last year

I really like your recreation of the monkey experiment. It shows the enormous deviation in returns in such a short period of time. (And the recent bull trend, every portfolio has positive returns?!)

I'm not a fan of market timing, especially with backtesting. At first glance, it always seems that a 'golden rule' or 'perfect trading strategy' exists. But when you backtest on a different time period, it suddenly doesn't work. However, I'm often tempted to try to time the market, so every once in a while I like to go back to Vanguards investing guide: https://personal.vanguard.com/us/insights/investingtruths/investing-truth-about-emotion
If you play around with the interactive chart you can see that small changes have a big effect and that overall, it's hard to beat the market.

Don't think that I didn't like your project though! Love it, just don't like market timing. ;)

·
·  last year

I think that's the beauty in price point smoothing (aka buying incrementally over time), and finding low cost options with baskets of securities

Another reason why letting the Winklevii get their ETF would have been a helpful investment vehicle

·
·  last year

Thank you for that Vanguard link, a great read right there.

·  last year

Do you think that your model would benefit from incorporating some qualitative factors in to its framework. IE the history of the founders, their success on other projects ? The educational background of the founders and so on. At this point any crack pot who knows how to copy and paste can create their own crypto currency, with that being said, the ones that are most likely to succeed will be the ones who invest heavily into intellectual resources and human capital.

·  last year

loving this stuff

·
·  last year

push! such a great article!!

·  last year

Always nice to see visuals of what could have happened.

·  last year

What a super cool project you are on and I bet your trip only finds itself even more exciting by the results!?!

Thanks for sharing this knowledge with us, it is appreciated, Namaste :)

·  last year

Interesting strategy. What is the annual turnover? I like the way you take proffit!

·  last year

I have been really intrigued by the recent crypto market rise the past 2 months and I'm developing am interest to trade some on @poloniex and see if i can get a decent gain i will go in with just \$10 for starters

I'm a simple minnow so i can't go all in on huge amount of money

·
·  last year

Well, as you can see from the first chart, even small amounts invested in some of the top coins could be very profitable! Good luck! Don't put in anything you can't afford to lose.

·  last year

What's also important is its current value in relation to the coin max supply. If a coin is relatively cheap, and I'm really talking about a coin under \$1, while simultaneously having a low cap max supply, say under 100M coins, then that means you have a very good asymmetrical risk. You can buy a shitload of coins if they are under \$1, while their potential is great. Low supply, high demand.

·  last year

I love data, and enjoy the way you show it. Any chance on https://steemdata.com/charts we can have more chance to play with the charts and go back in time plus get the raw numbers (without being a coder)?

·  last year

·  last year

If we can get STEEM in the news, we can get it over \$5 each.

Everyone should use this Media email list (3000+ contacts)
https://steemit.com/steem/@marsresident/how-you-can-help-get-steem-in-the-news-simply-using-your-email

And send them this:
http://www.reuters.com/article/us-currency-steem-idUSKCN0ZS2MF

·  last year

Very interesting, cool stuff brother @furion thank you. We are involved in a space like no other. People are catching on this year more than ever.

·  last year

This space is growing very fast and many people a missing a lot of opporunity. Do u imagine that 700\$ invested in top 7 crypto-currencies in 2016 will be valued at 32 000\$ today. Not trading a good way to win BIG in crypto. As a value investor, I do not trade and usually follow the legend Warren Buffet strategy. Best luck !

·  last year

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

With the fees involved that would become very pricey,No?

·
·  last year

Possibly. I don't know. I should be looking for integration with some more sophisticated backtesting / analysis framework, such as zipline.

·
·
·  last year

Is 6 months worth of backtesting even a statistically significant span of time?

·  last year

Great work and infos.
I'm a programmer, I appreciate double your work ;)

·  last year

Jesus....as depressing as this is, it's really well done. I wish hindsight wasn't always 20/20!! haha. Cool article though!

·  last year

Nice post my friend, I will test it in my conputer. Thanks for share.

·  last year

Congratulations @furion!
Your post was mentioned in my hit parade in the following categories:

• Upvotes - Ranked 5 with 889 upvotes
• Comments - Ranked 9 with 143 comments
• Pending payout - Ranked 3 with \$ 1482,01
·  last year

dont do buy and sell!! just DO buy HOLD and SELL soon
and buy good project not really promising but can solve a problem.
remember "SOLUTION TO A PROBLEM" are the best products/services in any successful business.

·  last year

Expected it would've been lucrative, but this is very indepth! Thanks :)

·  last year

Great work mate
I am your new follower

How I withdraw cash from a Bitcoin Cash machine atm

·  last year

Great info, re-steeming and upvoted!

·  last year

Glad to see a post from a data scientist on Steemit.

·  last year

Have you tested with a exchange bot?

·  last year

very interesting lecture. my first day on steem and already reading up excellent post. I am certain cryptocurrency are here to stay. Keep it up..following you already and hope you do same...bless you

·  last year

Very interesting strategy you have made. The thing is that the market changes rapidly and thus you have to develop the code and strategy to change with the market!

·  last year

Looks good analysis thanks

·  last year

IOTA coin in a matter of hours became the 6th biggest coin in market capitalization. Excellent investment opportunity like never before! And it is revolutionary because it is the first cryptocoin that does not use blockchain technology. http://coinmarketcap.com/currencies/iota/#charts

·
·  last year

Heres a good article giving an overview of how IOTA aims to be different http://www.tangleblog.com/what-is-iota-what-is-the-tangle/

·
·  last year

I think Byteball or digiball or something like that already uses a DAG, so IOTA isn't the first.

·  last year

Thanks for sharing. Indeed - could be promising for Steem.

·  last year

Thanks for the share. I may apply the strat on my next trading.

·  last year

i got stuck at basic html by the way, python sounds wizadry to me......

·  last year

Really interesting, why not make a bot for this strategy :D

·  last year

excelente post amigo, very good interesting your publication @furion

·  last year

this could be a little bit risky(though trading cryptocoin is risky).
what if a coin that you think would grow in the next on year suddenly crash, just like what happened to some compnies stock.

what if it suddenly loses it value in a years time bringing it to a price lower than the price you bought it the previous year.

what if the owner dies before that one year ,most cryptocurrency are not inheritable.

what if the value of your money (dollar,euros e.t.c)loses value.

all this makes it ineffective

·  last year

Trading cryptos is a game of luck currently. Long-hauls are different story. Thanks for this excellent analysis.

·  last year

nice work keeep it up (y)

·  last year

As a programmer, I haven't really shown interest in Python Programming Language. I went for VB and PHP instead. But after going through this, my interest in Python has been piqued. I'm picking up a tutorial in it

·  last year

Python is an interesting tool I have not had the opportunity to analyze 100% its potential but I am integrating integrally in your world.
Python is great.

·  last year

good post. thank you

·  last year

This is a really interesting read. Really got my engrossed! thank you @furion

·  last year

This is some great work , while we see some investments fail , great to see as a new member of steemit that it has not let us down . Investments are always for long run

·  last year

good posting!

·  last year

Very helpful, i'll try to apply this with my next trades thankyou!

·  last year

With the <20% share of my crypto that I dare to keep on an exchange, I spread it somewhat equally over around 10 different currencies. Just buy and hold, some re-balancing every once in a while. In hindsight I would sure have done better if I had always just held onto things.

·
·  last year

Same lol. Lesson learned: if selling, don't sell all of it, you never know what will happen!

·  last year

Awesome read. I've been trying to wrap my head around crypto currency and what its all about so it definitely helps to read stuff like this.

·  last year

great tips for trading in crypto currencies , and at the moments these type of well experienced tips and posts are required to gain some handsome income from top currencies.

·  last year

Sorry for somebody can help me I will be very grateful, after running my python code of a small project throws me this error and I do not know what it should be.

TypeError: 'NoneType' object has no attribute 'getitem'

·  last year

This is some good research! I was looking for something like this. Thank you!

·  last year

This is a great project.

·  last year

Very interesting project. Create a trade system takes a lot of work, but you are on the right path.

What is the annual turnover? I like a lot the way you take proffit!

I also did some tests, we can share knowledge. Crypto market is the future.

·  last year

u rock yes this is a super bias strategy. did you use pyplot? also, what about accumulate after a major correction.. I would like to see that.. u rock rock rock .

·  last year

Oh cool! It looks like http://coinmarketcap.northpole.ro has historical data on all coins!

·  last year

Interesting analysis and strategy, looking forward to your next post covering it more in depth.

·  last year

Awesome article, I follow you

·  last year

Cool analysis, nice utilization of programming. Can you cook something up for alt coin day trading short term periods?

·  last year

I could have been a millionaire if i invested 10\$ in btc in 2012

·  last year

I like it i thing Dash or Lite coin doing best

·  last year

thanks follow me upvote me.. inturn i will follow you upvote you

·
·  last year

I seen you next to my comment, always down to help a guy trying to come up in the world. Consider yourself followed, not a whale here but I am a full timer who helps out in the community so if you need anything let me know. Gotta give it to the guys trying to come up in Steemit, know how that is.

·  last year

Pretty interesting Stuff , i am just getting into cryptocurrencies i am doing alot of research i have a couple of bitcoins to invest in alt coins(longterm) i am very optimistic about the future !

·  last year

Really sophisticated, but thanks you simplified it @furion

·  last year

A beautiful strategy, it's worth taking the risk. Beautiful work! @furion

·  last year

Super cool. Im printing this. Ill be in touch soon with results.

@watchout

Domi
upvote max

·  last year

wow, It's new point of view in invest coin

I keep watching your post THank you ^^

·  last year

interesting
i ll try it out

·  last year

Thank you for this explanation, I just got involved in trading currencies a week ago (BTC and ETH), had more luck with one than the other :p but i'm very interested in trading strategies like the one that you described. @furion If you have any more info for "begginners" or where to find it, It will be much appreciated. Great post by the way!

·  last year

Nice strategy...

·  last year

Nice write up! very Informative while staying visually stimulating!
DESPERATE PLEA 4 HELP!
I need some MINNOWS and WHALES to Help!
Lets prove my WIFE wrong! :)!
https://steemit.com/story/@justcallmemyth/lets-prove-my-wife-wrong-she-thinks-steemit-is-fake-minnows-and-whales-unite-plus-custom-gif-giveaway

(Like The Gif? View The Blog For More) (Free 2 Use)

·  last year

Great Write UP! Can't wait for more..
Got approved few hours ago, enjoying it already.

·  last year

Good strategy.

·  last year

Furion! Thank for posting!

This is a interesting post here!
Currently I am part time forex trader and hope to develop more automatic trading using codes.

I am sure I can learn some techniques regarding python code or trading idea.

Keep the hard works. Definitely will follow your posts.

·  last year

This is an interesting project, a lot of insight. Not sure whether it would be good to diversify one's portfolio in multiple coins or simply stick to the big ones (BTC and ETH) and invest around \$100 a month.

·  last year

you're analyzing good, just don't neglect hat bitcoin currently has less than 10 million users so far. what does that tell you when you now? It means that the Federal Reserve is buying their product (actually selling, but at an expense) at \$2, and selling those same bonds at 25 cents?

Can you fucken believe what they are doing to us while getting rich out of our nine to five routine? this is bullshit, and that's why I am on the front line fighting them today.

·
·  last year

From which source did you got to know that there are 10 million users ?

·  last year

Nice artice, I Have resteem it on my timeline. Take a look to my channel if you want;)

·  last year

Don't mind this comment. This is for me to reference back...

I am still very new to Crypto and would not mind a mentor.

·  last year

Hello.Thank you for your useful information.^^
Have a nice day today.

·  last year

Very cool post! Very empowering kind of posts.

·  last year

thank you for your information. very interesting data and graphs.

·  last year

Nice simple strategy . What's your reasoning for avoiding the top 10 coins?

·  last year

Interesting strategy you got here. Thanks for sharing ☺

·  last year

I'm curious to know. Did anyone of you follow this 30% up buy, 100% up sell half, 50% down sell all investing strategy?

What are your results? Loss or gain?

·  last year

Nice work thanks for sharing

·  last year

hi @furion can you help me starting in steem my local money is not convertible to usd

·  last year

Good job, interesting

·  last year

interesting facts

·  last year

Is it possible to apply this analysis to horse racing?

·  last year

Thanks man!! This post is gold

·  last year

thinking of long term investments is always better than scalping. Scalping needs expertise skills which involves risks. Long term investments are safe and might come out with profits after certain lock-in period(maybe self lock-in in case of crypto), but never gonna lose investment when diversified our investments. But need some expert like you to say which one will do good in future, done well in the past.
Thanks for the sharing @furion. Very valuable information.

·
·  last year

I agree with this comment. I also have learned that long term investments usually gives best results.
I also appreciated this article, and learn a lot from it.

·  last year

Superb post. I am teaching myself Programming for Data Analytics in Python and R these days, so great motivation to see how I can apply it to my crypto-trading :)

THank you for posting this!

·  last year

As a new guy to this, this was fantastic. Thanks

·  last year

Analysis is good, but remember this is crypto... where a good meme can 10x a company's value lol

·  last year

Thanks for sharing with us

·  last year

This is fantastic @furion. Thank you for sharing this

·  last year

Invest in ETH it is soon going to \$450+ . currently around \$380 .
Already made \$50 Profit in 6 Days.
![]()