A way to gain some visibility into the weights assigned by order_optimal_portfolio,
Edit: Better version below, thus removed the original.
A way to gain some visibility into the weights assigned by order_optimal_portfolio,
Edit: Better version below, thus removed the original.
Visibility into optimize ordering.
Improved. An 'alpha' column added shows the weight inputs to order_optimal_portfolio().
MaximizeAlpha ignores weights as demonstrated here and uses PositionConcentration values until no more room per MaxGrossExposure, ignores the remaining stocks.
For example, if PositionConcentration max/min are +-.04, there will be 25 stocks allocated. If +-.02: 50 stocks (so long as pipeline is supplying at least that many).
Hoping the community will ask some questions and find answers.
What is the MaximizeAlpha criteria for deciding which subset of stocks to invest in?
Is TargetWeights ever influenced by constraints?
[... your questions & answers ...]
In this output, there are 30 stocks with position concentration set automatically to .0333.
Column 'new': What opt is targeting.
Column 'old': Where the allocations landed after the previous targeting of .0333, and reflecting price changes since then surely.
Column 'alpha': Normalized weights in the input to MaximizeAlpha().
I set
conc = .333
expecting 3 positions, there were 4 but the big surprise was they are all short. Curious to know why it selects those 4, knowledge that could be useful. After enabling DollarNeutral() became balanced as expected.
This tool should be educational if you spend some time with it. Or extract just the essentials into your code and look at specific sids for instance or try Frozen() on changes merely 99-101% and see what that does for turnover wiggle-room and so on.
Example output for one day
2018-04-11 05:45 before_trading_start:36 INFO lvrg 1.02 positions 30
2018-04-11 06:31 show_opt_weights:122 INFO
Close
alpha old new
0 0.0361 => 0 DRYS
2018-04-11 06:31 show_opt_weights:150 INFO
Open
alpha old new
0.0312 0 => 0.0333 ACHN
2018-04-11 06:31 show_opt_weights:177 INFO
Changes
alpha old new pct
-0.0011 0.0331 => -0.0333 -100.8% AVP
0.0118 0.0300 => 0.0333 111.0% UPL
0.0032 0.0321 => 0.0333 103.9% PDLI
-0.0118 -0.0323 => -0.0333 103.2% NGD
-0.0269 -0.0325 => -0.0333 102.5% APRN
0.0183 0.0328 => 0.0333 101.5% LC
0.0075 0.0329 => 0.0333 101.3% OPK
-0.0226 -0.0329 => -0.0333 101.2% SGYP
0.0269 0.0330 => 0.0333 101.0% BLDP
0.0011 -0.0357 => 0.0333 -93.5% PDS
0.0290 0.0335 => 0.0333 99.6% ZNGA
-0.0247 -0.0335 => -0.0333 99.4% PLUG
-0.0290 -0.0337 => -0.0333 99.0% EGO
-0.0140 -0.0338 => -0.0333 98.6% ASNA
-0.0172 -0.0340 => -0.0333 98.0% MUX
-0.0043 -0.0341 => -0.0333 97.7% AUY
0.0097 0.0343 => 0.0333 97.3% CHK
-0.0172 -0.0343 => -0.0333 97.1% NVAX
0.0054 0.0344 => 0.0333 96.9% TRQ
2018-04-11 06:31 show_opt_weights:180 INFO
alpha old new pct
-0.0043 -0.0344 => -0.0333 96.9% GTE
0.0226 0.0345 => 0.0333 96.6% JCP
0.0204 0.0346 => 0.0333 96.5% RIGL
-0.0097 -0.0347 => -0.0333 96.1% WFT
0.0247 0.0349 => 0.0333 95.6% TTI
-0.0075 -0.0349 => -0.0333 95.5% BTG
-0.0204 -0.0351 => -0.0333 95.0% STNG
0.0161 0.0355 => 0.0333 93.9% BTE
0.0140 0.0365 => 0.0333 91.2% DNR
-0.0312 -0.0390 => -0.0333 85.5% GSAT