Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
plotting question

I've attached an algorithm that records and plots the relative difference in price for Netflix (NFLX) from the end of trading on day 0 to the start of trading on day 1:

if context.new_day:  
        print data[context.stocks[0]].datetime  
        price_diff = 100*(current_price/context.previous_price-1)  
        print price_diff  
        record(price_diff = price_diff)  

When the algorithm starts plotting, the resolution appears to be day-level. However, it then switches to averaged/smoothed data and the plot becomes inaccurate and misleading.

Is there any way to turn off the averaging/smoothing so that the data are plotted at full resolution?

UPDATE: It appears that when I post an algorithm, the plot is at full resolution, but the results shown to me at the end of the backtest are averaged/smoothed. I will do a screen shot and post it, to highlight the difference.

--Grant

5 responses

Here's what I see when I run the backtest:

Our charting software looks like it's getting aggressive in that display. I'll write a bug and see if we can keep the higher resolution.

Dan

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.

Hello Dan,

How is the charting supposed to work? Should it display all of the points? Does it smooth/average/bin? The help page only states:

Records the given series and values. Generates a chart for all recorded series.

Aside from the problem noted above, the scaling seems to have a problem. In the attached example backtest, shouldn't current_price and price_diff be plotted on different scales? As it is, only current_price is on a scale that reveals its variation.

Grant

Hi Grant

Charting does not display all of the points. It does things like average values (like prices) and sum (bin) for things like volumes. I don't have a hard set of rules for when that happens. In general, we display as much data as we can, and start collapsing when we have to. If you think about a minutely test for 4 years, for instance, that's 340,000 data points - no monitor can display that. We've made efforts to make the graphs "true" - no interpolation, no curve fitting, stuff like that. But you shouldn't look at a graph and think that you are seeing all of the data.

As for the second question, about plotting custom variables: we made a design decision to plot it all on one axis. You can plot up to five variables, and there isn't a clean way to plot against five different axes. What you can do is click the word "current_price" in your graph. You'll see that toggles the data on and off the graph, and the axis will redraw. That lets you see your individual custom variables as you see fit.

In the long run, I'm sure we'll add more detailed plotting capabilities. The current implementation has its limitations, as you see, but it solves many of the use cases.

Thanks Dan,

Good tip on clicking the variable name to toggle it on/off.

Grant