quantopian / zipline

Zipline, a Pythonic Algorithmic Trading Library
https://www.zipline.io
Apache License 2.0
17.56k stars 4.71k forks source link

UsageError: Line magic function `%%zipline` not found. #2835

Open threehappy opened 2 years ago

threehappy commented 2 years ago

%%zipline --start 2010-1-1 --end 2018-1-1 --data-frequency daily --no-benchmark from zipline.api import order_target, record, symbol import pandas as pd

def initialize(context): context.i = 0 context.assets = [symbol('FB'), symbol('GOOG'), symbol('AMZN')]

def handle_data(context, data): df = data.history(context.assets, fields=['price', 'volume'], bar_count=1, frequency="1d")
df = df.reset_index()

if context.i == 0:
    df.columns = ['date', 'asset', 'price', 'volume']
    df.to_csv('stock_data.csv', index=False)
else:
    df.to_csv('stock_data.csv', index=False, mode='a', header=None)
context.i += 1

when running above,error happen: UsageError: Line magic function %%zipline not found.

andycwang commented 2 years ago

@.***邮箱联系我,谢谢!