Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STOXX 600 Equity Bundle help #2826

Open
r54885ab opened this issue Aug 6, 2021 · 1 comment
Open

STOXX 600 Equity Bundle help #2826

r54885ab opened this issue Aug 6, 2021 · 1 comment

Comments

@r54885ab
Copy link

r54885ab commented Aug 6, 2021

Hi there,

This is my first ever issue on GitHub so really sorry if my question is unclear or not in the appropriate format.

I am currently trying to build an equity bundle filled with the STOXX 600. Given this is a basket of European stocks, they all trade on different exchanges throughout Europe with different trading holidays and opening hours.

It appears to me that Zipline is very much geared towards equity bundles which contain stocks that all trade on the exact same exchange. Does anyone know how I might be able to ingest a bundle that does not follow only one trading calendar, but multiple?

What I have done so far:

I have followed the guide located here: https://analyzingalpha.com/zipline-equity-bundle

and with this guide, I have been able to utilize BColzDailyBarWriter() to write the stocks into a BColz format. In the below code, I am looping through my asset_metadata table, which contains information on each stock (i.e its associated exchange code like "XLON", its trading start date and trading end date, etc...), and then setting the calendar argument via the get_calendar() function.

for asset_sid, row in assets_metadata.iterrows():


    daily_bar_writer = BcolzDailyBarWriter(
        calendar=get_calendar(row['exchange']),  # Would love to default to LSE for everything
        start_session=pd.Timestamp("2010-01-04", tz='UTC'),
        end_session=pd.Timestamp("2021-07-29", tz='UTC'),
        filename=r'Stefan_Jansen/ch4/Pt_2_zipline_single_factor/bcolz_sxxp_data/bcolz_sxxp.bcolz'
    )


    daily_bar_writer.write(
        data = parse_pricing_and_vol(
            raw_data,
            asset_sid,
            row['symbol'],
            row['sessions']
        ),
        show_progress=True
    )

But when I get to the register() step, the function is forcing me to select a single calendar (via the register() argument, calendar_name) and so I am a bit stumped because all my stocks must then follow the trading days of that one calendar. Should I write a new register() function for every exchange and its associated stocks?

from zipline.data.bundles import register, sxxp_bundle

register('sxxp_bundle', sxxp_bundle.ingest, calendar_name='????')

Any help on this issue would be a huge godsend! Thank you all.

@beglitis
Copy link

beglitis commented Jul 5, 2023

Hi there, did you ever figure out the answer on this one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants