Blueshift NIFTY50 symbol error

Hello Team,



Recently I have been receiving error: 

Equity(959 [NIFTY50]) does not exist on 2020-07-31 00:00:00+00:00. It stopped trading on 2020-07-06 00:00:00+00:00.

I have to explicitly code to skip it in looping operations because code breaks if this symbol shows up on scan.



Any inputs on better way to handle it?



Thanks.

I assume you are using Pipeline API, probably the example here. Right now I can offer a hackish solution for this. We will soon migrate our data infrastructure, where we can offer a more elegant solution. 



For the time being, define a custom filter like below that exclude specified assets from scan.

 

from zipline.pipeline import CustomFilter
def exclude_assets(universe):
    class FilteredUniverse(CustomFilter):
        inputs = ()
        window_length = 1
 
        def compute(self,today,assets,out):
            in_universe = [asset not in universe for asset in assets]
            out[:] = in_universe
 
return FilteredUniverse()


Then define a variable somewhere in your initialize function that lists the symbols to exclude, like below:
 
context.exclude = [symbol(s) for s in ['NIFTY50']]

Finally, instantiate this filter in your pipeline definiton function (make_strategy_pipeline in the link) 
 
universe_filter = exclude_assets(context.exclude)

and use this filter in the pipeline set_screen call (or combine with existing filter), like:
 
pipe.set_screen(volume_filter & universe_filter)

Hope this solves your problem. You can add or remove symbols from the context.exclude list.

Thanks a lot Prodipta for a prompt reply and solution.



Yes, I use Pipeline API most of the times without any custom filter or custom factor which gives me list of NIFTY 500 symbols which use in loop for further computations for each symbol.



From Blueshift and Quantopian/Zipline documentation I know that custom filters and custom factors is the right way to code on these platforms. You showed that with example for my query very nicely.



One thing I would like to mention here is,after I was comfortable with Blueshift, I started coding outside of Blueshift  using some freely available APIs without broker account, free API that comes with broker account and then immediately noticed that there were limitations on per minute or per second API calls, thier data accuracy is questionable. Support was extremely poor. Many times there were no replies from support team. API solutions which are reliable and have data accuracy, charge good amount for it. More of if someone is new to Python ecosystem there well be problems with pip install too. 



No need to say, I was back to Blueshift :slight_smile:

Blueshift is gem. It lifts all above burden off your shoulders and set you free to focus on strategy implementation.



Kudos to Prodipta and Blueshift team. 

We are absolutely delighted that you find the platform useful. Please feel free to share your feedback or suggestions to make it better!