Skip to content

Commit ec23846

Browse files
author
Olivier Davant
committed
Initial version
1 parent 9f6cb5e commit ec23846

19 files changed

+18161
-2
lines changed

1.0.0 - Function - Sessions.ipynb

Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Refinitiv Data Platform Library for Python\n",
8+
"## Function - How to use sessions\n",
9+
"\n",
10+
"Depending on the access point your application uses to connect to the Refinitiv Data Platform, it has to create and open either a PlatformSession, a DesktopSession or a DeployedPlatform session: \n",
11+
"\n",
12+
" - **PlatformSession:** This type of session is used to connect directly to the Refinitiv Data Platform. It requires a Refinitiv Data Platform account (either a user account or a machine account). In both cases you will need to provide Refinitiv Data Platform credentials to create the session\n",
13+
" - **DesktopSession:** This type of session is used to connect the Refinitiv Data Platform either via Eikon or via the Refinitiv Workspace. It requires Eikon or the Refinitiv Workspace to be running alongside your application Python application.\n",
14+
" - **DeployedPlatformSession:** This type of session is used to connect the Refinitiv Data Platform via a local (deployed) enterprise platform like (a.k.a. TREP). It requires the IP of the local platform and a user name (a.k.a. DACS user name)\n",
15+
" \n",
16+
"These 3 session types aslo require an App Key that uniquely identifies your application. Please refer to the Refinitiv Data Platform Libraries Quick Start guide to learn how to create an App Key for your application. Once created with one of the following functions, the session will become the default session used by all other Refinitiv Data Platform function calls."
17+
]
18+
},
19+
{
20+
"cell_type": "markdown",
21+
"metadata": {},
22+
"source": [
23+
"## Import the library and load credentials\n",
24+
"\n",
25+
"Credentials used by this notebook are stored in the ./credentials.ipynb. Please edit ./credentials.ipynb to set your credentials and run the next cell to continue with this scripts"
26+
]
27+
},
28+
{
29+
"cell_type": "code",
30+
"execution_count": 1,
31+
"metadata": {},
32+
"outputs": [],
33+
"source": [
34+
"import refinitiv.dataplatform as rdp\n",
35+
"import datetime\n",
36+
"\n",
37+
"%run ./credentials.ipynb"
38+
]
39+
},
40+
{
41+
"cell_type": "markdown",
42+
"metadata": {},
43+
"source": [
44+
"## Open the session of your choice"
45+
]
46+
},
47+
{
48+
"cell_type": "markdown",
49+
"metadata": {},
50+
"source": [
51+
"#### Either\n",
52+
"\n",
53+
"Create and open a Desktop session to connect to the Refinitiv Data Platform pvia Eikon 4 or the Refinitiv Workspace."
54+
]
55+
},
56+
{
57+
"cell_type": "code",
58+
"execution_count": 2,
59+
"metadata": {},
60+
"outputs": [
61+
{
62+
"data": {
63+
"text/plain": [
64+
"<refinitiv.dataplatform.core.session.desktop_session.DesktopSession at 0xaa8bc50>"
65+
]
66+
},
67+
"execution_count": 2,
68+
"metadata": {},
69+
"output_type": "execute_result"
70+
}
71+
],
72+
"source": [
73+
"rdp.open_desktop_session(APP_KEY)"
74+
]
75+
},
76+
{
77+
"cell_type": "markdown",
78+
"metadata": {},
79+
"source": [
80+
"#### or\n",
81+
"\n",
82+
"Create and open a Platform session to connect directly to the Refinitiv Data Platform. "
83+
]
84+
},
85+
{
86+
"cell_type": "code",
87+
"execution_count": 4,
88+
"metadata": {},
89+
"outputs": [
90+
{
91+
"data": {
92+
"text/plain": [
93+
"<refinitiv.dataplatform.core.session.platform_session.PlatformSession at 0xab71cf8>"
94+
]
95+
},
96+
"execution_count": 4,
97+
"metadata": {},
98+
"output_type": "execute_result"
99+
}
100+
],
101+
"source": [
102+
"rdp.open_platform_session(\n",
103+
" APP_KEY, \n",
104+
" rdp.GrantPassword(\n",
105+
" username = RDP_LOGIN, \n",
106+
" password = RDP_PASSWORD\n",
107+
" )\n",
108+
")"
109+
]
110+
},
111+
{
112+
"cell_type": "markdown",
113+
"metadata": {},
114+
"source": [
115+
"#### or\n",
116+
"\n",
117+
"Create and open a Deployed Platform session to connect directly to a deployed enterprise platform (a.k.a.TREP). "
118+
]
119+
},
120+
{
121+
"cell_type": "code",
122+
"execution_count": 6,
123+
"metadata": {},
124+
"outputs": [
125+
{
126+
"data": {
127+
"text/plain": [
128+
"<refinitiv.dataplatform.core.session.deployed_platform_session.DeployedPlatformSession at 0xabceb38>"
129+
]
130+
},
131+
"execution_count": 6,
132+
"metadata": {},
133+
"output_type": "execute_result"
134+
}
135+
],
136+
"source": [
137+
"rdp.open_deployed_platform_session(\n",
138+
" APP_KEY,\n",
139+
" DEPLOYED_PLATFORM_HOST,\n",
140+
" DEPLOYED_PLATFORM_USER_NAME\n",
141+
")"
142+
]
143+
},
144+
{
145+
"cell_type": "markdown",
146+
"metadata": {},
147+
"source": [
148+
"## Check the open state"
149+
]
150+
},
151+
{
152+
"cell_type": "code",
153+
"execution_count": 7,
154+
"metadata": {},
155+
"outputs": [
156+
{
157+
"data": {
158+
"text/plain": [
159+
"<State.Open: 3>"
160+
]
161+
},
162+
"execution_count": 7,
163+
"metadata": {},
164+
"output_type": "execute_result"
165+
}
166+
],
167+
"source": [
168+
"rdp.get_default_session().get_open_state()"
169+
]
170+
},
171+
{
172+
"cell_type": "markdown",
173+
"metadata": {},
174+
"source": [
175+
"## Close the default session when done"
176+
]
177+
},
178+
{
179+
"cell_type": "code",
180+
"execution_count": 8,
181+
"metadata": {},
182+
"outputs": [],
183+
"source": [
184+
"rdp.close_session()"
185+
]
186+
},
187+
{
188+
"cell_type": "code",
189+
"execution_count": null,
190+
"metadata": {},
191+
"outputs": [],
192+
"source": []
193+
}
194+
],
195+
"metadata": {
196+
"kernelspec": {
197+
"display_name": "Python 3",
198+
"language": "python",
199+
"name": "python3"
200+
},
201+
"language_info": {
202+
"codemirror_mode": {
203+
"name": "ipython",
204+
"version": 3
205+
},
206+
"file_extension": ".py",
207+
"mimetype": "text/x-python",
208+
"name": "python",
209+
"nbconvert_exporter": "python",
210+
"pygments_lexer": "ipython3",
211+
"version": "3.7.0"
212+
}
213+
},
214+
"nbformat": 4,
215+
"nbformat_minor": 2
216+
}

0 commit comments

Comments
 (0)