Upgrade from Eikon -> Workspace. Learn about programming differences.

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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
1 1 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-apipythonrefinitiv-dataplatform-eikonworkspaceworkspace-data-apiapidate
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.

Hello @antoineperrin.pro1

Thank you for your participation in the forum. Is the reply below satisfactory in resolving your query?

If yes, please click the 'Accept' text next to the reply. This will guide all community members who have a similar question. Otherwise please post again offering further insight into your question.

Thanks,

AHS

@antoineperrin.pro1

Hi,

Please be informed that a reply has been verified as correct in answering the question, and has been marked as such.

Thanks,

AHS

Upvotes
Accepted
10.2k 18 6 9

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
10.2k 18 6 9

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 1 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.4k 77 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.

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.