Live data from Hacker News

Show HN: I discovered a trading algorithm that returns ~24.85% annually

github.com

41–50 of 134 posts

Re: Show HN: I discovered a trading algorithm that returns ~24.85% annually

#41
post #21
post #14

Earlier quoted context omitted.

Overfitting, even on a 20 year dataset.

Interesting My ML knowledge is somewhat rusty... does overfitting occur more often on models with many input parameters (ie.. neural networks). His algorithm seems very simple, without really using ML at all, it's more of just a procedural 1-2-3 step thing, with no actual learning. Can you explain how overfitting works into his algorithm?

There's no overfitting in the traditional/model sense here. This is a pretty rudimentary momentum strategy (long best performers). Implementing this on any kind of scale would be expensive to trade since it rebalance's daily.

For momentum, Jegadeesh-Titman paper is much of the foundation for these types of strategies, if you're interested. But as others have pointed out, the "smart money" saturated this trade decades ago.

Re: Show HN: I discovered a trading algorithm that returns ~24.85% annually

#42
post #21
post #14

Earlier quoted context omitted.

Overfitting, even on a 20 year dataset.

Interesting My ML knowledge is somewhat rusty... does overfitting occur more often on models with many input parameters (ie.. neural networks). His algorithm seems very simple, without really using ML at all, it's more of just a procedural 1-2-3 step thing, with no actual learning. Can you explain how overfitting works into his algorithm?

There are still parameters here.

On {day/week/month} n, determine which {n} product(s) of {product brand}'s {product type} of {underlying asset type} gave the {highest/lowest/some of each} return.

At n + {a number} {days/weeks/months} go {short/long/some of each} at {market price/limit price} at {market open/market close/time in day} the previously identified securities. Close your position on day n + {a number} afterward at {market price/limit price} at {market open/market close/time of day}.

Re: Show HN: I discovered a trading algorithm that returns ~24.85% annually

#43

Earlier quoted context omitted.

It is a mean reversal bet. It can work. But what if one of the ETFs goes to zero? Then the algorithm will continously buy that all the way down. Erm - edit - scratch that: But what if one of the ETFs goes to the moon? Then the algorithm will continously sell that all the way up.

As I read it, the strategy never goes long -- it's always simply short one ETF. The bad cases look like "one sector consistently outperforms", or "leading sectors have bull runs of consecutive days before losing steam".

Sorry guys - it should have said: All the way to the moon.

Re: Show HN: I discovered a trading algorithm that returns ~24.85% annually

#44
post #29
post #6

Earlier quoted context omitted.

I decided not to add trading commissions because most brokers have removed them after Robinhood entered the market.

Short selling, though, incurs an additional borrowing cost. That's been going up for ETFs since 2020. "The price of short-selling U.S. exchange-traded funds has jumped dramatically since the beginning of March as investors seek to stem heavy losses in the wake of the coronavirus epidemic, according to data from S3 Partners."[1] This needs to be re-run with the borrowing costs added. The fact that EFT short selling co…

If you paired it with a "long everything" strategy (to reduce risk or whatever -- fewer eggs in this basket) the net strategy is something like "buy everything except yesterday's top performer", which can be done quite cheaply. Though fees on sector ETFs are high relative to broader ones.

Re: Show HN: I discovered a trading algorithm that returns ~24.85% annually

#45
post #30
post #15

Earlier quoted context omitted.

Another issue is that once the algorithm becomes known, and used be many people, it will not work any more.

It would eventually fail to perform even if it was kept secret.

Right on point -- it's called "alpha decay".

Re: Show HN: I discovered a trading algorithm that returns ~24.85% annually

#46
post #41
post #21

Earlier quoted context omitted.

Interesting My ML knowledge is somewhat rusty... does overfitting occur more often on models with many input parameters (ie.. neural networks). His algorithm seems very simple, without really using ML at all, it's more of just a procedural 1-2-3 step thing, with no actual learning. Can you explain how overfitting works into his algorithm?

