<jupyter_start><jupyter_text>Step1 - Set the ZIPLINE_ROOT<jupyter_code>import os


os.environ['ZIPLINE_ROOT'] = os.path.join(os.getcwd(), '.zipline')

os.listdir(os.environ['ZIPLINE_ROOT'])


os.environ['ZIPLINE_TRADER_CONFIG'] = os.path.join(os.getcwd(), "./zipline-trader.yaml")

with open(os.environ['ZIPLINE_TRADER_CONFIG'], 'r') as f:
    data = f.read()
    print(data[:20])<jupyter_output><empty_output><jupyter_text>Step2 - Load your Bundle<jupyter_code>import zipline
from zipline.data import bundles

bundle_name = 'alpaca_api'
bundle_data = bundles.load(bundle_name)<jupyter_output><empty_output><jupyter_text>Step3 - Create The Data Portal<jupyter_code>from zipline.pipeline.loaders import USEquityPricingLoader
from zipline.utils.calendars import get_calendar
from zipline.pipeline.data import USEquityPricing
from zipline.data.data_portal import DataPortal

import pandas as pd

# Set the dataloader
pricing_loader = USEquityPricingLoader.without_fx(bundle_data.equity_daily_bar_reader, bundle_data.adjustment_reader)


# Define the function for the get_loader parameter
def choose_loader(column):
    if column not in USEquityPricing.columns:
        raise Exception('Column not in USEquityPricing')
    return pricing_loader

# Set the trading calendar
trading_calendar = get_calendar('NYSE')

start_date = pd.Timestamp('2019-07-05', tz='utc')
end_date = pd.Timestamp('2020-11-13', tz='utc')

# Create a data portal
data_portal = DataPortal(bundle_data.asset_finder,
                         trading_calendar = trading_calendar,
                         first_trading_day = start_date,
                         equity_daily_reader = bundle_data.equity_daily_bar_reader,
                         adjustment_reader = bundle_data.adjustment_reader)<jupyter_output><empty_output><jupyter_text>Let's Get Some Historical Data<jupyter_code>equity = bundle_data.asset_finder.lookup_symbol("ACES", end_date)
data_portal.get_history_window(assets=[equity], end_dt=end_date, bar_count=10,
                               frequency='1d',
                               field='close',
                               data_frequency='daily')<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup