{
"cells": [
{
"cell_type": "markdown",
"id": "a2468e6e-b872-4c22-9d7c-bbd9e63b3960",
"metadata": {},
"source": [
"# Symbologies"
]
},
{
"cell_type": "markdown",
"id": "26263b8e-6573-4c93-82e4-bb1db1297aa8",
"metadata": {},
"source": [
"
\n",
"This is part of the OQD offering. Available in OneTick Cloud. Can be configured on prem.\n",
"
"
]
},
{
"cell_type": "markdown",
"id": "63dbbd13-4431-4e9f-afaf-a5f0f491cfab",
"metadata": {},
"source": [
"We can query data using different symbologies."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6eed0384-49d5-42f3-b00d-defb751c051c",
"metadata": {},
"outputs": [],
"source": [
"import onetick.py as otp\n",
"\n",
"trd = otp.DataSource('NYSE_TAQ', tick_type='TRD')\n",
"trd = trd[['PRICE','SIZE','EXCHANGE','COND']]\n",
"trd = trd.first(1)\n",
"merged = otp.merge([trd], symbols=['BTKR::::AAPL US','FGV::::btkr000BPH459'], identify_input_ts=True)\n",
"otp.run(merged, start=otp.dt(2022,3,1,10), end=otp.dt(2022,3,1,10,15), symbol_date=otp.dt(2022, 10, 1))"
]
},
{
"cell_type": "markdown",
"id": "2b8306e5-bc9c-41ac-824a-ef6da2f6f6a2",
"metadata": {},
"source": [
"We can create a mapping between symbologies."
]
},
{
"cell_type": "code",
"execution_count": 45,
"id": "bd8a4dc1-0a5b-4fd9-b21c-6c62346e82d5",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" Time | \n",
" SYMBOL_NAME | \n",
" ORIGINAL_SYMBOL_NAME | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" 2022-12-01 | \n",
" BBG000C2V3D6 | \n",
" NYSE_TAQ::A | \n",
"
\n",
" \n",
" 1 | \n",
" 2022-12-01 | \n",
" BBG00B3T3HD3 | \n",
" NYSE_TAQ::AA | \n",
"
\n",
" \n",
" 2 | \n",
" 2022-12-01 | \n",
" BBG01B0JRCS6 | \n",
" NYSE_TAQ::AAA | \n",
"
\n",
" \n",
" 3 | \n",
" 2022-12-01 | \n",
" BBG00LPXX872 | \n",
" NYSE_TAQ::AAAU | \n",
"
\n",
" \n",
" 4 | \n",
" 2022-12-01 | \n",
" BBG00YZC2Z91 | \n",
" NYSE_TAQ::AAC | \n",
"
\n",
" \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
"
\n",
" \n",
" 11007 | \n",
" 2022-12-01 | \n",
" BBG00YZ7S2J6 | \n",
" NYSE_TAQ::ZWRKW | \n",
"
\n",
" \n",
" 11008 | \n",
" 2022-12-01 | \n",
" BBG000H8R0N8 | \n",
" NYSE_TAQ::ZWS | \n",
"
\n",
" \n",
" 11009 | \n",
" 2022-12-01 | \n",
" BBG019XSYC89 | \n",
" NYSE_TAQ::ZYME | \n",
"
\n",
" \n",
" 11010 | \n",
" 2022-12-01 | \n",
" BBG007BBS8B7 | \n",
" NYSE_TAQ::ZYNE | \n",
"
\n",
" \n",
" 11011 | \n",
" 2022-12-01 | \n",
" BBG000BJBXZ2 | \n",
" NYSE_TAQ::ZYXI | \n",
"
\n",
" \n",
"
\n",
"
11012 rows × 3 columns
\n",
"
"
],
"text/plain": [
" Time SYMBOL_NAME ORIGINAL_SYMBOL_NAME\n",
"0 2022-12-01 BBG000C2V3D6 NYSE_TAQ::A\n",
"1 2022-12-01 BBG00B3T3HD3 NYSE_TAQ::AA\n",
"2 2022-12-01 BBG01B0JRCS6 NYSE_TAQ::AAA\n",
"3 2022-12-01 BBG00LPXX872 NYSE_TAQ::AAAU\n",
"4 2022-12-01 BBG00YZC2Z91 NYSE_TAQ::AAC\n",
"... ... ... ...\n",
"11007 2022-12-01 BBG00YZ7S2J6 NYSE_TAQ::ZWRKW\n",
"11008 2022-12-01 BBG000H8R0N8 NYSE_TAQ::ZWS\n",
"11009 2022-12-01 BBG019XSYC89 NYSE_TAQ::ZYME\n",
"11010 2022-12-01 BBG007BBS8B7 NYSE_TAQ::ZYNE\n",
"11011 2022-12-01 BBG000BJBXZ2 NYSE_TAQ::ZYXI\n",
"\n",
"[11012 rows x 3 columns]"
]
},
"execution_count": 45,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"figi = otp.Symbols('NYSE_TAQ', symbology='FGV', show_original_symbols=True, for_tick_type='TRD')\n",
"figi, _ = figi[figi['SYMBOL_NAME']!='']\n",
"otp.run(figi, start=otp.dt(2022, 12, 1), end=otp.dt(2022, 12, 2))"
]
},
{
"cell_type": "code",
"execution_count": 46,
"id": "d9510ca4-9f14-4ddf-907d-0e74ec45ee70",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" Time | \n",
" SYMBOL_NAME | \n",
" ORIGINAL_SYMBOL_NAME | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" 2022-12-01 | \n",
" A US | \n",
" NYSE_TAQ::A | \n",
"
\n",
" \n",
" 1 | \n",
" 2022-12-01 | \n",
" AA US | \n",
" NYSE_TAQ::AA | \n",
"
\n",
" \n",
" 2 | \n",
" 2022-12-01 | \n",
" AAA US | \n",
" NYSE_TAQ::AAA | \n",
"
\n",
" \n",
" 3 | \n",
" 2022-12-01 | \n",
" AAAU US | \n",
" NYSE_TAQ::AAAU | \n",
"
\n",
" \n",
" 4 | \n",
" 2022-12-01 | \n",
" AAC US | \n",
" NYSE_TAQ::AAC | \n",
"
\n",
" \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
"
\n",
" \n",
" 10926 | \n",
" 2022-12-01 | \n",
" ZWRKW US | \n",
" NYSE_TAQ::ZWRKW | \n",
"
\n",
" \n",
" 10927 | \n",
" 2022-12-01 | \n",
" ZWS US | \n",
" NYSE_TAQ::ZWS | \n",
"
\n",
" \n",
" 10928 | \n",
" 2022-12-01 | \n",
" ZYME US | \n",
" NYSE_TAQ::ZYME | \n",
"
\n",
" \n",
" 10929 | \n",
" 2022-12-01 | \n",
" ZYNE US | \n",
" NYSE_TAQ::ZYNE | \n",
"
\n",
" \n",
" 10930 | \n",
" 2022-12-01 | \n",
" ZYXI US | \n",
" NYSE_TAQ::ZYXI | \n",
"
\n",
" \n",
"
\n",
"
10931 rows × 3 columns
\n",
"
"
],
"text/plain": [
" Time SYMBOL_NAME ORIGINAL_SYMBOL_NAME\n",
"0 2022-12-01 A US NYSE_TAQ::A\n",
"1 2022-12-01 AA US NYSE_TAQ::AA\n",
"2 2022-12-01 AAA US NYSE_TAQ::AAA\n",
"3 2022-12-01 AAAU US NYSE_TAQ::AAAU\n",
"4 2022-12-01 AAC US NYSE_TAQ::AAC\n",
"... ... ... ...\n",
"10926 2022-12-01 ZWRKW US NYSE_TAQ::ZWRKW\n",
"10927 2022-12-01 ZWS US NYSE_TAQ::ZWS\n",
"10928 2022-12-01 ZYME US NYSE_TAQ::ZYME\n",
"10929 2022-12-01 ZYNE US NYSE_TAQ::ZYNE\n",
"10930 2022-12-01 ZYXI US NYSE_TAQ::ZYXI\n",
"\n",
"[10931 rows x 3 columns]"
]
},
"execution_count": 46,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"btkr = otp.Symbols('NYSE_TAQ', symbology='BTKR', show_original_symbols=True, for_tick_type='TRD')\n",
"btkr, _ = btkr[btkr['SYMBOL_NAME']!='']\n",
"otp.run(btkr, start=otp.dt(2022, 12, 1), end=otp.dt(2022, 12, 2))"
]
},
{
"cell_type": "code",
"execution_count": 51,
"id": "58c2d540-438e-4086-87fc-043c443cc1ec",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" Time | \n",
" FIGI | \n",
" BTKR | \n",
" DB_SYMBOL | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" 2022-12-01 | \n",
" BBG000C2V3D6 | \n",
" A US | \n",
" NYSE_TAQ::A | \n",
"
\n",
" \n",
" 1 | \n",
" 2022-12-01 | \n",
" BBG00B3T3HD3 | \n",
" AA US | \n",
" NYSE_TAQ::AA | \n",
"
\n",
" \n",
" 2 | \n",
" 2022-12-01 | \n",
" BBG01B0JRCS6 | \n",
" AAA US | \n",
" NYSE_TAQ::AAA | \n",
"
\n",
" \n",
" 3 | \n",
" 2022-12-01 | \n",
" BBG00LPXX872 | \n",
" AAAU US | \n",
" NYSE_TAQ::AAAU | \n",
"
\n",
" \n",
" 4 | \n",
" 2022-12-01 | \n",
" BBG00YZC2Z91 | \n",
" AAC US | \n",
" NYSE_TAQ::AAC | \n",
"
\n",
" \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
"
\n",
" \n",
" 11005 | \n",
" 2022-12-01 | \n",
" BBG00YZ7S2J6 | \n",
" ZWRKW US | \n",
" NYSE_TAQ::ZWRKW | \n",
"
\n",
" \n",
" 11006 | \n",
" 2022-12-01 | \n",
" BBG000H8R0N8 | \n",
" ZWS US | \n",
" NYSE_TAQ::ZWS | \n",
"
\n",
" \n",
" 11007 | \n",
" 2022-12-01 | \n",
" BBG019XSYC89 | \n",
" ZYME US | \n",
" NYSE_TAQ::ZYME | \n",
"
\n",
" \n",
" 11008 | \n",
" 2022-12-01 | \n",
" BBG007BBS8B7 | \n",
" ZYNE US | \n",
" NYSE_TAQ::ZYNE | \n",
"
\n",
" \n",
" 11009 | \n",
" 2022-12-01 | \n",
" BBG000BJBXZ2 | \n",
" ZYXI US | \n",
" NYSE_TAQ::ZYXI | \n",
"
\n",
" \n",
"
\n",
"
11010 rows × 4 columns
\n",
"
"
],
"text/plain": [
" Time FIGI BTKR DB_SYMBOL\n",
"0 2022-12-01 BBG000C2V3D6 A US NYSE_TAQ::A\n",
"1 2022-12-01 BBG00B3T3HD3 AA US NYSE_TAQ::AA\n",
"2 2022-12-01 BBG01B0JRCS6 AAA US NYSE_TAQ::AAA\n",
"3 2022-12-01 BBG00LPXX872 AAAU US NYSE_TAQ::AAAU\n",
"4 2022-12-01 BBG00YZC2Z91 AAC US NYSE_TAQ::AAC\n",
"... ... ... ... ...\n",
"11005 2022-12-01 BBG00YZ7S2J6 ZWRKW US NYSE_TAQ::ZWRKW\n",
"11006 2022-12-01 BBG000H8R0N8 ZWS US NYSE_TAQ::ZWS\n",
"11007 2022-12-01 BBG019XSYC89 ZYME US NYSE_TAQ::ZYME\n",
"11008 2022-12-01 BBG007BBS8B7 ZYNE US NYSE_TAQ::ZYNE\n",
"11009 2022-12-01 BBG000BJBXZ2 ZYXI US NYSE_TAQ::ZYXI\n",
"\n",
"[11010 rows x 4 columns]"
]
},
"execution_count": 51,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"figi = otp.Symbols('NYSE_TAQ', symbology='FGV', show_original_symbols=True, for_tick_type='TRD')\n",
"btkr = otp.Symbols('NYSE_TAQ', symbology='BTKR', show_original_symbols=True, for_tick_type='TRD')\n",
"btkr, _ = btkr[btkr['SYMBOL_NAME']!='']\n",
"figi, _ = figi[figi['SYMBOL_NAME']!='']\n",
"\n",
"mapping = otp.functions.join(figi, btkr, on=btkr['ORIGINAL_SYMBOL_NAME']==figi['ORIGINAL_SYMBOL_NAME'], how=\"inner\")\n",
"\n",
"mapping = mapping.rename({'RIGHT_SYMBOL_NAME' : 'BTKR',\n",
" 'SYMBOL_NAME' : 'FIGI',\n",
" 'ORIGINAL_SYMBOL_NAME': 'DB_SYMBOL'})\n",
"\n",
"mapping = mapping[['FIGI', 'BTKR', 'DB_SYMBOL']]\n",
"\n",
"otp.run(mapping, start=otp.dt(2022, 12, 1), end=otp.dt(2022, 12, 2))"
]
},