Thursday, January 14, 2021

Some things

You can beat efficient markets through management. A stock in an efficient market spends 85% of its trade in a price range. At the edges of the range it has like a 60% chance or so of reverting to the middle of the range. But to remain efficient the downside if you bet on a reversion is greater than if it doesn’t. Alternatively, the majority of the traders can just be wrong and exposed to a move in either direction and eventually the market is the market with emotional swings to correct price. Oversold become extended bear markets and rare collapses, overbought become explosive bull market breakouts. If you have an equal upside to equal downside or equal holding period in time, a 60% chance of an equal risk/reward is profitable.

Alternatively, if you take an outlier and let it run long enough and manage the stops, you can make enough money in the 15% of stocks that don’t stay in the range if you let it run long enough to offset all the losses and cut the losses short.


You can also beat a random market over time with equal allocation and rebalancing by benefiting from the volatility. The idea that you can’t beat an efficient market is probably a little bit wrong. You can certainly profit from one. Either the market is random and positive profit beats it, or it is not, in which case there are patters no matter how complicated, complex or how much statistical noise you add.

https://thepfengineer.com/2016/04/25/rebalancing-with-shannons-demon/


More risk doesn’t equal more reward

In fact, diversification among multiple assets with the least risk per asset beats concentration into a single asset (if each asset has equal probability and edge).

Options can be used to create a lot of different kinds of bets including a 50/50 chance (according to option pricing) of an up or down move. This offsets time and price so that at the end of a period if it’s above a price you make $5 a share no matter how far above that price it is and if it’s below a price you lose $5 a share no matter how far below it is. This strategy can boost high probability strategies where you have a 60% of a directional move but a 40% move of a disproportionally large move.

Alternatively, you can take a strategy where you make a huge amount if it goes over a particular amount, but offset your loss by costing nothing if it doesn’t go down by a slightly less huge amount, with that max loss capped at less than the max gain. This would be good if the probability of a huge move is mostly limited to a single direction.
You could also use options to gain from non directional move and/or from time decay when a stock doesn’t move a particular direction.
Options market can still be efficient in the way it’s priced, but it’s designed to be priced 50/50 chance of up or down move and only the magnitude of direction changes. Stock market can still be efficient in that it stays within price range and yet does so in a somewhat predictably directionally biased way. Combining the two can make for profits from smart traders.

Fundamentals, qualitative, sentiments, cyclical, technicals.
Fundamentals determine what you are buying. What are assets on the book. Fundamentals are compared to the cost. For instance, a company with 2billion in cash, one billion in debts would have book value of 1Billion. If it has a billion shares trading at $1 per share it’s fairly priced. If it is trading at $0.50 per share it is underpriced with a “market cap” of 500M. If it is trading at $2 It is overpriced with market cap of $2 billion. Those assets are tied to what the company is, what it can earn, how it can survive, and whether or not someone is going to come along, buy out the entire company, liquidate the assets, pay off the debts and return the money to shareholders. Additional “intangible” valuation depends on the qualitative.
 Qualitative estimates the intangible value. A good sign of quality business is one that is self funding, that doesn’t need to pile money into factory, plant and equipment just to keep up. A good quality business is one where it has a premium brand, intellectual property protects it, competitors have tried and failed to overtake its status, it has a cultlike following, it creates new products and it creates new customers and expands from local to state to national to global. It has declining costs (what company pays) and increased price (What customers pay), it has high referral rates and word of mouth effect, it has premium products that people will always pay for, it can maintain both a premium brand as well as make alternative economy products to expand customer base with discount option. It has regular income. It bennefits from being the go between of multiple businesses or consumer monopoly or both. These are some hallmarks of quality company.

Sentiment


There are two types of sentiment. Sentiment of the public (those buying stock) and of the forecasters. When everyone buys who is ever going to buy and all capital that ever is going to be allocated is in, the slightest bit of selling pressure or reduction in buying power and cause the stock to decline, particularly if volume is really top heavy. Markets have to top on optomism and overbuying and bottom on Liquidation or pessimism and forced selling.
All sorts of cycles exist in nature that drive human behavior. That’s a bigger topic but people’s mood change based on sun, they gravitate towards food which is governed by the sun, and it’s no surprise solar cycles correlate with recessesions, or why when humans have evolved to become less dependent upon farmland and the sun for food why it may gravitate away from that correlation and towards the debt cycle which is a kind of sentiment cycle of debt and credit. Cycles form by optomism of business participants and earnings forecasts as Well as debt cycle.
When businesses want into a particular market, they have to pay for it. Supply/demand rules the day. When demand to get into an industry is hot, people tend to overpay and overborrow based on promise of returns due to history of growth, that causes overpaying of price, over competitive markets that drive down price and margins and drive up costs and lead to liquidation and declining industry interest which eventually leads to the opposite side of the cycle. Disruptions and fire sales of assets or forced selling due to overleverage requiring sale of assets lead to distressed asset prices which cause others to have insane debt/equity which requires additional forced selling, which eventually rids the market of competition and allows for low price that is precisely what leads to great future returns, converts debt to an asset, expands margins and reverts the cycle until it attracts new set of customers and leads to herding which makes the business competative.

Price of a stock isn’t always directly correlated with value. When credit is tight, and few people are interested in stocks, smart money rules the day and they tend to anticipate some to a lot of this stuff. When the crowd is involved, price becomes king over value, algorithms of smart money feed off the short term movements of price, and market becomes detached from value. That to creates cycles in price as well.





So, cycles is a big part of understanding the market. Not all stocks are cyclical, some are only slightly levered to other cycles like the debt cycle, some are massively levered to the cycle. It’s important to know which one if you are going to use fundamentals, as nearly all fundamentals should be discounted, possibly even to the point of being precisely inverted at particular times. For instance, In 2009 real estate and banks had negative book value precisely at the bottom, the market had worst earnings ever aNd some of the best returns from the bottom were those with the worst possible fundamentals that didn’t go bankrupt. There is a reason for that, the stocks were highly levered to their “extrinsic value” or the potential for assets to move significantly higher as bankruptcy was mostly priced in and assets were eventually to become way more valuable than whatever was on the books, despite peple noticing the opposite trend at the time. The historical earnings that the market eventually reverted to resulted in companies that seemed totally unviable and undesirable at any price to recover and become legitimate businesses that just knocked out most of its smaller competitors who couldn’t make it, allowing them to gobble up market share and their massive levels of debt to small levels of equity to become an asset.

It’s difficult to say just how much the asset prices will “revert” and how far they are from the mean and just how much to discount fundamentals unless you really know the industry and the cycles, but you will be ahead of a lot of people if you focus on distressed industries and consider some margin of safety.
A company’s “book value” discounted to whatever it can be liquidated for at market price determines how much a company is worth “dead”, whereas the ability to convert a small amount of book value into a high amount of earnings and the future earnings power of the company or even the future growth of earnings multiplied by the multiple enthusiastic investors will be willing to pay later is what it is worth “alive”. Extrinsic value may also include things that aren’t obvious, mostly related to quality. Can it innovate products? Can it grow and expand its market? Will It be able to reduce costs over time or increase prices to customers? Or will it be the opposite and costs will increase? Can the company leverage strategic buyouts or joint ventures to immediately multiply its value? For instance, can a conglomerate like Berkshire Hathaway buy a company like Google and use its search engines to reduce advertising costs for its consumer products and increase business of Google at the same time for a win/win relationship?

Technicals have some value, but are more about matching a management style with an entry style. A mean reverting strategy works to the degree you manage your exits so that you have an equal holding period in duration or Roughly equal target and loss levels, or allow for diversification and strategic asset allocation. Alternatively a momentum style can help you manage risk such as using a moving average for an exit plus or minus 2 ATR(2 periods of average movement of the stock) whee you allow winners to run until they run out of momentum and the idea stop workings, the outlier moves pay for the frequent losses.
Aside from that, system based thinking can take market conditions and align them with style.






Some styles do well “in phase” but poorly “out of phase”, others do relatively well in all conditions but tend to do less well in certain conditions, some do well in some phases but not in others. Some relatively trade with the market, others tend to not be impacted by the market. Some trading styles are more effected by volatility (or lack of volatility), trend strength (or lack of), or rotation of capital (or lack of) than price. The best trading system using technicals pair the strategy, the time frame, the allocation/risk, the trading vehicle(s) and the market conditions. Most backtesting fails because they are based on all sorts of details that aren’t repeatable based on a specific kind of market that dominated. If you want to backtest, correlate the conditions (what the signal tells you the market is doing now) with the strategy. You could use a simple mechanism like monthly MACD to determine S&P direction in a bullish crossover (bullish condition) or bearish crossover (bearish) or 50 day Ma Vs 200 day moving average. And other things like volatility index below 15 or above 25 or in between for volatility low, high, or medium. Then you can pair the strategy with the condition and try it again using shorter time frames to see if the signal is as robust. You might test a “mean reversion” concept for the market conditions it works best in with an RSI and then use a different signal when you actually trade it. You are looking for general simplistic concepts to see what works when. When it comes to actual trading it’s more about what you believe and can execute that falls within that concept and aligns with market conditions. It’s hard to backtest “volume profiles” and they are a bit more intuitive/discretionary. But if you plan to trade by buying low end of the range and selling the high or middle during mean reverting markets. or by trading at the middle of the range below a thin volume profile or volume pocket during range expansion or in anticipation of breakout during conditions where momentum trades are likely to stick, you can do that even if you used a MACD or RSI for Backtesting. There was a long period of time where people swore by the 28 day RSI indicator and now that stopped working and the 5 day RSI began working, that may be the result of algorithmic trading scalping momentum in the short term and before that reduction of trading fees (costs) leading to shorter duration trading becoming more viable, or Moe crowd participation and financial network consisting of everyday news and headlines leading to greater short term emotional swings. I’m not sure. But the concept of mean reversion never stopped working and if you chased the backtested performance of the 28 day instead of something you could be effective at in the right conditions, you might have struggled. Moral is, stick to concepts you can personally trade well and backtest only to align conditions with strategy, not curve fit the exact method to use.

Algorithmic trading
Thee ae cheap trading platforms today that can run on “if-then-else” programming logic, “if this indicator is oversold AND these conditions are met, then do this, otherwise don’t”. Such algorithmic trading can allow for crisp precise execution of rules that takes emotion out of the equation. There are a lot of different sound trading logic, but most are some combination of momentum (Growth), reversion (contrarian) and neglect (value). Momentum relies on a few outliers continuing well beyond typical range. (Stocks that go uo 1500% have to go up 100% first) Reversion relies on management to “normalize” the range either over hundreds of trades or fixed holding periods, (Stocks overreact to price movement and then “normalize”) and neglect looks to buy low volatility rangebound stocks at lower end of the range and anticipate a range expansion or “breakout” before the momentum traders. You can also do simple game theory type trading that looks for a portfolio with minimal correlation overall and balance and uses rebalancing/allocation to profit from strong directional capital flows. An example is the “permenant portfolio” of 25% cash, 25% gold, 25% stock, 25% bonds where you adjust if any allocation falls below 15% or above 35%. An algorithmic strategy might rebalance a lot more frequently during range bound volatile conditions and rebalance less frequently during high trend strength and low volatility conditions (that lead to breakouts)



Thursday, March 5, 2020

Inversion of logic

The counterintuitive move at first glance seems to be an inversion of logic but where you can invert logic and find it still might work, you find opportunity. Cyclical stocks are great for this.

Earnings rates cycles with the availability of money. Availability of money can increase or decrease in two different ways. One with the expansion or deflation of credit and the other with the migration of capital into the hands of the consumer. (For instance if money piles into China along with tourism and GDP growth, trade, etc... that will likely make it easier to drive earnings.)

Earnings are driven by activity which can be driven by credit cycles. There may be other types of cycles as well and certainly sentiment will change for both market participants as well as industry insiders and key decision makers. Debt and demand funds expansion but also drives prices higher and eventually can threaten to reduce future returns if you pay a higher price. Over saturation can lead to pricing wars and margin and earnings declines which leads to declining equities and debt consolidation and bankruptcies and deleveraging which eventually limits the growth of assets and gives demand a chance to catch up to declining supply until it can lift again.




The counter intuitive thing goes like this... stocks priced below book values are overpriced until you know the assets on the books and thus the book value will stop going down. Even if book values are negative when it seems like the worst idea, it can be a good time to buy counterintuitively. If you know the assets can increase or the liabilities can decrease, the book value can flip around positive. Book value only tells you what a company is worth if it liquidates at market value. A company capable of earning money is worth more alive than dead so the book value only matters if it can impact future earnings. Earnings can be very negative but if a company is worth more dead than alive and you have the ability to liquidate without losing additional money and return more to shareholders than the market price, you can still find value. Growth will be negative on the downward part of the cycle. You will be best off overpaying for growth if you get opinions early and selling it when growth is cheap if you think growth will continue to decline.

That isn’t to say there isn’t logic to fundamentals... it’s just very tricky and has its reasons.

Markets Have Their Reasons

The markets have to behave in certain ways because of what they are and how humans behave. For instance, deflation might be scary, it might be a reason to sell, BUT it also triggers changes in where capital goes to try to protect itself to mitigate the damage. That eventually creates neglect where even if deflation never turns around there is opportunity and if it does turn around there is greater opportunity so once capital gets cornered into safety, it has to eventually move... some opportunity requires some more creativity than others. For instance, when oil is trading below a certain level (assuming you were managing ridiculous amounts of money) you could take over all companies trading below book value, either sell futures to lock in the value of the book that includes oil prices so if they go down you are hedged and can lock in the value until it resolved, or buy futures plus one company you intend to hold, liquidate the companies entirely except for the one and by doing so reduce the production of oil, have the value returned to shareholders, take physical delivery of the oil and force the price up and then convince a country to build up its national oil reserve so you could sell them the oil or halt production and use the oil you took delivery of to provide the demand... and if you take over a lot of energy companies you can certainly gain control over pricing by massively reducing production and then using up the supply. There are many people who would just hold onto a company with declining book value betting on a turnaround that never develops or betting on liquidation from the others that never happens, and it may even be break even, too small or profit or even negative profit at current oil prices to do so, but the act of doing this with several can actually reduce the increase of supply so that demand is greater than supply and eventually prices must stabilize and then go up. This process could work with many types of companies. If there are 50 ships and 20 shiploads of goods, you can buy out and liquidate, or acquire and shelf and stop creating competition that makes pricing and maintenance unprofitable.

The point is, capital has reasons to do things and this creates new conditions that lead to the next. A market will always act in a way that creates movement.

Capital might believe that there is a vicious cycle where politicians have mandated European a pension funds own 80% bonds and the ECB and fed will continue to ease if things ever get worse, and banks will be more reluctant to lend proportional to the fed’s change in rates as the fed tries to stimulate... so as the fed and central banks lower rates, the spread between borrowers and savers grow, liquidity declines and stocks go up on minimal volume and a risk of a sharp decline when the market gets spooked creates a no bid situation and the fed continues to stimulate by lowering rates, trying QE and doing whatever else. Then they see banks no longer willing to lend to banks at the low overnight rates fed is trying to enforce. So when rates have to go higher and higher and still no one lends, the fed steps in and continues to try to control markets. This process forces them to lower interest rates and stimulate more based on their logic, but since banks aren’t really lending that much more and it drives prices of stocks higher where fewer people are willing to participate, this creates volatility risk that moves people into bonds in anticipation that the central banks will always support it. In addition, people looking at the trend of lower and lower rates and talk of “negative rates” don’t really want to borrow if they think they will make more money by waiting in 6 months and seeing if the rates go down or they may wait if the fed cuts by half a percent and the actual rates haven’t gone down by an equal or greater amount. At any rate this cycle can’t necessarily continue forever as interest rates in Europe are already negative. While traditional models have been abandoned by parking money in bonds and waiting for fed to drive up the price and down the yield because that’s what accommodative policy does, this has created risk parody that isn’t proportional as you would expect.

Normally it might look like this: (image from Howard Marx The Most Important Thing)



But as rates offer lower and lower yield, other assets get more and more attractive by comparison and they have been neglected with the decline of global liquidity.

Ironically, it’s deflation due to China totally halting their economy to fight the corona virus that may actually cause stocks to go up if it eventually breaks the European economy. If we deflate further, that inflicts more pain on the economy and those who currently have experienced significant austerity like Germany may revolt at some point or they will have to steal even more from pension funds which could also cause riots, or they will have to steal from all bond holders or people with money. Brexit likely will not be the last country to leave and for them to turn to a marxist approach would only cause additional deflation that would break their economy even more. it may take a final breaking of the european economy to send money out, and the safest place in theory is still US bonds.

However, S&P stocks now yield close to twice as much and additional deflation would push that number above 2. So if you have to park your money do you keep it in something where you can only ever get under 1% tying it up for 10 years and if the government goes bankrupt you get nothing with risks of them forcing you to take a “haircut” (robbing from bond holders) or do you put it in something where you have legal rights to access book value in worse case scenario plus earnings in excess of dividends, plus potential for growth and potential to benefit from price appreciation due to movement of capital into stocks?

So deflation exacerbates the opportunity and may actually trigger the move. Markets always have their reasons, even if they are nuanced and tricky...

Let’s take for instance why value may invert. When credit is in excess, money is moving around and particularly when capital is heavily concentrated into that part of the world and tourism is high and money is coming in, a companies earnings will be inflated, so even if P/E is reasonable, it could still be overpriced. When markets sell off because of an event and/or credit crunch, the earnings are an unknown.

And yet if money has totally moved out, credit has totally deflated, Business activity and trade have halted earnings can be minimal or negative so any price wouldn’t seem justified and yet it might be the best time to buy and there may be the most value out there if earnings revert to historical levels.

Using Shiller PE can help somewhat as the average of the last 10 years of earnings might have some significance but its not always representative of a cycle average and even so, there isn’t any particular level of Shiller PE that you can definitely say is too high and will signal a bottom or too low.

