For a deeper look into our Eikon Data API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
1 0 1 1

How can I use date function in python ?

Hi,

I need to use in python some function that I currently use in excel , for example DfAddPeriod.

Do you know if there is a way to use eikon dates and calendar tools in python API ?

Thanks in advance.

eikoneikon-data-apipythonworkspaceworkspace-data-apirefinitiv-dataplatform-eikonapidate
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
7.5k 10 6 8

Hi @antoineperrin.pro1 The Adfin libraries are not really usable in Python - we are building similar types of service on our platform - some of which you can access now such as vol surfaces and forward curves etc using the Refinitiv Data Platform Libraries and opening a desktop session with an Eikon App Key. That said the date manipulations and calendrical functions piece is very well handled in python already. Personally I find these really simple and effective to use:

import datetime
from datetime import datetime
import dateutil.relativedelta
now = datetime.now()
earlier_date = now - dateutil.relativedelta.relativedelta(months=5)
later_date = now + dateutil.relativedelta.relativedelta(days=5, hours=-5)
print("Now: " + str(now), "Earlier: " + str(earlier_date), "Later: " + str(later_date))


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
7.5k 10 6 8

1604670464488.png (17.4 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.

Upvotes
1 0 1 1

Thanks but in fact with python classic datetime method we can't use a calendar. For example in your ScreenShot November 11, is a public holiday in France and the USA so DfAddPeriod in excel will return November 12...

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
39.3k 76 11 27

@antoineperrin.pro1

You can use Refinitiv Data Platform Library for this purpose. See an example on this thread. The example calculates swap points and outright for an FX forward, but it can also be used to perform calendar calculations: it returns start and end dates for an FX swap given valuation date and swap tenor.

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.