
{
"cell_type": "markdown",
"id": "61ae358f-6d6b-4054-a2c2-b743c97be56d",
"metadata": {},
"source": [
"And here is an example for a non-US market"
]
},
{
"cell_type": "code",
"execution_count": 52,
"id": "e58c23de-05b3-47eb-8a86-469ef1b88c26",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" Time | \n",
" TICKER | \n",
" FIGI | \n",
" DB_SYMBOL | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" 2022-12-01 | \n",
" 020Y | \n",
" BBG007XBDG85 | \n",
" LSE::020Y | \n",
"
\n",
" \n",
" 1 | \n",
" 2022-12-01 | \n",
" 0A05 | \n",
" BBG00SYG7Q00 | \n",
" LSE::0A05 | \n",
"
\n",
" \n",
" 2 | \n",
" 2022-12-01 | \n",
" 0A07 | \n",
" BBG00NWMW214 | \n",
" LSE::0A07 | \n",
"
\n",
" \n",
" 3 | \n",
" 2022-12-01 | \n",
" 0A08 | \n",
" BBG00NWMVL13 | \n",
" LSE::0A08 | \n",
"
\n",
" \n",
" 4 | \n",
" 2022-12-01 | \n",
" 0A0B | \n",
" BBG00NWMW143 | \n",
" LSE::0A0B | \n",
"
\n",
" \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
"
\n",
" \n",
" 5332 | \n",
" 2022-12-01 | \n",
" ZNWD | \n",
" BBG00JG082G0 | \n",
" LSE::ZNWD | \n",
"
\n",
" \n",
" 5333 | \n",
" 2022-12-01 | \n",
" ZOO | \n",
" BBG000DBR279 | \n",
" LSE::ZOO | \n",
"
\n",
" \n",
" 5334 | \n",
" 2022-12-01 | \n",
" ZPHR | \n",
" BBG000DB8YK5 | \n",
" LSE::ZPHR | \n",
"
\n",
" \n",
" 5335 | \n",
" 2022-12-01 | \n",
" ZTF | \n",
" BBG000BGXLF2 | \n",
" LSE::ZTF | \n",
"
\n",
" \n",
" 5336 | \n",
" 2022-12-01 | \n",
" ZYT | \n",
" BBG000BZPV76 | \n",
" LSE::ZYT | \n",
"
\n",
" \n",
"
\n",
"
5337 rows × 4 columns
\n",
"
"
],
"text/plain": [
" Time TICKER FIGI DB_SYMBOL\n",
"0 2022-12-01 020Y BBG007XBDG85 LSE::020Y\n",
"1 2022-12-01 0A05 BBG00SYG7Q00 LSE::0A05\n",
"2 2022-12-01 0A07 BBG00NWMW214 LSE::0A07\n",
"3 2022-12-01 0A08 BBG00NWMVL13 LSE::0A08\n",
"4 2022-12-01 0A0B BBG00NWMW143 LSE::0A0B\n",
"... ... ... ... ...\n",
"5332 2022-12-01 ZNWD BBG00JG082G0 LSE::ZNWD\n",
"5333 2022-12-01 ZOO BBG000DBR279 LSE::ZOO\n",
"5334 2022-12-01 ZPHR BBG000DB8YK5 LSE::ZPHR\n",
"5335 2022-12-01 ZTF BBG000BGXLF2 LSE::ZTF\n",
"5336 2022-12-01 ZYT BBG000BZPV76 LSE::ZYT\n",
"\n",
"[5337 rows x 4 columns]"
]
},
"execution_count": 52,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# 'FGV' is venue FIGI\n",
"# 'FGC' is composite FIGI\n",
"fgv = otp.Symbols('LSE', symbology='FGV', show_original_symbols=True, for_tick_type='TRD')\n",
"tkr = otp.Symbols('LSE', symbology='TKR', show_original_symbols=True, for_tick_type='TRD')\n",
"\n",
"mapping = otp.functions.join(fgv, tkr, on=fgv['ORIGINAL_SYMBOL_NAME']==tkr['ORIGINAL_SYMBOL_NAME'], how=\"inner\")\n",
"\n",
"mapping, _ = mapping[mapping['SYMBOL_NAME'] != '']\n",
"mapping = mapping.rename({'RIGHT_SYMBOL_NAME' : 'TICKER',\n",
" 'SYMBOL_NAME' : 'FIGI',\n",
" 'ORIGINAL_SYMBOL_NAME': 'DB_SYMBOL'})\n",
"\n",
"mapping = mapping[['TICKER', 'FIGI', 'DB_SYMBOL']]\n",
"start = otp.dt(2022, 5, 20)\n",
"end = otp.dt(2022, 5, 25)\n",
"\n",
"otp.run(mapping, start=otp.dt(2022, 12, 1), end=otp.dt(2022, 12, 2))"
]
},