Back to Community
Quantopian, computation intensive algos always crash

Quantopian, I run pretty computation intensive algos, and have been having serious crashing problems. attached is an example of code that crashes.

can we fix this?

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
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))
    schedule_function(my_rebalance, date_rules.every_day(), time_rules.market_open(minutes=2))
    context.count = 0
def before_trading_start(context, data):
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 handle_data(context,data):
    Called every minute.
There was a runtime error.
3 responses

Quantopian Staff?

Hi Toan,

There is a limit to memory consumption in Quantopian algorithms.

While we are working on extending the amount of computational power available to backtests, the best practice is to cut down on memory usage wherever possible.

In order to better understand the use case, could you share your algorithm? There may be a way to reduce its spatial complexity and get it running.

Lotanna Ezenwa


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.


if you run the code i posted above, it doesn't really use a lot of memory but will crash because it is computation intensive.