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

Calendar hardcoded to US stock market #2434

Open
willianpaixao opened this issue Feb 27, 2019 · 5 comments · May be fixed by #2674
Open

Calendar hardcoded to US stock market #2434

willianpaixao opened this issue Feb 27, 2019 · 5 comments · May be fixed by #2674

Comments

@willianpaixao
Copy link
Contributor

Hi fellow maintainers,

I've been trying to ingest non-USA CSV bundles with Zipline, but it proved much harder than I calculated.
Turns out that there are some hardcoded variables that bind the process to only NYSE and UTC data.
Follow some lines I had to change in order to have a successful (without crashes) bundle ingestion:

metadata['exchange'] = "CSVDIR"

register_calendar_alias("CSVDIR", "NYSE")

When I tried to fix the values, I've got an error here:

File "zipline/data/bundles/csvdir.py", line 161, in csvdir_bundle      
    metadata['exchange'] = calendar_name                                                                                 

NameError: name 'calendar_name' is not defined

It looked weird but I didn't have time to follow up and debug it.

My current state is simply change the hardcoded values from 'NYSE' to 'BVMF' and it works.
Any suggestions on how to fix it for the long term?

@willianpaixao
Copy link
Contributor Author

@ssanderson @freddiev4 any feedback?

@billmoling
Copy link

what you have made to get it work? @willianpaixao

@llllllllll
Copy link
Contributor

Instead of setting an exchange of CSVDIR, we should have an environment variable that can be set at ingest time where users can set the calendar. Maybe something like CSVDIR_EXCHANGE=XNYS or something. The string would need to be a name that trading_calendars can parse. We can preserve the default calendar of XNYS (which NYSE is an alias of) if a user doesn't provide a value.

I think the code changes needed to make this work are:

  1. Change line 161 to: metadata['exchange'] = os.environ.get('CSVDIR_EXCHANGE', 'XNYS')
  2. Remove line 227

@billmoling
Copy link

@llllllllll Thanks very much. It works.

willianpaixao added a commit to willianpaixao/zipline that referenced this issue Mar 25, 2020
Fix quantopian#2434

Pending testing. Still work in progress.
@willianpaixao willianpaixao linked a pull request Mar 25, 2020 that will close this issue
@willianpaixao
Copy link
Contributor Author

@llllllllll I've followed your suggestion then tested #2674 locally and it works.

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

Successfully merging a pull request may close this issue.

3 participants