Back to Community
Sneak Peek: Using a Quantopian Research Notebook to Analyze Share Buyback Data

About 4 months ago, we announced that we were hard at work building a hosted research platform for analyzing our curated datasets, your Quantopian algorithms, and your backtest results.

For the first time, we want to share a notebook here in the forums to give you a sneak peek into how the research platform is progressing and more importantly how it can help you craft better trading algorithms.

We collaborated with EventVestor, a data vendor who provides information about corporate events. Specifically, EventVestor has provided us with data on share buyback announcements. In the notebook, we explore the idea of a post-share buyback announcement drift in stocks. We load raw data from EventVestor into the notebook and dig into the various attributes provided by the data to better understand our options when building an algorithm. With that knowledge in hand, having built an algorithm to use the data, we then explore the results from each variation.

Below is a chart from the notebook that summarizes our findings. We're able to optimize our parameters through the course of the notebook. We find the optimal combination of variables for maximizing returns, maximizing Sharpe ratio and minimizing drawdown.

Click the "VIEW NOTEBOOK" button and scroll through the notebook to see our step by step process for testing and optimizing our strategy.

The algorithm used for this analysis is found on this thread, please scroll down to find the backtest.

The sample data in this algorithm provides a static snapshot between January 2007 - January 2015. That being said, fetch_eventvestor is not allowed in Live Trading and your algorithm will throw an error if you try to deploy it in either paper, context, or live trading modes!

We are working to incorporate this data in a more permanent fashion but until then, you can contact EventVestor for more information.

If you'd like to look at the drift found in this event, you can find the followup event study here.

Loading notebook preview...
Notebook previews are currently unavailable.
Disclaimer

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.

15 responses

Perhaps this event study is similar to Balch's insider trading analysis.

http://augmentedtrader.com/2013/08/12/assessment-of-insider-trading-information-for-investment-strategies/

I hope that "Clone this notebook" will be a next feature.

Would be interested to see results when taking into account relevant benchmarks in order to see excess returns over benchmark and thus to get a handle on the strategy's alpha.

Hi all,

The algorithm that we used for the backtest is included here. We use a custom fetch_eventvestor method that will get you a static set of data from 2007 up till January, 2015.

There are a number of different parameters that you can change in order to fiddle around with the algorithm:

  • context.days_to_hold_positions - The number of days to enter into a position before exiting
  • context.hedge_lookback - The number of days to look back before calculating our beta hedge (SPY)
  • In choose strategy, you have a number of different lines that you can comment/uncomment to turn on the different parts of the strategy found in the notebook.

Notes:

The sample data in this algorithm provides a static snapshot between January 2007 - January 2015. That being said, fetch_eventvestor is not allowed in Live Trading and your algorithm will throw an error if you try to deploy it in either paper, context, or live trading modes!

We are working to incorporate this data in a more permanent fashion but until then, you can contact EventVestor for more information.

Clone Algorithm
85
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
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
# Backtest ID: 54d52bbfcc61a806cdfdf313
There was a runtime error.

Say for example that ABC announces a buy-back, and you go long the position for say 20 days, and during those 20 days the stock went up 20% (annualized) while the S&P index went up 30%. DEF announced a buy back. You held the position for 20 days and DEF went up 8% while the S&P index went down 10%. Clearly DEF was the better trade, but is that captured in your analysis?

Abraham,

We're basing a lot of this algorithm off a previous event study, but I think you bring up a good point. The analysis we have above doesn't actually show the drift from the individual trade alone, rather it shows the effectiveness of the trading strategy using buybacks as a signal.

Would you be interested in seeing the event study using our same Research Notebook?

Seong

Yes please!

I find this to be very interesting. It would be great if Quantopian could make this a corporate event-like data feed available in production.

I attached a version that I think will improve the accuracy of the beta hedge (eg, shorting SPY) to better meet the objective of being both risk neutral and approximately cash neutral.

http://quant-coder.prokopyshen.com

Clone Algorithm
33
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
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
# Backtest ID: 54db5eaffbac58092859440e
There was a runtime error.

Richard,

We are definitely working in that direction! In the mean time, you can contact Anju from EventVestor to gain access to the data. I'll PM you his email address (or you can submit your name on the form at www.eventvestor.com/quanto)

EventVestor is very interested in providing this kind of data at prices that individuals can afford. We have used fetcher successfully with their data.

All the best,
Josh

Disclaimer

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.

Hi all,

A followup event study has been conducted to this thread. Check out (https://www.quantopian.com/posts/research-looking-for-drift-an-event-study-with-share-buybacks-announcements) to see the results!

Seong

I found this writeup on zerohedge.com interesting given this algo's approach. Specifically the data on the volume of buybacks in the previous month: http://www.zerohedge.com/news/2015-02-28/here-reason-why-stocks-just-had-their-best-month-october-2011

Hi Seong, Thank you for this innovative algo. When I clone and build, I get an error message for line 211. Am i doing something wrong?

Could be a data issue.

Commenting out line 211 and inserting some print statements:

# symbols = [s.symbol for s in sids]  
print 'sids',type(sids),sids  
symbols=[]  
for s in sids:  
    print 's',type(s),s  
    symbols.append(s.symbol)

And then running 01/25/2007 to 02/02/2007.

On 2007-01-26 we see that the usual format of the fetcher_data['sid'] looks like this:

2007-01-26 PRINT sids
2007-01-26 PRINT type 'set'
2007-01-26 PRINT
set([Security(12160, symbol='COF', security_name='CAPITAL ONE FINANCIAL CORP', exchange='NEW YORK STOCK EXCHANGE', start_date=Timestamp('1994-11-16 00:00:00+0000', tz='UTC'), end_date=Timestamp('2015-04-01 00:00:00+0000', tz='UTC'), first_traded=None)])

But on 2007-02-01, the entry returned looks different:

2007-02-01PRINT sids
2007-02-01PRINT type 'set'
2007-02-01PRINT
set([0, Security(20163, symbol='WCC', security_name='WESCO INTERNATIONAL INC', exchange='NEW YORK STOCK EXCHANGE', start_date=Timestamp('1999-05-12 00:00:00+0000', tz='UTC'), end_date=Timestamp('2015-04-01 00:00:00+0000', tz='UTC'), first_traded=None)])

There is an integer of value zero as the first element in the set instead of the expected security object.

Richard
http://quant-coder.prokopyshen.com/ContactMe

Hi Easan and Richard,

I believe that this: There is an integer of value zero as the first element in the set instead of the expected security object. is the answer to the question. The best fix for now is to have the following line of code while we investigate the problem!

if 0 in sids: sids.remove(0)

A belated thank you, Richard and Seong.