What would the appropriate Shiller PE be if costs of goods approaches zero and excess capital available for the investment class only rises over time? More excess money equals more money to invest and that means higher valuations. There are only so many ways you can spend money in a great economy, investing should be a growing percentage over time and Shiller PE must rise.

The market can be complex, and it may even drive itself to and from extremes from one to the other, but it always has its reasons. I say this because it’s useful to understand things like how deflation would make materials and oil and such even cheaper and at some point an activist buying up multiple companies to reduce production and pricing competition might accelerate the turnaround or else companies can go bankrupt and are forced to liquidate or have their assets sold in bankruptcy courts.

It may seem at the time like when bankruptcies force assets to be sold for pennies on the dollar that it would also put equities lower and debt to equity higher and force others into action and additional bankruptcies. But eventually the gravity that pulled it downward pulls it around and back up. The decreased production and decreases amount of assets in the industry influences prices to go up.

So a real estate company may have vacancies and depressed earnings at depressed prices, when the normalized rent yields when the property isn’t vacant is very high relative to price at the same time its book value goes negative and it is at the highest risk of bankruptcy. The relationship between value and price over time can only be understood when you understand how it can be very counterintuitive most of the time and when you can also find an edge the market doesn’t recognize or can’t capitalize off of or else it wouldn’t be there to trade.

Markets have their reasons.

Saturday, February 15, 2020

Highs vs low


On the right is % of stocks in the industry within 5% of the 52 week low
On the left is the percentage of stocks within 5% of the 52 week high.

I use this scan to find distressed industries to scan from for setups.

Monday, March 26, 2018

How Does Statistical Arbitrage Work?

 


Statistical arbitrage is the term usually involving both long and short hedged positions or paired trades that tend to revert to the mean historically. You are using anything with a statistical edge and usually using mean reversion strategies. This works well when there is a volatile trading environment and lower correlation among assets. THe period from 1997 to 1999 tended to trend more and mean revert less as everyone was selling everything to buy dot com stocks and capital kept flowing into internet stocks. As the crowd began to participate the smart money then began to sell early and buy stuff that had been down so from 1999 to 2000 and beyond you saw statistical arbitrage begin to outperform, despite the rotation and sell offs being sharp and continuing as the market entered bear market.

There are several narratives for why statistical arbitrage occurs, but one example I like also displays the potential for a variation of statistical arbitrage involving cash vs a long or short position provided you are able to totally mitigate margin risks. As that is not practical without using very small position size a hedge is needed and then you end up with more of a standard statistical arbitrage. So instead let's only use a long only position vs cash to illustrate.

Let's assume a totally random market. How would you gain? Some may say it's impossible, but they must not have read or heard about Claude Shannon in detail because he was a brilliant man accomplished for a lot of reasons that also constructed a model for beating a random market. Modern day game theory would come to the same conclusion which is identifying what is called "nash equilibrium". Positioning yourself in "nash equilibrium" in some conditions (this is one of them) allows gains to the degree which opponent makes mistakes. In other situations like a game of rock paper scissors it only mitigates chances for opponent to exploit patterns by going equal parts rock, paper and scissors and using some random generation method.

