我正在阅读 Andreas Clenow 所著的《Trading Evolved》一书,并在尝试在 zipilne 上运行第一次回测的代码时遇到断言错误。我是 python 和 zipline 的新手,非常感谢有关如何解决此错误的任何指导。以下是从本书网站获取的源代码:
# This ensures that our graphs will be shown properly in the notebook.
%matplotlib inline
#Import pandas as pd
import pandas as pd
# Import Zipline functions that we need
from zipline import run_algorithm
from zipline.api import order_target_percent, symbol
# Import date and time zone libraries
from datetime import datetime
import pytz
# Import visualization
import matplotlib.pyplot as plt
def initialize(context):
# Which stock to trade
context.stock = symbol('AAPL') …
Run Code Online (Sandbox Code Playgroud) 我正在循环列,但在第一列上不断收到错误,因为它似乎是日期时间。有没有办法让我在第二列开始 for 循环。这是使用 Quantopian 基本数据
for column in Fundamentals.columns:
#print(column)
start=1+start
next = str(column)
Prev=Previous(inputs=[column],window_length=window_length)
Curr=column.latest
diff=Prev-Curr
if(diff>0):
pipe.add(column.latest,next)
if start>10:
break
#print('{}:{},').format(next,column)
Run Code Online (Sandbox Code Playgroud)