Open threehappy opened 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.
%%zipline
@.***邮箱联系我,谢谢!
%%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()
when running above,error happen: UsageError: Line magic function
%%zipline
not found.