In this section, we will go over using Dual Class Arbitrage data to identify trade signals.
We will first import the index values from the Google Dual Class Arbitrage Index, then we will identify which share is the under/overperformer and enter into a position.
You can read more about how the strategy works here.
Importing Data #
First, import the package and use the download function to get the day’s data.
datetime | Cumulative Returns | GOOGL Cumulative Returns | Spread | GOOG Intraday Performance | GOOGL Intraday Performance | Underperformer | Overperformer |
---|---|---|---|---|---|---|---|
2022-11-30 09:30:00 | 100.0 | 100.0 | 0.0 | 0.0% | 0.0% | GOOG | GOOG |
2022-11-30 09:31:00 | 99.7896508204 | 99.7575374236 | 0.0321133968 | -0.21% | -0.24% | GOOGL | GOOG |
2022-11-30 09:32:00 | 99.7376373296 | 99.7053638537 | 0.0165521329 | -0.26% | -0.29% | GOOGL | GOOG |
2022-11-30 09:33:00 | 100.2119105053 | 100.212537395 | 0.01312691 | 0.21% | 0.21% | GOOG | GOOGL |
2022-11-30 09:34:00 | 100.2750596769 | 100.3074710871 | 0.0252199177 | 0.28% | 0.31% | GOOG | GOOGL |
Now that we have data to work with, we wait for the values in the spread column to increase above our threshold. For this example, we will enter a trade when the spread increases above 0.10. This represents a 0.10% theoretical profit opportunity, as detailed in the methodology.
datetime | Cumulative Returns | GOOGL Cumulative Returns | Spread | GOOG Intraday Performance | GOOGL Intraday Performance | Underperformer | Overperformer |
---|---|---|---|---|---|---|---|
2022-11-30 12:16:00 | 101.4287213995 | 101.3332365583 | 0.0953688439 | 1.43% | 1.33% | GOOGL | GOOG |
2022-11-30 12:17:00 | 101.3250353639 | 101.2344093459 | 0.0972505096 | 1.33% | 1.23% | GOOGL | GOOG |
2022-11-30 12:18:00 | 101.3458102436 | 101.2500430085 | 0.0956922387 | 1.35% | 1.25% | GOOGL | GOOG |
2022-11-30 12:19:00 | 101.3354324519 | 101.2344277721 | 0.0976258548 | 1.34% | 1.23% | GOOGL | GOOG |
2022-11-30 12:20:00 | 101.1381431829 | 101.015659324 | 0.1048191045 | 1.14% | 1.02% | GOOGL | GOOG |
Now that the index (spread) has broken above the threshold, we can see that the underperformer is GOOGL, and the overperformer is GOOG.
We’ll use an example of what that order submission can look like when using the TDAmeritrade API, but the logic works the same for any other broker or trading platform.
Trade Logic #
import QuantGlobal as qg
import tda
from tda.orders.equities import equity_buy_market, equity_sell_short_market
# Authenticate with the TDAmeritrade platform
API_KEY = 'YOUR_GENERATED_KEY'
TOKEN_PATH = 'C:\YOUR_FILE_PATH'
REDIRECT_URL = 'http://localhost'
Connection = tda.auth.client_from_token_file(TOKEN_PATH, API_KEY, asyncio=False, enforce_enums=True)
data = qg.download(key = 'authenticated_user@email.com', strategy = 'dca', underlying = 'google', from_date = '2022-11-30')
# Check if the last value of the index is above the threshold
threshold = 0.10
if data['Spread'].iloc[-1] >= threshold:
# If it is above the threshold, then buy 100 shares of the underperformer, and short 100 shares of the overperformer
underperformer = data['Underperformer'].iloc[-1]
overperformer = data['Overperformer'].iloc[-1]
long_order = Connection.equity_buy_market(underperformer, 100)
short_order = Connection.equity_sell_short_market(overperformer, 100)
else:
# If it isn't above the threshold, then do nothing.
Now that a trade is open, profit is realized when the index falls below the threshold, so a trader waits until this condition is true. When the value falls below the threshold, or back down closer to 0.00, the trader flattens both legs of the position.
datetime | Cumulative Returns | GOOGL Cumulative Returns | Spread | GOOG Intraday Performance | GOOGL Intraday Performance | Underperformer | Overperformer |
---|---|---|---|---|---|---|---|
2022-11-30 13:38:00 | 102.9899432667 | 102.9749475455 | 0.0245756967 | 2.99% | 2.97% | GOOGL | GOOG |
2022-11-30 13:39:00 | 103.1820509905 | 103.1490791537 | 0.030063563 | 3.18% | 3.15% | GOOGL | GOOG |
2022-11-30 13:40:00 | 103.1245582554 | 103.1082128466 | 0.0276466693 | 3.12% | 3.11% | GOOGL | GOOG |
2022-11-30 13:41:00 | 103.2840377078 | 103.2921960745 | 0.014668304 | 3.28% | 3.29% | GOOG | GOOGL |
2022-11-30 13:42:00 | 103.0800991293 | 103.0826718783 | 0.0032690456 | 3.08% | 3.08% | GOOG | GOOGL |
As demonstrated, about an hour later, the index went back down to near-0 and a profit of ~0.10% was realized. You can intuitively calculate PnL by tracking the Cumulative Return columns. In this example, we bought GOOGL at 101.01, then sold it for 103.08. Since the index starts each day at 100 and tracks returns, this means a 2.07% profit on the GOOGL leg (3.08% – 1.01%). Then, we were short GOOG at 101.13, and bought it back at 103.08 for a -1.95% loss. So when tallied, the net profit on the position was 0.12% (2.07% – 1.95%).
Optimization #
This example featured a rudimentary implementation of the Dual Class Arbitrage strategy using one underlying (the shares of Alphabet, Inc.) and crude market orders. Optimal configurations make use of limit orders to reduce/eliminate slippage, and using data from not just the Google index, but all other Dual Class Arbitrage indices to further reduce market correlation and strategy volatility.