Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Noob question on downlaoding minute data

Hi there,

I'm a noob to Quantopian so sorry for the stupid question.

I simply want to edit the example from the getting started tutorial to use minute instead of daily data.

https://www.quantopian.com/research/notebooks/Cloned%20from%20%22Getting%20Started%20Tutorial%20-%20Lesson%201%22%202.ipynb

My attempt below is based on the description of the data object given here:

https://www.quantopian.com/help#api-data-methods.

I'm currently getting the error: AttributeError: 'DataFrame' object has no attribute 'history'.

Can someone please point me in the right direction.

# Research environment functions  
from quantopian.research import prices, symbols  
# Pandas library: https://pandas.pydata.org/  
import pandas as pd  
'''
# Query historical pricing data for AAPL  
aapl_close = prices(  
    assets=symbols('AAPL'),  
    start='2013-01-01',  
    end='2016-01-01',  
)
'''
appl_close = data.history('AAPL', 'price', 5*390, '1m').dropna(axis=1) 

# Compute 20 and 50 day moving averages on  
# AAPL's pricing data  
aapl_sma20 = aapl_close.rolling(20).mean()  
aapl_sma50 = aapl_close.rolling(50).mean()

# Combine results into a pandas DataFrame and plot  
pd.DataFrame({  
    'AAPL': aapl_close,  
    'SMA20': aapl_sma20,  
    'SMA50': aapl_sma50  
}).plot(
    title='AAPL Close Price / SMA Crossover'  
);
1 response

Hi Baz,

Attached is a notebook that plots minute data. Unfortunately, it seems matplotlib plots the x axis as though it were a monotonically increasing timeseries. The whacky lines you see in the first plot are from gaps on weekends/overnight. The second plot removes the gaps but doesn't have the datetime on the axis. I spent some time trying to add a datetime on the x axis for the second plot, but didn't manage to get it. Perhaps someone else might be able to help with that step.

P.S. The best way to share code from a notebook in the community is by 'Attaching' the notebook when you post.

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.