Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Stock chart that show your strategy entries and exit ?

Hello everybody,

I just created a strategy that works on Apple stock, but in order to arrange it I will need to see the Apple chart with the plots of my strategy's buy and sell (like in Metatrader).
Is there a way to have it in quantopian ?

Thank you in advance.
Chris

5 responses

Hi,
You can use the record() function to help see the days where buys/sells occur. Let's say you want to show a timeseries that shows you buys and sells on the days you make trades. Let's plot a 1 for a Buy, a -1 for a Sell, and 0 when no position.

After you do a buy, on the next line of your code just do:
record(Trade=1)

After you do a sell place this on the line below the sell order:
record(Trade=-1)

Or on days when you don't trade:
record(Trade=0)

Now in your backtest results you'll see this 'Trade' timeseries show up below your trading strategy chart.

Is this way of going about it helpful?

-Justin

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 Justin,

Thank you very much for your answer, I will try it as soon as possible.

Chris

I tried but would it be possible to see those entry/exit point on a Candlestick chart?

Thank you in advance.
Chris

Hi Chris,
Quantopian does not currently have Candlestick charts. The backtest results chart plot is currently really only used to allow user visualization of their portfolio performance in the main plot, and then the plotting of custom timeseries in the sub-plot (which is where any values saved off using the record() metric is plotted after the backtest is run.)

Hopefully adding the recorded buy/sell points as described was somewhat useful -- I understand how you would like to match the buy/sells up with trading of the actual underlying -- its definitely a reasonable request.. Let us know if you were not able to get it recorded and plotted correctly and we can try to help.

-Justin

One of the simple means to accomplish a view into the data produced by a strategy would be to offer a CSV download of the results of a formal backtest. The data is already there, stuffed in JSON no doubt, but buried within the backtest results viewer. A link to fetch the underlying JSON or a CSV translation such that the data could be exported into either Excel or into one of the popular Web3.0 JavaScript visualization tools might be a simple, if temporary step toward providing a more comprehensive charting utility. Such a capability might spawn some creative tools that could be visualization add-ons to the Q's considerable back-end.