Is there a way to pass a proxy as a parameter in refinitiv.data library (Python)?
Hi,
Similar to this question from 2 years ago, I want to connect to the refinitiv.data library via a proxy server. This is because I need to run rd.get_data requests from an internal private server with, let's just say, highly strict network configurations. Right now, running rd.get_data() the regular way will return an empty dataframe and sometimes this error:
"An error occurred while requesting URL('http://localhost:9060/api/udf').
ReadError('[WinError 10053] An established connection was aborted by the software in your host machine')".
My question is - is it now possible to configure my session to use a proxy server? If yes, how? If no, any alternatives?
Edit: Correction in title
Thanks and regards,
RC
Best Answer
-
Thanks for reaching out to us.
As I knew, currently, you need to set a proxy via environment variables.
The RD library uses the httpx Python lib which uses these variables: https://www.python-httpx.org/environment_variables/#http_proxy-https_proxy-all_proxy.
For example:
import os
os.environ['HTTP_PROXY']="http://127.0.0.1:8080"
os.environ['HTTPS_PROXY']="http://127.0.0.1:8080"
os.environ['SSL_CERT_FILE'] = "C:\\Users\\U8009686\\.mitmproxy\\mitmproxy-ca.pem"I hope that this information is of help.
0
Answers
-
Hi @Jirapongse,
This seems to work for platform sessions but not desktop sessions. (For others' reference, please see code snippet below). Not sure if this is just specific to me but I was hoping both options to work. Regardless, I'll accept this as the answer. Thank you very much!
Desktop Session
import refinitiv.data as rd
import os
os.environ["HTTP_PROXY"] = "YOUR_PROXY"
os.environ["HTTPS_PROXY"] = "YOUR_PROXY"
appKey = "YOUR_APPKEY"
rd.open_session(app_key=appKey)
df = rd.get_data("MSFT.O", ["TR.ClosePrice"])
print(df)
rd.close_session()Returns:
Empty DataFrame
Columns: []
Index: []Platform Session
import refinitiv.data as rd
import os
os.environ["HTTP_PROXY"] = "YOUR_PROXY"
os.environ["HTTPS_PROXY"] = "YOUR_PROXY"
session = rd.session.platform.Definition(
app_key = "YOUR_APPKEY",
grant = rd.session.platform.GrantPassword(
username = "YOUR_USERNAME",
password = "YOUR_PASSWORD"
)
).get_session()
rd.session.set_default(session)
session.open()
df = rd.get_data("MSFT.O", ["TR.ClosePrice"])
print(df)
session.close()Returns:
Instrument Close Price
0 MSFT.O 308.650 -
The desktop session gets the data from the localhost (127.0.0.1). I am not sure if the proxy can connect to the localhost that runs a desktop application.
If I set a proxy on my local machine and use it with the desktop session, it works fine.
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 中文论坛