From 8590f7e0483d9df037d9ae6b9f28edaec882efa1 Mon Sep 17 00:00:00 2001 From: Matthew Date: Fri, 20 Aug 2021 12:52:21 -0400 Subject: [PATCH] DOC: Add override example to docs --- doc/source/quickstart.ipynb | 598 +++++++++++++++++++++--------------- doc/source/quickstart.py | 22 +- 2 files changed, 376 insertions(+), 244 deletions(-) diff --git a/doc/source/quickstart.ipynb b/doc/source/quickstart.ipynb index da2181b..17344d9 100644 --- a/doc/source/quickstart.ipynb +++ b/doc/source/quickstart.ipynb @@ -246,7 +246,7 @@ " 0\n", " CL1 Comdty\n", " Generic 1st 'CL' Future\n", - " 65.37\n", + " 62.7\n", " \n", " \n", "\n", @@ -254,7 +254,7 @@ ], "text/plain": [ " security NAME PX_LAST\n", - "0 CL1 Comdty Generic 1st 'CL' Future 65.37" + "0 CL1 Comdty Generic 1st 'CL' Future 62.7" ] }, "execution_count": 4, @@ -300,118 +300,118 @@ " \n", " \n", " 0\n", - " BON1\n", - " 4.26\n", + " BOZ1\n", + " 3.83\n", " \n", " \n", " 1\n", - " C N1\n", - " 6.29\n", + " C Z1\n", + " 5.46\n", " \n", " \n", " 2\n", - " CLN1\n", - " 9.04\n", + " CLX1\n", + " 8.86\n", " \n", " \n", " 3\n", - " COU1\n", - " 7.40\n", + " COX1\n", + " 7.30\n", " \n", " \n", " 4\n", - " CTN1\n", - " 1.35\n", + " CTZ1\n", + " 1.54\n", " \n", " \n", " 5\n", - " GCQ1\n", - " 12.17\n", + " GCZ1\n", + " 11.96\n", " \n", " \n", " 6\n", - " HGN1\n", - " 5.87\n", + " HGZ1\n", + " 5.17\n", " \n", " \n", " 7\n", - " HON1\n", - " 2.38\n", + " HOX1\n", + " 2.34\n", " \n", " \n", " 8\n", - " KCN1\n", - " 2.83\n", + " KCZ1\n", + " 3.60\n", " \n", " \n", " 9\n", - " KWN1\n", - " 1.49\n", + " KWZ1\n", + " 1.68\n", " \n", " \n", " 10\n", - " LAN21\n", - " 4.39\n", + " LAX21\n", + " 4.62\n", " \n", " \n", " 11\n", - " LCQ1\n", - " 3.43\n", + " LCV1\n", + " 3.76\n", " \n", " \n", " 12\n", - " LHN1\n", - " 2.35\n", + " LHV1\n", + " 1.90\n", " \n", " \n", " 13\n", - " LNN1\n", - " 2.27\n", + " LNX1\n", + " 2.43\n", " \n", " \n", " 14\n", - " LXN1\n", - " 2.85\n", + " LXX1\n", + " 2.91\n", " \n", " \n", " 15\n", - " NGN21\n", - " 7.82\n", + " NGX21\n", + " 10.28\n", " \n", " \n", " 16\n", - " QSN1\n", - " 2.88\n", + " QSX1\n", + " 2.86\n", " \n", " \n", " 17\n", - " S N1\n", - " 5.88\n", + " S X1\n", + " 4.97\n", " \n", " \n", " 18\n", - " SBN1\n", - " 2.81\n", + " SBV1\n", + " 3.32\n", " \n", " \n", " 19\n", - " SIN1\n", - " 3.78\n", + " SIZ1\n", + " 3.26\n", " \n", " \n", " 20\n", - " SMN1\n", - " 3.01\n", + " SMZ1\n", + " 2.58\n", " \n", " \n", " 21\n", - " W N1\n", - " 2.74\n", + " W Z1\n", + " 2.92\n", " \n", " \n", " 22\n", - " XBN1\n", - " 2.69\n", + " XBX1\n", + " 2.45\n", " \n", " \n", "\n", @@ -419,29 +419,29 @@ ], "text/plain": [ " Member Ticker and Exchange Code Percentage Weight\n", - "0 BON1 4.26\n", - "1 C N1 6.29\n", - "2 CLN1 9.04\n", - "3 COU1 7.40\n", - "4 CTN1 1.35\n", - "5 GCQ1 12.17\n", - "6 HGN1 5.87\n", - "7 HON1 2.38\n", - "8 KCN1 2.83\n", - "9 KWN1 1.49\n", - "10 LAN21 4.39\n", - "11 LCQ1 3.43\n", - "12 LHN1 2.35\n", - "13 LNN1 2.27\n", - "14 LXN1 2.85\n", - "15 NGN21 7.82\n", - "16 QSN1 2.88\n", - "17 S N1 5.88\n", - "18 SBN1 2.81\n", - "19 SIN1 3.78\n", - "20 SMN1 3.01\n", - "21 W N1 2.74\n", - "22 XBN1 2.69" + "0 BOZ1 3.83\n", + "1 C Z1 5.46\n", + "2 CLX1 8.86\n", + "3 COX1 7.30\n", + "4 CTZ1 1.54\n", + "5 GCZ1 11.96\n", + "6 HGZ1 5.17\n", + "7 HOX1 2.34\n", + "8 KCZ1 3.60\n", + "9 KWZ1 1.68\n", + "10 LAX21 4.62\n", + "11 LCV1 3.76\n", + "12 LHV1 1.90\n", + "13 LNX1 2.43\n", + "14 LXX1 2.91\n", + "15 NGX21 10.28\n", + "16 QSX1 2.86\n", + "17 S X1 4.97\n", + "18 SBV1 3.32\n", + "19 SIZ1 3.26\n", + "20 SMZ1 2.58\n", + "21 W Z1 2.92\n", + "22 XBX1 2.45" ] }, "execution_count": 5, @@ -453,6 +453,91 @@ "bquery.bds(\"BCOM Index\", \"INDX_MWEIGHT\")" ] }, + { + "cell_type": "markdown", + "id": "06501ec0", + "metadata": {}, + "source": [ + "### Using overrides\n", + "\n", + "Various fields can be overriden. For info on what fields support what overrides, the best place to check is using\n", + "`FLDS` from the terminal" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "a5cefec7", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
defaultoverride
securityCRNCY_ADJ_PX_LASTsecurityCRNCY_ADJ_PX_LAST
0IBM US Equity139.24IBM US Equity118.978
\n", + "
" + ], + "text/plain": [ + " default override \n", + " security CRNCY_ADJ_PX_LAST security CRNCY_ADJ_PX_LAST\n", + "0 IBM US Equity 139.24 IBM US Equity 118.978" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "pandas.concat(\n", + " [\n", + " bquery.bdp([\"IBM US Equity\"], [\"CRNCY_ADJ_PX_LAST\"]),\n", + " bquery.bdp(\n", + " [\"IBM US Equity\"], [\"CRNCY_ADJ_PX_LAST\"], overrides=[(\"EQY_FUND_CRNCY\", \"EUR\")]\n", + " )\n", + " ],\n", + " axis=1,\n", + " keys=[\"default\", \"override\"]\n", + ")" + ] + }, { "cell_type": "markdown", "id": "olympic-semester", @@ -465,7 +550,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 7, "id": "drawn-distributor", "metadata": {}, "outputs": [ @@ -515,7 +600,7 @@ "1 TLT US Equity 2971546" ] }, - "execution_count": 6, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -529,7 +614,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 8, "id": "cross-update", "metadata": {}, "outputs": [ @@ -681,7 +766,7 @@ "13 2019-01-10 /sedol1/2971546 120.46 8222860.0" ] }, - "execution_count": 7, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -732,7 +817,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 9, "id": "sharing-teens", "metadata": {}, "outputs": [ @@ -740,7 +825,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "Response for 'NOT_A_TICKER US Equity' contains securityError {'securityError': {'source': '5681::bbdbh2', 'code': 15, 'category': 'BAD_SEC', 'message': 'Unknown/Invalid securityInvalid Security [nid:5681] ', 'subcategory': 'INVALID_SECURITY'}}\n" + "Response for 'NOT_A_TICKER US Equity' contains securityError {'securityError': {'source': '139::bbdbh4', 'code': 15, 'category': 'BAD_SEC', 'message': 'Unknown/Invalid securityInvalid Security [nid:139] ', 'subcategory': 'INVALID_SECURITY'}}\n" ] }, { @@ -835,7 +920,7 @@ "6 2019-01-10 SPY US Equity 258.88 96823923.0" ] }, - "execution_count": 8, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -869,7 +954,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 10, "id": "diverse-reasoning", "metadata": {}, "outputs": [ @@ -907,7 +992,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 11, "id": "exempt-wichita", "metadata": {}, "outputs": [], @@ -933,7 +1018,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 12, "id": "multiple-spider", "metadata": { "scrolled": false @@ -951,7 +1036,7 @@ " \"message\": {\n", " \"fragmentType\": 0,\n", " \"correlationIds\": [\n", - " 23\n", + " 25\n", " ],\n", " \"messageType\": \"HistoricalDataResponse\",\n", " \"timeReceived\": null,\n", @@ -1006,7 +1091,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 13, "id": "marine-version", "metadata": {}, "outputs": [ @@ -1198,7 +1283,7 @@ "18 2021-01-29 GME US Equity 325.00 50566055.0" ] }, - "execution_count": 12, + "execution_count": 13, "metadata": {}, "output_type": "execute_result" } @@ -1224,10 +1309,9 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 14, "id": "warming-nurse", "metadata": { - "lines_to_next_cell": 3, "scrolled": false }, "outputs": [ @@ -1251,142 +1335,143 @@ " \"USDCAD Curncy\"\n", " ],\n", " \"messageType\": \"MarketDataEvents\",\n", - " \"timeReceived\": \"2021-04-06T01:23:44.286675+0000\",\n", + " \"timeReceived\": \"2021-08-20T16:50:17.396011+0000\",\n", " \"element\": {\n", " \"MarketDataEvents\": {\n", " \"MKTDATA_EVENT_TYPE\": \"SUMMARY\",\n", " \"MKTDATA_EVENT_SUBTYPE\": \"INITPAINT\",\n", - " \"BID\": 1.2522,\n", - " \"ASK\": 1.2523,\n", - " \"BEST_BID\": 1.2522,\n", - " \"BEST_ASK\": 1.2523,\n", - " \"BID_ALL_SESSION\": 1.2522,\n", - " \"ASK_ALL_SESSION\": 1.2523,\n", + " \"BID\": 1.2839,\n", + " \"ASK\": 1.284,\n", + " \"BEST_BID\": 1.2839,\n", + " \"BEST_ASK\": 1.284,\n", + " \"BID_ALL_SESSION\": 1.2839,\n", + " \"ASK_ALL_SESSION\": 1.284,\n", " \"IND_BID_FLAG\": false,\n", " \"IND_ASK_FLAG\": false,\n", - " \"BID_TDY\": 1.2522,\n", - " \"PRICE_LAST_BID_RT\": 1.2522,\n", - " \"ASK_TDY\": 1.2523,\n", - " \"PRICE_LAST_ASK_RT\": 1.2523,\n", + " \"BID_TDY\": 1.2839,\n", + " \"PRICE_LAST_BID_RT\": 1.2839,\n", + " \"ASK_TDY\": 1.284,\n", + " \"PRICE_LAST_ASK_RT\": 1.284,\n", " \"BID_DIR\": -1,\n", " \"ASK_DIR\": 1,\n", - " \"BID2\": 1.2522,\n", - " \"ASK2\": 1.2523,\n", - " \"BID_ALL_SESSION_TDY_RT\": 1.2522,\n", - " \"ASK_ALL_SESSION_TDY_RT\": 1.2523,\n", + " \"BID2\": 1.2839,\n", + " \"ASK2\": 1.284,\n", + " \"BID_ALL_SESSION_TDY_RT\": 1.2839,\n", + " \"ASK_ALL_SESSION_TDY_RT\": 1.284,\n", " \"CURRENT_SESSION_RT\": 2,\n", - " \"PX_OPEN_ALL_WITH_SWITCHOVER_RT\": 1.2524700164794922,\n", - " \"PX_CLOSE_ALL_WITH_SWITCHOVER_RT\": 1.2525,\n", + " \"PX_OPEN_ALL_WITH_SWITCHOVER_RT\": 1.2827529907226562,\n", + " \"PX_CLOSE_ALL_WITH_SWITCHOVER_RT\": 1.2828,\n", " \"LAST_PRICE_ALL_SESSION_DIR_RT\": 1,\n", " \"SIMP_LAST_PX_ALL_SESS_DIR_RT\": 1,\n", " \"ID_BB_SEC_NUM_SRC\": 12884922137,\n", - " \"LAST_PRICE\": 1.2523,\n", - " \"LAST2_TRADE\": 1.2523,\n", - " \"HIGH\": 1.2529,\n", - " \"LOW\": 1.2517,\n", - " \"OPEN\": 1.2525,\n", - " \"OPEN_TDY\": 1.2525,\n", - " \"PRICE_OPEN_RT\": 1.2525,\n", - " \"LAST_PRICE_TDY\": 1.2523,\n", - " \"HIGH_TDY\": 1.2529,\n", - " \"PRICE_HIGH_RT\": 1.2529,\n", - " \"LOW_TDY\": 1.2517,\n", - " \"PRICE_LOW_RT\": 1.2517,\n", - " \"MID\": 1.2523,\n", - " \"MID_TDY\": 1.2523,\n", - " \"RT_EXCH_MARKET_STATUS\": \"ACTV\",\n", - " \"LAST_ALL_SESSIONS\": 1.2523,\n", - " \"PREV_CLOSE_VALUE_REALTIME\": 1.2525,\n", - " \"TRADING_DT_REALTIME\": \"2021-04-06T00:00:00.000000\",\n", - " \"PREV_TRADING_DT_REALTIME\": \"2021-04-05T00:00:00.000000\",\n", - " \"PRICE_CHANGE_1Y_NET_RT\": -0.15880000591278076,\n", - " \"PRICE_CHANGE_1Y_PCT_RT\": -11.253999710083008,\n", - " \"CLOSING_PRICE_1Y_AGO_RT\": 1.4111000299453735,\n", + " \"LAST_PRICE\": 1.284,\n", + " \"LAST2_TRADE\": 1.284,\n", + " \"HIGH\": 1.2949,\n", + " \"LOW\": 1.2814,\n", + " \"OPEN\": 1.2828,\n", + " \"OPEN_TDY\": 1.2828,\n", + " \"PRICE_OPEN_RT\": 1.2828,\n", + " \"LAST_PRICE_TDY\": 1.284,\n", + " \"HIGH_TDY\": 1.2949,\n", + " \"PRICE_HIGH_RT\": 1.2949,\n", + " \"LOW_TDY\": 1.2814,\n", + " \"PRICE_LOW_RT\": 1.2814,\n", + " \"MID\": 1.284,\n", + " \"MID_TDY\": 1.284,\n", + " \"LAST_ALL_SESSIONS\": 1.284,\n", + " \"PREV_CLOSE_VALUE_REALTIME\": 1.2828,\n", + " \"TRADING_DT_REALTIME\": \"2021-08-20T00:00:00.000000\",\n", + " \"PREV_TRADING_DT_REALTIME\": \"2021-08-19T00:00:00.000000\",\n", + " \"PRICE_CHANGE_1Y_NET_RT\": -0.03460000082850456,\n", + " \"PRICE_CHANGE_1Y_PCT_RT\": -2.6257998943328857,\n", + " \"CLOSING_PRICE_1Y_AGO_RT\": 1.318600058555603,\n", " \"ZERO_BID_PRICE_INDICATOR_RT\": false,\n", " \"ZERO_ASK_PRICE_INDICATOR_RT\": false,\n", " \"RT_API_MACHINE\": \"apipubx0@md1p-ob-336\",\n", - " \"PX_LOW_BID_RT\": 1.2516002655029297,\n", - " \"PX_HIGH_ASK_RT\": 1.2535302639007568,\n", - " \"PX_HIGH_BID_RT\": 1.252770185470581,\n", - " \"PX_LOW_ASK_RT\": 1.2517499923706055,\n", - " \"ALL_PRICE\": 1.2523,\n", - " \"MID2\": 1.2523,\n", + " \"PX_LOW_BID_RT\": 1.2813900709152222,\n", + " \"PX_HIGH_ASK_RT\": 1.2949600219726562,\n", + " \"PX_HIGH_BID_RT\": 1.294839859008789,\n", + " \"PX_LOW_ASK_RT\": 1.2814998626708984,\n", + " \"ALL_PRICE\": 1.284,\n", + " \"MID2\": 1.284,\n", " \"MID_DIR\": 1,\n", " \"RT_PRICING_SOURCE\": \"BGN\",\n", - " \"ASK_CHANGE\": -0.0007301568984985352,\n", - " \"BID_CHANGE\": 0.00036513805389404297,\n", + " \"ASK_CHANGE\": 0.0009603500366210938,\n", + " \"BID_CHANGE\": 0.0014553070068359375,\n", " \"SPREAD_BA\": 0.0001,\n", - " \"PRICE_52_WEEK_HIGH_RT\": 1.4265,\n", - " \"PRICE_52_WEEK_HIGH_DATE_RT\": \"2020-04-21T00:00:00.000000\",\n", - " \"PRICE_52_WEEK_LOW_RT\": 1.2365,\n", - " \"PRICE_52_WEEK_LOW_DATE_RT\": \"2021-03-18T00:00:00.000000\",\n", - " \"PRICE_PREVIOUS_CLOSE_RT\": 1.2525,\n", - " \"PRICE_LAST_RT\": 1.2523,\n", + " \"PRICE_52_WEEK_HIGH_RT\": 1.3421,\n", + " \"PRICE_52_WEEK_HIGH_DATE_RT\": \"2020-09-30T00:00:00.000000\",\n", + " \"PRICE_52_WEEK_LOW_RT\": 1.2007,\n", + " \"PRICE_52_WEEK_LOW_DATE_RT\": \"2021-06-01T00:00:00.000000\",\n", + " \"PRICE_PREVIOUS_CLOSE_RT\": 1.2828,\n", + " \"PRICE_LAST_RT\": 1.284,\n", " \"15_SECOND_PRICE_CHANGE_RT\": 0.0,\n", " \"1_MINUTE_PRICE_CHANGE_RT\": 0.0,\n", - " \"5_MINUTE_PRICE_CHANGE_RT\": 9.999999747378752e-05,\n", - " \"15_MINUTE_PRICE_CHANGE_RT\": -0.0003000000142492354,\n", - " \"10_MINUTE_PRICE_CHANGE_RT\": 9.999999747378752e-05,\n", - " \"30_MINUTE_PRICE_CHANGE_RT\": -9.999999747378752e-05,\n", - " \"1_HOUR_PRICE_CHANGE_RT\": 0.00019999999494757503,\n", - " \"PREVIOUS_CLOSE_BID_PRICE_RT\": 1.2519,\n", - " \"PREVIOUS_CLOSE_ASK_PRICE_RT\": 1.2531,\n", - " \"LAST_CONTINUOUS_TRADE_PRICE_RT\": 1.2523,\n", + " \"5_MINUTE_PRICE_CHANGE_RT\": -0.0006000000284984708,\n", + " \"15_MINUTE_PRICE_CHANGE_RT\": -0.0007999999797903001,\n", + " \"10_MINUTE_PRICE_CHANGE_RT\": -0.0006000000284984708,\n", + " \"30_MINUTE_PRICE_CHANGE_RT\": -0.0019000000320374966,\n", + " \"1_HOUR_PRICE_CHANGE_RT\": -0.0012000000569969416,\n", + " \"PREVIOUS_CLOSE_BID_PRICE_RT\": 1.2825,\n", + " \"PREVIOUS_CLOSE_ASK_PRICE_RT\": 1.2831,\n", + " \"LAST_CONTINUOUS_TRADE_PRICE_RT\": 1.284,\n", " \"LAST_TRADE_CANCELED_IND_RT\": false,\n", - " \"UNADJUSTED_PREV_LAST_PRICE_RT\": 1.2525,\n", - " \"ADJUSTED_PREV_LAST_PRICE_RT\": 1.2525,\n", + " \"UNADJUSTED_PREV_LAST_PRICE_RT\": 1.2828,\n", + " \"ADJUSTED_PREV_LAST_PRICE_RT\": 1.2828,\n", " \"BASE_PRICE_ENABLED_RT\": false,\n", " \"NUM_TRADES_RT\": 0,\n", " \"BLOOMBERG_CLOSE_METHOD_RT\": \"NA\",\n", " \"LAST_TICK_DIRECTION_RT\": 0,\n", - " \"CHG_NET_REG_SES_PRV_RG_SES_CL_RT\": -0.00018203258514404297,\n", - " \"CHG_PCT_REG_SES_PRV_RG_SES_CL_RT\": -0.014533800508882894,\n", - " \"SHORTENED_BID_ASK_RT\": \"1.2522/23\",\n", + " \"CHG_NET_REG_SES_PRV_RG_SES_CL_RT\": 0.0012083053588867188,\n", + " \"CHG_PCT_REG_SES_PRV_RG_SES_CL_RT\": 0.09419521083891727,\n", + " \"SHORTENED_BID_ASK_RT\": \"1.2839/40\",\n", " \"IS_DELAYED_STREAM\": false,\n", - " \"CHG_NET_MTD_RT\": -0.0039,\n", - " \"CHG_PCT_MTD_RT\": -0.3105,\n", - " \"CHG_NET_QTD_RT\": -0.0039,\n", - " \"CHG_PCT_QTD_RT\": -0.3105,\n", - " \"CHG_NET_YTD_RT\": -0.0202,\n", - " \"CHG_PCT_YTD_RT\": -1.5874,\n", - " \"CHG_NET_1M_RT\": -0.0142,\n", - " \"CHG_PCT_1M_RT\": -1.1212,\n", - " \"CHG_NET_3M_RT\": -0.0154,\n", - " \"CHG_PCT_3M_RT\": -1.2148,\n", - " \"REALTIME_2_DAY_CHANGE_NET\": -0.0055,\n", - " \"REALTIME_2_DAY_CHANGE_PERCENT\": -0.4373,\n", - " \"REALTIME_5_DAY_CHANGE_NET\": -0.0111,\n", - " \"REALTIME_5_DAY_CHANGE_PERCENT\": -0.8786,\n", - " \"RT_PX_AS_PCT_INTRADAY_RANGE\": 50.0,\n", - " \"REALTIME_PERCENT_BID_ASK_SPREAD\": 0.007999999999995566,\n", + " \"EXCH_CODE_LAST_ALL_SESSION_RT\": \"\",\n", + " \"LOC_SRC_FOR_LST_TRD_ALL_SESS_RT\": \"\",\n", + " \"CHG_NET_MTD_RT\": 0.0365,\n", + " \"CHG_PCT_MTD_RT\": 2.9259,\n", + " \"CHG_NET_QTD_RT\": 0.0442,\n", + " \"CHG_PCT_QTD_RT\": 3.5651,\n", + " \"CHG_NET_YTD_RT\": 0.0115,\n", + " \"CHG_PCT_YTD_RT\": 0.9037,\n", + " \"CHG_NET_1M_RT\": 0.0158,\n", + " \"CHG_PCT_1M_RT\": 1.2459,\n", + " \"CHG_NET_3M_RT\": 0.0779,\n", + " \"CHG_PCT_3M_RT\": 6.4588,\n", + " \"REALTIME_2_DAY_CHANGE_NET\": 0.0182,\n", + " \"REALTIME_2_DAY_CHANGE_PERCENT\": 1.4378,\n", + " \"REALTIME_5_DAY_CHANGE_NET\": 0.0325,\n", + " \"REALTIME_5_DAY_CHANGE_PERCENT\": 2.5969,\n", + " \"RT_PX_AS_PCT_INTRADAY_RANGE\": 19.2593,\n", + " \"REALTIME_PERCENT_BID_ASK_SPREAD\": 0.007800000000003138,\n", " \"REALTIME_15_SEC_PRICE_PCT_CHG\": 0.0,\n", " \"REALTIME_ONE_MIN_PRICE_PCT_CHG\": 0.0,\n", - " \"REALTIME_FIVE_MIN_PRICE_PCT_CHG\": 0.008,\n", - " \"REALTIME_15_MIN_PRICE_PCT_CHG\": -0.024,\n", - " \"REALTIME_ONE_HOUR_PRICE_PCT_CHG\": 0.016,\n", - " \"CHG_NET_1D_ALL_FROM_REGULAR_RT\": -0.0002,\n", - " \"CHG_PCT_1D_ALL_FROM_REGULAR_RT\": -0.016,\n", - " \"PX_CHG_NET_1D_ALL_SWITCHOVER_RT\": -0.0002,\n", - " \"PX_CHG_PCT_1D_ALL_SWITCHOVER_RT\": -0.016,\n", + " \"REALTIME_FIVE_MIN_PRICE_PCT_CHG\": -0.0467,\n", + " \"REALTIME_15_MIN_PRICE_PCT_CHG\": -0.0623,\n", + " \"REALTIME_ONE_HOUR_PRICE_PCT_CHG\": -0.0934,\n", + " \"CHG_NET_1D_ALL_FROM_REGULAR_RT\": 0.0012,\n", + " \"CHG_PCT_1D_ALL_FROM_REGULAR_RT\": 0.0935,\n", + " \"PX_CHG_NET_1D_ALL_SWITCHOVER_RT\": 0.0012,\n", + " \"PX_CHG_PCT_1D_ALL_SWITCHOVER_RT\": 0.0935,\n", " \"API_RULES_VERSION\": 201411210,\n", - " \"PREV_SES_LAST_PRICE\": 1.2525,\n", - " \"RT_PX_CHG_NET_1D\": -0.0002,\n", - " \"RT_PX_CHG_PCT_1D\": -0.01600000075995922,\n", - " \"PRICE_CHANGE_ON_DAY_RT\": -0.0002,\n", - " \"NET_CHANGE_ON_DAY_TODAY_RT\": -0.0002,\n", - " \"PERCENT_CHANGE_ON_DAY_TODAY_RT\": -0.016,\n", - " \"LAST_UPDATE_BID_RT\": \"09:23:43\",\n", - " \"LAST_UPDATE_ASK_RT\": \"09:23:43\",\n", - " \"TIME\": \"09:23:43\",\n", + " \"PREV_SES_LAST_PRICE\": 1.2828,\n", + " \"RT_PX_CHG_NET_1D\": 0.0012,\n", + " \"RT_PX_CHG_PCT_1D\": 0.09350000321865082,\n", + " \"PRICE_CHANGE_ON_DAY_RT\": 0.0012,\n", + " \"NET_CHANGE_ON_DAY_TODAY_RT\": 0.0012,\n", + " \"PERCENT_CHANGE_ON_DAY_TODAY_RT\": 0.0935,\n", + " \"LAST_UPDATE_BID_RT\": \"00:50:17\",\n", + " \"LAST_UPDATE_ASK_RT\": \"00:50:17\",\n", + " \"TIME\": \"00:50:17\",\n", " \"PROXY_TIME_OF_LAST_UPDATE_RT\": null,\n", - " \"BID_ASK_TIME\": \"09:23:43\",\n", + " \"BID_ASK_TIME\": \"00:50:17\",\n", " \"SES_START\": \"05:00:00\",\n", " \"SES_END\": \"04:59:59\",\n", - " \"PRICE_LAST_TIME_RT\": \"09:23:43\",\n", - " \"LAST_BID_TIME_TODAY_REALTIME\": \"09:23:43\",\n", - " \"LAST_ASK_TIME_TODAY_REALTIME\": \"09:23:43\",\n", - " \"LAST_PRICE_TIME_TODAY_REALTIME\": \"09:23:43\",\n", - " \"LAST_UPDATE_ALL_SESSIONS_RT\": \"09:23:43\"\n", + " \"PRICE_LAST_TIME_RT\": \"00:50:17\",\n", + " \"LAST_BID_TIME_TODAY_REALTIME\": \"00:50:17\",\n", + " \"LAST_ASK_TIME_TODAY_REALTIME\": \"00:50:17\",\n", + " \"LAST_PRICE_TIME_TODAY_REALTIME\": \"00:50:17\",\n", + " \"LAST_UPDATE_ALL_SESSIONS_RT\": \"00:50:17\"\n", " }\n", " }\n", "}\n", @@ -1396,27 +1481,28 @@ " \"USDCAD Curncy\"\n", " ],\n", " \"messageType\": \"MarketDataEvents\",\n", - " \"timeReceived\": \"2021-04-06T01:23:44.312849+0000\",\n", + " \"timeReceived\": \"2021-08-20T16:50:17.449316+0000\",\n", " \"element\": {\n", " \"MarketDataEvents\": {\n", " \"MKTDATA_EVENT_TYPE\": \"TRADE\",\n", " \"MKTDATA_EVENT_SUBTYPE\": \"NEW\",\n", - " \"LAST_ALL_SESSIONS\": 1.2523,\n", - " \"LAST2_TRADE\": 1.2523,\n", - " \"LAST_PRICE\": 1.2523,\n", - " \"LAST_PRICE_TDY\": 1.2523,\n", + " \"LAST_ALL_SESSIONS\": 1.284,\n", + " \"LAST2_TRADE\": 1.284,\n", + " \"LAST_PRICE\": 1.284,\n", + " \"LAST_PRICE_TDY\": 1.284,\n", " \"LAST2_DIR\": null,\n", " \"LAST_TICK_DIRECTION_RT\": 0,\n", " \"ALL_PRICE_COND_CODE\": null,\n", - " \"ALL_PRICE\": 1.2523,\n", + " \"ALL_PRICE\": 1.284,\n", " \"LAST_PRICE_COND_CODE_RT\": null,\n", - " \"PRICE_CHANGE_1Y_NET_RT\": -0.15880000591278076,\n", - " \"PRICE_CHANGE_1Y_PCT_RT\": -11.253600120544434,\n", - " \"LAST_CONTINUOUS_TRADE_PRICE_RT\": 1.2523,\n", - " \"PRICE_LAST_RT\": 1.2523,\n", - " \"EVT_TRADE_PRICE_RT\": 1.2523,\n", + " \"PRICE_CHANGE_1Y_NET_RT\": -0.03460000082850456,\n", + " \"PRICE_CHANGE_1Y_PCT_RT\": -2.624000072479248,\n", + " \"LAST_CONTINUOUS_TRADE_PRICE_RT\": 1.284,\n", + " \"PRICE_LAST_RT\": 1.284,\n", + " \"EVT_TRADE_PRICE_RT\": 1.284,\n", " \"EVT_TRADE_SIZE_RT\": 0,\n", " \"EVT_TRADE_CONDITION_CODE_RT\": null,\n", + " \"EVT_TRADE_LOCAL_EXCH_SOURCE_RT\": null,\n", " \"EVT_TRADE_SOURCE_TYPE_CODE_RT\": null,\n", " \"EVT_TRADE_INTEGER_IDENTIFIER_RT\": null,\n", " \"EVT_TRADE_IDENTIFIER_RT\": null,\n", @@ -1428,36 +1514,36 @@ " \"CHG_PCT_PREV_DAY_POST_CLS\": null,\n", " \"CHG_NET_1D_PRE_FROM_REGULAR_RT\": null,\n", " \"CHG_PCT_1D_PRE_FROM_REGULAR_RT\": null,\n", - " \"CHG_NET_1D_ALL_FROM_REGULAR_RT\": -0.0002,\n", - " \"CHG_PCT_1D_ALL_FROM_REGULAR_RT\": -0.016,\n", + " \"CHG_NET_1D_ALL_FROM_REGULAR_RT\": 0.0012,\n", + " \"CHG_PCT_1D_ALL_FROM_REGULAR_RT\": 0.0935,\n", " \"CHG_NET_1D_POST_FROM_REGULAR_RT\": null,\n", " \"CHG_PCT_1D_POST_FROM_REGULAR_RT\": null,\n", - " \"PX_CHG_NET_1D_ALL_SWITCHOVER_RT\": -0.0002,\n", - " \"PX_CHG_PCT_1D_ALL_SWITCHOVER_RT\": -0.016,\n", - " \"CHG_NET_REG_SES_PRV_RG_SES_CL_RT\": -0.0002,\n", - " \"CHG_PCT_REG_SES_PRV_RG_SES_CL_RT\": -0.015968,\n", - " \"CHG_NET_MTD_RT\": -0.0039,\n", - " \"CHG_PCT_MTD_RT\": -0.3105,\n", - " \"CHG_NET_QTD_RT\": -0.0039,\n", - " \"CHG_PCT_QTD_RT\": -0.3105,\n", - " \"CHG_NET_YTD_RT\": -0.0202,\n", - " \"CHG_PCT_YTD_RT\": -1.5874,\n", - " \"CHG_NET_1M_RT\": -0.0142,\n", - " \"CHG_PCT_1M_RT\": -1.1212,\n", - " \"CHG_NET_3M_RT\": -0.0154,\n", - " \"CHG_PCT_3M_RT\": -1.2148,\n", - " \"REALTIME_2_DAY_CHANGE_NET\": -0.0055,\n", - " \"REALTIME_2_DAY_CHANGE_PERCENT\": -0.4373,\n", - " \"REALTIME_5_DAY_CHANGE_NET\": -0.0111,\n", - " \"REALTIME_5_DAY_CHANGE_PERCENT\": -0.8786,\n", - " \"RT_PX_AS_PCT_INTRADAY_RANGE\": 50.0,\n", - " \"REALTIME_PERCENT_BID_ASK_SPREAD\": 0.007999999999995566,\n", + " \"PX_CHG_NET_1D_ALL_SWITCHOVER_RT\": 0.0012,\n", + " \"PX_CHG_PCT_1D_ALL_SWITCHOVER_RT\": 0.0935,\n", + " \"CHG_NET_REG_SES_PRV_RG_SES_CL_RT\": 0.0012,\n", + " \"CHG_PCT_REG_SES_PRV_RG_SES_CL_RT\": 0.093545,\n", + " \"CHG_NET_MTD_RT\": 0.0365,\n", + " \"CHG_PCT_MTD_RT\": 2.9259,\n", + " \"CHG_NET_QTD_RT\": 0.0442,\n", + " \"CHG_PCT_QTD_RT\": 3.5651,\n", + " \"CHG_NET_YTD_RT\": 0.0115,\n", + " \"CHG_PCT_YTD_RT\": 0.9037,\n", + " \"CHG_NET_1M_RT\": 0.0158,\n", + " \"CHG_PCT_1M_RT\": 1.2459,\n", + " \"CHG_NET_3M_RT\": 0.0779,\n", + " \"CHG_PCT_3M_RT\": 6.4588,\n", + " \"REALTIME_2_DAY_CHANGE_NET\": 0.0182,\n", + " \"REALTIME_2_DAY_CHANGE_PERCENT\": 1.4378,\n", + " \"REALTIME_5_DAY_CHANGE_NET\": 0.0325,\n", + " \"REALTIME_5_DAY_CHANGE_PERCENT\": 2.5969,\n", + " \"RT_PX_AS_PCT_INTRADAY_RANGE\": 19.2593,\n", + " \"REALTIME_PERCENT_BID_ASK_SPREAD\": 0.007800000000003138,\n", " \"RT_THEORETICAL_PCT_CHG_FROM_LAST\": null,\n", " \"REALTIME_15_SEC_PRICE_PCT_CHG\": 0.0,\n", " \"REALTIME_ONE_MIN_PRICE_PCT_CHG\": 0.0,\n", - " \"REALTIME_FIVE_MIN_PRICE_PCT_CHG\": 0.008,\n", - " \"REALTIME_15_MIN_PRICE_PCT_CHG\": -0.024,\n", - " \"REALTIME_ONE_HOUR_PRICE_PCT_CHG\": 0.016,\n", + " \"REALTIME_FIVE_MIN_PRICE_PCT_CHG\": -0.0467,\n", + " \"REALTIME_15_MIN_PRICE_PCT_CHG\": -0.0623,\n", + " \"REALTIME_ONE_HOUR_PRICE_PCT_CHG\": -0.0934,\n", " \"REALTIME_VOLUME_5_DAY_INTERVAL\": null,\n", " \"DELTA_AVAT_1_DAY_INTERVAL\": null,\n", " \"DELTA_AVAT_5_DAY_INTERVAL\": null,\n", @@ -1473,26 +1559,52 @@ " \"DELTA_ATAT_30_DAY_INTERVAL\": null,\n", " \"DELTA_ATAT_100_DAY_INTERVAL\": null,\n", " \"DELTA_ATAT_180_DAY_INTERVAL\": null,\n", - " \"RT_PX_CHG_NET_1D\": -0.0002,\n", - " \"RT_PX_CHG_PCT_1D\": -0.01600000075995922,\n", - " \"PRICE_CHANGE_ON_DAY_RT\": -0.0002,\n", - " \"NET_CHANGE_ON_DAY_TODAY_RT\": -0.0002,\n", - " \"PERCENT_CHANGE_ON_DAY_TODAY_RT\": -0.016,\n", - " \"LAST_UPDATE_CHG_1D_RT\": -0.00019999999494757503,\n", - " \"EVT_TRADE_TIME_RT\": \"09:23:44\",\n", - " \"TRADE_UPDATE_STAMP_RT\": \"2021-04-06T09:23:44.000000+0800\",\n", + " \"RT_PX_CHG_NET_1D\": 0.0012,\n", + " \"RT_PX_CHG_PCT_1D\": 0.09350000321865082,\n", + " \"PRICE_CHANGE_ON_DAY_RT\": 0.0012,\n", + " \"NET_CHANGE_ON_DAY_TODAY_RT\": 0.0012,\n", + " \"PERCENT_CHANGE_ON_DAY_TODAY_RT\": 0.0935,\n", + " \"LAST_UPDATE_CHG_1D_RT\": 0.0012000000569969416,\n", + " \"EVT_TRADE_TIME_RT\": \"00:50:17\",\n", + " \"TRADE_UPDATE_STAMP_RT\": \"2021-08-21T00:50:17.000000+0800\",\n", " \"IS_DELAYED_STREAM\": false,\n", " \"EVT_UPDATE_ACTIONS_RT\": 271,\n", - " \"TIME\": \"09:23:44\",\n", - " \"PRICE_LAST_TIME_RT\": \"09:23:44\",\n", - " \"LAST_PRICE_TIME_TODAY_REALTIME\": \"09:23:44\",\n", - " \"EVENT_TIME\": \"09:23:44\",\n", - " \"LAST_UPDATE_ALL_SESSIONS_RT\": \"09:23:44\",\n", - " \"BLOOMBERG_SEND_TIME_RT\": \"01:23:44\"\n", + " \"TIME\": \"00:50:17\",\n", + " \"PRICE_LAST_TIME_RT\": \"00:50:17\",\n", + " \"LAST_PRICE_TIME_TODAY_REALTIME\": \"00:50:17\",\n", + " \"EVENT_TIME\": \"00:50:17\",\n", + " \"LAST_UPDATE_ALL_SESSIONS_RT\": \"00:50:17\",\n", + " \"BLOOMBERG_SEND_TIME_RT\": \"16:50:17\"\n", " }\n", " }\n", "}\n" ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "20AUG2021_12:50:34.721 28102:140461514245888 WARN blpapi_platformcontroller.cpp:377 blpapi.session.platformcontroller.{1} Connectivity lost, no connected endpoints. \n", + "\n", + "20AUG2021_12:50:34.722 28102:140461479098112 WARN blpapi_platformcontroller.cpp:377 blpapi.session.platformcontroller.{2} Connectivity lost, no connected endpoints. \n", + "\n", + "20AUG2021_12:50:34.724 28102:140461522839296 WARN apicm_apiconnector.cpp:570 ApiConnector::negotiatorCallback localhost: Session negotiation failed for 127.0.0.1:8194 result = 1 \n", + "\n", + "20AUG2021_12:50:34.724 28102:140461487490816 WARN apicm_apiconnector.cpp:570 ApiConnector::negotiatorCallback localhost: Session negotiation failed for 127.0.0.1:8194 result = 1 \n", + "\n", + "20AUG2021_12:50:34.724 28102:140461522839296 WARN blpapi_apicmadapter.cpp:335 blpapi.session.transporttcp.apicmadapter.{1} Failed BBCOMM session negotiation localhost:8194 <127.0.0.1:8194> \n", + "\n", + "20AUG2021_12:50:34.724 28102:140461487490816 WARN blpapi_apicmadapter.cpp:335 blpapi.session.transporttcp.apicmadapter.{2} Failed BBCOMM session negotiation localhost:8194 <127.0.0.1:8194> \n", + "\n", + "20AUG2021_12:50:34.724 28102:140461522839296 WARN blpapi_platformtransporttcp.cpp:151 blpapi.session.transporttcp.{1}. { platformId=0 } 127.0.0.1, session pool state=Failed \n", + "\n", + "20AUG2021_12:50:34.724 28102:140461522839296 WARN blpapi_platformcontroller.cpp:607 blpapi.session.platformcontroller.{1} Platform failed 1 consecutive connect attempts, stopped trying to reconnect. { PlatformId=0 } \n", + "\n", + "20AUG2021_12:50:34.724 28102:140461487490816 WARN blpapi_platformtransporttcp.cpp:151 blpapi.session.transporttcp.{2}. { platformId=0 } 127.0.0.1, session pool state=Failed \n", + "\n", + "20AUG2021_12:50:34.724 28102:140461487490816 WARN blpapi_platformcontroller.cpp:607 blpapi.session.platformcontroller.{2} Platform failed 1 consecutive connect attempts, stopped trying to reconnect. { PlatformId=0 } \n" + ] } ], "source": [ @@ -1504,6 +1616,8 @@ " n += 1\n", " if n > 1:\n", " break\n", + "\n", + "\n", "\n" ] }, @@ -1521,7 +1635,7 @@ "formats": "py:percent,ipynb" }, "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -1535,7 +1649,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.6" + "version": "3.9.6" } }, "nbformat": 4, diff --git a/doc/source/quickstart.py b/doc/source/quickstart.py index a6bee09..bf9ace4 100644 --- a/doc/source/quickstart.py +++ b/doc/source/quickstart.py @@ -6,9 +6,9 @@ # extension: .py # format_name: percent # format_version: '1.3' -# jupytext_version: 1.10.2 +# jupytext_version: 1.11.4 # kernelspec: -# display_name: Python 3 +# display_name: Python 3 (ipykernel) # language: python # name: python3 # --- @@ -44,6 +44,24 @@ # %% bquery.bds("BCOM Index", "INDX_MWEIGHT") +# %% [markdown] +# ### Using overrides +# +# Various fields can be overriden. For info on what fields support what overrides, the best place to check is using +# `FLDS` from the terminal + +# %% +pandas.concat( + [ + bquery.bdp(["IBM US Equity"], ["CRNCY_ADJ_PX_LAST"]), + bquery.bdp( + ["IBM US Equity"], ["CRNCY_ADJ_PX_LAST"], overrides=[("EQY_FUND_CRNCY", "EUR")] + ) + ], + axis=1, + keys=["default", "override"] +) + # %% [markdown] # ### Using sedols