Back to Community
Announcing: Mergers and Acquisitions available through Pipeline

Mergers and Acquisitions (M&As) are a hotbed of news in finance. One bad deal can send a company's stock price spiraling while another can take it to the moon. For this reason, M&As can often pose a significant risk to quantitative trading strategies. For those who aren't familiar with M&As, Investopedia provides a short summary,


“A merger happens when two firms, often of about the same size, agree
to go forward as a single new company rather than remain separately
owned and operated."


"When one company takes over another and clearly established itself as
the new owner, the purchase is called an acquisition. From a legal
point of view, the target company ceases to exist, the buyer
"swallows" the business and the buyer's stock continues to be traded.”

While there are ways to trade directly on M&As (merger arb), this post will focus on these corporate events from a risk management perspective.

Risk Management

Both the target and acquiring company are publicly announced in an acquisition deal. These strategies pose a large risk to quant strategies because quant strategies, by definition, use historical price data or otherwise to make predictions about the future. However, when a stock becomes the target of an acquisition, the security becomes a fundamentally different stock with no continuity to its past. That means quant strategies attempting to trade on acquisition targets are trying to make predictions based on historical data that is no longer relevant to the given security. To avoid this, targets of an M&A should be removed from a strategy's portfolio.

The algorithm below shows you how to use M&A from a risk management perspective by excluding all securities that are the target of a Cash Acquisition offer. The available options are cash, stock, mixed, all. For those who are interested in learning more in how these corporate actions can affect a quantitative trading strategy, view the research walkthrough.


What am I getting from these factors?

These factors are created from EventVestor's Mergers and Acquisitions dataset (available for $85/mo) and allow you to identify which stocks are targets of acquisitions or proposed acquisitions. You can search them by the offer payment type (cash, stock, mixed) and the number of business days since the announcement.

Do I know also know the acquiring security along with the target?

For now, you're only able to identify targets of mergers and acquisitions. While we plan to allow support for identifying acquirers in the future, we haven't reached that point yet.

This dataset missed a target, is the data broken?

Not all data is perfect. Sometimes our partners provide us imperfect data. Sometimes Quantopian’s processing of the data introduces problems. Please submit a ticket to [email protected]

Loading notebook preview...

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

7 responses

Basic algorithm framework to use M&A Pipeline factors in an algo

Please find the framework below and post if you have any questions on how to use it.

Clone Algorithm
Total Returns
Max Drawdown
Benchmark Returns
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
This is a template algorithm on Quantopian for you to adapt and fill in.
from quantopian.algorithm import attach_pipeline, pipeline_output
from quantopian.pipeline import Pipeline
from import USEquityPricing
from quantopian.pipeline.factors import AverageDollarVolume

from quantopian.pipeline.classifiers.eventvestor import (
from quantopian.pipeline.factors.eventvestor import (
from quantopian.pipeline.filters.eventvestor import (
def screen_ma_targets_by_type(target_type='cash'):
        (string) Available options are 'cash', 'stock', 'mixed', 'all'.
        This will filter all offers of type target_type.
    if target_type == 'all':
        return (~IsAnnouncedAcqTarget())
        if target_type == 'cash':
            filter_offer = 'Cash Offer'
        elif target_type == 'stock':
            filter_offer = 'Stock Offer'
        elif target_type == 'mixed':
            filter_offer = 'Mixed Offer'
        return (~AnnouncedAcqTargetType().eq(filter_offer))
def screen_ma_targets_by_days(days=200):
        (int) Filters out securities that have had an announcement
        less than X days. So if days is 200, all securities
        that have had an announcement less than 200 days ago will be
        filtered out.
    b_days = BusinessDaysSinceAnnouncedAcquisition()
    return ((b_days > days) | b_days.isnull())
def initialize(context):
    Called once at the start of the algorithm.
    # Rebalance every day, 1 hour after market open.
    schedule_function(my_rebalance, date_rules.every_day(), time_rules.market_open(hours=1))
    # Record tracking variables at the end of each day.
    schedule_function(my_record_vars, date_rules.every_day(), time_rules.market_close())
    # Create our dynamic stock selector.
    attach_pipeline(make_pipeline(), 'my_pipeline')
def make_pipeline():
    A function to create our dynamic stock selector (pipeline). Documentation on
    pipeline can be found here:
    # Create a dollar volume factor.
    dollar_volume = AverageDollarVolume(window_length=1)
    # Pick the top 1% of stocks ranked by dollar volume.
    high_dollar_volume = dollar_volume.percentile_between(99, 100)
    pipe = Pipeline(
        screen=(screen_ma_targets_by_type(target_type='cash') &
    return pipe
def before_trading_start(context, data):
    Called every day before market open.
    context.output = pipeline_output('my_pipeline')
    # These are the securities that we are interested in trading each day.
    context.security_list = context.output.index
def my_assign_weights(context, data):
    Assign weights to securities that we want to order.
def my_rebalance(context,data):
    Execute orders according to our schedule_function() timing. 
def my_record_vars(context, data):
    Plot variables at the end of each day.
def handle_data(context,data):
    Called every minute.
There was a runtime error.

Very nice. I wonder how much of a risk this is (unless you are trading a small number of stocks).

Interesting to investigate how much sharper benefits but much more interesting to use acquirer + target details to model arb strategies.

Always something I have wanted to do. Of course Gordon Gekko had a rather different method of "arbing" M&A and the practice continues we understand!

Great. This solves an issue I had, whereby an acquisition target's volatility becomes very low, and my position sizes became so massive, I had to introduce a cap.

Another area which is nice to have is pending delisting. You can close out your positions in advance.

It should be noted that the price for this data is $85 per month and that this data is not part of the Q pipeline data bundle.

@Seong Lee
Thanks for posting sample algo using this dataset. My question: does it mean that only these 5 data fields are available?

From the link: and its notebook, there are other useful information in the dataset table, e.g. target_type, is_crossboarder, deal_amount,price_pershare. Are these avaiable to access via pipeline not only research model?

Thank you.

I don't find this dataset satisfying. From my casual search of couple M&A deals, PCLN acquires OPEN on Jun 13. 2014 is missing. Also, for those rumor cases, the dataset doesn't follow through, so we have no indication of whether that rumor turns into reality or not. Finally, I know the price of the data set is quite low compared to Thomson Reuter's M&A database. But still, this is rather unsatisfying.