from Hacker News

Show HN: Find the 10 highest and 10 lowest correlations to any stock

by macco on 5/3/22, 12:10 PM with 143 comments

During the start of the year I was thinking how could I bet against certain stocks (in my case mainly Tesla) without using derivatives and the risks that come with them.

After I had success betting on the oil price with a highly correlated investment fond, I came to the conclusion that negative correlations could be used to bet against the price of other assets. Unfortunately, it is not easy to find correlations between assets if you don't know which assets to compare in the first place.

So I created a website where you can find the 10 highest and 10 lowest correlations of certain assets.

  • by HFguy on 5/3/22, 2:54 PM

    Couple of random thoughts:

    - Building things like this is always great. And its a fun site to poke around on.

    - I would not count on this approach or expect it to be reliable in terms of actually hedging. Correlation, as a measure, has lots of issues. You are boiling down a lot of complex relationships into a single number. While it is convenient for many calculations, there are many problems. For example, many asset classes will go through periods with positive correlation and then later, negative correlation. This is due to a factor driving both securities price becoming more or less volatile compared to the other drivers. E.g., recent increased volatility around inflation expectations driving correlations between rates and equities. Whereas, few years ago, inflation was not driving anything.

    - One alterative approach is to have a "risk model". Which essentially decomposes a security into drivers. Each security then represents a basket of these drivers. You can then use this model for range of purposes. While not perfect by any means, the model contains more information than a correlation. These too have a range of issues and creation and use is as much art as science.

    - In general, you won't find many negative (or even very low) correlations across individual equities. Most stocks are driven by a common set shared risk factors that drive much of the risk. But if you can find negatively correlated securities (or lowly correlated), then that is certainly helpful.

  • by runeks on 5/3/22, 1:29 PM

    Super useful!

    However, I get a “504 Gateway Time-out” error for https://betagainst.fun/asset/bz__f_bno/. HN hug of death?

  • by Bostonian on 5/3/22, 1:15 PM

    "We calculate the correlations between 2 securities on the daily closing values of the last 20 years."

    It's better to correlate daily returns than daily prices, since the latter are nonstationary, and I suggest using 1 year of daily returns rather than 20 since correlations do change over time. When I worked as a financial quant no one looked at 20 year correlations to measure near-term risk.

  • by natly on 5/3/22, 2:32 PM

    Random question: Would it be illegal to use insider information to trade on the result of a correlated stock that you suspect will be affected by the actual company you have information about? (I mean I get that it probably is since you're using insider information but wouldn't it be really hard to prove.) Just curious, I'm not intending on doing it myself.
  • by tdehnel on 5/3/22, 1:14 PM

    I’ve often wondered the same thing, good on you for actually doing it.

    That said, in any set of 20+ variables there will be a 10 highest/10 lowest correlating.

    Without a good (specific, hard to vary) explanation as to why the correlation happens, I would not use this information to gamble real money.

  • by iso1631 on 5/3/22, 2:01 PM

    I can see the risk in short positions - you theoretically could lose an infinite amount (if you borrow X shares of something, sell them, but then can't find any to buy when it comes to returning them), and it's certainly possible to lose more than you put in (sell 100 short at $10 netting you $1000, price doubles overnight on new news, you have to buy $2000, losing a total of $1000 in the process. If price trippled overnight you'd lose $2000 -- more than you could have ever made even if the company went bankrupt overnight)

    But put options? Surely all you can do is lose what you bet in the first place?

  • by Aachen on 5/3/22, 3:13 PM

    How does this submission have both text and a URL? When hitting submit it's shown as either/or. Does the server not enforce it?
  • by snake_doc on 5/3/22, 1:46 PM

    In many ways, compared to a vanilla short position or a synthetic short via derivatives, you are implicitly accepting higher risk to “short” via this manner. This is generally a bad idea as it’s hard enough to arbitrage the same equity on different exchanges[1]. Now imagine trying locate perfect negative substitutes for an equity…

    [1] https://papers.ssrn.com/sol3/papers.cfm?abstract_id=525282

  • by cosmic_quanta on 5/3/22, 1:16 PM

    Very cool!

    Where are you getting the historical data? There's a ton of fun stuff you can do with this kind of long-horizon of data

  • by vortico on 5/3/22, 12:48 PM

    Very cool, although index funds like S&P 500 and DJI don't seem to work.

    https://betagainst.fun/asset/_gspc_spy/

    https://betagainst.fun/asset/_dji_dia/

  • by marcrosoft on 5/3/22, 1:49 PM

    Nitpick: you can’t lose over 100% of your investment using a put option. You can only lose the premium.
  • by joshuak on 5/3/22, 2:05 PM

    Is it just me or do others see a correlation between people who short Tesla, and posting on HN about investment tools that use questionable prediction models based on historical "patterns"?

    These are starting to look like perpetual motion submissions to the patent office.

  • by flying_sheep on 5/3/22, 6:03 PM

    Well this tool does not cater for splits and dividends :-/ very misleading IMO
  • by dom96 on 5/3/22, 2:21 PM

    This is a really great idea, unfortunately also getting 504s.
  • by dmitrygr on 5/3/22, 4:23 PM

    This tool does not correctly handle stock splits and thus all the correlations it produces are wrong for any stock that has ever had a split or a reverse split. It shows a split as a huge price drop, but that is not really how that works, since the number of shares expands, thus anyone holding the stock does not, in fact, face a 4x loss for a 1:4 split.
  • by Def_Os on 5/3/22, 5:47 PM

    Data source? Did you correct for splits and dividends? Why not use returns? Nice idea, but we’re left with so many questions.
  • by surfsvammel on 5/3/22, 4:26 PM

    Correlation between assets change over time. Predicting what the correlation will be in the future is important for asset managers.

    I am supervising a master thesis project (in fact the second such project on the matter) where we are trying to predict the covariance matrix of a portfolio of assets using machine learning. Results are promising!

  • by sdcoffey on 5/3/22, 9:29 PM

  • by mountaineer on 5/14/22, 4:57 PM

    FYI, the link in the copyright/footer is broken.
  • by mfrye0 on 5/3/22, 4:05 PM

    Seems like an interesting project, but so far the UX isn't great.

    The searching UI for companies has no loading or success/failure indicators. A note on performance - waiting an extra second before firing the search request can help take some of the load off the server, along with cancelling requests after I change the search.

    Some requests time out, and others return no results (e.g. HOOD, TLRY).

    For other requests that returned results, there's no correlation (Apple).

    Maybe an example page could be helpful to illustrate what the app can do?

  • by work_ta_220503 on 5/3/22, 3:31 PM

    Cool!

    Little offtopic highjacking: does it make sense to "bootstrap" correlation among stock returns (frankly, any multidimensional time series, but since we're talking about stocks) with different time periods?

    Say, for any pair of stock a and b, randomly selecting a startint point and a period (N days) and using this as a better estimator for the "true" correlation instead of using all the data points? Or something like this, not this process exactly

  • by loxias on 5/3/22, 4:50 PM

    Great project! Even more so, congrats on shipping something!

    A little tip from someone who dabbles in algorithmic trading, look into cointegration as well as correlation. Also, the cross correlation matrix changes over time, you can have great fun seeing spikes and convergence/divergence as markets tend to get more or less correlated reacting to real life events.

  • by betwixthewires on 5/3/22, 9:04 PM

    I'm interested in knowing how you do your correlation calculations, if there are any criteria for them (such as if a correlation is weighted against if the industries are unrelated). Also interested in your information feeds. I'm not looking to compete or do it for myself, this field just draws my playful interest and I'm curious.
  • by LudwigNagasena on 5/3/22, 1:35 PM

    I don't think the method is sound. You should look into finance literature on the topic, maybe something about diversification.
  • by daxaxelrod on 5/3/22, 12:49 PM

    Getting 429 status codes after I hit search
  • by omarhaneef on 5/3/22, 1:03 PM

    I wonder if correlation is the best measure. Cointegration might be more important for this sort of trading. And might be a supplementary measure you want to add since you’re doing all the pairwise comparisons. (If I recall there is a computational shortcut that helps)
  • by jnwatson on 5/3/22, 7:58 PM

    Searching “By industry” doesn’t make a lot of sense. Do you mean “within the same industry”?

    Mispelling “higest” in tab.

    A convenient tool. I’m restricted from trading in my employer’s stock. There are no rules about trading in a highly correlated proxy.

  • by karxxm on 5/3/22, 2:01 PM

    Are you also considering time lagged correlations?

    To me I don't care if a certain stock is correlated by something, I would more like to know which stocks do have correlations or if there are correlations with a time lag

  • by macilacilove on 5/3/22, 6:29 PM

    Can someone explain why Microsoft has overall the strongest negative correlation with Activision/Blizzard(-0.87) on a 1 year basis. That must be related to the aquistion but I can not figure out how.
  • by noduerme on 5/3/22, 12:11 PM

    And the answer is... Nvidia.

    Cool idea, by the way. I'll have to play with this more.

  • by vohu43 on 5/4/22, 6:36 PM

    Very interesting results for tesla for example. So can it make sense to buy a stock with very low correlations as "stabilisator" for example?
  • by throwamon on 5/3/22, 6:53 PM

    Cool. Not sure how useful it is considering what other commenters said, but is there anything like this for indices or currencies?

    Also, typo: Higest -> Highest

  • by pmarreck on 5/3/22, 6:14 PM

    HN hug of death. I didn't see any results. Even without shorting intention, this information would be interesting!
  • by chychiu on 5/3/22, 3:04 PM

    Great site! I've been playing around with it and seeing some interesting patterns.

    One small typo: Highest -> Higest on the graphs

  • by c_o_n_v_e_x on 5/4/22, 12:54 AM

    Nice. I've been stewing on a similar idea but that finds correlations in equities with commodity futures.
  • by lbhdc on 5/3/22, 2:02 PM

    Does this support all publicly listed tickers? It didn't seem to find the few I searched for.
  • by lupire on 5/3/22, 1:31 PM

    Bet Against?

    I thought the opposite of buying a single stock (Alpha) would be in service of.... Beta Gains T.

  • by throwaway4good on 5/3/22, 4:14 PM

    Where do you get your data from?
  • by macco on 5/3/22, 8:07 PM

    Wow, I was hoping for some feedback. I didn't expect to get on the HN homepage.
  • by TradingPlaces on 5/3/22, 3:57 PM

    HN Hug of Death continues. 503 and 504 all morning. Congrats?
  • by ltbarcly3 on 5/3/22, 3:28 PM

    "any stock"? First two I tried are not available.
  • by nairboon on 5/3/22, 3:50 PM

    Can you add Gamestop?
  • by matt321 on 5/3/22, 4:28 PM

    I want LAGGING correlation please thanks.
  • by sk8terboi on 5/3/22, 2:44 PM

    Betting against only wins with communism and socialism. And that's not really a win, is it?