Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
memory error - 20 days of minute bars for all stocks

Here's another test case that results in:

There was a runtime error.
MemoryError
Algorithm used too much memory. Need to optimize your code for better performance. Learn More

Note that I am pulling 20 days of minutely data across ~8000 stocks: 62.4 million price values. How many can Q2 support? If it is 8 bytes per point (see Scott's comment, Oct 12, 2015, https://www.quantopian.com/posts/introducing-the-pipeline-api), then it would only take 0.5 GB of RAM, so I don't understand the memory overflow problem.

from quantopian.algorithm import attach_pipeline, pipeline_output  
from quantopian.pipeline import Pipeline  
from quantopian.pipeline.data.builtin import USEquityPricing  
from quantopian.pipeline.factors import CustomFactor

class OvernightGap(CustomFactor):  
    inputs = [USEquityPricing.open,USEquityPricing.close]  
    window_length = 2  
    def compute(self, today, assets, out, open, close):  
        out[:] = 100*(open[-1,:] - close[0,:])/close[0,:]  
def make_pipeline():  
    pipe = Pipeline()  
    gap = OvernightGap()  
    pipe.add(gap, "gap")  
    return pipe

def initialize(context):  
    attach_pipeline(make_pipeline(), 'example')  
    schedule_function(place_orders,  
                      date_rules.every_day(),  
                      time_rules.market_open(hours=1))  
def before_trading_start(context,data):  
    context.output = pipeline_output('example')  
    context.security_list = context.output.index  
    prices = data.history(context.security_list, 'close', 20*390, '1m')  
def handle_data(context,data):  
    pass

def place_orders(context,data):  
    for stock in context.security_list[0:10]:  
        order(stock,1)  
    # prices = data.history(context.security_list, 'close', 20*390, '1m')  
3 responses

Hello, has this been answered somewhere? Thanks

@Martin: Unfortunately there's no concretely defined limit to the number of price values can be loaded. You'll have to try playing with it in your algo.

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.

howdy grant, try removing class overnight gap and calc in function to see if that changes anything.