Custom loss functions for XGBoost using PyTorch

Yes. The objective can drive stddev to small value to inflate the Sharpe ratio.

So far, in my experiment this doesn’t seem to be an major issue yet.

My issue is that it seems to optimize for high turnover portfolio, this is even after I subtracted transaction cost from the return in objective function. I am trying artificially larger transaction cost to see if it helps.

There are papers suggesting machine learning based stock prediction typically will optimize toward high turnover, and many so called high return will be gone after taking into account the transaction cost.

How can I use hessian in your sample code? You used np.ones().

I asked the question here python - Custom loss functions for XGBoost using PyTorch: hessian does not work - Stack Overflow.

Thanks a lot.

You probably want to check out this as they got proper hessians working for this purpose: JAX vs PyTorch: Automatic Differentiation for XGBoost | by Daniel Rosenberg | Towards Data Science

2 Likes

@mdo thanks for sharing, their assumption is Hessian is diagonal, when does this usually hold?