In this case, with no directional bias and only two assets, equilibrium would be 50% cash and 50% stock. As cash becomes more valuable vs the stock position (stock goes down, you add enough stock to create a new equilibrium. As stock rises you sell enough or buy cash position using stock to maintain this equilibrium. Given enough volatility and enough time for prices to normalize your net worth would rise over time. If you wanted to simply recover to new highs faster but with less gain and less volatility to total net worth, you could trade more capital to the less volatile position (cash) and maintain that allocation. The allocation of say 25% stock, 75% cash would still work, it would just produce less gains.

Nash equilibrium isn't necessarily the best possible strategy for maximizing gains vs all other strategies as it assumes oppponents are all of equal and perfect skill and the moment participants begin to switch strategies, a new strategy becomes dominant and players would adjust until no one have an advantage. If for example market participants were dramatically under positioned or over positioned and you had reason to believe it had reached an extreme, you could go 100% long or more. If they were over positioned and you could go 100% cash or even go short. In between the extremes, it's possible you can identify trends towards extreme and not adjust your strategy until the extremes are reached. The point is not that you should seek this strategy out if it isn't right for you, but to explain that even though equilibrium may not make money as fast as another strategy, it can still profit regardless of what others do over enough time and enough volatility

While mentioning this it's important to keep in mind that statistical arbitrage is NOT necessarily an equilibrium strategy itself as calculating that would be too difficult but it in general benefits for similar reasons in that capital flows as people move away from equilibrium and it eventually finds its way back and away again in whatever direction it does for whatever reasons that are only obvious in hindsight.

It's possible because of how many variables influence strategy of actual participants that there is no actual equilibrium and instead it's something that always changes. Equilibrium for a more complicated market is difficult to identify, but you can create something that functions in a similar way.

This sort of illustrates why statistical arbitrage works. Anyone who is aware of the possibility would generally be able to buy a basket of stocks vs an equal amount cash position, and so if market was out of equilibrium after a sell off in any given stock, the risk is to the upside. RSI measures buying and selling pressure so you are buying positions that have become underowned relative to the time frame at a fast enough rate for long enough time.

When the selling pressure cannot continue as people have already sold that wanted to, the least amount of buying pressure can produce the fastest amount of gain.

Statistical arbitrage is a little bit of contrarian strategy only the RSI 5 only refers to 5 day period so this is only contrarian on the short term time horizon and some stocks could be in an uptrend for years while others could be trading near their lows so it isn't a contrarian strategy on any other time frame but the given time period of the strategy.

Another explanation is emotion. People tend to emotionally overreact and sell now and ask questions later. when stops get triggered it can trigger more stops and soon people find themselves out of the position. Once emotions normalize, they realize they didn't need to sell everything and these previous holders may become buyers at higher prices



 
Above you will see a statistical arbitrage strategy that goes long when the RSI 5 is below 20 and takes profit and sells the full position when it is above 50 and sells short any stock above an RSI of 90 and takes profit when it is below 50. It uses any stock in the Russel 3000 that meets the condition and doesn't adjust the number of positions to maintain some kind of balance and instead relies on what the market offers. While this is a little different than typical statistical arbitrage that usually does create balance, it's close enough for you to understand the effectiveness.



Shorting stocks is a little more dangerous because stocks can go up more than 100% requiring you to come up with more than double the capital you started with. If you are only short you are at significant risk of this happening. Nevertheless, you can see it does well in bear markets and even was able to find some trades that worked


We can isolate how it did from May 2007 to June 2010 to get an idea for how it performs just before and just after a bear market.


Above is a long only strategy which produces a greater compounded rate of return but does so at greater volatility and has a lower sharp ratio as a result. Theoretically leveraging up a hedged strategy or reducing down the position sizes of the long only portfolio so that they have equal levels of volatility would make the long AND short portfolio superior for return and it produces a greater return on risk.

However, market timers may instead select a strategy right for market environment, or at least
position 60/40 long or 40/60 short depending on predicted market conditions.

While not everyone will be a statistical arbitrage trader nor should they be, we can learn some important lessons from it. If you are trading a particular strategy that does NOT work in almost all market environments, you should be sure to have some means to measure what environment your trading strategy works in. If you trade momentum breakouts, look for growth periods and anticipate trending markets. If you trade price patterns, you may wish to consider buying dips in anticipation of breakouts or post breakout moves to retest if that strategy works for you. And if you decide to trade a particular strategy, understand that it may not work in all market environments and be willing to do some work identifying the reasons why or the conditions in which the strategy works.

Another important understanding is that you may wish to do a periodic review to determine if what was working is still working. Below in green shows buying falling wedge breakouts and holding for 3 months. It worked well from 2011 to 2014 but since then at least until July 2017 it no longer has worked. That may be because the conditions for buying or selling have changed, (buying the breach of the low and selling into the breakout may still work) or the pattern itself has become less effective vs alternatives. You would have to backtest a number of variables to decide and even then it only works in hindsight, so be mindful of the conditions we are in, what made that strategy work in the past, and what made it not work and what you expect moving forward if you are going to use that strategy.
 

Historically growth has not spent a ton of time outperforming value, but when it does it can make some really strong moves near market highs like in 1999-2000. Lately Growth has outperformed around the time period shortly before falling wedge breakouts with 3 month holding period began failing.
Some things in market are related and others are not, and conditions can quickly change so in order to remain a leg up on the competition you have to determine what role volatility has in the strategy and what the volatility is (measured by the VIX for example).
Notice whether we are in trending or mean reverting markets and bull or bear conditions and if there are any anticipatory signals for conditions changing. Notice how long trends are lasting and what correlations are.

Just a bit of information can give you a great overview if you track them, or you can track market internals looking at individual stocks, industries, sectors, etc. which perhaps is more  complicated but when the market doesn't always move with stocks (correlation is low) then using the broad market as your only indicator may miss opportunities to identify sectors and industries that work according to your system or what you are most comfortable with and what fits your psychological make up.

Even a winning system doesn't mean much if you have poor execution so you had better find out what works for you personally and always manage risk. Statistical arbitrage can work for some if they align the time frame and market conditions and risk management appropriately but it may not be best for everyone nor may any other strategy mentioned, but hopefully this sort of detailed analysis as to what works and why will give you a thin slice of things you can look at to determine what works best for you.

Even passive investing can look at changes that lasts from months to years and have 3 types of changes they can make and look for longer term extremes to shift allocations from a "green light" to "yellow light" or "red light" type of strategy going from conservative allocation to stocks and preferring slower moving stocks and bond markets can be looked at separately and aggressive small cap or growth stocks and greater allocations from extreme lows or a monthly signal that momentum has shifted from down to up and another signal when things get extreme and markets may stop trending may shift them to neutral. There are different ways to every approach that can work, but regardless of what works for you, be aware that there are conditions in which changes to that strategy may be preferable. Additionally there are a few strategies that may work in any conditions, but even so volatility and account drawdown may increase or decrease requiring adjustments in position size or potential hedging in certain time periods if you want to reduce the potential drawdowns to a range you are comfortable with.  Even day traders can be away of both the long and short term conditions in which their edge may change. If they wait for movement to scalp a trade or look for some kind of daily breakout then higher volatility markets may require adjustments CHanges to margin rates and volatility may impact speed of moves and changes to algorithmic high frequency trading may also change your edge. There are always things changing and even legislation may pass that change the rules of business and taxes and investment and cause reactions and behavior and paradigm shifts. The market isn't like blackjack or poker where the odds are always the same, it's like being blindfolded and spun around in circles and sitting down at a different table with a different game and different rules. Fortunately everyone else is too and you have a lot of time to monitor the conditions and determine the rules that fit the conditions best.

Saturday, March 10, 2018

Modeling expectations of a portfolio Part 1

Some people like to use a combination of options, long term investments and short term trades in a more complex portfolio. This can be tricky, particularly if the amount of capital used for each changes with the conditions of the market.

However, you can still model an entire portfolio over a time period with given assumptions. Just be sure you also test the extreme end of assumptions that would be an unprecedented result. For instance, although we've had a 20% loss in a day in 1987 crash, what about a 60% decline in a month? This sort of decline would be very very very rare, but if an event like this wipes you out erasing decades of gains, your system may not even be profitable at all in the long run due to the very rare event.

Let's start with a hypothetical coinflip to keep things simple. Heads you net double what you risk. Risk 1, win 3, profit 2. Tails you lose 1.

If we flipped a coin and then adjusted our bet based upon the new position size we can calculate our return over several flips very simply. Assume 50 heads and 50 tails.
Let's calculate the win result for 50 heads. For a position size of 1%.
It's 1.02^50  or 1 plus the win ratio times the position size. This equals your multiplier factor. The result is 2.691588. in other words, over 50 wins your wealth will have multiplied by ~2.7 or an increase of ~170%.
Now we also have 50 losses. Since each loss we will adjust our position size, the wealth will decrease by a factor of .99 per loss and size will be adjusted downwards. .99^50=0.60500607 or about 60% of what we started with if we lose 50 times in a row or a loss of about 40%.
So now we can combine them ~2.7*~.60=~1.62 or a 62% gain over 100 flips.
But hold on just a second, it's very possible that you only get 40 heads or perhaps only 30. We need to test the outliers in terms of number of flips as well as the magnitude of the results (how big each individual win or loss can be). Since this trade is fixed (the upside does not change and the downside does not change) we don't have to adjust the magnitude of the win. But we should test for what sort of drawdown we are looking at at 1% position size if we lose 70/100. The results are (1.02^30)*(.99^70=~.896 or a loss of ~10.4%. What about 20/80? THe loss would be closer to 33.5% in a year. what about 10/90? Results are a loss of about 51%. You can see how even modest positioning with limited upide and a clear edge can still produce a lot of volatility over time if you go through a rough streak. We can test the upside as well if you'd like. 90 heads to 10 tails would be 437.5%. 80/20=299% 70/30=195.85%.

This is similar to a hypothetical system, but it is not equal. Before we go looking at more complex outcomes with multiple outcomes, let's look at smaller as well as larger position sizes. For now let's summarize 1% position size.

Expected results (50/50)=62.8% gain per 100 flips
outside range results 40/60 to 60/40= 20.8% to 119.5%
extreme range (30/70 to 70/30) = -10.37% to 195.8%
very extreme range 20/80 to 80/20 = -33.5% to 298.8%
unprecedented extreme 10/90 to 90/10 = -50.67 to 437.48%

I'll go ahead and do the work to summarize 5% position sizes and 0.25% position sizes, but for those looking to make sure they do it right, it's position size times expectation plus starting portfolio for one trade. For instance starting portfolio in this case will always be 100% or 1. expectations in this system will always be either minus a full position or plus 2 full positions. So if position size is 5% a 5% loss from the 100% will leave us with 95% of what we started with or .95. A win will leave us with 10% plus what we started with of 1.10. So now we can build out the results table for 5%

Expected results (50/50)=803% gain per 100 flips
outside range results 40/60 to 60/40= 8.5% to 3812%
extreme range (30/70 to 70/30) = -51.86% to 16851%
very extreme range 20/80 to 80/20 = -88.89% to 733.32%
unprecedented extreme 10/90 to 90/10 = -97.43% to 318010%
The biggest problem with this strategy in real life is there is very little ability to separate a broken system from an extreme outcome and by the time you figure it out, the damage can already be done.

The other extreme of 0.25% positions will see .9975 of what we started with per trade or 1.0050

Expected results (50/50)=13.27% gain per 100 flips
outside range results 40/60 to 60/40= 5.1% to 22%
extreme range (30/70 to 70/30) = -2.5% to 31.5%
very extreme range 20/80 to 80/20 = -9.50% to 41.75%
unprecedented extreme 10/90 to 90/10 = -16.1% to 52.78%

We can see the dramatic difference in outcomes. Just for fun, let's see what happens if we position size way too large at 60%.
expected gain at 50/50=~-100%*. Even a winning strategy with less than 100% going as expected results in ruin if we bet too large. *The exact loss is 99.83%

While we could simulate more realistic trades with options and more than 2 possible results to more accurately model the outcomes there is another problem we run into comparing reality to the theory as currently modeled. In reality you won't wait until one trade is done to start another. So we will stick to the coinflip argument until we resolve it.
This simultaneous trading provides both benefits (in that you can put more capital to work while less is at risk since the odds of a lot of small trades simultaneously not working out at once is less than if all that capital were tied up in one trade) as well as a hindrance (In that while losing 40 1% positions over 40 trades will only lose you 1-(.99^40)=.33 or 33%, 40 losses simultaneously will lose you 40. In addition while 40 1% coinflips that win one at a time will compound and win you 1.02^40=~2.2 or 120%, when placed all at once they will only win you 40%.

Still, it's far less riskier with far better results to bet 1% on 40 coinflips than 40% of the capital on a single coinflip. Even as we will transition into a model that models actual trades, no two trades are exactly correlated, so there is still a bennefit for diversification (before fees) that can act to reduce risk if used properly.

Nevertheless, we have to change the calculation entirely to how many simultaneous trades over a period to where it adds up the sum of all results as opposed to multiplying. For instance, if we have 1% position with 30 wins and 20 losses simultaneously, rather than (30^1.02) * (20^.99)=1.48 or 48% return, the calculation is (1.02*30)-(.01*20)=.40 or 40% return if we have multiple overlapping periods like this we can add the separate periods. For instance if we had 2 periods of 30 wins and 20 losses, we can still adjust position sizes after a period so the result is 1-(1.4^2)=.96 or 96% instead of just 40%*2 or  40%+40%=80%.

In reality, a very important variable determining success or failure when using overlapping trades is how correlated each trade is to another. For instance, if all you have are calls in each individual S&P stock expiring at the same time, you are going to be very exposed to a broad market sell off during that time, and you might as well have a single call in the S&P. There is no real diversification of risk if you are exposed to the same correction in the broad market or rotation out of it. Having 40 1% of various S&P stocks is about the same as having a 40% position on for the S&P over that period. If instead you have a variety  of strike prices across a variety of time periods and each are in a variety of underlying stocks in different sectors of the market as well as focusing on the underowned stocks, then a rotation from the overowned into the underowned or the big cap into the small or the index correlated to the uncorrelated can actually be your gain as the market declines. However, 40 1% positions bought over approximately the same way (within the same price range or time range) with approximately the same expiration date (within a month of each other) even if you are seeking out underowned names is still vulnerable to the type of everything down correlated sell off common during major corrections (down 15-20%) and bear markets. Although there will be numerous sell offs where you are not impacted by uncorrelated sell offs, the selloffs that are correlated can do enough damage where you better plan for a strategy that can weather multiple extreme moves over a few years and still be profitable over a time period, otherwise you will need to position differently or adjust your strategy. One such adjustment may be buying insurance in the form of index puts over a long period of time to pay the minimum and then rolling that time premium as needed. This doesn't protect against a long period where your individual trades fail to gain traction or where the market doesn't ever rotate into underowned names and instead is lead by the names leveraged to the index.

Consider that when modeling against all extremes which I will show you how to do briefly. Remember when I showed you the table of expected return, outside range, outside extreme etc? One thing you may wish to do is run a calculation for a 10 year period that contains a couple outside extremes to the downside, one to the upside and the rest either in the normal or outside range or results. You can test different position sizes over this time period. Keep in mind that it will be very easy and possibly appropriate to adjust following a significant decline as you don't know whether or not that was just an extreme or representative. You don't know if your expectations moving forward will equal the past, be better than or worse than the past. Emotionally, you may also determine you've had enough. For this reason, your effective bankroll may actually be smaller than you calculated and your proportional risk to that bankroll may be higher than you realize.


We are ultimately going to seek out a balance between multiple strategies across multiple portfolios to try to mitigate risk of our overall wealth and obtain our goals.
For instance one such overall wealth building strategy may look something like this.
1)401k aims to capture the very long term wealth effect over multiple credit cycles (usually 7-11 years) as well as overall movement from and to stocks and other assets like bonds, and may reposition to try to capitalize off of moves lasting months to years.
2)Roth IRA aims to bennefit from swings in stocks lasting weeks to months.
3)Individual option account combined with individual stock accounts aim to insure against the longer term moves when insurance is relatively cheap and in appropriate times, while primarily seeking the non-correlated moves and counter moves and spotting individual bullish and bearish setups when appropriate. The taxible individual trading accounts will dynamically adjust position size by having some exposure to the index and some exposure to cash and hedges and increasing or decreasing that exposure as the short term and long term trades swell up in size to maintain a proportional bias consistent with expectations and avoid overexposure to any one period of time or expiry or overallocation to risk.

