Error 500 just started no longer retrieving Market FX data
We use API/Python the retrieve Market data for various funds, it was working perfectly fine yesterday.
is there any server issues?
0
Best Answer
-
@peter.akester What API call are you using - please post the code. Is it intermittent or continuous fail. Is your code in a try catch block etc. Thanks.
0
Answers
-
Eikon API
def find_unique_currencies(sec_report_df, funds_df):
"""Find the unique currencies from the Funds and Portfolio Excels
:param sec_report_df: (pandas dataframe) of the security report
excel sheet in Portfolio data Excel file
:return: (list of strings) containing unique currencies
"""
security_currencies = (
sec_report_df["II_Security_Currency"].dropna().unique().tolist()
)
# check currencies in Fund information, in case Portfolio file doesn't capture them
funds_currencies = funds_df["FI_Share_Class_Currency"].dropna().unique().tolist()
currency_list = list(set(security_currencies + funds_currencies))
return currency_list
def retrieve_RIC_Currencies(list_of_currencies):
"""Convert list of currencies into list of RICs (Reuters Instrument Codes)
:param list_of_currencies: (list of strings) containing unique
currencies
:return: (list of tuples) with each tuple containing a currency and RIC string
"""
# Convert the currencies into a list
RIC_Currencies = []
for currency in list_of_currencies:
if currency == "USD":
RIC_Currencies.append((currency, "GBP="))
elif currency == "GBP":
pass
else:
RIC_Currencies.append((currency, "GBP" + currency + "=R"))
return RIC_Currencies # return a list of tuples with currency and RIC code
def process_single_currency(start_date, end_date, RIC_Currencies_value):
"""Retrieve market data for an individual currency from the Reuters Eikon API
:param start_date: (datetime or date object) from which the fund
begins, from the submitted file
:param end_date: (datetime or date object) at which the fund ends,
from the submitted file
:param RIC_Currencies_value: (tuple) containing currency string
and RIC string
:return: (pandas dataframe) containing market data information
for a single currency
"""
currency, RIC = RIC_Currencies_value # unpack the tuple
# get currency market values by each individual
# currency to reduce the chance of timeout
print("Processing currency: ", currency)
single_currency_df = ek.get_timeseries(
RIC,
fields=["CLOSE"],
start_date=str(start_date), # +'T00:00:00', #start_date as datetime
end_date=str(end_date), # +'T00:00:00', #end_date as datetime
interval="daily",
calendar="calendardays",
)
# append base and local currency columns
single_currency_df["XM_Base_Currency"] = pd.Series(
"GBP", index=single_currency_df.index
)
single_currency_df["XM_Local_Currency"] = pd.Series(
currency, index=single_currency_df.index
)
return single_currency_df
# Function to clean up dataframe columns
def clean_df_columns(currency_dataframe):
"""Clean currency dataframe into structure required for Halo
:param currency_dataframe: (pandas dataframe) returned from the
process_single_currency function
:return: (pandas dataframe) cleaned for the final Halo output
"""
currency_dataframe = (
currency_dataframe.reset_index()
) # Remove date from the index so that date is also a column
datetime_series = currency_dataframe["Date"].apply(
cf.convert_date_short
) # Convert date to Halo appropriate format
currency_dataframe[
"XM_FX_Date"
] = datetime_series # Append the new date column to the dataframe
currency_dataframe.set_index(
"XM_FX_Date", inplace=True
) # Set the new date column to be the index
currency_dataframe = currency_dataframe.drop(columns="Date").rename(
columns={"CLOSE": "XM_FX_Rate_Mkt"}
) # Drop the old date column, rename columns to proper values
currency_dataframe = currency_dataframe.reset_index()
if currency_dataframe.empty:
raise Exception("Error: no currency data pulled")
return currency_dataframe
def create_GBP_dataframe(start_date, end_date):
"""Create a currency dataframe for GBP
GBP is not generated as a RIC code due to the process of funds
so we must create it manually
:param start_date: (datetime or date object) from which the fund
begins, from the submitted file
:param end_date: (datetime or date object) at which the fund ends,
from the submitted file
:return: (pandas dataframe) containing market data information for GBP
"""
# generate a single currency dataframe as if we were using USD,
# so that we get the correct dates
temp_df = process_single_currency(start_date, end_date, ("GBP", "GBP="))
temp_df["CLOSE"] = 1.0
temp_df["XM_Local_Currency"] = "GBP"
return temp_df
def process_all_currencies(start_date, end_date, RIC_Currency_list):
"""Retrieve the market data for all currencies
:param start_date: (datetime or date object) from which the fund begins,
from the submitted file
:param end_date: (datetime or date object) at which the fund ends,
from the submitted file
:param RIC_Currency_list: (list of tuples) with each tuple containing
currency string and RIC string
:return: (pandas dataframe) containing market data information for GBP
"""
all_currencies_df = pd.DataFrame()
for RIC_currency in RIC_Currency_list:
temp_df = process_single_currency(
start_date, end_date, RIC_currency
) # retrieve dataframe for each currency
all_currencies_df = pd.concat(
[all_currencies_df, temp_df]
) # aggregate all individual currency dataframes
time.sleep(2)
all_currencies_df = pd.concat(
[all_currencies_df, create_GBP_dataframe(start_date, end_date)]
) # add GBP data to the dataframe
return all_currencies_df
def main(sec_report_df, fund_info_df, start_date, end_date):
"""Return market data for currencies
:param path: (string) consisting of the path to the fund folder
:param start_date: (datetime or date object) from which the fund
begins, from the submitted file
:param end_date: (datetime or date object) at which the fund ends,
from the submitted file
"""
print("Pulling Exchange Rate data from Reuters...")
try:
currencies = find_unique_currencies(sec_report_df, fund_info_df)
RIC_Currencies_ = retrieve_RIC_Currencies(currencies)
data_df = process_all_currencies(start_date, end_date, RIC_Currencies_)
data_df = clean_df_columns(data_df)
print("Finished running Exchange Rate data\n")
return data_df
except Exception as e:
print(
"Error encountered in retrieving FX data\nNo FX data pulled: "
+ str(e)
+ "\n"
)
return pd.DataFrame()0 -
From the code, you are using Eikon Data API (ek.get_timeseries). If the problem still occurs, please enable logging in the Eikon DATA API by using the following code.
ek.set_log_level(1)
ek.set_app_key('<app key>')Please share the API log if the problem occurs again.
0
Categories
- All Categories
- 6 AHS
- 39 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 中文论坛