Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Quantopian is not buying and selling when I tell it to.

I have made an algorithm which sells shares when the market was increasing yesterday and starts falling today and buy them when it was falling yesterday and starts increasing today. However from the back test I can see that it is not following these rules.

I am new to quantopian and I am not sure if it is an error on my part or a bug. The log.info doesnt seem to be working which is further hindering my ability to debug. Any help is much appreciated.

It is not supposed to sell it on December 16 as market was increasing both yesterday and today but it sold it anyway. It should try to sell (0 shares) on 12th, buy on 15th and sell on 18th.

2 responses

Hi Ghost,

I took a look at your algo and I'm not sure that I totally follow. According to the recorded variables graph, I would expect trades to occur on the 11th, 14th, and 17th if I understand the logic correctly. The 12th was a Saturday so I definitely wouldn't expect that! That being said, it looks like there is a problem with the trade on the 11th and it's being logged as a weekend trade (on the 13th) in transaction history. This is definitely a bug and we'll have to get that fixed.

As a 'now' solution, I would recommend you use minute mode and use the schedule_function() method to get your logic to run once at the end of each day. Running in minute mode should avoid the problem in the transaction logs. I've attached a minute mode version to this post.

Regarding the logging issue, we are aware of this and our engineers are currently working on a solution. If you run a "Full Backtest", wait until the backtest is complete, and then refresh the backtest page, your logs will show up in the "Log Output" tab. Alternatively, you can use the debugger tool to step through your code one line at a time.

I hope 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.

Thanks I got it to work. Here is a full commented code.