Equities Lab
Features Articles Help Account
Free Trial
Overview

Charting Tool

FAQ

Six Steps to Validate a Stock Screen

Crafting Strategies

Filtering and Ranking

When to Use Compare Close or EPS to a Number

Using Rank Across

What is a Red Flag in Finance?

FRED Properties

What is the Piotroski F-Score?

Putting Piotroski to the Test

Relative Strength Indicator (RSI)

The Investable Universe

Undefined Property Handling

Backtesting

Backtest Rebalancing

Can’t Compare Split Adjusted Prices

Changing the Benchmark

Creating long short portfolios

Creating Your Own Score

How do delisted stocks affect your portfolio?

Learning about Green Flags and the Green Flag Score

Factor Analysis

Monte Carlo Simulation – Advanced Investing

Ohlson O-Score

Being too selective with your screener

Simulating a Short Strategy

Survivorship Bias – How does it work?

Tear Sheet – How To Create (2024 Update)

How To Use Monte Carlo With The Piotroski Score

Dynamic metric averages

Why does past rank ever change?

UI Features

Charting Individual Stocks

How the screener works

Watchlists

Importing formulas

Press release — We’ve integrated with Tradier!

Run Backtests in the Background with Recent Backtests

Stock Analysis – Creating a Tear Sheet

Utilizing Plot Panels

A Charting Tool

Why is the P/E Line Broken

Common Models

Supposedly Boring Dividend Screener – New Featured Screen

CAPM – Capital Asset Pricing Model

How to Screen for Covered Calls

Low volatility with good returns

Financial Valuation: Gordon Growth Model

O’Shaughnessy Tiny Titans Screen

How does the S&P criteria work?

Value Across Time YRLY – New Featured Screen

Tiny Titans Stock Screener: History, Performance, and Refinements

Creating long short portfolios

Creating Long Short Portfolios in Equities Lab

Shorting stocks is hard to do profitably. Very hard. That said, adding a short component to portfolios can reduce drawdown. Long/Short portfolios are also useful to see if factors are important for good investment performance.

Using the islongshort macro

To model a long/short portfolio with maximum control, use the islongshort macro. To do this, from an empty stock screener, type “import islongshort” and hit return.

The five blanks can be filled in as follows:

  1. Restrictions — this will contain the set of stocks you want to consider at all. Stocks that don’t match this will not show up in the portfolio, either long or short. This is a good way to ensure all your choices are reasonable.
  2. Buying – this will be the stocks you want to buy, because they will go up — you hope
  3. Shorting – this defines the stocks you think/hope will go down
  4. Weight – The weight you want to give the short side of your portfolio. 1 is a very good default, but 0.5 will model a portfolio that is two thirds long, one third short.  2 will model a portfolio that is one third long, two thirds short. 

To create a trivial example, we create a long/short strategy where we buy GE and short AAPL.

Shorting AAPL and Buying GE

That’s obviously not a winning strategy. We can remove things from the first term to see where the performance comes from.

Getting rid of GE made the performance worse! How is that? GE had negative performance for the time period. The answer is simple: the first screen was a mix of 50% shorting AAPL and 50% buying GE, while the second screen went all in on shorting AAPL. Clearly shorting AAPL is worse.

What happens if the first blank is just filled in with true?  This will allow the screener to pick from the whole universe of stocks.  Which won’t make much difference as it only has two stocks on its mind.  If it were going to pick more stocks on the long or short side, then this would matter more. 

It gives us the same as the GE/AAPL case. Stocks that aren’t bought or shorted are just thrown out.

Doing it “right” by shorting GE and buying AAPL

This is rampant future prediction. It would have been impossible to know that AAPL would crush all expectations, and GE would do horribly. That said, here it is.

That is certainly less amazing than expected. Turning off the GE, it is apparent that the shorting is the problem. Selecting GE, and hitting Ctrl-D will disable just the GE, putting a gray box around it.  With no other terms in the ticker is, the term will never be true, and our short side will never happen. 

The performance looks a lot like AAPL, with the grey line indicating AAPL without dividends. Disabling AAPL instead of GE yields a puzzling graph.

It is apparent that the green line and the pink line go in opposite directions, but the result is still a loss for investors holding GE, and a loss for investors shorting GE, rebalancing quarterly. Puzzling. Changing the rebalance to Never indicates that the culprit is in the rebalance.

contact sales@equitieslab.com