Setting start date for fxforward and is it possible to get the data of multiple tenors and fx forwar

fwd_contract = cross.Definition(fx_cross_code='GBPCNY',

fx_cross_type='FxForward',

legs = [cross.LegDefinition(start_date='2024-06-30T00:00:00Z', tenor='3M')])

response = fc.get_cross_analytics(fwd_contract,

fields = ['StartDate',

'EndDate',

'FxSwapsCcy1Ccy2',

'FxOutrightCcy1Ccy2'])

print(response.data.df)


I read the documentation and isn't start_date suppose to be in legdefinition, but when i run the code it turns into error

TypeError: LegDefinition.__init__() got an unexpected keyword argument 'start_date'


also can I only search 1 result in a time? I want to achieve a similar effect of exporting all the tenors available of an exchange when I search it on SPO. Many Thanks!!

Best Answer

Answers

  • Hi @Sheep

    Have a look at the sample below. It may help you to understand how to use start_date parameter and also how to price more than one tenor at the time.

    import refinitiv.data as rd
    from refinitiv.data.content.ipa.financial_contracts import cross
    rd.open_session()

    cross.Definition(
    instrument_tag="Fx-Forward",
    fx_cross_type=cross.FxCrossType.FX_FORWARD,
    fx_cross_code="GBPCNY",
    legs=[
    cross.LegDefinition(tenor="SW"),
    cross.LegDefinition(tenor="1M"),
    cross.LegDefinition(tenor="2M"),
    cross.LegDefinition(tenor="10M"),
    cross.LegDefinition(tenor="2Y"),
    cross.LegDefinition(start_date="2024-08-01",end_date="2024-08-20"),
    ],
    pricing_parameters=cross.PricingParameters(
    valuation_date="2024-07-18"),
    extended_params={"instrumentDefinition":
    {"fxCrossType": "FxMultileg"}},
    fields=[
    "StartDate",
    "EndDate",
    "Tenor",
    "FxSwapsCcy1Ccy2",
    "FxOutrightCcy1Ccy2"
    ]).get_data().data.df
  • @Jirapongse

    Thanks for the response. I am quite new so I am still confused on what to do. I was using rdp

    import refinitiv.dataplatform as rdp

    import datetime

    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='GBPCNY',

    fx_cross_type='FxForward',

    legs = [cross.LegDefinition(start_date='2024-06-30T00:00:00Z', tenor='3M')],

    pricing_parameters=cross.PricingParameters(price_side=cross.PriceSide.ASK))

    #valuation_date="2024-07-17T00:00:00Z",

    response = fc.get_cross_analytics(fwd_contract,

    fields = ['StartDate',

    'EndDate',

    'FxSwapsCcy1Ccy2',

    'FxOutrightCcy1Ccy2'])

    print(response.data.df)

  • nvm sorry I didn't see the other message, it was great help