There's no overfitting in the traditional/model sense here. This is a pretty rudimentary momentum strategy (long best performers). Implementing this on any kind of scale would be expensive to trade since it rebalance's daily. For momentum, Jegadeesh-Titman paper is much of the foundation for these types of strategies, if you're interested. But as others have pointed out, the "smart money" saturated this trade decades…

Interesting... what do you mean by this bit?

> Implementing this on any kind of scale would be expensive to trade since it rebalance's daily.

Re: Show HN: I discovered a trading algorithm that returns ~24.85% annually

#47
post #10
post #9

What software do you use to implement algorithms like this? Do you have to write your own python/other scripts and interact with trading API's for whatever service you use, or are there nice pre-written open source trading algorithms that make building stuff like this easier.

I just downloaded historical data on Yahoo Finance and parsed the CSV files. There are definitely more efficient ways to do this.

Does the endpoint on Yahoo Finance just download the CSV file? Could use a node HTTP fetch go nab the latest CSV, check if it's new, if it is throw it in the data set then run the algo.

I'm not familiar with Yahoo Finance so I'm not sure how feasible this is.

Re: Show HN: I discovered a trading algorithm that returns ~24.85% annually

#48
post #42
post #21

Earlier quoted context omitted.

Interesting My ML knowledge is somewhat rusty... does overfitting occur more often on models with many input parameters (ie.. neural networks). His algorithm seems very simple, without really using ML at all, it's more of just a procedural 1-2-3 step thing, with no actual learning. Can you explain how overfitting works into his algorithm?

There are still parameters here. On {day/week/month} n, determine which {n} product(s) of {product brand}'s {product type} of {underlying asset type} gave the {highest/lowest/some of each} return. At n + {a number} {days/weeks/months} go {short/long/some of each} at {market price/limit price} at {market open/market close/time in day} the previously identified securities. Close your position on day n + {a number} afte…

Ah ok, interesting. Thanks

Re: Show HN: I discovered a trading algorithm that returns ~24.85% annually

#49
post #34
post #26

Earlier quoted context omitted.

If you really want the answer to this question on your own, try out his algorithm and you will see what happens. Either he's right, and you make the suggested returns in a year, or he's wrong and you slowly realize why. It will be a learning experience. Don't take anyone's word for it.

To do that would be to presume I doubt the validity of your claim (I DO believe what you said). I specifically asked how overfitting applies to a simple procedural technique, rather than a multi-dimensional method like a neural network. Trying myself, and losing money, doesn't explain how overfitting applies to procedural steps (as I said, my ML is rusty)

I find people start learning things very quickly when they start losing money.

Re: Show HN: I discovered a trading algorithm that returns ~24.85% annually

#50
post #11
post #7

You did not discover a trading algorithm that returns ~24.85% annually. You massaged an algorithm until it produced a 24.85% annual return training on historical data. Come back when you are ready to claim you have made ~24.85% per year with an algorithm you created 5-10 years ago. Deny it, Downvote it: Destiny still arrives.

Serious question: I fully understand the idea of historical algorithms being no true indicator of the future. With that said....... If an algorithm consistently performs over 20+ years of data (through multiple black swan events, multiple major events), then why is it not safe to assume it likely will continue going forward? Wouldn't 20 years of "evidence" be a huge amount, such that future events likely wouldn't dev…

This is the layman’s explanation I was given to me by my finance professor in college:

In the extreme: If you take completely random price fluctuations and plot them on a graph then review them, they are no longer “random” - they become fixed because they’ve been recorded. It becomes possible to look for patterns, of which there will always be some (that’s the nature of randomness). It doesn’t matter the time scale. So your system that works over 20, 30, 50 years of past data is just fitting to the randomly-generated but not-actually-random once recorded set of data. From now into the future, the randomness will re-emerge and the system will fail.

Another way of thinking about it: imagine you click a button to generate a random time series over 20 years, then build a trading algorithm based on that single click. Great - it works! Now click again and regenerate the entire series and see if it still works :)

Post reply on HN