
{
"cell_type": "markdown",
"id": "4a5f2236-e7a9-4b20-859b-2fa3e3e0d7da",
"metadata": {},
"source": [
"# Symbol name changes\n",
"Symbol name changes are easy to handle with the `symbol_date` parameter of `otp.run()` which provides the \"as of\" date for the symbols. For example, we can pass `META` while setting `symbol_date` to any date after 2022-06-09 or `FB` and `symbol_date` before 2022-06-09."
]
},
{
"cell_type": "code",
"execution_count": 53,
"id": "5dd68a3d-4f69-47d4-ba08-ccd3a3f33377",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" Time | \n",
" EXCHANGE | \n",
" COND | \n",
" STOP_STOCK | \n",
" SOURCE | \n",
" TRF | \n",
" TTE | \n",
" TICKER | \n",
" PRICE | \n",
" DELETED_TIME | \n",
" TICK_STATUS | \n",
" SIZE | \n",
" CORR | \n",
" SEQ_NUM | \n",
" TRADE_ID | \n",
" PARTICIPANT_TIME | \n",
" TRF_TIME | \n",
" OMDSEQ | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" 2023-02-02 00:00:00.100474511 | \n",
" Q | \n",
" @ TI | \n",
" | \n",
" N | \n",
" | \n",
" 0 | \n",
" META | \n",
" 183.13 | \n",
" 1970-01-01 | \n",
" 0 | \n",
" 10 | \n",
" 0 | \n",
" 7286117 | \n",
" 160978 | \n",
" 2023-02-02 00:00:00.100458331 | \n",
" 1970-01-01 00:00:00.000000000 | \n",
" 0 | \n",
"
\n",
" \n",
" 1 | \n",
" 2023-02-02 00:00:00.825173183 | \n",
" Q | \n",
" @FT | \n",
" | \n",
" N | \n",
" | \n",
" 1 | \n",
" META | \n",
" 183.13 | \n",
" 1970-01-01 | \n",
" 0 | \n",
" 100 | \n",
" 0 | \n",
" 7286118 | \n",
" 160979 | \n",
" 2023-02-02 00:00:00.825157012 | \n",
" 1970-01-01 00:00:00.000000000 | \n",
" 0 | \n",
"
\n",
" \n",
" 2 | \n",
" 2023-02-02 00:00:00.835111354 | \n",
" K | \n",
" @ TI | \n",
" | \n",
" N | \n",
" | \n",
" 1 | \n",
" META | \n",
" 183.18 | \n",
" 1970-01-01 | \n",
" 0 | \n",
" 2 | \n",
" 0 | \n",
" 7286119 | \n",
" 54129 | \n",
" 2023-02-02 00:00:00.834865000 | \n",
" 1970-01-01 00:00:00.000000000 | \n",
" 0 | \n",
"
\n",
" \n",
" 3 | \n",
" 2023-02-02 00:00:00.837461982 | \n",
" Q | \n",
" @ TI | \n",
" | \n",
" N | \n",
" | \n",
" 0 | \n",
" META | \n",
" 183.18 | \n",
" 1970-01-01 | \n",
" 0 | \n",
" 5 | \n",
" 0 | \n",
" 7286123 | \n",
" 160980 | \n",
" 2023-02-02 00:00:00.837446438 | \n",
" 1970-01-01 00:00:00.000000000 | \n",
" 0 | \n",
"
\n",
" \n",
" 4 | \n",
" 2023-02-02 00:00:00.877120054 | \n",
" D | \n",
" @ TI | \n",
" | \n",
" N | \n",
" Q | \n",
" 0 | \n",
" META | \n",
" 183.13 | \n",
" 1970-01-01 | \n",
" 0 | \n",
" 13 | \n",
" 0 | \n",
" 7286124 | \n",
" 117854 | \n",
" 2023-02-02 00:00:00.875000000 | \n",
" 2023-02-02 00:00:00.877093881 | \n",
" 0 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" Time EXCHANGE COND STOP_STOCK SOURCE TRF TTE TICKER PRICE DELETED_TIME TICK_STATUS SIZE CORR SEQ_NUM TRADE_ID PARTICIPANT_TIME TRF_TIME OMDSEQ\n",
"0 2023-02-02 00:00:00.100474511 Q @ TI N 0 META 183.13 1970-01-01 0 10 0 7286117 160978 2023-02-02 00:00:00.100458331 1970-01-01 00:00:00.000000000 0\n",
"1 2023-02-02 00:00:00.825173183 Q @FT N 1 META 183.13 1970-01-01 0 100 0 7286118 160979 2023-02-02 00:00:00.825157012 1970-01-01 00:00:00.000000000 0\n",
"2 2023-02-02 00:00:00.835111354 K @ TI N 1 META 183.18 1970-01-01 0 2 0 7286119 54129 2023-02-02 00:00:00.834865000 1970-01-01 00:00:00.000000000 0\n",
"3 2023-02-02 00:00:00.837461982 Q @ TI N 0 META 183.18 1970-01-01 0 5 0 7286123 160980 2023-02-02 00:00:00.837446438 1970-01-01 00:00:00.000000000 0\n",
"4 2023-02-02 00:00:00.877120054 D @ TI N Q 0 META 183.13 1970-01-01 0 13 0 7286124 117854 2023-02-02 00:00:00.875000000 2023-02-02 00:00:00.877093881 0"
]
},
"execution_count": 53,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"trd = otp.DataSource('NYSE_TAQ', tick_type='TRD')\n",
"trd = trd.first(5)\n",
"otp.run(trd, start=otp.dt(2023,2,2), end=otp.dt(2023,2,3), symbols='META', symbol_date=otp.dt(2023,2,2))"
]
},