How-to use Spyder IDE (in linux) to run/debug Zipline/Quantopian compatible scripts

763 views
Skip to first unread message

xmph .forex

unread,
Oct 21, 2014, 8:31:58 PM10/21/14
to zip...@googlegroups.com
Dear all,
I cannot seem to execute simple examples on spyder IDE, most probably because I would need to load the run_algo.py at some point.
Could anyone let me know how this could be done ?

Here is the zipline/quantopian code I used, that runs OK with run_algo.py

from zipline.api import order_target, record, symbol
from collections import deque as moving_window
import numpy as np

def initialize(context):
    context.short_window = moving_window(maxlen=100)
    context.long_window = moving_window(maxlen=300)
   
def handle_data(context, data):
    # save price to window
    context.short_window.append(data[symbol('AAPL')].price)
    context.long_window.append(data[symbol('AAPL')].price)
   
    # compute averages
    short_mavg = np.mean(context.short_window)
    long_mavg = np.mean(context.long_window)
   
    # trading logic
    if short_mavg > long_mavg:
        order_target(symbol('AAPL'),100)
    elif short_mavg < long_mavg:
        order_target(symbol('AAPL'),0)
       
    # save values for later inspection
    record(AAPL=data[symbol('AAPL')].price,
           short_mavg=short_mavg,
           long_mavg=long_mavg)

Bob Schmidt

unread,
Oct 22, 2014, 9:19:42 PM10/22/14
to zip...@googlegroups.com
Hi xmph,

Here is a link to an example of a file designed to be run in Spyder with Zipline from awhile back.  It is overly long and fancy because I was playing around with stuff but alot of it is just putting together print strings so I could make sure it was doing what I wanted.

best regards

Message has been deleted

xmph .forex

unread,
Dec 5, 2014, 7:47:45 AM12/5/14
to zip...@googlegroups.com
working very well indeed ... (I only saw your post recently as I was spending more time on Q rather than Z).
Thanks for sharing your code.
Reply all
Reply to author
Forward
0 new messages