@vyacheslav_b Hi, I agree that diversification is always a good idea for trading. It might be helpful if there was an additional function like check_diversification
whith a parameter for the minimum number of assets you want to trade. But this function should only warn you and not fix an undiversified portfolio, because the only way would be to add more assets to trade and asset selection should be done by the strategy itself in my opinion.
@support Hi, I just checked out qnt 0.0.504
and the problem I mentioned seems to be fixed now, thanks!
Would you perhaps consider to add a leverage check to the check
function?
Because one might think "qnout.check says everything is OK, so I have a valid portfolio" while actually having vastly overleveraged like in my 2nd example where weights.sum('asset').values.max()
is 505.0
.
Adding something like this to check
would tell us about it:
log_info("Check max portfolio leverage...")
max_leverage = abs(output).sum(ds.ASSET).values.max()
if max_leverage > 1 + 1e-13: # (give some leeway for rounding errors and such)
log_err("ERROR! The max portfolio leverage is too high.")
log_err(f"Max leverage: {max_leverage} Limit: 1.0")
log_err("Use qnt.output.clean() or normalize() to fix.")
else:
log_info("Ok.")