question

Upvotes
Accepted
1 0 0 0

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

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!!

python#technologyrdp-apipython apirefinitiv-data-libraries
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
Accepted
84.6k 287 53 77

@Sheep

Thank you for reaching out to us.

Are you using the Refinitiv Data Platform Library?

import refinitiv.dataplatform as rdp

start_date in the legdefinition is available in Refintiv Data Library for Python.

import refinitiv.data as rd
from refinitiv.data.content.ipa.financial_contracts import cross

1721276975544.png



1721276975544.png (37.6 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvote
1.5k 5 3 7

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
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
1 0 0 0

@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)

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
1 0 0 0

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

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.