
{
"cell_type": "code",
"execution_count": 54,
"id": "4ca8dd4e-9212-4d8c-b063-3de40286e034",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" Time | \n",
" EXCHANGE | \n",
" COND | \n",
" STOP_STOCK | \n",
" SOURCE | \n",
" TRF | \n",
" TTE | \n",
" TICKER | \n",
" PRICE | \n",
" DELETED_TIME | \n",
" TICK_STATUS | \n",
" SIZE | \n",
" CORR | \n",
" SEQ_NUM | \n",
" TRADE_ID | \n",
" PARTICIPANT_TIME | \n",
" TRF_TIME | \n",
" OMDSEQ | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" 2023-02-02 00:00:00.100474511 | \n",
" Q | \n",
" @ TI | \n",
" | \n",
" N | \n",
" | \n",
" 0 | \n",
" META | \n",
" 183.13 | \n",
" 1970-01-01 | \n",
" 0 | \n",
" 10 | \n",
" 0 | \n",
" 7286117 | \n",
" 160978 | \n",
" 2023-02-02 00:00:00.100458331 | \n",
" 1970-01-01 00:00:00.000000000 | \n",
" 0 | \n",
"
\n",
" \n",
" 1 | \n",
" 2023-02-02 00:00:00.825173183 | \n",
" Q | \n",
" @FT | \n",
" | \n",
" N | \n",
" | \n",
" 1 | \n",
" META | \n",
" 183.13 | \n",
" 1970-01-01 | \n",
" 0 | \n",
" 100 | \n",
" 0 | \n",
" 7286118 | \n",
" 160979 | \n",
" 2023-02-02 00:00:00.825157012 | \n",
" 1970-01-01 00:00:00.000000000 | \n",
" 0 | \n",
"
\n",
" \n",
" 2 | \n",
" 2023-02-02 00:00:00.835111354 | \n",
" K | \n",
" @ TI | \n",
" | \n",
" N | \n",
" | \n",
" 1 | \n",
" META | \n",
" 183.18 | \n",
" 1970-01-01 | \n",
" 0 | \n",
" 2 | \n",
" 0 | \n",
" 7286119 | \n",
" 54129 | \n",
" 2023-02-02 00:00:00.834865000 | \n",
" 1970-01-01 00:00:00.000000000 | \n",
" 0 | \n",
"
\n",
" \n",
" 3 | \n",
" 2023-02-02 00:00:00.837461982 | \n",
" Q | \n",
" @ TI | \n",
" | \n",
" N | \n",
" | \n",
" 0 | \n",
" META | \n",
" 183.18 | \n",
" 1970-01-01 | \n",
" 0 | \n",
" 5 | \n",
" 0 | \n",
" 7286123 | \n",
" 160980 | \n",
" 2023-02-02 00:00:00.837446438 | \n",
" 1970-01-01 00:00:00.000000000 | \n",
" 0 | \n",
"
\n",
" \n",
" 4 | \n",
" 2023-02-02 00:00:00.877120054 | \n",
" D | \n",
" @ TI | \n",
" | \n",
" N | \n",
" Q | \n",
" 0 | \n",
" META | \n",
" 183.13 | \n",
" 1970-01-01 | \n",
" 0 | \n",
" 13 | \n",
" 0 | \n",
" 7286124 | \n",
" 117854 | \n",
" 2023-02-02 00:00:00.875000000 | \n",
" 2023-02-02 00:00:00.877093881 | \n",
" 0 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" Time EXCHANGE COND STOP_STOCK SOURCE TRF TTE TICKER PRICE DELETED_TIME TICK_STATUS SIZE CORR SEQ_NUM TRADE_ID PARTICIPANT_TIME TRF_TIME OMDSEQ\n",
"0 2023-02-02 00:00:00.100474511 Q @ TI N 0 META 183.13 1970-01-01 0 10 0 7286117 160978 2023-02-02 00:00:00.100458331 1970-01-01 00:00:00.000000000 0\n",
"1 2023-02-02 00:00:00.825173183 Q @FT N 1 META 183.13 1970-01-01 0 100 0 7286118 160979 2023-02-02 00:00:00.825157012 1970-01-01 00:00:00.000000000 0\n",
"2 2023-02-02 00:00:00.835111354 K @ TI N 1 META 183.18 1970-01-01 0 2 0 7286119 54129 2023-02-02 00:00:00.834865000 1970-01-01 00:00:00.000000000 0\n",
"3 2023-02-02 00:00:00.837461982 Q @ TI N 0 META 183.18 1970-01-01 0 5 0 7286123 160980 2023-02-02 00:00:00.837446438 1970-01-01 00:00:00.000000000 0\n",
"4 2023-02-02 00:00:00.877120054 D @ TI N Q 0 META 183.13 1970-01-01 0 13 0 7286124 117854 2023-02-02 00:00:00.875000000 2023-02-02 00:00:00.877093881 0"
]
},
"execution_count": 54,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"trd = otp.DataSource('NYSE_TAQ', tick_type='TRD')\n",
"trd = trd.first(5)\n",
"otp.run(trd, start=otp.dt(2023,2,2), end=otp.dt(2023,2,3), symbols='FB', symbol_date=otp.dt(2021,2,2))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "05e3ce48-53bc-40ef-a260-ff948622c2c6",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "276a6e9d-3831-469c-aaec-f923bb0b600d",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"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.9.8"
}
},
"nbformat": 4,
"nbformat_minor": 5
}