Instrument Pricing Analytics - Pricing THB IRS gives only errors

mikael.ohman
mikael.ohman Newcomer
edited December 2024 in Refinitiv Data Platform

I used to be able to price an IRS like this:

def get_thb_legs(fixed_rate_pct:float=None, floating_spread_bps:float=None, receive_fixed:bool=True, notional_amount:float=100):
  fixed_dir, float_dir = ('Received', 'Paid') if receive_fixed else ('Paid', 'Received')

fixed_leg = { 'legTag':'Fixed', 'direction':fixed_dir, 'interestType':'Fixed', 'notionalCcy':'THB', 'notionalAmount':notional_amount, 'interestPaymentFrequency':'SemiAnnual', 'interestCalculationMethod':'Dcb_Actual_365', } if fixed_rate_pct is not None: fixed_leg['fixedRatePercent'] = fixed_rate_pct float_leg = { 'legTag':'Floating', 'direction':float_dir, 'interestType':'Float', 'interestPaymentFrequency':'SemiAnnual', 'interestCalculationMethod':'Dcb_Actual_365', 'notionalCcy':'THB', 'notionalAmount':notional_amount, 'indexName':'THBFIX', 'indexTenor':'6M' } if floating_spread_bps is not None: float_leg['spreadBp'] = floating_spread_bps return [fixed_leg, float_leg]


return { 'fields': flds, 'universe': [{ 'instrumentType': 'Swap', 'instrumentDefinition': { 'instrumentTag': instr_tag, 'startDate': start_date.strftime('%Y-%m-%d'), 'tenor': tenor, 'legs': legs, #'settlementCcy': settlement_currency , could not get this to work. } }], 'pricingParameters': { 'valuationDate': valuation_date.strftime('%Y-%m-%d'), 'discounting_ccy': deal_currency, 'discounting_tenor': 'OIS' }, 'outputs': ['Data', 'Headers'], }


But now I just get errors:

'Invalid market data input for interest rate curve. No curve points could be determined to build discount rate model.'


How can we price THB IRS ?

Best Answer

  • mikael.ohman
    mikael.ohman Newcomer
    Answer ✓

    The solution is to use:

    'pricingParameters': {

            'valuationDate': valuation_date.strftime('%Y-%m-%d'),
    
            'useCurveBuilder': True, # THB fails if not using the curve build
    
            'discounting_ccy': deal_currency, # could not get settlement currency to work.
    
            'discounting_tenor': 'OIS'
    
        },

    in the call.

Answers

  • Hi @mikael.ohman ,

    I had simillar issues in the past, and wrote this article as a result:

    Troubleshooting IPA & RD Python Library: https://developers.lseg.com/en/article-catalog/article/troubleshooting-ipa-and-the-data-library-api-in-python


    The way I found the culprit in my body was through trial and error. I would suggest the same here. I wrote about just this at the end of the article:



     

    I recently came uppon a second error returned from IPA, ''ErrorMessage" `Unable to calculate the Implied Volatility` and "ErrorCode" `QPS-Pricer.4011`.

    I went through the technique above, and found the folowing test call totry out on the API Playground:

     

    {

      "universe": [

        {

          "instrumentType": "Option",

          "instrumentDefinition": {

            "buySell": "Buy",

            "callPut": "Call",

            "underlyingType": "Eti",

            "instrumentCode": "STXE45500N4.EX",

            "strike": 4550

          },

          "pricingParameters": {

            "pricingModelType": "BlackScholes",

            "underlyingTimeStamp": "Default",

            "volatilityType": "Implied",

            "marketValueInDealCcy": 4534.61,

            "reportCcy": "EUR",

            "riskFreeRatePercent": 3.938,

            "underlyingPrice": 4534.61,

            "valuationDate": "2023-12-18T11:10:00Z"

          }

        }

      ],

      "fields": [

        "ErrorMessage",

        "ErrorCode",

        "MarketValueInDealCcy",

        "RiskFreeRatePercent",

        "UnderlyingPrice",

        "Volatility",

        "DeltaPercent",

        "GammaPercent",

        "RhoPercent",

        "ThetaPercent",

        "VegaPercent"

      ]

    }

     What I then did, on the Playground, was remove one (and only one) argument. I found out, through this trial and error proccess that the the culprit was "marketValueInDealCcy".

    apitroubleshoot.PNG

     

    Removing this argument showed that this option was trading at a much lower rate, making Greeks imposible to calculate.

    Please do let me know if you did not find the culprit argument in the body after going through the above.

  • Hi @mikael.ohman

    Thank you for your participation in the forum.

    Is the reply above satisfactory in answering your question?

    If yes please click 'Yes' next to the text ‘Did this answer the question?’, and then close the question. This will guide all community members who have a similar question.

    Otherwise please post again offering further insight into your question.

    Thanks,

    AHS

  • Hi @mikael.ohman

    Thank you for your reply. Leaving the answer after finding it yourself is very appreciated; it helps anyone else using this API to find the answer quickly on this Forum in the future.

    Thank you!