Back to Community
many intermittent crashes/errors when running backtests

Hi everyone,

i've ran many backtests and some of them complete, but most of them break part way through with an error:

Something went wrong. Sorry for the inconvenience. Try using the built-in debugger to analyze your code. If you would like help, send us an email. Need Help? Contact Support  

It seems that the errors occur stochastically. quick and lightweight scripts always finish, and scripts that are computationally intensive often crash at random/intermittent points. is anyone else experiencing this? and Quantopian, any knowledge of the cause?

10 responses

Hi folks, I'm still gettting crashes when running computationally intensive algorithms. Any ideas? Thanks.

Hard to tell what's going on without seeing the code. Every time I've gotten that message, I found a bug somewhere in the code.

so right now, i'm trying to write a crashing algo that is extremely simple.

my issue is that the same algo will run and crash at random times during the backtest, for example, at 22%, 50%, 91%, with no changes to the algo.

You might try sharing your code.

yeah, indeed. I'm trying to invoke an error first to be sure this one breaks.

I don't believe the problem is in toan tran code. In the last week I have been experiencing the same issue, even with algorithms that used to run properly. I believe they made some changes in the platform that resulted in this constant crash of many algorithms.

this one crashes.

Clone Algorithm
Total Returns
Max Drawdown
Benchmark Returns
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
This is a template algorithm on Quantopian for you to adapt and fill in.
import numpy as np
import pandas as pd
import time
def initialize(context):
    schedule_function(my_rebalance, date_rules.every_day(), time_rules.market_open(minutes=1))
    context.count = 0
def before_trading_start(context, data):
def my_assign_weights(context, data):
    Assign weights to securities that we want to order.
def my_rebalance(context,data):
    Execute orders according to our schedule_function() timing. 
    tic = time.time()
    m = []
    for i in range(2000):
    m = pd.DataFrame(m)
    for i in range(2000):
        n = m.sort(i)
    print context.count
    context.count += 1
    toc = time.time()
def my_record_vars(context, data):
    Plot variables at the end of each day.
def handle_data(context,data):
    Called every minute.
There was a runtime error.

I have an algo which is running live fine (and has for months) but I can no longer start a backtest of it. I am not sure if that is the same problem.

I'm guessing they've added something that is causing memory fragmentation. when I ran toan's code it crashed when it was trying to create the big pandas dataframe.

Simon, I've had a similar problem in the past. I think that at some point i accidentally pasted some white space character. this may be the case, or you may have erased 1 character from your code by accident.

So actually, I've had this crashing problem for as long as i can remember. If your algorithms uses machine learning or other computationally intensive processes, there is a much greater chance that it will crash at some intermittent point. It could still be due to memory frag, but I don't think it was a result of recent updates.