Back to Community
TypeError in MaximizeAlpha()

I know someone asked this question before and it turned out that his problem was with divide by zero or empty series passed in.

In my case, I pass a Non-empty series of float type and get this error: "TypeError: MaximizeAlpha() expected a value with dtype 'float64' or 'int64' for argument 'alphas', but got 'object' instead." . then I tried to replace (any) inf with nan and dropna, that did not fix the problem.

I added log to see what happended:
objective = opt.MaximizeAlpha(alpha)
except:'MaximizeAlpha exception')

here is the log:
2014-05-05 09:35 do_portfolio_construction:191 INFO MaximizeAlpha exception
2014-05-05 09:35 do_portfolio_construction:192 INFO
Equity(43721 [SCTY]) 9.45685
Equity(41579 [P]) 2.63471
Equity(42118 [GRPN]) 2.46888
Equity(44747 [DATA]) 1.52521
Equity(42230 [TRIP]) 1.24
Equity(39840 [TSLA]) 0.95456
Equity(42788 [PSX]) 0.940191
Equity(39095 [CHTR]) 0.868083
Equity(13711 [PCYC]) 0.852267
Equity(32301 [CTRX]) 0.80803
Equity(43405 [KRFT]) 0.786578
Equity(168 [AET]) 0.685958
Equity(26892 [HLF]) 0.666981
Equity(38650 [AVGO]) 0.624734
Equity(28016 [CMG]) 0.506531
Equity(3620 [HFC]) 0.499281
Equity(20208 [FFIV]) 0.391471
Equity(33698 [TMUS]) 0.351509
Equity(4799 [CVS]) 0.333276
Equity(23021 [ECA]) 0.278887
Equity(6119 [PPL]) 0.27836
Equity(1539 [CI]) 0.262415
Equity(24475 [CME]) 0.253666
Equity(7792 [UNH]) 0.252637
Equity(20541 [RHT]) 0.250401
Equity(7684 [TSN]) 0.233789
Equity(7244 [SWN]) 0.21916
Equity(21448 [SINA]) 0.212618
Equity(9736 [GMCR]) 0.210744
Equity(27809 [ICE]) 0.202887

2 responses

For some reason, the alpha I passed in was not what I expected to be a series. So I make the conversion into float64 now.

Have you rectified the issue? And how? I am stuck with the same error as well :(