[HN Gopher] Show HN: I discovered a trading algorithm that retur...
       ___________________________________________________________________
        
       Show HN: I discovered a trading algorithm that returns ~24.85%
       annually
        
       Author : Kibae
       Score  : 160 points
       Date   : 2021-06-06 17:29 UTC (5 hours ago)
        
 (HTM) web link (github.com)
 (TXT) w3m dump (github.com)
        
       | bionhoward wrote:
       | Sounds promising if true, and it's cool that you're working on
       | this. What happens when you paper trade with it? Test it going
       | forward and see if it still works, please make another post if
       | you do!
        
       | ryanmonroe wrote:
       | As others have said, "Average return is just one statistic". When
       | trading, losses hit harder than wins. Go up 50% then down 50% and
       | you're not even, you're down 25%. The degree of overestimation
       | from this mean return -> "annualized return" calculation depends
       | on what the returns distribution looks like.
       | 
       | Here's the calculation used in main.js line 77 applied to a very
       | extreme unrealistic example. I simulated 253 days of return
       | percentages from a uniform distribution between -5.5% and 5.6%,
       | and then the actual total return percent, calculated in R
       | set.seed(2020)         n <- 253         daily_gain <- runif(n,
       | -.055, .056)                  total_gain <- sum(daily_gain)
       | avg <- total_gain/n         annualizedReturn <- (1 + avg)^n -1
       | annualizedReturn         # [1] 0.2933685                  prod(1
       | + daily_gain) - 1         # [1] 0.1324846
       | 
       | Edit:
       | 
       | In reality the actual numbers are likely to be not nearly as
       | different as this example. I chose uniformly distributed returns
       | with a wide range to make the reason against this calculation
       | very obvious. Here's an example return distribution where there's
       | hardly any difference. Normal returns with average of 0.085% and
       | standard deviation of .05 i.e. daily_gain <- rnorm(n, .085/100,
       | .05/100) gives                   annualizedReturn         # 1]
       | 0.2414539                  prod(1 + daily_gain) - 1         # [1]
       | 0.2414051
       | 
       | For good measure here's one in the middle where your returns are
       | normally distributed with an average of 0.35% and a sd of .2%,
       | but then you have on average 10 bad days a year where returns are
       | 5 percentage points lower than that distribution i.e. daily_gain
       | <- rnorm(n, .35/100, .2/100) - rbinom(n, 1, 10/n)*.05 gives
       | annualizedReturn         # [1] 0.2712024                  prod(1
       | + daily_gain) - 1         # [1] 0.2490317
        
         | joppy wrote:
         | Is it normal to deal with returns over time as log-returns
         | log(R) rather than simple returns (R - 1) for this reason? The
         | average log return does the right thing.
        
         | hervature wrote:
         | Don't know why this is on HN front page given it is an error.
        
           | ryanmonroe wrote:
           | The wording in the original comment was too strong, I've
           | edited it. It's probably not best to consider it a plain
           | "error" since this calculation is actually a typical one
           | provided in finance. It's just that you usually look at other
           | stats too rather than _just_ this one, which gives you an
           | idea about its accuracy wrt realized return e.g. Sharpe, Max
           | Drawdown, Skew, Kurtosis
        
         | jiofih wrote:
         | Where do you take that uniform distribution from? I don't think
         | any ETF would conform to that.
        
           | whoisburbansky wrote:
           | > _I chose uniformly distributed returns with a wide range to
           | make the reason against this calculation very obvious._
           | 
           | The uniform distribution is a pedagogical choice, to explain
           | why OP's average return calculation is misleading.
        
           | [deleted]
        
       | happytrader wrote:
       | As previously said, this is probably just mean reversion. It's a
       | commonly used signal that appears to print money all the time,
       | until you take transaction costs into account. If you want to
       | have even more fun, try back testing this same idea on intraday
       | data. Your performance should look phenomenal, and your Sharpe
       | ratio should be well above 10.
        
       | hazard wrote:
       | There's kind of a lot of missing pieces here:
       | 
       | * This is a simple strategy, which is fine, but also means you
       | are not the only person who has noticed this. Why do you think
       | this makes money? Is there some risk you are being compensated
       | for, or is there some forced trading you're picking up the other
       | side of, or something else?
       | 
       | * Which of the common equity factors
       | (https://mba.tuck.dartmouth.edu/pages/faculty/ken.french/data...)
       | is your strategy exposed to, and by how much?
       | 
       | * What are the basic return statistics of the strategy, like
       | Sharpe and drawdown?
       | 
       | * How sensitive is the strategy to parameter variations? What if
       | you sell the second best ETF instead of the best? What if you
       | sell on day n+2 instead of n+1? What if you buy the worst ETF?
       | 
       | And about a dozen other things that you should look into before
       | you actually try trading.
        
       | MR4D wrote:
       | Clearly the author does not have real world experience with this
       | algorithm.
       | 
       | If so, it would be clear that buying anything at the opening
       | price is not easy.
        
       | joneholland wrote:
       | I'm amused that a node app was used to do this rather than a
       | Google sheet. The =GOOGLEFINANCE function is super handy for
       | building backdated simulations.
        
       | belter wrote:
       | Now add trading commissions :-)
        
         | Kibae wrote:
         | I decided not to add trading commissions because most brokers
         | have removed them after Robinhood entered the market.
        
           | verdverm wrote:
           | Taxes would be a good one to add
        
             | mypalmike wrote:
             | This would all be short term trading, so it would be
             | counted as ordinary income, which is bracketed.
        
             | hungryforcodes wrote:
             | If one of my algos makes money, I'm happy to pay.
        
           | throwaway4good wrote:
           | There is still a spread.
        
             | ucha wrote:
             | There is no spread when you trade at the open and the
             | close. There could be slippage (you can create a market
             | impact) but it would be minimal on sectorial ETF because
             | they are extremely liquid.
        
             | throwaway4good wrote:
             | And shorting is not free.
        
           | Animats wrote:
           | 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 costs have gone up indicates
           | that others are active in this space, which means the profit
           | opportunities for a simple algorithm have probably been
           | already taken.
           | 
           | [1] https://www.reuters.com/article/us-usa-stocks-shorts-
           | etfs-id...
        
             | repsilat wrote:
             | 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.
        
             | panarky wrote:
             | There's no stock loan fee if you close the position the
             | same day.
        
       | xwdv wrote:
       | 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.
        
         | Grustaf wrote:
         | He's using one of the most basic and obvious algorithms in
         | existence, you can hardly call that "massaging".
        
         | Exuma wrote:
         | 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 deviate much from that...?
        
           | iamadog4 wrote:
           | January effect.
        
           | Grustaf wrote:
           | It's very simple, the best strategy for the last 20 years
           | (with hindsight) would be to buy the shares that have
           | performed best over this period, but it wouldn't work better
           | than chance going forward.
           | 
           | Obviously, sitting down and creating that "strategy" would be
           | silly, nobody would think that would work. But if you're
           | using ML or just test a million random strategies, you could
           | end up with something along those lines, a strategy that is
           | optimised for the particular paths stock prices took up to
           | know.
        
             | teachingassist wrote:
             | > the best strategy for the last 20 years (with hindsight)
             | would be to buy the shares that have performed best over
             | this period,
             | 
             | The best strategy doesn't seem to me to be straightforward
             | to calculate, even with perfect hindsight.
             | 
             | It might be to continually switch in the short-term most
             | profitable asset, after taking into account the transaction
             | costs and risks of influencing the market.
        
               | Grustaf wrote:
               | Sure, it's just an example. Let's say you're looking for
               | the best buy and hold strategy then, the point is that
               | what you actually want in the future is a strategy that
               | doesn't depend on the particular circumstances in the
               | preceding 20 years.
        
           | ffggvv wrote:
           | imo in market cycle terms 20 years isn't that long.
           | 
           | especially since market paradigms shift.
           | 
           | ie the last 20 years have been low interest rates, low
           | inflation, with strong secular growth in tech and stagnation
           | elsewhere, and globalization
           | 
           | this varies a lot from the 60s or 70s where there was massive
           | inflation, high in interest, etc..
           | 
           | we may be entering a new paradigm with the changes in fiscal,
           | monetary policy and globalism running its course
        
           | nlh wrote:
           | 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 :)
        
           | AS37 wrote:
           | Overfitting, even on a 20 year dataset.
        
             | Exuma wrote:
             | 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?
        
               | dmillar wrote:
               | 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.
        
               | Exuma wrote:
               | 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.
        
               | dmillar wrote:
               | Trading $100 vs $1000 vs $1M vs $1B worth of these ETFs.
        
               | Exuma wrote:
               | Oh, I see. I just looked at what rebalancing is. Thank
               | you, that is very interesting
        
               | AS37 wrote:
               | 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}.
        
               | Exuma wrote:
               | Ah ok, interesting. Thanks
        
               | 0-_-0 wrote:
               | I think you're right and overfitting certainly wouldn't
               | explain bad performance of this algorithm, you can't
               | overfit with such a simple strategy. The market can
               | change in response to discovering this strategy though.
        
               | quantumofalpha wrote:
               | Multiple hypothesis testing.
               | 
               | This particular attempt seemed to have succeeded. But how
               | many were tried that didn't? If you torture the data long
               | enough it will confess.
        
               | xwdv wrote:
               | 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.
        
               | Exuma wrote:
               | 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)
        
               | xwdv wrote:
               | I find people start learning things very quickly when
               | they start losing money.
        
               | Exuma wrote:
               | What a bizarre answer to a specific question, but thanks
               | for trying
        
               | seoaeu wrote:
               | The concern with these sorts of strategies is that you
               | might discover the problem _quickly_. Say for instance if
               | the stock you shorted doubles in value and you lose all
               | your money. Even if there 's only a small probability of
               | that happening in a given year, going bankrupt by
               | definition negates all the gains you got previously.
               | Worse still, when you short stocks it is actually
               | possible to lose more than your entire investment so a
               | strategy can work amazingly 99/100 times and still have
               | negative expected value.
        
           | elcomet wrote:
           | Another issue is that once the algorithm becomes known, and
           | used be many people, it will not work any more.
        
             | xwdv wrote:
             | It would eventually fail to perform even if it was kept
             | secret.
        
               | hungryforcodes wrote:
               | Right on point -- it's called "alpha decay".
        
           | praptak wrote:
           | No, because of the survivorship bias.
           | 
           | People invent many algorithms all the time. You only hear
           | about the ones which turned out exceptionally well.
        
           | dmillar wrote:
           | trading costs, liquidity, structural changes in the economy
           | etc. del prado's machine learning in finance book gives some
           | good insight into common backtesting pitfalls/thinking that
           | are present here. the "safe" assumption if you find a
           | systematic strategy that backtests well is that your actual,
           | go-forward sharpe ratio will print 50% of what your backtests
           | suggest.
        
           | Jeff_Brown wrote:
           | I don't know, but it surely depends in part on whether you've
           | published the algorithm. Once a strategy becomes well-known,
           | its gains are likely to be arbitraged away.
        
         | vmception wrote:
         | This is the right answer.
         | 
         | If anyone is interested in trading algorithms there are entire
         | communities that filter out random backtests that havent been
         | run live.
         | 
         | Check out QuantConnect
        
       | Majromax wrote:
       | Average return is just one statistic. You can earn an arbitrarily
       | high daily average return by taking an ordinary strategy (e.g.
       | buy and hold the S&P 500) and applying large amounts of leverage.
       | Returns will be great until the strategy blows up.
       | 
       | What was the volatility of this strategy? When backtested on the
       | historical data, what was the maximum drawdown? What happens when
       | trading costs or slippage (buying at the ask, selling at the bid)
       | are modeled additionally?
       | 
       | 252 trading days times two trades per day (short sell at open,
       | buy to close at close) is a lot of trades, and execution quality
       | will be very important.
       | 
       | Does this strategy hold up with week-long holding times?
        
         | jliptzin wrote:
         | He is trading Vanguard Sector ETFs, I doubt there is any issues
         | with execution quality or getting blown up by a rise in
         | volatility.
        
           | X6S1x6Okd1st wrote:
           | At sufficiently high leverage any volatility is high enough
           | to bring on a total loss
        
       | Exuma wrote:
       | 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.
        
         | asperous wrote:
         | There are cloud services which will run your trading
         | algorithms.
         | 
         | Here's one I found just with a google search:
         | https://alpaca.markets/
        
         | Kibae wrote:
         | I just downloaded historical data on Yahoo Finance and parsed
         | the CSV files. There are definitely more efficient ways to do
         | this.
        
           | droobles wrote:
           | 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.
        
           | pc86 wrote:
           | Since the question was "How do you implement this" I assume
           | they meant how do you automate the _actual trading_ , not how
           | do you run a backtest.
        
       | herpderperator wrote:
       | This doesn't take into account taxes. If you are consistently
       | profitable on a yearly basis you're expected to pay 100% of last
       | year's capital gains split into Estimated Taxes every quarter
       | going forward. That eats into your return if you're reinvesting
       | profits.
        
       | zucker42 wrote:
       | Over what time period was the 24.85% measured? This seems like it
       | would do better during time periods where stock prices are
       | volatile and/or not increasing, so if the returns were measured
       | over the last year, then results could be misleading.
        
       | EMM_386 wrote:
       | Many moons ago I ran a site called ETF Timing that automated
       | technical analysis against ETFs.
       | 
       | There is so much wrong with this I don't know where to start. But
       | this seems common these days, I think it's due to the influx of
       | inexperienced traders who have no proper statistical background.
       | 
       | I'll let ryanmonroe point out the first glaring problem with
       | these types of simple "algorithms":
       | 
       | https://news.ycombinator.com/item?id=27415821
        
       | ffggvv wrote:
       | var total = 0;                 for (var i = 0; i <
       | performance.length; i++) {              total += performance[i];
       | }            var avg = total / performance.length;            var
       | tradingDays = performance.length;            var annualizedReturn
       | = (1 + avg) \* 253 - 1;
       | 
       | }
       | 
       | I think this math is wrong. You cant just add the daily
       | performances up to get the total return. unless im missing
       | something.
       | 
       | Though seems like your "cash" variable is correctly calculated.
        
       | mgamache wrote:
       | Most mean reversion systems have a high win rate. But the profits
       | from wins are usually small and a losses are large. You have a
       | hard time avoiding losses because you have to let mean reversion
       | trades run and you can't have small stop loss settings.
        
       | Kibae wrote:
       | This is a simple trading algorithm I discovered that operates on
       | the Vanguard sector ETFs. This backdating algorithm provides on
       | average a return of ~0.0878% for each trading day, or ~24.85%
       | annualized return assuming 253 trading days per year.
       | 
       | ## The Algorithm
       | 
       | This algorithm is really simple.
       | 
       | 1. On day `n`, determine which ETF gave the highest return
       | 
       | 2. On day `n+1`, short sell the previous day's highest performing
       | ETF at market open and close your short position at market close.
       | 
       | Because this algorithm operates on Vanguard's 11 Sector ETFs, it
       | is resilient against the volatility of individual stocks.
       | 
       | ### Caution
       | 
       | Hindsight is 20/20 and because this is a backdating algorithm,
       | similar results are not guaranteed in the future. Use at your own
       | risk.
        
         | chasebank wrote:
         | I forked your project and added a financial metrics analysis
         | package.
         | 
         | .067 sharpe ratio, .11 sortino, largest drawdown was ~41%
         | 
         | Not very good numbers. Fun stuff though!
         | 
         | [0] https://github.com/maxto/ubique
        
           | jalopy wrote:
           | If there a link to your fork?
        
             | fullstackchris wrote:
             | all forks on GitHub are public, i took the liberty and did
             | some snooping, the only fork which had some new commits was
             | this one:
             | https://github.com/jesshowe/SectorTradingAlgorithm
        
       | TacticalCoder wrote:
       | It is great to see a trading strategy that actually make gains
       | while short-selling, during mostly bull markets. "Everybody looks
       | like a genius during a bull market". Short-selling is something
       | else...
        
       | paulpauper wrote:
       | Pretty smart. Tempt the reader with a 'killer' but incomplete
       | statrgy and make us do all the work to test it and find the flaws
       | so you don't have to. I am sure this is way too good to be true.
        
       | throwaway4good wrote:
       | The algorithm of just selling the best performing etf of
       | yesterday???
        
         | Kibae wrote:
         | Yup
        
           | throwaway4good wrote:
           | 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.
        
             | mypalmike wrote:
             | That is not what this algorithm would do.
        
             | repsilat wrote:
             | 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".
        
               | throwaway4good wrote:
               | Sorry guys - it should have said: All the way to the
               | moon.
        
               | throwaway4good wrote:
               | The algorithm has a buddy:
               | 
               | The algorithm of just buying the worst performing etf of
               | yesterday.
        
             | vmception wrote:
             | It will short it for one market day and then ignore it.
        
               | Closi wrote:
               | It would short for the next day too if the EFT was
               | growing enough.
        
       | ucha wrote:
       | There are so many misconceptions on this thread about what makes
       | a good quant trading strategy.
       | 
       | First of all, if you're shorting US equities and making 25%
       | annually, that would be awesome. Heck, even being flat would be
       | great because a strategy that is long SP500 could also short your
       | equities and be delta-neutral and likely have a much lower
       | volatility for the same return.
       | 
       | Second, so many people are mentioning commissions, trading fees,
       | taxes and so on. Commissions and trading fees are much less than
       | 1 basis point per trade if you use reputable brokerages. That
       | would, at most, amount to a 1-2% in fees per year. Market impact
       | matters but opening and closing auctions are very liquid and
       | represent respectively more than 1% and 5% of the daily volume,
       | probably even more for these kind of ETFs. Shorting fees are also
       | quite small, in the range of 0-2% for liquid ETFs. If you don't
       | hold positions overnight which is your case, you also don't pay
       | to short!
       | 
       | Finally, here's what really matters. Returns by themselves don't
       | matter. If you want a very high return strategy, you can short a
       | long VIX ETF like VXX but every once in a while, you will be down
       | more than a 100% ; it will bankrupt you if your available capital
       | is less than the value of your short. You also need to look at
       | your Sharpe ratio and maximum drawdown. Anyone somewhat
       | experienced could tell you if the strategy is valid by having a
       | look at plot of returns. If it's not too volatile, it could be a
       | good strat.
       | 
       | Edit: addressing shorting fees
        
         | yaitsyaboi wrote:
         | You seem to know your stuff about this. Do you know any good
         | starting points to learn about algorithmic trading? Any youtube
         | channel or book?
        
         | paulpauper wrote:
         | This would get killed in a bull market. Financial stocks
         | doubled in 2009
        
       | johnwheeler wrote:
       | So let's assume the trick works and everyone catches on. Surely
       | we can't _all_ get 25%
       | 
       | And that's the problem with any successful algorithm except buy
       | and hold value investing. The latter being hard because it
       | requires doing little, and nobody believes that which requires
       | the least effort to be the best.
        
       | anti-nazi wrote:
       | i just don't care. it's all worthless to me
        
       | bronzeage wrote:
       | This is a shorting strategy, which means you need to decide on
       | how much of a collateral do you set aside for the short. As you
       | increase the collateral, your real returns are reduced, but as
       | you reduce the collateral, your chances of getting short squizzed
       | increase and you depend more on the intraday volatility.
        
       | ffggvv wrote:
       | what time period did you backdate over?
       | 
       | i'm curious what the backdated return would be for different time
       | periods
        
         | Kibae wrote:
         | January 30, 2005 - June 6, 2021.
         | 
         | You can try sampling different time periods by downloading data
         | from Yahoo Finance. I may need to make the code more robust
         | because there is some data that I hard-coded just for the dates
         | I selected.
        
       | ArtWomb wrote:
       | This is mean reversion, right? Essentially fading market
       | volatility. I recall an article on Bloomberg about a quant fund
       | using VIX ETNs to implement something similar. Gradually adding
       | short positions as volatility rises. Knowing it will dissipate
       | once turmoil subsides. My recommendation: try entering a trading
       | contest on Alpaca ;)
       | 
       | https://alpaca.markets/data
        
         | Kibae wrote:
         | It looks like it is mean reversion. This is my first time
         | hearing that term.
         | 
         | The way I discovered this algorithm was initially I wanted to
         | buy the previous day's best performing sector ETF, with a
         | hypothesis that the momentum would continue. But I learned that
         | it actually ended up losing money.
         | 
         | So I decided to inverse the algorithm. There are still a few
         | optimizations I can test out, e.g. Buying the previous day's
         | worst performing sector.
        
           | Grustaf wrote:
           | No offence, but how can you have spent any time trading
           | without knowing about mean reversion? It's the most basic and
           | well known phenomenon in trading, along with momentum.
        
             | sowbug wrote:
             | Not everyone learns by studying prior art. Some people's
             | brains are wired to need to get their hands dirty before an
             | abstract concept or solution makes sense.
             | 
             | I'm sure that in the ~60 seconds I wrote this post, some
             | brilliant future software engineer just reinvented binary
             | search.
        
       | frakkingcylons wrote:
       | Hook it up to interactive brokers for a year and update us!
        
       | wernercd wrote:
       | "Caution Hindsight is 20/20 and because this is a backdating
       | algorithm, similar results are not guaranteed in the future. Use
       | at your own risk."
       | 
       | You don't say...
        
       | lend000 wrote:
       | Congrats. While it can be exciting to come up with a profitable
       | algorithm, publicizing a mean reversion algorithm is
       | counterproductive if you intended to make any money with it. The
       | returns here are low enough that it could stay under the radar
       | for a while, but all the same.
       | 
       | Some other metrics to measure your performance are drawdown, best
       | month/worst month (to see if a small number of events account for
       | the majority of returns), and Sharpe ratio. As other commenters
       | said, try backtesting with fees/slippage. Even if there aren't
       | fees now, you should include fees at points in history when there
       | were higher fees. HFT's have been forced to tighten their spreads
       | as retail traders have become more liquid with lower/nonexistent
       | fees, so that will affect any mean reversion strategy being
       | tested across fee change periods.
       | 
       | I do like the idea of spot mean reverting on large indices. Takes
       | a lot of risk out of it (while a company can tank overnight, any
       | decently weighted index will lack that volatility).
        
       | dezmou wrote:
       | I like those naive way to test trading bot, you can check my
       | attempt here, but mine doesn't work :)
       | https://github.com/dezmou/CryptoGPU
        
       | lightbendover wrote:
       | This is a good time to note that it is incredibly easy to
       | overestimate your ability to determine a trend based on
       | historical data and also incredibly easy to underestimate the
       | likelihood of a never-before-seen occurrence. "The turkey that
       | gets fed well every day relies on that trend continuing and never
       | sees the week before Thanksgiving coming."
        
       ___________________________________________________________________
       (page generated 2021-06-06 23:01 UTC)