Skip to content

Commit 039c20e

Browse files
committed
More StreamingEvents changes and delete badly named cache notebook
1 parent 84b37e7 commit 039c20e

File tree

2 files changed

+121
-231
lines changed

2 files changed

+121
-231
lines changed

2.Content/2.2-Pricing/2.2.02-Pricing-StreamingCacheipynb renamed to 2.Content/2.2-Pricing/2.2.02-Pricing-StreamingCache.ipynb

Lines changed: 72 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
{
6969
"data": {
7070
"text/plain": [
71-
"<refinitiv.data._data.core.session._platform_session.PlatformSession at 0x129bd165610>"
71+
"<refinitiv.data._data.core.session._platform_session.PlatformSession at 0x2442e0461c0>"
7272
]
7373
},
7474
"execution_count": 2,
@@ -123,30 +123,30 @@
123123
" <tr>\n",
124124
" <th>0</th>\n",
125125
" <td>EUR=</td>\n",
126-
" <td>1.1901</td>\n",
127-
" <td>1.1905</td>\n",
126+
" <td>1.1908</td>\n",
127+
" <td>1.1909</td>\n",
128128
" </tr>\n",
129129
" <tr>\n",
130130
" <th>1</th>\n",
131131
" <td>GBP=</td>\n",
132-
" <td>1.3904</td>\n",
133-
" <td>1.3908</td>\n",
132+
" <td>1.3897</td>\n",
133+
" <td>1.3898</td>\n",
134134
" </tr>\n",
135135
" <tr>\n",
136136
" <th>2</th>\n",
137137
" <td>JPY=</td>\n",
138-
" <td>110.47</td>\n",
139-
" <td>110.5</td>\n",
138+
" <td>110.67</td>\n",
139+
" <td>110.68</td>\n",
140140
" </tr>\n",
141141
" </tbody>\n",
142142
"</table>\n",
143143
"</div>"
144144
],
145145
"text/plain": [
146146
" Instrument BID ASK\n",
147-
"0 EUR= 1.1901 1.1905\n",
148-
"1 GBP= 1.3904 1.3908\n",
149-
"2 JPY= 110.47 110.5"
147+
"0 EUR= 1.1908 1.1909\n",
148+
"1 GBP= 1.3897 1.3898\n",
149+
"2 JPY= 110.67 110.68"
150150
]
151151
},
152152
"execution_count": 3,
@@ -208,93 +208,119 @@
208208
" <tr>\n",
209209
" <th>0</th>\n",
210210
" <td>EUR=</td>\n",
211-
" <td>1.1901</td>\n",
212-
" <td>1.1905</td>\n",
211+
" <td>1.1907</td>\n",
212+
" <td>1.1911</td>\n",
213213
" </tr>\n",
214214
" <tr>\n",
215215
" <th>1</th>\n",
216216
" <td>GBP=</td>\n",
217-
" <td>1.3904</td>\n",
218-
" <td>1.3908</td>\n",
217+
" <td>1.3896</td>\n",
218+
" <td>1.3898</td>\n",
219219
" </tr>\n",
220220
" <tr>\n",
221221
" <th>2</th>\n",
222222
" <td>JPY=</td>\n",
223-
" <td>110.47</td>\n",
224-
" <td>110.5</td>\n",
223+
" <td>110.66</td>\n",
224+
" <td>110.69</td>\n",
225225
" </tr>\n",
226226
" </tbody>\n",
227227
"</table>\n",
228228
"</div>"
229229
],
230230
"text/plain": [
231231
" Instrument BID ASK\n",
232-
"0 EUR= 1.1901 1.1905\n",
233-
"1 GBP= 1.3904 1.3908\n",
234-
"2 JPY= 110.47 110.5"
232+
"0 EUR= 1.1907 1.1911\n",
233+
"1 GBP= 1.3896 1.3898\n",
234+
"2 JPY= 110.66 110.69"
235235
]
236236
},
237-
"execution_count": 4,
238237
"metadata": {},
239-
"output_type": "execute_result"
238+
"output_type": "display_data"
240239
}
241240
],
242241
"source": [
243-
"streaming.get_snapshot()"
242+
"snap = streaming.get_snapshot()\n",
243+
"display(snap)"
244244
]
245245
},
246246
{
247247
"cell_type": "markdown",
248248
"metadata": {},
249249
"source": [
250+
"\n",
250251
"### Alternative ways of accessing instruments + values"
251252
]
252253
},
253254
{
254255
"cell_type": "markdown",
255256
"metadata": {},
256257
"source": [
257-
"#### Direct Access to fields"
258+
"#### Direct Access to fields\n",
259+
"We can directly access the cache without the need to call **get_snapshot()**"
258260
]
259261
},
260262
{
261263
"cell_type": "code",
262-
"execution_count": 5,
264+
"execution_count": 6,
263265
"metadata": {},
264266
"outputs": [
265267
{
266268
"data": {
267269
"text/plain": [
268-
"1.1901"
270+
"1.1907"
269271
]
270272
},
271-
"execution_count": 5,
273+
"execution_count": 6,
272274
"metadata": {},
273275
"output_type": "execute_result"
274276
}
275277
],
276278
"source": [
279+
"# Directly access the latest 'BID' price for the EURO\n",
277280
"streaming['EUR=']['BID']"
278281
]
279282
},
280283
{
281284
"cell_type": "code",
282-
"execution_count": 6,
285+
"execution_count": 7,
283286
"metadata": {},
284287
"outputs": [
285288
{
286289
"data": {
287290
"text/plain": [
288-
"1.3908"
291+
"1.3901"
289292
]
290293
},
291-
"execution_count": 6,
294+
"execution_count": 7,
292295
"metadata": {},
293296
"output_type": "execute_result"
294297
}
295298
],
296299
"source": [
300+
"## Access the individual StreamingPrice object for GBP\n",
297301
"gbp = streaming['GBP=']\n",
302+
"# and then use object to access individual fields\n",
303+
"gbp['ASK']"
304+
]
305+
},
306+
{
307+
"cell_type": "code",
308+
"execution_count": 8,
309+
"metadata": {},
310+
"outputs": [
311+
{
312+
"data": {
313+
"text/plain": [
314+
"1.3901"
315+
]
316+
},
317+
"execution_count": 8,
318+
"metadata": {},
319+
"output_type": "execute_result"
320+
}
321+
],
322+
"source": [
323+
"# Will be different from above if price has changed\n",
298324
"gbp['ASK']"
299325
]
300326
},
@@ -307,16 +333,16 @@
307333
},
308334
{
309335
"cell_type": "code",
310-
"execution_count": 7,
336+
"execution_count": 12,
311337
"metadata": {},
312338
"outputs": [
313339
{
314340
"name": "stdout",
315341
"output_type": "stream",
316342
"text": [
317343
"JPY=\n",
318-
"\tBID : 110.47\n",
319-
"\tASK : 110.5\n"
344+
"\tBID : 110.64\n",
345+
"\tASK : 110.65\n"
320346
]
321347
}
322348
],
@@ -335,22 +361,22 @@
335361
},
336362
{
337363
"cell_type": "code",
338-
"execution_count": 8,
364+
"execution_count": 13,
339365
"metadata": {},
340366
"outputs": [
341367
{
342368
"name": "stdout",
343369
"output_type": "stream",
344370
"text": [
345371
"EUR=\n",
346-
"\tBID : 1.1901\n",
347-
"\tASK : 1.1905\n",
372+
"\tBID : 1.1907\n",
373+
"\tASK : 1.1911\n",
348374
"GBP=\n",
349-
"\tBID : 1.3904\n",
350-
"\tASK : 1.3908\n",
375+
"\tBID : 1.3897\n",
376+
"\tASK : 1.3901\n",
351377
"JPY=\n",
352-
"\tBID : 110.47\n",
353-
"\tASK : 110.5\n"
378+
"\tBID : 110.64\n",
379+
"\tASK : 110.65\n"
354380
]
355381
}
356382
],
@@ -370,20 +396,9 @@
370396
},
371397
{
372398
"cell_type": "code",
373-
"execution_count": 9,
399+
"execution_count": null,
374400
"metadata": {},
375-
"outputs": [
376-
{
377-
"data": {
378-
"text/plain": [
379-
"<StreamState.Closed: 1>"
380-
]
381-
},
382-
"execution_count": 9,
383-
"metadata": {},
384-
"output_type": "execute_result"
385-
}
386-
],
401+
"outputs": [],
387402
"source": [
388403
"streaming.close()"
389404
]
@@ -399,70 +414,9 @@
399414
},
400415
{
401416
"cell_type": "code",
402-
"execution_count": 10,
417+
"execution_count": null,
403418
"metadata": {},
404-
"outputs": [
405-
{
406-
"data": {
407-
"text/html": [
408-
"<div>\n",
409-
"<style scoped>\n",
410-
" .dataframe tbody tr th:only-of-type {\n",
411-
" vertical-align: middle;\n",
412-
" }\n",
413-
"\n",
414-
" .dataframe tbody tr th {\n",
415-
" vertical-align: top;\n",
416-
" }\n",
417-
"\n",
418-
" .dataframe thead th {\n",
419-
" text-align: right;\n",
420-
" }\n",
421-
"</style>\n",
422-
"<table border=\"1\" class=\"dataframe\">\n",
423-
" <thead>\n",
424-
" <tr style=\"text-align: right;\">\n",
425-
" <th></th>\n",
426-
" <th>Instrument</th>\n",
427-
" <th>BID</th>\n",
428-
" <th>ASK</th>\n",
429-
" </tr>\n",
430-
" </thead>\n",
431-
" <tbody>\n",
432-
" <tr>\n",
433-
" <th>0</th>\n",
434-
" <td>EUR=</td>\n",
435-
" <td>1.1901</td>\n",
436-
" <td>1.1905</td>\n",
437-
" </tr>\n",
438-
" <tr>\n",
439-
" <th>1</th>\n",
440-
" <td>GBP=</td>\n",
441-
" <td>1.3904</td>\n",
442-
" <td>1.3908</td>\n",
443-
" </tr>\n",
444-
" <tr>\n",
445-
" <th>2</th>\n",
446-
" <td>DUMMY</td>\n",
447-
" <td>&lt;NA&gt;</td>\n",
448-
" <td>&lt;NA&gt;</td>\n",
449-
" </tr>\n",
450-
" </tbody>\n",
451-
"</table>\n",
452-
"</div>"
453-
],
454-
"text/plain": [
455-
" Instrument BID ASK\n",
456-
"0 EUR= 1.1901 1.1905\n",
457-
"1 GBP= 1.3904 1.3908\n",
458-
"2 DUMMY <NA> <NA>"
459-
]
460-
},
461-
"execution_count": 10,
462-
"metadata": {},
463-
"output_type": "execute_result"
464-
}
465-
],
419+
"outputs": [],
466420
"source": [
467421
"# Define our Streaming Price object\n",
468422
"mixed = rd.content.pricing.Definition(\n",
@@ -483,20 +437,9 @@
483437
},
484438
{
485439
"cell_type": "code",
486-
"execution_count": 11,
440+
"execution_count": null,
487441
"metadata": {},
488-
"outputs": [
489-
{
490-
"data": {
491-
"text/plain": [
492-
"<StreamState.Open: 3>"
493-
]
494-
},
495-
"execution_count": 11,
496-
"metadata": {},
497-
"output_type": "execute_result"
498-
}
499-
],
442+
"outputs": [],
500443
"source": [
501444
"mixed['DUMMY'].state"
502445
]
@@ -521,7 +464,7 @@
521464
},
522465
{
523466
"cell_type": "code",
524-
"execution_count": 12,
467+
"execution_count": null,
525468
"metadata": {
526469
"pycharm": {
527470
"name": "#%%\n"

0 commit comments

Comments
 (0)