Can someone help with the error message shown below? I'm trying to exclude the symbol 'SHA', altogether, although if there's a global fix I'd rather use that. I thought the 'exclusion_filter' would exclude SHA but apparently something's not set up correctly.

Is there a simpler method to exclude single SIDs as part of the mask?

Something went wrong. Sorry for the inconvenience. Try using the built-in debugger to analyze your code. If you would like help, send us an email.
Rows/Columns with NaNs:
row=Equity(32430 [SHA]) col='industrials'
row=Equity(32430 [SHA]) col='momentum'
row=Equity(32430 [SHA]) col='short_term_reversal'
row=Equity(32430 [SHA]) col='size'
row=Equity(32430 [SHA]) col='value'
... (1 more)
Rows/Columns with Infs:
None
There was a runtime error on line 413.



Code for the exclusion list (note that SHA (32430) is included):

def initialize(context):
context.exclusion_list = [sid(34692), sid(19666), sid(46369), sid(3585), sid(32620), sid(42786),sid(32430)]


Code for the exclusion filter, included with the pipeline screen.


exclusion_filter = ~StaticAssets(context.exclusion_list)
# --------------
# Create and register a pipeline computing our combined alpha and a sector
# code for every stock in our universe. We'll use these values in our
# optimization below.
pipe = Pipeline(
columns={
'alpha': combined_alpha,
'sector': Sector(),
'factor': factor,
},
# combined_alpha will be NaN for all stocks not in our universe,
# but we also want to make sure that we have a sector code for everything
screen=combined_alpha.notnull() & Sector().notnull()& mask & exclusion_filter,
#screen=exclusion_filter,
)


Lines 411 through 414:

    constrain_sector_style_risk = opt.experimental.RiskModelExposure(
)


My coding skills aren't great, so actual code examples to rectify this would be greatly appreciated.

Thanks,
Troy

1 response

Problem solved. I changed line 412 to the following:

 context.risk_loading_pipeline.dropna(),


This was based on the following post: ValueError: NaN or Inf values provided to FactorExposure for argument 'loadings'

Troy