Hacker News new | past | comments | ask | show | jobs | submit login
Cryptocurrency Analysis with Python – Buy and Hold (romanorac.github.io)
89 points by HIP_HOP on Dec 26, 2017 | hide | past | favorite | 67 comments



Unless you can include the complete irrationality of the users fueling the crypto bubble to get rich into the statistical model, any statistical analysis of those prices will be misleading.

Traditional historical trend analyses of stock prices assume the market is somewhat rational. (but not 100% efficient, which is where money can be made)


It's not irrational. It's an asset whose price is rising. If you want to make money, it's a good asset to trade. Just avoid hodling the bag when the music stops...


If the assumption is that the price will crash, then every dollar made by someone on bitcoin is a dollar lost by someone on bitcoin, since the underlying asset had no intrinsic value at all. Given that there are a lot of people who have more resources than me, and can do better research and better market manipulation, I am pretty sure I have a better chance of being in the group that loses the money.


Long-term it is hard to justify a conclusion that cryptocurrencies will fail as a technology. It's too big of a leap forward in too many industries. Short term, bitcoin might move too slowly and be surpassed by a competitor, or big money might manipulate the market and take advantage of people who have no idea what they're doing. I see these as issues that will diminish and fade over time as the technology matures. The solution is to stay attentive, invest with caution and hold on through the booms and busts. Not hard to do, all said and done, though I understand why many fear it.


Cryptocurrencies generically, sure. Permissioned blockchains are going to be huge. Medium to long term, decentralized validation mechanisms are going to get hit hard by double spends, and decentralized currencies will fall drastically when that happens.


Considering banks have taken to use ripple, crypto obviously has it’s place. Bitcoin doesn’t really seem like it’ll have much of a future though.

Well unless people keep pretending the naked emperor has clothes, which they might.


> Just avoid hodling the bag when the music stops...

and how do you know exactly when the music has stopped?


It's easy to tell when the music has stopped. The hard part is anticipating the stopping.


Is it that easy? The Nasdaq bubble took roughly 6 years to inflate and 3 years to "pop". The real estate bubble took about 11 years to inflate and 6 years to fully deflate. Even Enron took the better part of a year to fully deflate.

Maybe balloon is a better word than bubble.


People who can't tell it has popped are the ones keeping it on life support for years. :-)


What do you think of the "buy low, sell high" strategy? ;-)


I've told people to buy at $3,800, $5,900, and $14,000 and got shouted down each time. All of these were after major crashes, so of course the price was about to bounce back.

Even if you know when the music hasn't stopped yet, it's very hard to get anyone to listen.


For what is worth, I also thought that ~5500 dip in mid november was a good time as well. I wish I had money in the exchange that weekend because it quickly recovered days afterward.

The recent dip was scarier though and time will tell whether we are still on the rise or just a temporary recovery.


A friend and I used to joke that a crash was a sale. Stock up while supplies last!


Oh boy... I told my dad to buy at $8, $27, $200, $2000, $3000, $6000, and $12000. None of these times has he actually taken any action. :(

If only I turned 18 a couple years earlier...


Your dad is a wise man!


On the other hand, if he had put in $8 at $8, he'd have $16,000 today.


It's easy to see in retrospect that the beginning of bitcoin would've been a good place to throw in some meaningless quantities of cash, but I think once you divide by the number of small, potential investments you could make that wouldn't have made you money, and subtract the amount of time commitment to keep track of those investments, the outcome is less appealing.

(Obviously, some people knew it was about explode, but I'm looking at everything you hear your kid, or a co-worker giving you hot tips about, which was the boat I was in and it sounds like this kid's dad was in).


Buying at $8 would be easy. Not selling at $200 would be hard. Not selling at $2000 would be even harder.


Good question. Many thought the music had stopped in 2014, when the price crashed from $1200 to less than $200. (Previously in 2011-2012 it crashed from $35 to less than $2, which was pre-ASICs, so you really couldn't mine at a profit)


It crashes during scandals like Mt Gox, and the big crash will come when a major nation-state decides to crack down on it.

Full disclosure: I don't own any Bitcoin, but I own other cryptocurrencies.


When you’re broke.


a lot more people sell than buy cryptocurrency


How would that work? Any coin that is bought is also sold, so you're saying that the buys come from a few people buying big amounts? But all those sellers were buyers at some point...


buyers are willing to trade USD for more bitcoins. the price might never go to zero, but it will approach it.


Are you sure it's complete?


if Gold can be irrational for 2k years, I don't see why not bitcoin can't, the only think gold has going for "longer history", yet HN folk love to say "past performance are not an...bla bla", yes it also has the 5% - 10% industrial use, but bitcoin has that too by being able to transfer it without third party, so will also not go to zero because will be useful as transfer of value.


Well ~78% of gold is used for jewelry and only ~19% is used as a store of value:

https://goldprice.com/facts-about-gold


Jewelry and "store of value" are not mutually exclusive uses. Lots of people would buy "store of value" gold in the form of a nice necklace rather than a lump of metal.


Gold has a price floor because it has some industrial utility and is useful for making jewelry.

All that has to happen to destroy bitcoin is a flaw in the implementation.

Seriously, look at OpenSSL and tell me the same issues aren’t possible in bitcoin.

When did we get so trusting of software that we decided it’d be a good idea to base currency on a distributed algorithm?


The project can always fork if major issues are found.

Bitcoin is very very far from a perfect solution, but it is a solution to many problems currencies have.


Given how hard it is for the community to do something as simple as increase the block size a tiny bit, I'm not confident that a fork could fix such a problem.


making jewelry is in the store of value spectrum, with only industrial use, would be at 5% - 10% of current price.


Aren't 'miners' the third party?


At our local Chicago Python User group chapter (chipy.org) one of the organizers of the Financial Group did a similar analysis. HODL is extremely hard to beat if not impossible.

See https://github.com/Chipy-Finance/CryptoTechnicals/blob/maste...

https://github.com/Chipy-Finance/CryptoTechnicals/blob/maste...

There is more in the github directory also.


thank you. Gonna look at it


I ran some tests of my own with simulated automated trading strategies over the past few years of historical Bitcoin price data. I used a genetic algorithm to encode a range of time parameters for MACD, along with different trading triggers and amounts. After a day or two of running it against a huge number of permutations and generations optimized for highest overall return, I came to a similar conclusion: the fittest configurations could do fairly well in automated trading (the more active ones were highly sensitive to trading fees [which were simulated] and market depth [was not simulated]), but over the span of more than a few months, a simple buy and hold strategy produced better returns in almost any time window.


Depending on the automated strategy, they can dramatically reduce risk though. That has value well beyond the simple return of buy and hold, where if you don't time the sell perfectly, it's all useless. I think that's the big advantage automated trading strategies can have if designed well.


Yes - I found that to be true in my testing as well. The configurations optimized for highest absolute returns did very poorly in unfavorable market conditions (and max drawdown became significant), while there were some that performed moderately well and were much less affected by downturns in the market. Like most investments, it really comes down to the same thing: risk vs return.


Reduce risk but also involve more time and energy.


Not really for an automatic trading algorithm. Write once, use for quite a while. Say a week of work (40 hours) for returns say 1/10th of holding is still quite worth it. Both of those numbers are quite conservative.


Not to be rude but I stopped reading at "MACD". TA is not the go-to strategy in stock trading for a reason. Indicators like MACD, RSI, Bollinger Bands etc re-paint a lot. So the perfect signals everyone sees on the charts are, for the most part, are just "profitable system" mirage.


Thanks. The conclusions may be obvious to experts in algo trading (and I heard similar things about the problems of TA for stock trading prior to doing this), but it was educational for me to go through the exercise because (1) it confirmed to me that the crypto markets behave similar to other markets, and (2) it helped me understand exactly where and how a technical indicator like MACD falls short for making trade decisions.

Before trying it myself, I was somewhat skeptical when reading about how these indicators don't work well. The overlays on charts always looked like good buy/sell indicators, so I didn't really understand why they couldn't make for a good algorithm. Only after trying it myself did I gain insight as to why they don't actually work so well.

I guess it's better to learn the hard way than to learn the hard-and-painful way with real money ;)


It isn't clear to me why technical indicators aren't viable.


> Only after trying it myself did I gain insight as to why they don't actually work so well.

Would you care to elaborate on which indicators you tried, and what happened?


From my experience with MACD specifically, it basically came down to the fact that with longer periods (or less sensitive thresholds), you lose out on most of a price swing by the time your trigger fires, and with shorter periods (or more sensitive thresholds), you end up making a lot of trades that don't move the needle (can also rack up significant fees if you aren't careful). You can find something reasonable in the middle, but by doing so, you're decreasing both risk and potential returns.

There are at least two other important considerations apart from the indicator itself: how to actually execute effectively with limited funds (when your trigger fires, do you trade everything you can, only a certain percentage, or some variable amount based on technical factors? - that's an entirely separate algorithmic rabbit hole); and even if you do find a good algorithm and it performs great in backtesting historical data, it's almost always harder to achieve the same results in real market conditions (it's difficult to simulate the spread and dynamics of limited market depth).


What is an example of a "go-to strategy in stock trading"?


1. Buy undervalued groups of stocks 2. Hold on to them for a few decades 3. Profit.


TA is "Technical Analysis", according to Google. You're telling me those indicators are NOT used by rules-based traders in the stock market?


The reason TA is a bunch of malarkey is because if somebody could simply look at a chart to predict future price movements than everybody else would do it to, making such prediction worthless. Same is true of anything else that is public knowledge. Once everybody has that knowledge, you lose the ability to profit off it.

It is one of the core foundations that underpin up modern finance (something that Bitcoin advocates would be keen to learn about...) - see also [Efficient Market Hypothesis](https://en.wikipedia.org/wiki/Efficient-market_hypothesis), [Modigliani and Miller Capital Structure Theory](https://en.wikipedia.org/wiki/Modigliani%E2%80%93Miller_theo...), or the [Modern Portfolio Theory](https://en.wikipedia.org/wiki/Modern_portfolio_theory).

In short, TA has refuted time and time again. It's complete garbage used only by amatures.


I can't argue on merit, and I agree that if everyone used it, it would be worthless. The insiders and professional market researchers would do best, then the group who uses TA, then the buy/hold crowd, then the shoot-the-rabbit sell-low-buy-high group.

I don't think TA is complete garbage, but I agree it's not a fundamental.


Is that another way of saying "the bubble hasn't burst yet"?


Well, the data did include Bitcoin's first rise above $1000 and subsequent crash (which most people called "a bubble"). If you had bought right before that one "popped", yes - you would have waited a while to be back in positive territory, so that's one time window where you might have lost money compared to the algorithm, but only if you were impatient.


I find this an impressive fit, did you come up with it on the spot or did you read about strategy simulation somewhere else ?


This may be a bit pedantic, but the phrase the author uses in his disclaimer "Experts agree that cryptocurrencies are a bubble." bothers me because it's kind of misleading.

The actual fact at hand is ~96% of economists think that the crypto market has been subject to a massive speculation bubble as of November. While that's sort of close to Roman's disclaimer, there is some nuance that ought to be given, since a) 4% of professionals dissent, and b) the question asked of economists had a temporal element to it, and they might have answered differently if the market hadn't tripled in value in as many months. It's the difference between 'the housing market is in a bubble currently', and 'housing is a bubble'.


there is some nuance that ought to be given, since a) 4% of professionals dissent, and b)