This is just one such possible idea, but another involves complex rotation. Another variable is market condition. certain strategies do better during sideways markets, others during quiet markets, others during choppy markets, others during bull and others during bear market and combination of the 2 variables of volatility and trend/direction (or no direction if it's a sideways correction through time).

Here is one such strategy I sort of tentatively mapped out. The idea is you get some market correlated names and perhaps include owning companies run by money managers like Warren Buffett like birkshire hathaway shares. At the time I made this I mistakenly thought WCC (Westco Financial) was still run by Charlie Munger, but there may be some sort of publicly held company that has a large float of investible securities that is run by a quality asset manager. The idea is to own market correlated names that you believe in over the long run to equal perform or outperform. Your 401k might also be allocated into long term outperform but in a more permenant sort of way so you may view that separately. Then you may consider a basket of commodities that start as a very small position and you might buy for the long term at historically significant prices when possible. You might have a currency trading account or just trade calls/puts  in currency ETFs to place trades that move differently from the market itself. You also may want to own some proportion of long term corporate bond and treasury bonds, however, we are at a historical period where rates are probably rising so keeping this percentage very small or finding some way to hedge against rising rates on the extreme end (perhaps long term puts in TLT) may be appropriate.
Then you have your stock timing portion of your portfolio that tries to maintain a mixture across varying strike prices. And finally you have some hedging capital and cash, and since you won't need all of your cash at even extremes, some percentage can be held in income.



The design of this portfolio is very important to understand. The idea is that overall some percentage of your portfolio will be allocated to "risk on" and some percentage to "risk off" That should be consistent with your expectations of winners vs losers plus a buffer for your personal tolerance to varience over time. However, individual option trades that post huge wins can expand and contract. This is where the balancing act comes in in the form of rebalancing your allocation strategy appropriately. For instance, if your stock and option trades are working well, they will expand in size and overall you will be more exposed to violent corrections. As such, you simply reduce your market correlated calls or shares in S&P or leveraged ETFs like SPXL or TNA to maintain the desired balance. Beyond that if you are still more risk on than you want, you can purchase a hedge.

The goal of holding commodities and bonds is to capture rotations in capital into and out of the stock market as well as provide the buffer for your individual stock timing/outperforming portion of your account(s). The goal of having large cash and income amount is both for future opportunity of better prices as well as some degree of protection from deflation as well as reducing account volatility to desirable size, particularly if you are seeking maximum volatility. The goal of having market correlated names is to both have something to balance out growth in stocks and to generally add lower and reduce higher while options are by design going to increase exposure higher and decrease lower and some trading strategies involving stocks or options may stop out lower and add higher.

In order to optimize the portfolio according to risk tolerance and our goals we will need to run several calculations like the calculations that we already did stress testing the portfolio against hypothetical extremes and determining the blend that we desire. That will be for another time.
The goal will be to accomplish a goal of return (or better) while keeping max drawdown limited to a particular amount (or less)... or else over a time period to maximize the probability of an event with a secondary time period where an amount must be reached. This may put less focus on the drawdown in a given month or year, but ultimately the drawdown must be limited such that you are able to recover and obtain your goal.

Friday, April 7, 2017

How FindingThe Best Stocks is A Needle in The Haystack Problem

Finding the best stocks in certain ways is like finding a needle in the haystack. I don't mean with regards to difficulty necessarily but procedure. Awhile ago I was watching a show called Mythbusters: The Search in which they had contestants compete to become a part of the next generation's "Mythbuster's group". One of the problems that they had to solve for was how to find a needle in the haystack. Contestants invented ways of burning the hay that would not burn the needle, using magnates that would work on the needle but not the hay, using water in which the hay would float and the needle would sink and other ideas en route to attempting to filter out the noise.

One of the more eccentric contestants named Hackett suggested that this was a "signal and noise problem". He explained that you had a lot of noise (hay) and had to filter it out without also filtering out the signal (the needle).

I realized that stock picking methods involved mostly the same process. A lot of people like to look at only just the winners and seeing what they have in common. The problem with that is you might be very effective at identifying traits that are also true with losing stocks. Even if 75% of winning stocks have a certain characteristic, if 90% of all stocks share that trait then the trait in itself is not useful. Another problem is that even if you can compare it to the baseline and say that 90% of big winners paid no dividend and 75% of stocks that made big moves were under $10 per share and 60% of stocks that made big moves were under a $1B market cap--and even if you can also say that these big winners percentages are higher than the baseline rate for each stat---it is still possible in combination that this isn't the best match of filters. For example, perhaps although a small percentage of all stocks pay no dividend, 92% of $10 stocks with a small market cap pay no dividend. You'd have to decide which filter is more important.

Nevertheless, as long as you set up a way to objectively find out how to increase your hit rate of capturing big winners while reducing your chance of getting a non winner and still providing enough opportunities you are being productive in your methodology.

I want to focus on methods not stocks and not markets here. You could look at quarterly performance or yearly performance... but for an example I"m going to assume daily performance as you can run this every day and build a large sample size of what works and also plot some sort of measure of market condition in terms of trend, breadth and volatility just in case you notice certain scans work conclusively better in certain conditions.

So here is the method:
1)Develop a scan from a universe of stocks (say 5,500 stocks as an example)
2)Develop scan A to seek stocks up more than 1% and scan B to seek stocks up more than 4% in a single day (or 3% or 5% or whatever you prefer).
3)Either subtract the results or come up with a scan to seek stocks NOT up more than 1% and 4%.
4)Determine the baseline "hit rate" or percentage of all stocks that are up 1% vs up 4%.
This establishes a baseline. Let's imagine that out of 5,500 stocks 400 of them are up 1% or more and 150 of them are up 4%.

