Back to Community
How to control position concentration?

I am new to the Q . I am doing my first algo and have some difficulty dealing with position concentration using the optimzealpha. When I run backtest, I meet 6/7 risk profiles except that I see a one day spike in positions. I am not sure how to fix that. Please help!

Here are some of the params/constraints I use:

Constraint Parameters

MAX_GROSS_LEVERAGE = 1.0  
MAX_SHORT_POSITION_SIZE = 0.025  # 1.5%  
MAX_LONG_POSITION_SIZE = 0.025   # 1.5%  
MIN_BETA_EXPOSURE = -0.005  
MAX_BETA_EXPOSURE = 0.005  
MAX_SECTOR_EXPOSURE = 0.10

 constraints = []

constrain_gross_leverage = opt.MaxGrossExposure(MAX_GROSS_LEVERAGE)  
constraints.append(constrain_gross_leverage)  


constrain_pos_size = opt.PositionConcentration.with_equal_bounds(  
    -MAX_SHORT_POSITION_SIZE,  
    MAX_LONG_POSITION_SIZE,  
)  
constraints.append(constrain_pos_size)  

market_neutral = opt.WeightedExposure(  
    loadings=pd.DataFrame({'beta': context.returns.beta}),  
    min_exposures={'beta': -MAX_BETA_EXPOSURE},  
    max_exposures={'beta': MAX_BETA_EXPOSURE},  
)  
constraints.append(market_neutral)

dollar_neutral = opt.DollarNeutral(tolerance=0.001)  
constraints.append(dollar_neutral)  

sector_neutral = opt.NetGroupExposure.with_equal_bounds(  
    labels=context.sector,  
    min=-0.1,  
    max=0.1,  
)  
constraints.append(sector_neutral)  

constrain_sector_style_risk = opt.experimental.RiskModelExposure(  
    context.risk_loading_pipeline,  
    version=opt.Newest,  

)  
constraints.append(constrain_sector_style_risk)

order_optimal_portfolio(
objective=objective,
constraints=constraints
)

4 responses

As prices change, the position concentration of each stock in your portfolio would change as well.

Try rebalancing more frequently, decreasing the position concentration constraint you have in (MAX_SHORT_POSITION_SIZE, MAX_LONG_POSITION_SIZE), or strengthening the alpha signal.

Thanks, Adam,

I find out that the spike was caused by XL_8340 at Aug 25 2015. I cannot find what its name is. My guess is it has been de-listed

That's great, perhaps you could pass a filter not to trade that stock and see if it improves anything. I don't think Q releases a mapping between sids (8340) and company tickers.

I did as you suggest. Problem solved. Now I meet all criteria. Thanks a lot!