Navigation

    Quantiacs Community

    • Register
    • Login
    • Search
    • Categories
    • News
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    ERROR! The max exposure is too high

    Support
    4
    4
    36
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • O
      omohyoid last edited by

      @support
      After I tested my strategy,
      I got the warnings below:
      螢幕擷取畫面 2025-06-01 234009.png
      It stated that:

      1. 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.
      2. 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.

      V 1 Reply Last reply Reply Quote 0
      • M
        Marktreadwell Banned last edited by

        This post is deleted!
        1 Reply Last reply Reply Quote 0
        • V
          Vyacheslav_B @omohyoid last edited by

          @omohyoid Hello.

          1. Check which dataset you're loading

          You might have loaded stocks_nasdaq100, but are checking it as if it were stocks_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 of check() for auto-correction

          If you want the system to automatically fix issues like exposure or normalization, replace check() with clean():

          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.

          1 Reply Last reply Reply Quote 0
          • M
            MaryVelez last edited by

            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.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post
            Powered by NodeBB | Contributors
            • Documentation
            • About
            • Career
            • My account
            • Privacy policy
            • Terms and Conditions
            • Cookies policy
            Home
            Copyright © 2014 - 2021 Quantiacs LLC.
            Powered by NodeBB | Contributors