Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Please make order_optimal_portfolio contraint reporting messages concise

A suggestion to Q for efficiency.
+1 if you'd like this to happen.

Errors in order_optimal_portfolio show up in the logging window when using try ... except Exception as e; log.info(e)

These messages often exceed logging limits with their verbose style

2015-10-23 06:37  PRINT The attempted optimization failed because no portfolio could be found that  
satisfied all required constraints.

The following special portfolios were spot checked and found to be in violation  
of at least one constraint:

Target Portfolio (as provided to TargetWeights):

   Would violate DollarNeutral() because:  
      Net exposure (0.677157540706) would be greater than max net exposure (0.0001).

   Would violate MaxTurnover(0.3) because:  
      Portfolio turnover (0.682818566498) would be greater than max turnover (0.3).

   Would violate PositionConcentration because:  
      Weight in Equity(23709 [NFLX]) (0.0566395886773) would be greater than max bound (0.045).  
      Weight in Equity(45815 [TWTR]) (0.0602000632003) would be greater than max bound (0.045).  
      Weight in Equity(47208 [GPRO]) (0.0543897175676) would be greater than max bound (0.045).

   Would violate RiskModelExposure() because:  
      Exposure to 'energy' (0.23001977648) would be greater than max exposure (0.18).  
      Exposure to 'health_ca...  

.

Notice the error above is truncated, an unknown amount of lost info.
.

Same information easier to comprehend and would not be truncated, or at least not at that point.

2015-10-23 06:37  PRINT Attempted optimization would not satisfy all required constraints.  
TargetWeights():  
  DollarNeutral()  
    Net exposure 0.67715 > 0.0001  
  MaxTurnover(0.3)  
    Portfolio turnover 0.68 > max  
  PositionConcentration(0.045)  
    Equity23709 [NFLX] 0.0566 > max  
    Equity45815 [TWTR] 0.0602 > max  
    Equity47208 [GPRO] 0.0543 > max  
  RiskModelExposure()  
    'energy' 0.230 > max 0.18  
    'health_ca...  

.

PositionConcentration should always be last in case logging window limits are hit.

Notice the original is offering numbers to the millionths, not useful to us and using up characters, you can set those to just one more decimal vs the limit (as in my example). So, something like that.