Eliminating The Noise And Burning The Hay

Now you are going to come up with a variety of scans you may like to use of what happened prior to today and not including today such as a stock was oversold 3 days ago or a stock was down 3 days in a row until today. Or perhaps you come up with a bollinger band squeeze or a scan that a stock over last several days prior to the breakout closed lower but not too much lower and never made a move more than 1%. Come up with at least a few methods between consolidating volatility, oversold, breakouts, trends, etc.


1)Develop these scans.
2)Scan them from all stocks to see the total number of stocks that pass the filter (say 500 stocks for a particular scan).
3)Add into a version of one of these scans that they pass this scan AND are up more than 1% and 4% or sort by today's change and count them (say 60 stocks in the scan are up 1% or more and 30 of them are up 4%)
4)Determine if randomly selecting a stock from this scan is better than randomly selecting from all stocks in terms of hit percentage and if so how much?
Example: In the example 400/5500 stocks or 7.27% are up 1%+. 150/5500 or 2.72% are up 4%+. In the example scan 60/500 are up 1% or 12%. And 30/500 or 6% are up 4% or more. This is a clear increase in your success rate over picking stocks randomly, so the filter added value today.

Repeat this process
I would run multiple scans and filters and even multiple "universes" from which you run the scan. Is scanning just the russel 3,000 going to produce a better hit rate than all stocks? What if you create a list of stocks that IPO'd in the last 5 years or less vs more than 5 years? What about stocks with positive earnings vs negative? What about stocks with accelerating earnings growth (growth % greater than last year) vs decelerating? What if you create a list of stocks that have been out of favor at one point or another and peaked in 2015 or earlier and are still down from their peak vs those within 15% of a prior peak in any year before 2015 (possible multiyear breakouts from ranges) or a list of stocks with positive uptrend or oversold on a longer term basis? This would be separate from the scan and it needs to have a pretty large number of names on that list to be statistically valid.  You can remove the results that would have stopped out if you want as well.

