ERROR! The max exposure is too high
-
@support
After I tested my strategy,
I got the warnings below:
It stated that:- WARNING! The kind of the data and the output are different.
The kind of the data is None and the kind of the output is stocks_s&p500
The output will be cleaned with the data kind. - ERROR! The max exposure is too high.
Max exposure: [0.05555556 0.05555556 0.05555556 ... 0.05882353 0.05882353 0.05882353] Hard limit: 0.1
Use qnt.output.cut_big_positions() or normalize_by_max_exposure() to fix.
Do I need to fix the exposure? Exposure of 0.0588 is below the hard limit 0.1, so it seems that I don't need to decrease the current weights. Am I correct?
BTW, can I just ignore the warning " WARNING! The kind of the data and the output are different." ?
I don't know what should I fix according to this warning. - WARNING! The kind of the data and the output are different.
-
This post is deleted! -
@omohyoid Hello.
1. Check which dataset you're loading
You might have loaded
stocks_nasdaq100
, but are checking it as if it werestocks_s&p500
.Incorrect:
import qnt.data as qndata import qnt.ta as qnta import qnt.stats as qnstats import qnt.output as qnout import xarray as xr data = qndata.stocks.load_ndx_data(min_date="2005-06-01") qnout.check(weights, data, kind="stocks_s&p500")
Correct:
data = qndata.stocks.load_spx_data(min_date="2005-06-01") qnout.check(weights, data, kind="stocks_s&p500")
️
kind
must match the actual dataset being used, otherwise some checks (e.g., liquidity or available dates) will not behave correctly.
2. Handling Exposure
If your exposure does exceed the limit on some days, you can fix it using one of the following methods (see the documentation — Applying Exposure Filters:
import qnt.output as qnout import qnt.exposure as qnexp weights_1 = qnexp.cut_big_positions(weights=weights, max_weight=0.049) weights_2 = qnexp.drop_bad_days(weights=weights, max_weight=0.049) weights_3 = qnexp.normalize_by_max_exposure(weights, max_exposure=0.049) weights_4 = qnout.clean(weights, data, "stocks_s&p500")
3. Use
clean()
instead ofcheck()
for auto-correctionIf you want the system to automatically fix issues like exposure or normalization, replace
check()
withclean()
:import qnt.output as qnout weights = qnout.clean(weights, data, "stocks_s&p500")
Exposure of 0.0588 is below the hard limit of 0.1, so in this particular case, it does not violate any constraints. The error may have been triggered by other days or higher values elsewhere in the data — it's worth double-checking.
-
This script provides valuable insights into portfolio optimization, especially for managing exposure limits. Thank you for sharing! To address the max exposure error, consider adjusting the optimization parameters, reducing position sizes, or exploring alternative asset allocation strategies. qnt.output.cut_big_positions() is a good suggestion, and perhaps also tweaking risk tolerance settings.