Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Is there a way to utilize the mavg method from .CSV data?

I'm successfully getting data from a .CSV, and I'd like to chart the price compared to a stock's context sid.

For example:
context.exxon = sid(8347)
exxon = context.exxon
exxon_data = data[exxon]

average_price = exxon_data.mavg(30)
crude_price = int(data['crude']['price'])

is great, but I can't apply .mavg(30) on an int object.

Very new; thanks for any tips.

1 response

Hello Eric,

I don't believe it is possible to use the .mavg() method on your own data, although I may be wrong. I imported the Brent Crude spot price from Quandl. If you only wanted a Moving Average you could use pandas but I have used TA-Lib. I have used talib.SMA() for both Exxon and Brent Crude since I'm not allowed to use:

record(Exxon_MAVG=data[context.exxon].mavg(Window))  

You can see the results are (almost) identical.

P.