hi, I refer to your tutorial for Pipeline API. I copy your code and test run in Quantopian. However, my result and your result was hugely different. In your tutorial example, your algorithm run returns vs SPy is 238.2% vs 174.4% While for my run with your code, which started from the same date until today, the returns is -39.6% I am confuse why the same code, should have give me the same result but it doesn't. Also, the log part was # as I run into run time error
from quantopian.pipeline import Pipeline from quantopian.algorithm import attach_pipeline, pipeline_output from quantopian.pipeline.data.builtin import USEquityPricing from quantopian.pipeline.factors import SimpleMovingAverage
def handle_data(context, data): cash = context.portfolio.cash purchase_value = 1500 for stock in context.my_universe.index: if stock not in context.portfolio.positions: if purchase_value < cash: try: order_target_value(stock, purchase_value) cash -= purchase_value #################################### if stock in context.stocks_sold: context.stocks_sold.remove(stock) except: pass
for stock in context.portfolio.positions: if stock not in context.my_universe.index and stock not in context.stocks_sold: order_target_value(stock, 0) ################################# context.stocks_sold.append(stock)