Morning All,
A customer of mine is trying the code below but for some odd reason he is not getting any Streaming Prices and it worked before. Sadly I'm no Eikon Data API boffin so Lost ATM.
Example Of His Script below:
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<httplib2.Http at 0x24e92e9f670>"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import eikon as ek\n",
"import datetime\n",
"import yfinance as yf\n",
"import numpy as np\n",
"import pandas as pd\n",
"from eikon import Profile as profile\n",
"ek.set_app_key('<app_key>')\n",
"import httplib2\n",
" \n",
"# detect presense of proxy and use env varibles if they exist\n",
"pi = httplib2.proxy_info_from_environment()\n",
"if pi:\n",
" import socks\n",
" socks.setdefaultproxy(pi.proxy_type, pi.proxy_host, pi.proxy_port)\n",
" socks.wrapmodule(httplib2) \n",
" \n",
"# now all calls through httplib2 should use the proxy settings\n",
"httplib2.Http()\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"def display_refreshed_fields(streaming_price, instrument_name, fields):\n",
" current_time = datetime.datetime.now().time()\n",
" print(current_time, \"- Refresh received for\", instrument_name, \":\", fields)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"def display_updated_fields(streaming_price, instrument_name, fields):\n",
" current_time = datetime.datetime.now().time()\n",
" print(current_time, \"- Update received for\", instrument_name, \":\", fields)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"def display_status(streaming_price, instrument_name, status):\n",
" current_time = datetime.datetime.now().time()\n",
" print(current_time, \"- Status received for\", instrument_name, \":\", status)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"\n",
"def display_complete_snapshot(streaming_prices):\n",
" current_time = datetime.datetime.now().time()\n",
" print(current_time, \"- StreamingPrice is complete. Full snapshot:\")\n",
" display(streaming_prices.get_snapshot())"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"streaming_prices = ek.StreamingPrices(\n",
" instruments = ['EUR=','GBP=','JPY=', 'CAD='], \n",
" fields = ['SALTIM', 'CF_BID','CF_ASK','OPEN_PRC', 'CF_HIGH','CF_LOW', 'CF_CLOSE'],\n",
" on_refresh = lambda streaming_price, instrument_name, fields : \n",
" display_refreshed_fields(streaming_price, instrument_name, fields),\n",
" on_update = lambda streaming_price, instrument_name, fields : \n",
" display_updated_fields(streaming_price, instrument_name, fields),\n",
" on_status = lambda streaming_price, instrument_name, status : \n",
" display_status(streaming_price, instrument_name, status),\n",
" on_complete = lambda streaming_price : \n",
" display_complete_snapshot(streaming_price)\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"streaming_prices.open()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"streaming_prices.close()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "EIKON",
"language": "python",
"name": "eikon"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Any suggestions to help would be greatly appreciated.