How do grant and deployed_platform_username work in platform.Definition
I am having issues creating a session using the Python API.
We have a local ADS and DACS. deployed_platform_host is the ADS address and I have put a valid DACS user in deployed_platform_username.
For grant I am using GrantPassword with my Eikon username and password. I suspect this is wrong but I don't have any other users that seem to work.
I can also connect without using the DACS with the Eikon user but then I get an insufficient scope for trapi.streaming.pricing.read or trapi.data.pricing.read. I believe this is expected for an Eikon user?
Since we can connect and receive prices from our ADS using the C++ RFA libraries without having to use a username and password I was wondering if there is a way to do this using the Python libraries?
The application I am working on is a server side application that will retrieve volatility information to store in a database so I am conscious that there could be licensing issues here. Let me know if this is something that should be resolved with our account manager.
Best Answer
-
How did you check the WebScoket connection with the curl command?
The default WebSocket connection TCP port on ADS is 15000, not 14002.
The curl command should look like this:
curl --include --no-buffer --header "Connection: Upgrade" --header "Upgrade: websocket" --header "Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==" --header "Sec-WebSocket-Version: 13" --header "Sec-WebSocket-Protocol: tr_json2" http://127.0.0.1:15000/WebSocket
The output is:
If I use the TCP port 14002, I will get the 400 Bad Request.
1
Answers
-
If you have code, can you share it here?
I would suggest you look at the explanation/example that discusses how to connect into a deployed ADS using your DACS credentials.
For example:
0 -
Hi,
I had worked through most of the connection examples, but I was mostly trying to use snapshot data and not streaming data which I see is not supported by the RTDS.
Converting my request to streaming data I now have a different problem. My script hangs when I call stream.open() with a 400 Bad Request. Note that any attempt I make to call stream.open() hangs my process because it just keeps retrying, I can't seem to find a way to disable retries.
I have confirmed port 14002 is a valid HTTP service using curl. I'm told ADS version should be ads3.2.1.L1 although this seems a little old. Don't know if that might be part of the problem.
Snippet from the log file:
[2024-01-08T14:32:01.680258+02:00] - [sessions.platform.default.0] - [DEBUG] - [62020 - ThreadOMMSTREAMING_PRICING_0.0] - [stream_connection] - [run] - [OMMSTREAMING_PRICING_0.0] try to reconnect over url ws://<redacted>:14002/WebSocket
[2024-01-08T14:32:01.681259+02:00] - [sessions.platform.default.0] - [DEBUG] - [62020 - ThreadOMMSTREAMING_PRICING_0.0] - [stream_connection] - [run] - [OMMSTREAMING_PRICING_0.0] wait start connecting
[2024-01-08T14:32:01.681259+02:00] - [sessions.platform.default.0] - [DEBUG] - [62020 - ThreadOMMSTREAMING_PRICING_0.0] - [stream_connection] - [run] - [OMMSTREAMING_PRICING_0.0] is connecting
[2024-01-08T14:32:01.681259+02:00] - [sessions.platform.default.0] - [DEBUG] - [62020 - ThreadOMMSTREAMING_PRICING_0.0] - [stream_connection] - [_run_websocket_listener] - [OMMSTREAMING_PRICING_0.0] connect
num_attempt : 3
url : ws://<redacted>:14002/WebSocket
headers : ['User-Agent: Python']
cookies : None
transport : websocket
subprotocols: ['tr_json2']
[2024-01-08T14:32:02.189103+02:00] - [sessions.platform.default.0] - [ERROR] - [62020 - ThreadOMMSTREAMING_PRICING_0.0] - [stream_connection] - [_on_ws_error] - [OMMSTREAMING_PRICING_0.0] on_ws_error: Exception: Handshake status 400 Bad Request
[2024-01-08T14:32:02.191107+02:00] - [sessions.platform.default.0] - [DEBUG] - [62020 - ThreadOMMSTREAMING_PRICING_0.0] - [stream_connection] - [_on_ws_error] - Traceback (most recent call last):
File "C:\Program Files\Front\Front Arena\CommonLib\PythonLib397\lib\site-packages\websocket\_app.py", line 395, in setSock
self.sock.connect(
File "C:\Program Files\Front\Front Arena\CommonLib\PythonLib397\lib\site-packages\websocket\_core.py", line 253, in connect
self.handshake_response = handshake(self.sock, url, *addrs, **options)
File "C:\Program Files\Front\Front Arena\CommonLib\PythonLib397\lib\site-packages\websocket\_handshake.py", line 57, in handshake
status, resp = _get_resp_headers(sock)
File "C:\Program Files\Front\Front Arena\CommonLib\PythonLib397\lib\site-packages\websocket\_handshake.py", line 147, in _get_resp_headers
raise WebSocketBadStatusException("Handshake status %d %s", status, status_message, resp_headers)
websocket._exceptions.WebSocketBadStatusException: Handshake status 400 Bad Request
[2024-01-08T14:32:02.192081+02:00] - [sessions.platform.default.0] - [DEBUG] - [62020 - ThreadOMMSTREAMING_PRICING_0.0] - [stream_connection] - [_on_ws_close] - [OMMSTREAMING_PRICING_0.0] on_ws_close: close_status_code=None, close_msg=None, state=StreamCxnState.Connecting
[2024-01-08T14:32:02.192081+02:00] - [sessions.platform.default.0] - [DEBUG] - [62020 - ThreadOMMSTREAMING_PRICING_0.0] - [stream_connection] - [run] - [OMMSTREAMING_PRICING_0.0] tried all infos, waiting time 60 secs until the next attempt.Code:
RD_CONFIG = {
"usage_logger.enabled": True,
"logs.transports.file.name": r"C:\TEMP\refinitiv-data-lib.log",
"logs.transports.file.enabled": True,
"logs.level": "debug",
"http.auto-retry.number-of-retries": 0,
}
def _fetch_prices():
from refinitiv.data import get_config
from refinitiv.data.content import pricing
from refinitiv.data.session import platform
config = get_config()
if config:
for k, v in RD_CONFIG.items():
config.set_param(k, v)
print(f"CONFIG:\n{dumps(config.as_dict(), indent=2)}")
session = platform.Definition(
app_key=RTDS_APP_KEY,
signon_control=False,
deployed_platform_host=RTDS_HOST,
deployed_platform_username=RTDS_USER
).get_session()
session.open()
print(f"Session state: {session.open_state}")
print(" Getting stream...")
stream = pricing.Definition(
['EUR=', ],
fields=['BID', 'ASK']
).get_stream(session=session)
print(" Opening stream...")
stream.open()
print("DATA:")
print(stream.get_snapshot())0 -
Thanks. I was not aware the ADS port was different to WebSocket. Turns out WebSocket is not enabled on our RTDS.
Explains why it has been so difficult to get this working.
Still waiting for WebSocket to be enabled but once that is done I think I'll have much more success.
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 中文论坛