You can improve the results by identifying the samples most representative of the current market and sticking to methods that worked in the past under those EXACT same conditions.

This may seem like a lot of work but once it's done you can have confidence in the process and selection method's. Once you have collected samples over various periods and begin to determine the best scans to trade from, you may even develop the habit of reviewing the lists and developing your own personal skill or eye for identifying unique features that are hard to quantify in a scan or algorithm and begin to only focus on the best names from the list according to your experience.

If you'd like to shorten the time you have to wait to do this process you can set up the 4% movers for yesterday and just set up more scans and just keep running it for each day before today of how the scan would have came out. It's more work but you can do this all at once if you'd like. Or perhaps you'd like to do all of this over the weekend for each day of the week rather than once after close every day. Or perhaps you'd like to play for weekly moves or monthly moves of larger amounts rather than 1 day moves.

More Accurate Modeling
A more accurate way to model how your portfolio will result over a period assuming certain conditions is to actually look at 5 different distributions of outcome based upon the scan rather than just the success rate. You can sell at the stop, sell at the target, sell break even, sell below the stop or sell above the target. Using spreadsheets and getting a little app that runs monte carlo simulations on random numbers, you can set it up so that a range of random numbers between zero and one represents an outcome consistent with the actual results. For example if 40% of stocks stop out at the stop rather than gaping down or gaping down you'd set it up so that a number less than or equal to 0.40 results in a stop out and set up 5 different cells that determine 1 for the outcome and zero for no outcome and then translates that to a result for a single trade. Trying to plot simultaneous trades is more difficult particularly if your outcomes have any degree of correlation (they will) so modeling your entire portfolio of multiple trades with simultaneous holding periods and different entry and exit times that overlap is really hard to program for me. But you can do a simplified version of perhaps ALWAYS holding 10 stocks so that way your results over a period of 4 trade periods doesn't allow you to compound more than 4 times of the sum of all 10 results for each period.

This can be set up with rules such as if the result of a particular trading year or series of 100 or 1000 trades is over a certain amount to trigger a 1 otherwise a zero. Then a montecarlo simulation determining the average will give you the probability that that outcome is reached. SO you can determine a particular allocation and risk % how many series of trade results in obtaining your goal of minimum (what percentage of these periods are not down more than 20%) and maximum thresholds (what percentage of these periods are up more than 50%). Or you can look at the total distribution of all simulated outcomes at the end of a period.

I'm planning on trying to do a similar process at some point but I'm working on setting it up. This post serves as me getting the logic down so I have an idea of how to run it but now I actually have to set up the scans and process. I plan to track it on an excel spreadsheet which I have not yet build yet. I've attempted such a feat for quarterly results and some fundamentals, but those results were based upon recent data rather than the data BEFORE the stock made their move so it may not be accurate.