Hi,
How can I see buy and sell signals on the chart and table, can I draw a forward looking chart with this signals ?
Thanks,
Hi,
How can I see buy and sell signals on the chart and table, can I draw a forward looking chart with this signals ?
Thanks,
Hi Joe,
You can create a custom signal to indicate when the algorithm buys/sells positions by track the length of your portfolio. You can then draw it on the custom graph using the record() function.
For example,
record(pos = len(context.portfolio.positions))
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.
Alisa, do you have any example of a video of how it looks like? I was trying to search for any kind of an example, but failed to find any.
I mean an example, where I can see a chart with buy and sell entries for a backtesting strategy, even the simplest one.
There isn't a video of how to record signals that I am aware of. However, attached is a backtest which records both a buy and a sell signal. The specific code is
def record_vars(context, data):
"""
Plot variables at the end of each day.
Here we record the buy and sell signals returned from our pipeline
Record only supports single numeric values.
If a signal is a boolean value convert to integer first
"""
pipe_results = algo.pipeline_output('pipeline')
record(buy=int(pipe_results.buy_signal), sell=int(pipe_results.sell_signal))
The plot of the signals appears in the bottom of the IDE graph when running 'build algorithm' and labeled 'custom data' (which can be seen in the attached algo below). The signals can also be viewed in the full backtest results by clicking on the activity
tab and then clicking custom data
.
A few things to note about using the record
function.
record
statements within a program (all the variables do not need to be defined at one time).Hope that helps.
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.