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.

Best Answer

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


Answers