[HN Gopher] Offline Algorithms in Low-Frequency Trading
       ___________________________________________________________________
        
       Offline Algorithms in Low-Frequency Trading
        
       Author : hypomnemata
       Score  : 264 points
       Date   : 2021-01-30 11:51 UTC (11 hours ago)
        
 (HTM) web link (queue.acm.org)
 (TXT) w3m dump (queue.acm.org)
        
       | lowfreqtrader wrote:
       | If low frequency trading interests you, here's a project some
       | people might want to check out:
       | https://github.com/brndnmtthws/thetagang
       | 
       | It's designed to sell option premium on major indices (like the
       | S&P500 or NASDAQ-100) to generate mostly passive income, with a
       | fairly reasonable risk-adjusted return. It uses a combination of
       | strategies that involve selling naked puts and covered calls,
       | which both have the same risk profile, but naked puts tend to
       | have higher premiums.
        
         | jkhdigital wrote:
         | I've observed the opposite in cryptocurrency option markets;
         | covered calls tend to net a higher yield than the equivalent
         | puts.
        
           | lionyo wrote:
           | Where are you writing your options? Only the stablecoin pairs
           | seem to be liquid
        
           | nullc wrote:
           | That is the normal behaviour for commodities. It's arguably
           | reasonable that Bitcoin behaves more like a commodity than a
           | stock, at least so far as anything is arguably reasonable in
           | the realm of cryptocurrency.
           | 
           | But maybe strategies involving puts will become more
           | successful if we can convince more of the HN Bitcoin
           | naysayers to sign up for LedgerX and put their money where
           | their mouth is. :)
        
         | lordnacho wrote:
         | Ex pro options trader here. Looks interesting, and I've starred
         | it, but it does sound like it's just collecting premium?
         | 
         | If you're selling options, you probably need to risk adjust
         | your returns a bit more than what's common:
         | 
         | https://papers.ssrn.com/sol3/papers.cfm?abstract_id=377260
         | 
         | That's by Andrew Lo, big name in the area.
         | 
         | I'm sure you've also come across Taleb, who knows a thing or
         | two about selling options.
        
           | Goosee wrote:
           | SSRN only let me view the abstract. Here's a link to the pdf
           | that worked for me.
           | 
           | https://alo.mit.edu/wp-content/uploads/2017/06/The-
           | Statistic...
        
           | JimBlackwood wrote:
           | Do you maybe have some books you could recommend? I have a
           | strong math background, so that's not a problem.
           | 
           | I have a hard time finding courses or books that cover how
           | these instruments work in some depth.
        
             | lordnacho wrote:
             | The problem is the books don't really tell you. They're
             | written in this mathematical way that kinda obscures how to
             | actually think about them practically. If you're more into
             | math maybe stochastic calc will be just fine for you.
             | 
             | Here we go anyway:
             | 
             | Hull: Futures, Options, and Other Derivatives
             | 
             | Natenberg. Don't recall the name, but this is maybe the
             | closest to practical.
             | 
             | Paul Wilmott, Quantitative finance.
             | 
             | Taleb, Dynamic Hedging. Got a signed copy :)
             | 
             | Also I think it's smart to read about instruments that
             | aren't options, ie don't just cut to the chase. Time value
             | of money, futures, forwards, bonds, swaps, equities. Then
             | vanilla options on all those things, then exotics.
        
               | pvitz wrote:
               | Someone with a strong math background should cut Wilmott
               | and go directly to Shreve: Stochastic Calculus for
               | Finance II (or Bjork: Arbitrage Theory in Continuous
               | Time).
        
               | hackton wrote:
               | "Natenberg: Option volatility and Pricing" I guess. Very
               | instructive, but I have a slight preference for the Hull.
               | They are both rather old but well explained. They give a
               | very good starting point.
        
         | icedchai wrote:
         | Seems like it would be less trouble to buy QYLD (nasdaq-100
         | covered call ETF), or one of the equivalent funds.
        
         | kgwgk wrote:
         | https://www.daytrading.com/selling-volatility
        
           | WJW wrote:
           | There's a fantastic quote in the book about the LTCM fiasco
           | ("When genius failed") about how academics always want to
           | short volatility because they have view of how society
           | "should be" and it is not very volatile. IIRC, the quote was
           | by some old grizzled options trader who used to have the same
           | view but had been bitten often enough to internalize that
           | volatility is much more common than beginners think.
        
         | varyherb wrote:
         | Genuine question, does this strike others as immensely off-
         | topic? I'm curious if the parent commenter even opened the
         | link. I'm sure there are applications of generalized knapsack
         | problems (or dynamic programming generally) in options trading,
         | but this isn't it.
        
         | svmt wrote:
         | I briefly looked at the README and code. The strategy is an
         | implementation of The Wheel. Did you backtest the strategy
         | including commissions?
         | 
         | I doubt there is much left after commissions. See [0] for a
         | backtest including commissions and [1] for a blog post from
         | ORATS on how to backtest the strategy using the ORATS
         | backtester.
         | 
         | [0]
         | https://www.reddit.com/r/options/comments/j3ofna/the_wheel_b...
         | 
         | [1] https://blog.orats.com/backtest-basics-how-to-set-up-the-
         | whe...
        
           | opportune wrote:
           | What many people don't understand about the relatively low-
           | risk options strategies like the wheel or basic covered call
           | selling is that, because they are low risk, they are less
           | lucrative than many simpler strategies.
           | 
           | The financial industry would not just leave that much risk-
           | adjusted return on the table, after all. Just because a
           | strategy is complex does not mean it is lucrative.
        
         | RyanShook wrote:
         | Have you been successful running this script/strategy?
        
         | beezle wrote:
         | Generally speaking, a seller of naked puts is looking to
         | supplement income via a stock they are willing to own at a
         | lower level. If you are not willing to take delivery, it is
         | probably better to sell a vertical spread so that there is a
         | built in stop out. Here I'm speaking of transactions of a
         | reasonable premium amount, not 5 or 10 cents.
         | 
         | While it is true that the upside is unlimited against a naked
         | call (and the downside is 0 on a naked put), naked puts suffer
         | from systemic risk that calls for all intents do not. Both are
         | subject to news/events specific to the company in question, but
         | the risk of the short call running away from you because the
         | market had a +20% day are well, fleeting. On the other hand,
         | unexpected economic news, politcal/military events, liquidity
         | issues, etc can tank the entire market 10, 20, 30% and have
         | numerous times. A rise of similar magnitude, to my knowledge,
         | has only happened after market crashes (so you would then be
         | alert to the upside risk).
        
           | qeternity wrote:
           | This is why skew exists, and should not deter anyone. The
           | vast majority of people should buy a 20-30% dip, and so the
           | fact that 99% of the time you're not going to be assigned
           | means that it's a good idea in most scenarios.
           | 
           | I suggest most retail to be short straddles against a core
           | underlying position for yield enhancement. Yes, over a number
           | of decades you will have something go against you, but under
           | the current monetary and fiscal regimes, you should be hoping
           | for the day that you can buy the dip or sell the rip via a
           | systemic short vol overlay.
        
           | [deleted]
        
         | hntrader wrote:
         | What does the tail risk look like on this strategy and what
         | kind of annual return do you expect?
        
           | omarhaneef wrote:
           | You're taking the tail risk on the down side but you've sold
           | it on the upside for extra yield.
        
             | artemonster wrote:
             | I undestand words but I have absolutely no clue what you're
             | talking about. Can you recommend some books on the topic?
        
               | wbl wrote:
               | The only book you should read is John Bogel's. Do what he
               | says like Goldman partners, Bank of America senior
               | executives, almost every economist does with their money
               | and stick it in low cost diversified mutual funds.
               | 
               | Or you can learn stochastic calculus and end up in the
               | same place once you realize half of all active traders do
               | worse than the market, before fees.
        
               | smabie wrote:
               | None of the kinds of people you listed are good at
               | trading (esp economists). From experience, professional
               | traders do tend to use passive indices for part of their
               | PA, but also actively trade a portion.
               | 
               | But you're right in that if you don't have a passion for
               | it, you'll never be able to truly outperform spy on a
               | risk adjusted basis. However, if you do have the
               | knowledge and the passion, I definitely think you can.
               | 
               | Investing is personal, and just holding spy doesn't
               | fulfill everyone's objectives.
               | 
               | Here's an example of a strategy that outperforms spy in
               | most cases: 1/3 of your portfolio goes to upro (3x
               | leveraged spy) and 2/3s goes to a bond fund/etf. As long
               | as the bond etf returns above the upro expense ratio
               | (~1%), you will outperform. From my backtests, this
               | strategy will earn you an extra 1-2% return a year, while
               | also having a slightly higher risk adjusted returns.
               | 
               | I list the above as a great example because it's the kind
               | of strategy that is great for a PA: easy to manage,
               | doesn't require babysitting, and backed by solid academic
               | research. When people think active vs passive, they think
               | actively trading single stocks vs just holding an index.
               | My point is that you can use some quant-lite strategies
               | that tilt your portfolio to eek out a little return. You
               | don't have to be trading everyday or even holding
               | anything except ETFs.
        
               | victor106 wrote:
               | While I always preached just buying the S&P one risk i've
               | been seeing with it is if, a majority of investors just
               | buy the S&P index, since the index is market cap
               | weighted, it would just make the largest stocks in the
               | index more expensive.
               | 
               | This would make the stocks that have less weight in the
               | index or stocks outside the index relatively cheap and
               | obviously offer better returns.
               | 
               | Anyone disagree?
        
               | eloff wrote:
               | This strategy seems to make a lot of sense to me, so I
               | just checked out the performance of UPRO over the last 5
               | years versus SPY (^GSPC).
               | 
               | UPRO is up 426% (wow) $17.37-$74.01
               | 
               | and
               | 
               | ^GSPC is up 192% (talk about a bull run) $1932-$3714
               | 
               | So with UPRO you would have had an average profit of
               | 65.2% per year, and with SPY 18.4% per year. That's even
               | better than x3 returns.
               | 
               | Plus you'd have the bond returns. Interesting idea.
        
               | StrangeDoctor wrote:
               | You absolutely do not want to own upro for 5 years. High
               | fees and more importantly beta-slippage will eat you
               | alive.
        
               | smabie wrote:
               | by beta slippage you mean volatility drag? On a risk
               | adjusted basis, upro is definitely a loser due to
               | volatility drag and high expense ratio. However, you can
               | easily calculate optimal leverage ratio in order to
               | maximize the geometric growth of your portfolio. The
               | equation is:
               | 
               | lev = E(r) / Var(r)
               | 
               | So if the expected return is 10% and the expected
               | volatility is 10%, optimal leverage to maximize geometric
               | growth is 10x.
               | 
               | This of course is much too high and the risk of losing
               | everything due to excessive kurtosis and downside skew is
               | very high. Like the everything else in finance,
               | fundamental sin of that formula is assumption of the log
               | normality of returns.
               | 
               | However, is 3x too high for the long term? I dunno, but
               | over long time periods, a pure 3x leveraged spy portfolio
               | is going to outperform significantly. The problem is most
               | people will be unable to weather the storm as you can
               | easily lose half of your money in a week.
               | 
               | I wouldn't hold pure spy 3x and wouldn't exactly
               | recommend it, but from a mathematical perspective it is a
               | defensible (as in, you can make cogent arguments for it)
               | long term investment.
               | 
               | On the other hand, I would probably recommend 1.5x lev or
               | possibly even 2x lev to certain people.
               | 
               | As a quant, I approach these things like leverage from a
               | mathematical perspective. It's important not to have an
               | emotional reaction. There are very smart people running
               | books that have 10x leverage but you would never be able
               | to guess by looking at their volatility. It's all about
               | the factor exposures, net delta, etc.
               | 
               | For example I've seen 15x leveraged delta neutral books
               | that have absolutely insane Sharpe ratios (>15) and
               | annualized volatility of less than 5%.
        
               | eloff wrote:
               | Well you would have done just amazing (as I pointed out)
               | over the last 5 years. Better than 3x the S&P 500.
               | 
               | I'm not saying you don't have a point, but one would need
               | to look at how it performs over longer periods with more
               | varied market conditions to answer your question.
        
               | hntrader wrote:
               | Isn't UPRO just a leveraged SPY. Seems different to the
               | above option selling strategy
        
               | eloff wrote:
               | You must have skipped over and didn't read the parent
               | post at all. We're not talking about the wheel strategy
               | here.
        
               | smabie wrote:
               | UPRO is only 1/3 of your portfolio, so you have the same
               | exposure as SPY i.e: you are not going to make those
               | crazy returns.
               | 
               | The idea is to get cheap borrowing by using a leverage
               | ETF and then buying bonds such that the bond yield > cost
               | of leverage.
        
               | eloff wrote:
               | You're arguing against a strawman argument that you
               | invented.
               | 
               | I didn't say you would get those crazy returns - merely
               | pointed out that you would have beat the S&P 500 over the
               | last 5 years with the strategy outlined by the parent
               | post.
               | 
               | How well it holds up over a time period that also
               | includes bear markets is another question - you can't
               | just look at a bull market and assume it's representative
               | of all time.
        
               | joshribakoff wrote:
               | Buffet sells 5b in options premium a year
        
               | atomicnumber3 wrote:
               | I think a big distinction that retail traders need to
               | come to terms with is that, while yes, technically you
               | can make reasonably good sums of money with various
               | trading strategies of various risk profiles, as one
               | person, so many of them are just not worth the trouble.
               | 
               | If your passion is this sort of thing, by all means, go
               | ahead.
               | 
               | But it's like running a homelab. Yes, you can get pretty
               | decent "savings" (vs running in AWS/DO) but I can
               | guarantee you, you will end up in the basement replugging
               | ethernet cables trying to figure out which one is the bad
               | one while your family and relatives are waiting upstairs,
               | fairly bemused, for you to fix "the internet".
               | 
               | It's possible, but as a person with a life, unless it's
               | your passion, I'd recommend just not. Do the financial
               | equivalent of paying DigitalOcean 5 dollars a month: buy
               | sp500 etfs and sit on them.
        
               | hntrader wrote:
               | I wonder if we can invest in a fund manager who does this
               | strategy. And if it's so good then why do pension funds
               | and endowments not allocate to it typically.
        
               | rusticpenn wrote:
               | Yes, me too. I just read about someone calle 1ronyman on
               | Reddit, and I am interested too.
        
               | im3w1l wrote:
               | The "tail" in tail risk referes to the tails of a
               | probability distribution. A normal distribution has
               | "thin" tails. The probability of huge outliers is pretty
               | low.
               | 
               | If you have tail risk, then it means you have a decent
               | chance of losing a lot more money than the typical
               | variation. Your returns might look like +1.1, +0.9, +1.2
               | +1.05, -3. So your profit is pretty predictable with
               | little variation, until suddenly you lose a lot of money.
        
               | omarhaneef wrote:
               | I would look up two terms:
               | 
               | Covered calls
               | 
               | Naked puts
               | 
               | If you want to go heavy duty into it I recommend the Hull
               | book (options, futures and other derivatives) but for
               | your purposes the investopedia articles are enough.
               | 
               | Basically naked puts means you're selling downside
               | insurance so if the stock crashes you eat the loss.
               | Covered calls mean you sell upside risk but have the
               | stock so if it goes up you make a little.
        
               | beezle wrote:
               | Hull is a great book and is not too heavy on the math.
               | However, for someone just getting their feet wet, Options
               | as a Strategic Investment by MacMillan is a classic.
        
           | im3w1l wrote:
           | Selling a _deep in the money_ put behaves like owning the
           | stock (probably with margin, but it depends on how many puts
           | you are selling compared to your reserves of cash and short
           | term  "safe" bonds) except that you are capping your gains.
           | 
           | The further towards out of the money you go the more it
           | behaves like _picking up pennies in front of a steamroller_.
           | But an interesting quirk of selling puts compared to calls is
           | that the downside _is_ limited. The stock can 't go below 0.
        
             | hntrader wrote:
             | That gives me a good intuitive picture. I'd really love a
             | basic online simulator where I can plug in portfolio
             | characteristics (eg percent of calls Vs puts, ATM Vs OTM)
             | and simulate an equity curve over the last ten years. I
             | could build my own of course but I think a tool like this
             | would be generally useful for investors.
        
           | Schweigi wrote:
           | I did make my own option trading algo which is similar to the
           | one in the Git Hub repo (but I used Scala, which gave me
           | additional returns, jk :) ). Return totally depends on the
           | delta of the options you write and the option symbols in your
           | basket. Mine could be configured to be between 10-100+%. The
           | higher the return the more volatile.
           | 
           | The idea of using multiple symbols like SPY and TLT is to
           | reduce the tail risk. But in the end there is still tail risk
           | like for example in the crash of 2015. Making the strategy
           | delta neutral with hedging could improve it but I never
           | completed that part.
           | 
           | There is an interesting book with all the math by Euan
           | Sinclair about option writing and how to minimize the risk if
           | you are interested.
        
             | hannofcart wrote:
             | Another way to reduce tail risk when selling options is to
             | simply hedge with a protective call/put at a higher or
             | lower strike respectively. Sufficiently far off strikes
             | will have minimal impacts on returns while reducing tail
             | risk.
        
       | dgb23 wrote:
       | Interesting, we're in one of the largest crisis since decades and
       | all these stock trading stories are popping up.
        
         | mhh__ wrote:
         | Crisis for whom?
        
       | omarhaneef wrote:
       | This is worth a read if only because of the clear introductory
       | explanation of the market clearing mechanism.
       | 
       | However, it's not a profit maximizing algo that will make you
       | rich (not that there's anything wrong with that).
        
         | kwhitefoot wrote:
         | Will it make me better off?
        
           | WJW wrote:
           | Reading more about things you haven't read about before will
           | increase your total knowledge and therefore make you better
           | off in a holistic sense, yes. In a purely monetary sense, no
           | it will probably not have any effect on your life.
        
             | philosopher1234 wrote:
             | Knowledge is not infinitely accretive
        
               | WJW wrote:
               | I was making the gamble that people who compulsively ask
               | "Will it make me better off?" without having read the
               | article are not yet at the point where they've hit the
               | diminishing returns on additional knowledge.
               | 
               | Your statement is correct though, username checks out as
               | well.
        
       | secondcoming wrote:
       | The Vickery Auction was pretty much the de-facto auction type in
       | adtech realtime bidding.
       | 
       | It's since been replaced with standard first-price auctions for
       | reasons I don't fully understand, but I assume it was because
       | websites misunderstood bid prices and though they were being
       | ripped off.
        
       | 29athrowaway wrote:
       | Whatever you do, do not film yourself and emit a "guh" sound.
       | 
       | https://www.youtube.com/watch?v=d80ahvRSV8E
        
       | breck wrote:
       | Unzipped the code and put it here for easy viewing:
       | https://github.com/breck7/drillBits
       | 
       | (Note: if author wants to create a GitHub I'll edit this link and
       | point to theirs!)
        
         | boxfire wrote:
         | Given the clear copyright statement,
         | 
         | > Copyright (C) 2020-2021 Terence Kelly. All rights reserved.
         | 
         | did you happen to get the author's permission to put that up? I
         | don't even like IP law that much, but its funny to me how much
         | no one gives a shit. This was a crime, albeit a silly and small
         | one.
        
           | breck wrote:
           | https://giphy.com/gifs/reactiongifs-DsFhEEGzo9LVu
        
       | Jommi wrote:
       | There is a mistake in the article, the 2nd graph is repeated.
       | There is no figure 3.
        
         | msilb wrote:
         | I was also wondering about the missing figure 3. In the linked
         | pdf version everything seems to be in place.
        
       | bobbydreamer wrote:
       | Just asking anybody figured out, how to find high low for a
       | period of time. Say in a period of 6months, starting from a
       | initial point, next point could be a high or low, if high,
       | program needs to find next lowest point and afterward, it needs
       | to find highest amd continues to do so in zigzag. For low it's
       | vice versa.
        
         | IIAOPSW wrote:
         | I think what you are asking is given a time series (x_0, x_1...
         | x_n), what is the 6 month high (or low) on day i? In other
         | words you want the max (or min) of the sub series
         | (x_{i-180},x_{i-179}... x_i).
         | 
         | x_0 is obviously the 6 month high at day 0 (since there is no
         | previous data). If x_1 > x_0 then x_1 is the new 6 month high
         | so we can discard x_0 on day 1. If x_1 < x_0 then x_0 is still
         | the 6 month high on day 1, but we cannot discard x_1 because it
         | might become the 6 month high when x_0 expires on day 181. So
         | we need to maintain some sort of data structure of potential 6
         | month highs such that we can lookup the current high and remove
         | these highs as they expire or get replaced. The easiest way to
         | do this is with a list of pairs [(x_i1, i1), (x_i2, i2)...]
         | sorted by increasing x_i. Because it is sorted, the current
         | high is always found on the element closest to the end of the
         | list. Furthermore when a new element (x_k, k) is added, it
         | replaces all the elements which come before it (thus they can
         | be removed). As a corollary, because the newest element is
         | always added to the back (after removing what's in front of
         | it), the list is also sorted by order of expiry (with the
         | oldest (x_i,i) at the end). Start with an empty list and i = 0
         | 
         | Find the sorted insertion point in the list for (x_i,i).
         | 
         | Remove everything prior to the insertion point.
         | 
         | Insert (x_i, i) at the start of the list.
         | 
         | If the element at the end of the list (x_n, n) is expired (n <
         | i+180) then remove it.
         | 
         | The 6 month high on day i is found in the element at the end of
         | the list. Store this in a new series h_i.
         | 
         | Increment i by 1 and repeat.
         | 
         | This method trivially works for finding the 6 month low as
         | well.
        
       ___________________________________________________________________
       (page generated 2021-01-30 23:00 UTC)