Function FxCalcPeriod() in Eikon API (Codebook)

Please may you advise how I can use the same code from another question "https://community.developers.refinitiv.com/questions/83964/function-fxcalcperiod-in-eikon-api-codebook.html?" or similar to also clone the FX Calc period for a future valuation date?

=FxCalcPeriod("21MAR2022","USDKRW","1M") formula that works correctly in excel with future valuation dates "21MAR2022" (Assume todays actual date is 18th Mar 2022)


top dataframe returned is for todays date 18th Mar 22,

Bottom df is for future date since that works in Excel but seemingly not in python.


Formula works with future valuation_date that works (44641=21st March 2022)

13828-capture.png

13848-capture.png

import refinitiv.dataplatform as rdp

import refinitiv.dataplatform.eikon as rdp_ek
from refinitiv.dataplatform.content.ipa.contracts import cross
from refinitiv.dataplatform.content.ipa import FinancialContracts as fc

#%%
#%%

rdp.open_desktop_session(appkey)


fwd_contract = cross.Definition(fx_cross_code='USDKRW',
fx_cross_type='FxForward',
legs = [cross.LegDefinition(tenor='1M')])
response = fc.get_cross_analytics(fwd_contract,
fields = ['StartDate',
'EndDate',
'FxSwapsCcy1Ccy2',
'FxOutrightCcy1Ccy2'],
calculation_params = cross.CalculationParams(valuation_date='2022-03-21'))

response.data.df

Best Answer

  • wasin.w
    wasin.w admin
    Answer ✓

    Hello @william.smith01

    Please be informed that you can reopen cases 11059746 and 11059661 by sending an email to the support team with the intact subject. Then, the case will be reopened and the support team will take care of any further questions.

    According to the Eikon support team, a solution for the original question is as follows:

    Adfin function DfAddPeriod calculates start and maturity date based on valuation date and chosen currency rules that is why eg in case of USD when the valuation date is 23/03, start date will be 25/03 end date will be 25/04.
    Do you need to calculate only the maturity date or swap points and outrights as well?

    The FWD rates can be valuated as of today (tomorrow works as well) or any historical date.
    So, for example if on Friday (25/03) you want to valuate contract as of Monday (28/03) it won't work because the valuation date in this case is today + 3D.
    My suggestion is to keep current (today's) valuation date and just add StartDate parameter to force contract starting as of any future date you wish. EndDate will be calculated from StartDate automatically.

    If you and to have Python equivalent of DfAddPeriod, we have API endpoint for this (script attached)
    https://apidocs.refinitiv.com/Apps/ApiDocs#/details/L2RhdGEvcXVhbnRpdGF0aXZlLWFuYWx5dGljcy1kYXRlcy1hbmQtY2FsZW5kYXJzL3Yx/L2FkZC1wZXJpb2Rz/POST/PLAYGROUND

Answers