|
25 | 25 | "id": "560d68d9", |
26 | 26 | "metadata": {}, |
27 | 27 | "source": [ |
28 | | - "## Import the library and load credentials\n", |
29 | | - "\n", |
30 | | - "Credentials used by this and the other tutorials notebooks are stored in the **Configuration//credentials.ipynb** file. \n", |
31 | | - "\n", |
32 | | - "Please edit **Configuration/credentials.ipynb** to set your credentials and run the next cell to continue" |
| 28 | + "## Import the library" |
33 | 29 | ] |
34 | 30 | }, |
35 | 31 | { |
|
39 | 35 | "metadata": {}, |
40 | 36 | "outputs": [], |
41 | 37 | "source": [ |
42 | | - "import refinitiv.data as rd\n", |
| 38 | + "import refinitiv.data as rd" |
| 39 | + ] |
| 40 | + }, |
| 41 | + { |
| 42 | + "cell_type": "markdown", |
| 43 | + "id": "ab5d158c-c9db-4c70-a40e-69f3fe0a27bd", |
| 44 | + "metadata": {}, |
| 45 | + "source": [ |
| 46 | + "## Using the 'refinitiv-data.config.json' file\n", |
| 47 | + "The Refinitiv data library config file has a default name of **'refinitiv-data.config.json'** allows you to specify session related parameters such as:\n", |
| 48 | + "* the default session to use\n", |
| 49 | + "* credentials\n", |
| 50 | + "* connectivity parameters \n", |
43 | 51 | "\n", |
44 | | - "%run ../Configuration/credentials.ipynb" |
| 52 | + "for the various session types. \n", |
| 53 | + "Using the config file, where possible, provides the simplest approach to creating and opening sessions. \n", |
| 54 | + "For example, assuming you have specified a 'default' session in the config file, you can create and open the default session as follows:" |
| 55 | + ] |
| 56 | + }, |
| 57 | + { |
| 58 | + "cell_type": "code", |
| 59 | + "execution_count": null, |
| 60 | + "id": "94f821ff-a3ae-4a02-bf4d-c737ce581b07", |
| 61 | + "metadata": {}, |
| 62 | + "outputs": [], |
| 63 | + "source": [ |
| 64 | + "rd.open_session()" |
| 65 | + ] |
| 66 | + }, |
| 67 | + { |
| 68 | + "cell_type": "markdown", |
| 69 | + "id": "dbed0e57-0625-4561-a559-dcfc28b7d722", |
| 70 | + "metadata": {}, |
| 71 | + "source": [ |
| 72 | + "The above will look for an entry such as: \n", |
| 73 | + "> *\"sessions\": { \n", |
| 74 | + "> \"default\": \"desktop.default\", \n", |
| 75 | + "> .... \n", |
| 76 | + "> }* \n", |
| 77 | + "\n", |
| 78 | + "and then use the parameters defined in the config section - in this example *\"desktop.default\"*, to create and open a desktop session. \n", |
| 79 | + "Please refer to the supplied example **'refinitiv-data.config.json'** file for the full config example.\n", |
| 80 | + "\n", |
| 81 | + "### Open a specific configured session\n", |
| 82 | + "If you have multiple sessions configurations specified in the json file you can open a specific one by name e.g.:" |
| 83 | + ] |
| 84 | + }, |
| 85 | + { |
| 86 | + "cell_type": "code", |
| 87 | + "execution_count": null, |
| 88 | + "id": "693ee487-c6d0-4449-83b8-d206b4654867", |
| 89 | + "metadata": {}, |
| 90 | + "outputs": [], |
| 91 | + "source": [ |
| 92 | + "rd.open_session(name = 'platform.deployed')" |
| 93 | + ] |
| 94 | + }, |
| 95 | + { |
| 96 | + "cell_type": "markdown", |
| 97 | + "id": "6917355d-c1f3-4df8-a5d5-368e7dea0d02", |
| 98 | + "metadata": {}, |
| 99 | + "source": [ |
| 100 | + "The above would open a session based on the parameters specified in the '*\"platform.deployed\"* section of the json file." |
| 101 | + ] |
| 102 | + }, |
| 103 | + { |
| 104 | + "cell_type": "markdown", |
| 105 | + "id": "583edf78-f57e-4193-9681-2d0f0c7af4e7", |
| 106 | + "metadata": {}, |
| 107 | + "source": [ |
| 108 | + "#### Open a session defined in a custom configuration file \n", |
| 109 | + "As well as the default config filename of **'refinitiv-data.config.json'**, you can also use a custom file to specify the config. \n", |
| 110 | + "The following call opens the default session as defined in your custom configuration file - with the filename passed as a parameter." |
| 111 | + ] |
| 112 | + }, |
| 113 | + { |
| 114 | + "cell_type": "code", |
| 115 | + "execution_count": null, |
| 116 | + "id": "4553a5cd-4bfc-46db-ac26-e07a92d8336b", |
| 117 | + "metadata": {}, |
| 118 | + "outputs": [], |
| 119 | + "source": [ |
| 120 | + "rd.open_session(config_name=\"refinitiv-data.custom.config.json\")" |
45 | 121 | ] |
46 | 122 | }, |
47 | 123 | { |
48 | 124 | "cell_type": "markdown", |
49 | 125 | "id": "079c0ec3", |
50 | 126 | "metadata": {}, |
51 | 127 | "source": [ |
52 | | - "## Define the session of your choice" |
| 128 | + "<br> \n", |
| 129 | + "Alternatively, if you do not wish to use the refinitiv-data config file, you can define sessions by specifying the parameters and session type explicitly - as shown below.\n", |
| 130 | + "\n", |
| 131 | + "## Define the session of your choice\n", |
| 132 | + "The following example calls use credentials/connectivity parameters as defined in the **Configuration//credentials.ipynb** file. \n", |
| 133 | + "\n", |
| 134 | + "Please edit **Configuration/credentials.ipynb** to set your credentials and run the next cell before continuing" |
| 135 | + ] |
| 136 | + }, |
| 137 | + { |
| 138 | + "cell_type": "code", |
| 139 | + "execution_count": null, |
| 140 | + "id": "af7ee821-4413-4754-9f38-c3a22725a962", |
| 141 | + "metadata": {}, |
| 142 | + "outputs": [], |
| 143 | + "source": [ |
| 144 | + "%run ../Configuration/credentials.ipynb" |
53 | 145 | ] |
54 | 146 | }, |
55 | 147 | { |
|
59 | 151 | "source": [ |
60 | 152 | "#### Desktop Session\n", |
61 | 153 | "\n", |
62 | | - "Create and open a Desktop session to Refintiv Eikon 4 or Refinitiv Workspace application - running locally." |
| 154 | + "Create and open a Desktop session to Refintiv Eikon 4 or Refinitiv Workspace application - running locally (using the **APP_KEY** defined in the above notebook)." |
63 | 155 | ] |
64 | 156 | }, |
65 | 157 | { |
|
160 | 252 | }, |
161 | 253 | { |
162 | 254 | "cell_type": "code", |
163 | | - "execution_count": 3, |
| 255 | + "execution_count": null, |
164 | 256 | "id": "5eb4432c", |
165 | 257 | "metadata": {}, |
166 | | - "outputs": [ |
167 | | - { |
168 | | - "name": "stdout", |
169 | | - "output_type": "stream", |
170 | | - "text": [ |
171 | | - "[2021-09-03 10:53:56,954] - [INFO] - [sessions.desktop.default-session.0] - [28936] | MainThread\n", |
172 | | - "Checking port 9000 response : 200 - {\"statusCode\":\"ST_PROXY_READY\",\"version\":\"2.9.0\"}\n", |
173 | | - "[2021-09-03 10:53:56,957] - [INFO] - [sessions.desktop.default-session.0] - [28936] | MainThread\n", |
174 | | - "Port 9000 was retrieved from .portInUse file\n", |
175 | | - "[2021-09-03 10:53:56,959] - [INFO] - [sessions.desktop.default-session.0] - [28936] | MainThread\n", |
176 | | - "Try to handshake on url http://localhost:9000/api/handshake...\n", |
177 | | - "[2021-09-03 10:53:59,176] - [INFO] - [sessions.desktop.default-session.0] - [28936] | MainThread\n", |
178 | | - "Response : 200 - {\"access_token\":\"\",\"expires_in\":1209600,\"token_type\":\"bearer\"}\n", |
179 | | - "[2021-09-03 10:53:59,177] - [INFO] - [sessions.desktop.default-session.0] - [28936] | MainThread\n", |
180 | | - "Application ID: xxx\n" |
181 | | - ] |
182 | | - }, |
183 | | - { |
184 | | - "data": { |
185 | | - "text/plain": [ |
186 | | - "<SessionState.Open: 3>" |
187 | | - ] |
188 | | - }, |
189 | | - "execution_count": 3, |
190 | | - "metadata": {}, |
191 | | - "output_type": "execute_result" |
192 | | - } |
193 | | - ], |
| 258 | + "outputs": [], |
194 | 259 | "source": [ |
195 | 260 | "session.open()" |
196 | 261 | ] |
|
258 | 323 | }, |
259 | 324 | { |
260 | 325 | "cell_type": "code", |
261 | | - "execution_count": 5, |
| 326 | + "execution_count": null, |
262 | 327 | "id": "adb83bc9", |
263 | 328 | "metadata": {}, |
264 | | - "outputs": [ |
265 | | - { |
266 | | - "name": "stdout", |
267 | | - "output_type": "stream", |
268 | | - "text": [ |
269 | | - "Session State:EventCode.SessionAuthenticationSuccess | Successfully authorized to RDP authentication endpoint.\n", |
270 | | - "Session State:SessionState.Open | Session is opened.\n" |
271 | | - ] |
272 | | - }, |
273 | | - { |
274 | | - "data": { |
275 | | - "text/plain": [ |
276 | | - "<SessionState.Open: 3>" |
277 | | - ] |
278 | | - }, |
279 | | - "execution_count": 5, |
280 | | - "metadata": {}, |
281 | | - "output_type": "execute_result" |
282 | | - } |
283 | | - ], |
| 329 | + "outputs": [], |
284 | 330 | "source": [ |
285 | 331 | "# Callback to handle session state changes\n", |
286 | 332 | "def on_state_cb(session, state_code, state_msg):\n", |
|
0 commit comments