Python Eikon Integration - Function "FxCalcPeriod()"
Good afternoon,
At the organization I work at, we have been using python to integrate with Eikon to retrieve FX rates, Libor, Euribors and so on sucessfully.
Now we face a new challenge, which is: how to call the “=FxCalcPeriod()” function from a Python code and get the results from Eikon. This is the sample code we got in the Eikon Adfin Forex Calculation Guide: “=FxCalcPeriod("24FEB03";"EUR";"3M";"FROM:FXTRADE")”. We would like to know how to invoke it from Python x Eikon integration.
Thank you.
Daniel Barroso
Best Answer
-
FxCalcPeriod function is currently only available through a COM library known as AdfinX Analytics. It's possible to use this library in Python, although the use is not very straightforward and it's only possible in 32-bit Python. Here's an article that talks about using AdfinX Analytics COM library in Python.
https://developers.refinitiv.com/article/using-adfinx-analytics-python
Going forward we will be replacing Adfin Analytics client side libraries with Instrument Pricing Analytics (IPA) service on Refinitiv Data Platform that will provide equivalent calculations. The documentation for FX Cross contracts pricing is already published and there's a tutorial on using IPA service in Python. However currently this service is only available with credentials for Refinitiv Data Platform. We expect to make it available to Eikon users later this year.
0
Answers
-
Hi, Could you send more information about instrument Pricing Analytics (IPA) for Eikon user?
What technology will you be able to connect to use and download data? when do you plan to implement? will it be possible to download data via websocket?
0 -
IPA is now available to Eikon and Refinitiv Workspace users. You need to use Refinitiv Data Platform Library to access it. There are some examples available in recently launched Codebook service. Specifically, after launching Codebook, have a look at the following Jupyter notebooks under Examples/02 - Refinitiv Data Platform Library/
1.7.0 - Function - IPA - Bond Pricing
1.7.1 - Function - IPA - Option Pricing
2.7.0 - Content - FinancialContracts - Synchronous
2.7.1 - Content - FinancialContracts - Asynchronous
2.7.2 - Content - FinancialContracts - EventDrivenAll of the above mentioned examples use IPA service with Eikon or Refinitiv Workspace account.
0 -
This is how to do it (I used the argument of FxCalcPeriod for my needs, but one can change that). Note that you have to be running this on Python 32 and follow the steps in
https://developers.refinitiv.com/en/article-catalog/article/using-adfinx-analytics-in-python
to install what you need.
####
import pythoncom
import win32com.client
import datetime
import time
from enum import Enum
import sys
class ConnectionToEikonEnum(Enum):
Error_InitializeFail =2 # from enum EEikonDataAPIInitializeResult
Error_Reinitialize =1 # from enum EEikonDataAPIInitializeResult
Succeed =0 # from enum EEikonDataAPIInitializeResult
Connected =1 # from enum EEikonStatus
Disconnected =0 # from enum EEikonStatus
Disconnected_No_license_agreement_sign_off=8 # from enum EEikonStatus
LocalMode =2 # from enum EEikonStatus
Offline =4 # from enum EEikonStatus
#Calls to methods in AdfinX Analytics library can only be made while our application is connected to Eikon
#This variable is used to tell whether our Python application is connected to Eikon and therefore can make calls to AdfinX Analytics
connectedToEikon = False
class EikonDesktopDataAPI_EventHandler:
def OnStatusChanged(self, EStatus):
if EStatus == ConnectionToEikonEnum.Connected.value or EStatus == ConnectionToEikonEnum.LocalMode.value:
print("EikonDesktopDataAPI is connected in regular or local mode")
global connectedToEikon
connectedToEikon = True
elif EStatus == ConnectionToEikonEnum.Disconnected.value:
print("EikonDesktopDataAPI is disconnected or not initialized")
elif EStatus == ConnectionToEikonEnum.Disconnected_No_license_agreement_sign_off.value:
print("EikonDesktopDataAPI is disconnected because the user did not accept license agreement")
elif EStatus == ConnectionToEikonEnum.Offline.value:
print("EikonDesktopDataAPI has lost connection to the platform due to network or platform issue")
#This creates an instance of EikonDesktopDataAPI object used to manage the connection between our Python application and Eikon
connectionToEikon = win32com.client.DispatchWithEvents("EikonDesktopDataAPILib.EikonDesktopDataAPI", EikonDesktopDataAPI_EventHandler)
print("Connecting to Eikon...")
if not connectedToEikon:
retval = connectionToEikon.Initialize()
if retval != ConnectionToEikonEnum.Succeed.value:
print("Failed to initialize Eikon Desktop Data API")
sys.exit()
else:
print("Already connected to Eikon")
while True:
try:
time.sleep(1)
except KeyboardInterrupt:
print("KeyboardInterrupt")
break
#Windows message pump is required for COM objects to be able to raise events
pythoncom.PumpWaitingMessages()
if connectedToEikon:
#This creates an instance of CreateAdxForexModule object from AdfinX Analytics library
FXModule = connectionToEikon.CreateAdxForexModule()
fx_calc_date = pythoncom.MakeTime(datetime.date(2022,4,26))
try:
solve_fx = FXModule.FxCalcPeriod(fx_calc_date,"EUR","1Y","FROM:MMTRADE")
print ("Solve fx:")
print (solve_fx)
except pythoncom.com_error as e:
print (str(e))
break
0 -
Note the output is in the form of numbers such as 44679. These are the number of days counted from 1899-12-30 (not 31).
0
Categories
- All Categories
- 6 AHS
- 37 Alpha
- 161 App Studio
- 4 Block Chain
- 4 Bot Platform
- 16 Connected Risk APIs
- 47 Data Fusion
- 30 Data Model Discovery
- 608 Datastream
- 1.3K DSS
- 577 Eikon COM
- 4.9K Eikon Data APIs
- 7 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- Trading API
- 2.7K Elektron
- 1.3K EMA
- 236 ETA
- 519 WebSocket API
- 33 FX Venues
- 10 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 20 Messenger Bot
- 2 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 59 Open Calais
- 264 Open PermID
- 39 Entity Search
- 2 Org ID
- PAM
- PAM - Logging
- 8.4K Private Comments
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 20 RDMS
- 1.4K Refinitiv Data Platform
- 367 Refinitiv Data Platform Libraries
- 3 Refinitiv Due Diligence
- LSEG Due Diligence Portal API
- 3 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.1K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 10 World-Check Customer Risk Screener
- 990 World-Check One
- 44 World-Check One Zero Footprint
- 45 Side by Side Integration API
- Test Space
- 3 Thomson One Smart
- 1.2K TR Internal
- Global Hackathon 2015
- 2 Specialists Who Code
- 10 TR Knowledge Graph
- 150 Transactions
- 142 REDI API
- 1.7K TREP APIs
- 4 CAT
- 21 DACS Station
- 117 Open DACS
- 1.1K RFA
- 103 UPA
- 172 TREP Infrastructure
- 224 TRKD
- 886 TRTH
- 5 Velocity Analytics
- 5 Wealth Management Web Services
- 59 Workspace SDK
- 9 Element Framework
- 5 Grid
- 13 World-Check Data File
- Yield Book Analytics
- 46 中文论坛