Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Bug - missing split price adjustment.

https://www.quantopian.com/help#overview-datasources:

When your algorithm calls for historical price or volume data, it is adjusted for splits, mergers, and dividends as of the current simulation date. In other words, if your algorithm asks for a historical window of prices, and there is a split in the middle of that window, the first part of that window will be adjusted for the split. This adjstment is done so that your algorithm can do meaningful calculations using the values in the window.

What I see from attached backtest :
Returns are adjusted but not prices.
Missing 10:1 split price adjustment.

13 responses

The same with UWTI
twice missing 10:1 split price adjustments.

Same with JDST
Missing 1:5 split price adjustment.
Jamie, do you want me to continue?

Vladimir,

These are all correctly split adjusted. Before Quantopian 2, we would apply all split + dividend adjustments as of today's date. After the made a change so that the adjustment is applied on the current simulation date. For more information, check out this explanation page.

Let me know if this helps.

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.

Jamie,

These are all correctly split adjusted.

What I see from the chart above:
Put cursor on Sep 30 2015 and look at the price_h value in custom data it is 9.70
Move cursor to Oct 1 2015 and look at the price_h value in custom data it is 41.29
Is the price adjusted ?
You adjusted return for equity calculation but not the price.

That's correct. The price of JDST on Sep 30 2015 was 9.70, and on Oct 1 it was 41.29. The adjustments occur in the lookback window. When your simulation reaches Oct 1, in a data.history window, the values on Sep 30 and further back will be adjusted. For a better explanation, please see this page.

In your example, it might help if you print out prices. You'll see that the entire window will be adjusted on Oct. 1.

Jamie,

If after split prices are as traded and before split prices are as traded where are adjusted prices?
Is there a way to get 'equity' instead of 'price' in data.history?

Vladimir,

Please see this page for a better explanation.

Jamie,

On the charts above I have plotted prices using data.history all of them are as traded before and after split.
From Quantopian Overview

When your algorithm calls for historical price or volume data, it is adjusted for splits, mergers, and dividends as of the current simulation date. In other words, if your algorithm asks for a historical window of prices, and there is a split in the middle of that window, the first part of that window will be adjusted for the split. This adjustment is done so that your algorithm can do meaningful calculations using the values in the window.

I do not see any adjustments to prices in the first part of the window , they are as traded and so I can not do meaningful calculations using the values in the window. Garbage in -> garbage out.

If you do not have the answer to my questions above please do not send me to that page any more but better answer the questions you asked.
1 Are the prices adjusted for split according to above statement from Quantopian Overview?
2 If "Yes" to Q1 point me where they are on custom plot?
3 Is there a way to get 'equity' instead of 'price' in data.history?

Vladimir,

Perhaps this example will help illustrate the behavior.

In the plot, note how the mean as traded price from the last 20 days is different from the mean adjusted price for the 20 days following the split event.

In the logs, note how data.history returns a window of adjusted prices while a window of built up with prices from data.current is not adjusted (keep in mind that the logs on 10/01/2015 are not correct, related to the bug I mentioned earlier, it's being worked on).

Does this help?

Jamie,

I pasted yours part of the code for printing and logging "as_traded" and "adjusted" prices to my algo and I see no difference between them.

2015-09-29 trade:30 INFO as_traded adjusted
2015-09-29 trade:32 INFO 10.28 10.28
2015-09-30 trade:30 INFO as_traded adjusted
2015-09-30 trade:32 INFO 9.70 9.70
Split !:5
2015-10-01 trade:30 INFO as_traded adjusted
2015-10-01 trade:32 INFO 41.29 41.29
2015-10-02 trade:30 INFO as_traded adjusted
2015-10-02 trade:32 INFO 33.86 33.86
2015-10-05 trade:30 INFO as_traded adjusted
2015-10-05 trade:32 INFO 30.53 30.53
2015-10-06 trade:30 INFO as_traded adjusted
2015-10-06 trade:32 INFO 28.52 28.52

So there were no adjustments made to prices.
But what I see from main plot that the trading equity and benchmark equity are split adjusted.
How can I get that equity in my algo instead of data.history(context.asset,'price',20,'1d')?

Vladimir,

The reason the split isn't apparent in your example is because you are only plotting or printing the most recent price using data.history(). The adjusted prices are only visible when you have a lookback window extending back past the current day. I strongly encourage you to run the version I shared and look at the output logs. It should become more apparent. Again, this is meant to reflect how splits will look in live trading.

Jamie,

Lookback window in my algo is 20 days

adjusted_prices = data.history(context.asset,'price',20,'1d')

"adjusted_prices" are only the names they are equal to "as traded" in backtest and so they are not adjusted.

Vladimir,

The adjustments are not necessary for data from the current day, only for data in a lookback window. In your example, you only look at the most recent value from data.history which will be the same as data.current for price. I strongly urge you to look at the resources I've provided more carefully. Try running the example that I shared as is. It is designed to highlight the adjustment behavior.