That's roughly the same % of professionals that I've heard dissent about global warming, yet dissenting about that will get you labeled as stupid and/or corrupt. So what makes it worth calling out for nuance here?


I agree, I just wanted to make sure some noob doesn't think he'll invest and make a guaranteed profit.


Don't work with closing prices for statistical analysis. Work with returns (really log returns). This would have simplified some of the code, and made the plots in the same units rather than requiring separate axes.

More detail: https://quantivity.wordpress.com/2011/02/21/why-log-returns/


What do you mean by those plots currently have different units? Don't they consider the price in dollars as the unit?


They have the dollar as a unit, just y-axis scale is different. For BTC is from $4000 to $20000 and for LTC is from $50 to $350. This is a useful technique to check if curves move together or not.


Thx... I intend to use it next time. This is going to be a series of blog posts about cryptocurrency analysis.


It's an open secret that "buy and hold" is hard to beat.

This is the reason why ETFs and other unmanaged asset options have become so popular in recent years.

But that insight is not new. The phrase "time in the market beats timing the market" goes way back and also popular stock market participants like Buffet or Kostolany have been saying this for decades.

With regards to cryptocurrencies, we are seeing in a condensed time frame the same development that for example the stock market went through. Cryptocurrencies might become a new asset class but that doesn't mean that it works financially differently than the other asset classes. So it should be no surprise that the same trading strategies end up being the most profitable.


My next step is to implement strategy testing. I would like to end this series with a classifier that predicts buy or hold.

Follow me on Twitter to get the latest updates: https://twitter.com/romanorac


A classifier that flips a coin would probably have higher accuracy.


Give the coin a bias towards long and you've got a winner!


I am going to try. I am not saying I developed it.


I think you meant HODL.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: