\n",
" \n",
- " 2001-10-22 00:00:00+00:00 | \n",
- " 2001-10-22 02:00:00 | \n",
- " 2001-10-22 04:00:00 | \n",
- " 2001-10-22 05:00:00 | \n",
- " 2001-10-22 08:00:00 | \n",
+ " 2002-06-10 | \n",
+ " 2002-06-10 02:00:00+00:00 | \n",
+ " 2002-06-10 04:00:00+00:00 | \n",
+ " 2002-06-10 05:00:00+00:00 | \n",
+ " 2002-06-10 08:00:00+00:00 | \n",
"
\n",
" \n",
- " 2001-10-23 00:00:00+00:00 | \n",
- " 2001-10-23 02:00:00 | \n",
- " 2001-10-23 04:00:00 | \n",
- " 2001-10-23 05:00:00 | \n",
- " 2001-10-23 08:00:00 | \n",
+ " 2002-06-11 | \n",
+ " 2002-06-11 02:00:00+00:00 | \n",
+ " 2002-06-11 04:00:00+00:00 | \n",
+ " 2002-06-11 05:00:00+00:00 | \n",
+ " 2002-06-11 08:00:00+00:00 | \n",
"
\n",
" \n",
- " 2001-10-24 00:00:00+00:00 | \n",
- " 2001-10-24 02:00:00 | \n",
- " 2001-10-24 04:00:00 | \n",
- " 2001-10-24 05:00:00 | \n",
- " 2001-10-24 08:00:00 | \n",
+ " 2002-06-12 | \n",
+ " 2002-06-12 02:00:00+00:00 | \n",
+ " 2002-06-12 04:00:00+00:00 | \n",
+ " 2002-06-12 05:00:00+00:00 | \n",
+ " 2002-06-12 08:00:00+00:00 | \n",
"
\n",
" \n",
- " 2001-10-26 00:00:00+00:00 | \n",
- " 2001-10-26 02:00:00 | \n",
- " 2001-10-26 04:00:00 | \n",
- " 2001-10-26 05:00:00 | \n",
- " 2001-10-26 08:00:00 | \n",
+ " 2002-06-13 | \n",
+ " 2002-06-13 02:00:00+00:00 | \n",
+ " 2002-06-13 04:00:00+00:00 | \n",
+ " 2002-06-13 05:00:00+00:00 | \n",
+ " 2002-06-13 08:00:00+00:00 | \n",
"
\n",
" \n",
- " 2001-10-29 00:00:00+00:00 | \n",
- " 2001-10-29 02:00:00 | \n",
- " 2001-10-29 04:00:00 | \n",
- " 2001-10-29 05:00:00 | \n",
- " 2001-10-29 08:00:00 | \n",
+ " 2002-06-14 | \n",
+ " 2002-06-14 02:00:00+00:00 | \n",
+ " 2002-06-14 04:00:00+00:00 | \n",
+ " 2002-06-14 05:00:00+00:00 | \n",
+ " 2002-06-14 08:00:00+00:00 | \n",
"
\n",
" \n",
" ... | \n",
@@ -602,39 +664,39 @@
" ... | \n",
"
\n",
" \n",
- " 2022-10-17 00:00:00+00:00 | \n",
- " 2022-10-17 01:30:00 | \n",
- " 2022-10-17 04:00:00 | \n",
- " 2022-10-17 05:00:00 | \n",
- " 2022-10-17 08:00:00 | \n",
+ " 2023-06-05 | \n",
+ " 2023-06-05 01:30:00+00:00 | \n",
+ " 2023-06-05 04:00:00+00:00 | \n",
+ " 2023-06-05 05:00:00+00:00 | \n",
+ " 2023-06-05 08:00:00+00:00 | \n",
"
\n",
" \n",
- " 2022-10-18 00:00:00+00:00 | \n",
- " 2022-10-18 01:30:00 | \n",
- " 2022-10-18 04:00:00 | \n",
- " 2022-10-18 05:00:00 | \n",
- " 2022-10-18 08:00:00 | \n",
+ " 2023-06-06 | \n",
+ " 2023-06-06 01:30:00+00:00 | \n",
+ " 2023-06-06 04:00:00+00:00 | \n",
+ " 2023-06-06 05:00:00+00:00 | \n",
+ " 2023-06-06 08:00:00+00:00 | \n",
"
\n",
" \n",
- " 2022-10-19 00:00:00+00:00 | \n",
- " 2022-10-19 01:30:00 | \n",
- " 2022-10-19 04:00:00 | \n",
- " 2022-10-19 05:00:00 | \n",
- " 2022-10-19 08:00:00 | \n",
+ " 2023-06-07 | \n",
+ " 2023-06-07 01:30:00+00:00 | \n",
+ " 2023-06-07 04:00:00+00:00 | \n",
+ " 2023-06-07 05:00:00+00:00 | \n",
+ " 2023-06-07 08:00:00+00:00 | \n",
"
\n",
" \n",
- " 2022-10-20 00:00:00+00:00 | \n",
- " 2022-10-20 01:30:00 | \n",
- " 2022-10-20 04:00:00 | \n",
- " 2022-10-20 05:00:00 | \n",
- " 2022-10-20 08:00:00 | \n",
+ " 2023-06-08 | \n",
+ " 2023-06-08 01:30:00+00:00 | \n",
+ " 2023-06-08 04:00:00+00:00 | \n",
+ " 2023-06-08 05:00:00+00:00 | \n",
+ " 2023-06-08 08:00:00+00:00 | \n",
"
\n",
" \n",
- " 2022-10-21 00:00:00+00:00 | \n",
- " 2022-10-21 01:30:00 | \n",
- " 2022-10-21 04:00:00 | \n",
- " 2022-10-21 05:00:00 | \n",
- " 2022-10-21 08:00:00 | \n",
+ " 2023-06-09 | \n",
+ " 2023-06-09 01:30:00+00:00 | \n",
+ " 2023-06-09 04:00:00+00:00 | \n",
+ " 2023-06-09 05:00:00+00:00 | \n",
+ " 2023-06-09 08:00:00+00:00 | \n",
"
\n",
" \n",
"\n",
@@ -642,60 +704,95 @@
""
],
"text/plain": [
- " market_open break_start \\\n",
- "2001-10-22 00:00:00+00:00 2001-10-22 02:00:00 2001-10-22 04:00:00 \n",
- "2001-10-23 00:00:00+00:00 2001-10-23 02:00:00 2001-10-23 04:00:00 \n",
- "2001-10-24 00:00:00+00:00 2001-10-24 02:00:00 2001-10-24 04:00:00 \n",
- "2001-10-26 00:00:00+00:00 2001-10-26 02:00:00 2001-10-26 04:00:00 \n",
- "2001-10-29 00:00:00+00:00 2001-10-29 02:00:00 2001-10-29 04:00:00 \n",
- "... ... ... \n",
- "2022-10-17 00:00:00+00:00 2022-10-17 01:30:00 2022-10-17 04:00:00 \n",
- "2022-10-18 00:00:00+00:00 2022-10-18 01:30:00 2022-10-18 04:00:00 \n",
- "2022-10-19 00:00:00+00:00 2022-10-19 01:30:00 2022-10-19 04:00:00 \n",
- "2022-10-20 00:00:00+00:00 2022-10-20 01:30:00 2022-10-20 04:00:00 \n",
- "2022-10-21 00:00:00+00:00 2022-10-21 01:30:00 2022-10-21 04:00:00 \n",
+ " open break_start \\\n",
+ "2002-06-10 2002-06-10 02:00:00+00:00 2002-06-10 04:00:00+00:00 \n",
+ "2002-06-11 2002-06-11 02:00:00+00:00 2002-06-11 04:00:00+00:00 \n",
+ "2002-06-12 2002-06-12 02:00:00+00:00 2002-06-12 04:00:00+00:00 \n",
+ "2002-06-13 2002-06-13 02:00:00+00:00 2002-06-13 04:00:00+00:00 \n",
+ "2002-06-14 2002-06-14 02:00:00+00:00 2002-06-14 04:00:00+00:00 \n",
+ "... ... ... \n",
+ "2023-06-05 2023-06-05 01:30:00+00:00 2023-06-05 04:00:00+00:00 \n",
+ "2023-06-06 2023-06-06 01:30:00+00:00 2023-06-06 04:00:00+00:00 \n",
+ "2023-06-07 2023-06-07 01:30:00+00:00 2023-06-07 04:00:00+00:00 \n",
+ "2023-06-08 2023-06-08 01:30:00+00:00 2023-06-08 04:00:00+00:00 \n",
+ "2023-06-09 2023-06-09 01:30:00+00:00 2023-06-09 04:00:00+00:00 \n",
"\n",
- " break_end market_close \n",
- "2001-10-22 00:00:00+00:00 2001-10-22 05:00:00 2001-10-22 08:00:00 \n",
- "2001-10-23 00:00:00+00:00 2001-10-23 05:00:00 2001-10-23 08:00:00 \n",
- "2001-10-24 00:00:00+00:00 2001-10-24 05:00:00 2001-10-24 08:00:00 \n",
- "2001-10-26 00:00:00+00:00 2001-10-26 05:00:00 2001-10-26 08:00:00 \n",
- "2001-10-29 00:00:00+00:00 2001-10-29 05:00:00 2001-10-29 08:00:00 \n",
- "... ... ... \n",
- "2022-10-17 00:00:00+00:00 2022-10-17 05:00:00 2022-10-17 08:00:00 \n",
- "2022-10-18 00:00:00+00:00 2022-10-18 05:00:00 2022-10-18 08:00:00 \n",
- "2022-10-19 00:00:00+00:00 2022-10-19 05:00:00 2022-10-19 08:00:00 \n",
- "2022-10-20 00:00:00+00:00 2022-10-20 05:00:00 2022-10-20 08:00:00 \n",
- "2022-10-21 00:00:00+00:00 2022-10-21 05:00:00 2022-10-21 08:00:00 \n",
+ " break_end close \n",
+ "2002-06-10 2002-06-10 05:00:00+00:00 2002-06-10 08:00:00+00:00 \n",
+ "2002-06-11 2002-06-11 05:00:00+00:00 2002-06-11 08:00:00+00:00 \n",
+ "2002-06-12 2002-06-12 05:00:00+00:00 2002-06-12 08:00:00+00:00 \n",
+ "2002-06-13 2002-06-13 05:00:00+00:00 2002-06-13 08:00:00+00:00 \n",
+ "2002-06-14 2002-06-14 05:00:00+00:00 2002-06-14 08:00:00+00:00 \n",
+ "... ... ... \n",
+ "2023-06-05 2023-06-05 05:00:00+00:00 2023-06-05 08:00:00+00:00 \n",
+ "2023-06-06 2023-06-06 05:00:00+00:00 2023-06-06 08:00:00+00:00 \n",
+ "2023-06-07 2023-06-07 05:00:00+00:00 2023-06-07 08:00:00+00:00 \n",
+ "2023-06-08 2023-06-08 05:00:00+00:00 2023-06-08 08:00:00+00:00 \n",
+ "2023-06-09 2023-06-09 05:00:00+00:00 2023-06-09 08:00:00+00:00 \n",
"\n",
"[5184 rows x 4 columns]"
]
},
- "execution_count": 21,
+ "execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
- "hkg.schedule"
+ "sch = hkg.schedule\n",
+ "sch"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "The schedule is a pandas DataFrame. It shows the days the exchange is open and describes the bounds when the exchange is open for regular trading on each of those days.\n",
- "\n",
- "The index represents the calendar's sessions as a pandas DatetimeIndex with timezone as UTC. For each session, the columns offer the open, close and, if applicable, break-start and break-end time. **The times are defined in UTC terms although the actual columns' DatetimeIndex are tz-naive**.\n",
+ "The schedule is a pandas DataFrame. It shows the dates the exchange is open and describes the bounds when the exchange is open for regular trading on each of those dates.\n",
"\n",
- "**NB It's proposed that from version 4.0 the timezone of the columns' DatetimeIndex will be set to \"UTC\" whilst the index will become tz-naive.** Have your say [here](https://github.com/gerrymanoim/exchange_calendars/issues/42).\n",
- "\n",
- "The break_start/break_end columns take pd.NaT in the event that a session does not have a break."
+ "The index represents the calendar's sessions as a timezone-naive pandas `DatetimeIndex`. For each session, the columns offer the open, close and, if applicable, break-start and break-end time. **The times are defined in UTC terms** and columns have dtype as `datetime64[ns, UTC]`."
]
},
{
"cell_type": "code",
- "execution_count": 22,
+ "execution_count": 23,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "2002-06-10 2002-06-10 02:00:00+00:00\n",
+ "2002-06-11 2002-06-11 02:00:00+00:00\n",
+ "2002-06-12 2002-06-12 02:00:00+00:00\n",
+ "2002-06-13 2002-06-13 02:00:00+00:00\n",
+ "2002-06-14 2002-06-14 02:00:00+00:00\n",
+ " ... \n",
+ "2023-06-05 2023-06-05 01:30:00+00:00\n",
+ "2023-06-06 2023-06-06 01:30:00+00:00\n",
+ "2023-06-07 2023-06-07 01:30:00+00:00\n",
+ "2023-06-08 2023-06-08 01:30:00+00:00\n",
+ "2023-06-09 2023-06-09 01:30:00+00:00\n",
+ "Freq: C, Name: open, Length: 5184, dtype: datetime64[ns, UTC]"
+ ]
+ },
+ "execution_count": 23,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "sch.open"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "The break_start/break_end columns take `pd.NaT` in the event that a session does not have a break."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 24,
"metadata": {},
"outputs": [
{
@@ -719,89 +816,89 @@
" \n",
" \n",
- " 2020-12-23 00:00:00+00:00 | \n",
- " 2020-12-23 01:30:00 | \n",
- " 2020-12-23 04:00:00 | \n",
- " 2020-12-23 05:00:00 | \n",
- " 2020-12-23 08:00:00 | \n",
+ " 2021-12-23 | \n",
+ " 2021-12-23 01:30:00+00:00 | \n",
+ " 2021-12-23 04:00:00+00:00 | \n",
+ " 2021-12-23 05:00:00+00:00 | \n",
+ " 2021-12-23 08:00:00+00:00 | \n",
"
\n",
" \n",
- " 2020-12-24 00:00:00+00:00 | \n",
- " 2020-12-24 01:30:00 | \n",
+ " 2021-12-24 | \n",
+ " 2021-12-24 01:30:00+00:00 | \n",
" NaT | \n",
" NaT | \n",
- " 2020-12-24 04:00:00 | \n",
+ " 2021-12-24 04:00:00+00:00 | \n",
"
\n",
" \n",
- " 2020-12-28 00:00:00+00:00 | \n",
- " 2020-12-28 01:30:00 | \n",
- " 2020-12-28 04:00:00 | \n",
- " 2020-12-28 05:00:00 | \n",
- " 2020-12-28 08:00:00 | \n",
+ " 2021-12-28 | \n",
+ " 2021-12-28 01:30:00+00:00 | \n",
+ " 2021-12-28 04:00:00+00:00 | \n",
+ " 2021-12-28 05:00:00+00:00 | \n",
+ " 2021-12-28 08:00:00+00:00 | \n",
"
\n",
" \n",
"\n",
""
],
"text/plain": [
- " market_open break_start \\\n",
- "2020-12-23 00:00:00+00:00 2020-12-23 01:30:00 2020-12-23 04:00:00 \n",
- "2020-12-24 00:00:00+00:00 2020-12-24 01:30:00 NaT \n",
- "2020-12-28 00:00:00+00:00 2020-12-28 01:30:00 2020-12-28 04:00:00 \n",
+ " open break_start \\\n",
+ "2021-12-23 2021-12-23 01:30:00+00:00 2021-12-23 04:00:00+00:00 \n",
+ "2021-12-24 2021-12-24 01:30:00+00:00 NaT \n",
+ "2021-12-28 2021-12-28 01:30:00+00:00 2021-12-28 04:00:00+00:00 \n",
"\n",
- " break_end market_close \n",
- "2020-12-23 00:00:00+00:00 2020-12-23 05:00:00 2020-12-23 08:00:00 \n",
- "2020-12-24 00:00:00+00:00 NaT 2020-12-24 04:00:00 \n",
- "2020-12-28 00:00:00+00:00 2020-12-28 05:00:00 2020-12-28 08:00:00 "
+ " break_end close \n",
+ "2021-12-23 2021-12-23 05:00:00+00:00 2021-12-23 08:00:00+00:00 \n",
+ "2021-12-24 NaT 2021-12-24 04:00:00+00:00 \n",
+ "2021-12-28 2021-12-28 05:00:00+00:00 2021-12-28 08:00:00+00:00 "
]
},
- "execution_count": 22,
+ "execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
- "hkg.schedule.loc[\"2020-12-23\":\"2020-12-28\"]"
+ "hkg.schedule.loc[\"2021-12-23\":\"2021-12-28\"]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "The properties **`opens`**, **`closes`**, **`break_starts`** and **`break_ends`** return the corresponding column of the schedule as a pd.Series."
+ "The calendar properties **`opens`**, **`closes`**, **`break_starts`** and **`break_ends`** return the corresponding column of the schedule as a `pd.Series`."
]
},
{
"cell_type": "code",
- "execution_count": 23,
+ "execution_count": 25,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "2001-10-22 00:00:00+00:00 2001-10-22 02:00:00\n",
- "2001-10-23 00:00:00+00:00 2001-10-23 02:00:00\n",
- "2001-10-24 00:00:00+00:00 2001-10-24 02:00:00\n",
- "2001-10-26 00:00:00+00:00 2001-10-26 02:00:00\n",
- "2001-10-29 00:00:00+00:00 2001-10-29 02:00:00\n",
- " ... \n",
- "2022-10-17 00:00:00+00:00 2022-10-17 01:30:00\n",
- "2022-10-18 00:00:00+00:00 2022-10-18 01:30:00\n",
- "2022-10-19 00:00:00+00:00 2022-10-19 01:30:00\n",
- "2022-10-20 00:00:00+00:00 2022-10-20 01:30:00\n",
- "2022-10-21 00:00:00+00:00 2022-10-21 01:30:00\n",
- "Freq: C, Name: market_open, Length: 5184, dtype: datetime64[ns]"
+ "2002-06-10 2002-06-10 02:00:00+00:00\n",
+ "2002-06-11 2002-06-11 02:00:00+00:00\n",
+ "2002-06-12 2002-06-12 02:00:00+00:00\n",
+ "2002-06-13 2002-06-13 02:00:00+00:00\n",
+ "2002-06-14 2002-06-14 02:00:00+00:00\n",
+ " ... \n",
+ "2023-06-05 2023-06-05 01:30:00+00:00\n",
+ "2023-06-06 2023-06-06 01:30:00+00:00\n",
+ "2023-06-07 2023-06-07 01:30:00+00:00\n",
+ "2023-06-08 2023-06-08 01:30:00+00:00\n",
+ "2023-06-09 2023-06-09 01:30:00+00:00\n",
+ "Freq: C, Name: open, Length: 5184, dtype: datetime64[ns, UTC]"
]
},
- "execution_count": 23,
+ "execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
@@ -811,36 +908,50 @@
]
},
{
- "cell_type": "markdown",
+ "cell_type": "code",
+ "execution_count": 26,
"metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "2021-12-23 2021-12-23 08:00:00+00:00\n",
+ "2021-12-24 2021-12-24 04:00:00+00:00\n",
+ "2021-12-28 2021-12-28 08:00:00+00:00\n",
+ "Freq: C, Name: close, dtype: datetime64[ns, UTC]"
+ ]
+ },
+ "execution_count": 26,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
- "As for the schedule, **although these times are defined in terms of UTC, the properties are tz-naive** (again, it's anticipated that from version 4.0 the timezone of these properties will be set to \"UTC\", see [#42](https://github.com/gerrymanoim/exchange_calendars/issues/42))."
+ "hkg.closes[\"2021-12-23\":\"2021-12-28\"]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "The **`late_opens`** and **`early_closes`** properties return a DatetimeIndex of those sessions that have a later open/earlier close than the prevailing regular open/close time."
+ "The **`late_opens`** and **`early_closes`** properties return a `DatetimeIndex` of those sessions that have a later open/earlier close than the prevailing regular open/close time."
]
},
{
"cell_type": "code",
- "execution_count": 24,
+ "execution_count": 27,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "DatetimeIndex(['2017-11-24 00:00:00+00:00', '2018-07-03 00:00:00+00:00',\n",
- " '2018-11-23 00:00:00+00:00', '2018-12-24 00:00:00+00:00',\n",
- " '2019-07-03 00:00:00+00:00', '2019-11-29 00:00:00+00:00',\n",
- " '2019-12-24 00:00:00+00:00', '2020-11-27 00:00:00+00:00',\n",
- " '2020-12-24 00:00:00+00:00', '2021-11-26 00:00:00+00:00'],\n",
- " dtype='datetime64[ns, UTC]', freq=None)"
+ "DatetimeIndex(['2018-07-03', '2018-11-23', '2018-12-24', '2019-07-03',\n",
+ " '2019-11-29', '2019-12-24', '2020-11-27', '2020-12-24',\n",
+ " '2021-11-26', '2022-11-25'],\n",
+ " dtype='datetime64[ns]', freq=None)"
]
},
- "execution_count": 24,
+ "execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
@@ -860,32 +971,32 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "The **`first_*`** and **`last_*`** methods return pd.Series with index as `sessions` and value as the corresponding trading minute (UTC) for the session. NB As explained in the [minutes tutorial](./minutes.ipynb), these minutes are not necessarily the same as the session open/close/break times."
+ "The **`first_*`** and **`last_*`** methods return `pd.Series` with index as `sessions` and value as the corresponding trading minute (UTC) for the session. NB As explained in the [minutes tutorial](./minutes.ipynb), these minutes are not necessarily the same as the session open/close/break times."
]
},
{
"cell_type": "code",
- "execution_count": 25,
+ "execution_count": 28,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "2001-10-22 00:00:00+00:00 2001-10-22 13:30:00+00:00\n",
- "2001-10-23 00:00:00+00:00 2001-10-23 13:30:00+00:00\n",
- "2001-10-24 00:00:00+00:00 2001-10-24 13:30:00+00:00\n",
- "2001-10-25 00:00:00+00:00 2001-10-25 13:30:00+00:00\n",
- "2001-10-26 00:00:00+00:00 2001-10-26 13:30:00+00:00\n",
- " ... \n",
- "2022-10-17 00:00:00+00:00 2022-10-17 13:30:00+00:00\n",
- "2022-10-18 00:00:00+00:00 2022-10-18 13:30:00+00:00\n",
- "2022-10-19 00:00:00+00:00 2022-10-19 13:30:00+00:00\n",
- "2022-10-20 00:00:00+00:00 2022-10-20 13:30:00+00:00\n",
- "2022-10-21 00:00:00+00:00 2022-10-21 13:30:00+00:00\n",
- "Freq: C, Name: first_minutes, Length: 5289, dtype: datetime64[ns, UTC]"
+ "2002-06-10 2002-06-10 13:30:00+00:00\n",
+ "2002-06-11 2002-06-11 13:30:00+00:00\n",
+ "2002-06-12 2002-06-12 13:30:00+00:00\n",
+ "2002-06-13 2002-06-13 13:30:00+00:00\n",
+ "2002-06-14 2002-06-14 13:30:00+00:00\n",
+ " ... \n",
+ "2023-06-05 2023-06-05 13:30:00+00:00\n",
+ "2023-06-06 2023-06-06 13:30:00+00:00\n",
+ "2023-06-07 2023-06-07 13:30:00+00:00\n",
+ "2023-06-08 2023-06-08 13:30:00+00:00\n",
+ "2023-06-09 2023-06-09 13:30:00+00:00\n",
+ "Freq: C, Name: first_minutes, Length: 5288, dtype: datetime64[ns, UTC]"
]
},
- "execution_count": 25,
+ "execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
@@ -896,27 +1007,27 @@
},
{
"cell_type": "code",
- "execution_count": 26,
+ "execution_count": 29,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "2001-10-22 00:00:00+00:00 2001-10-22 19:59:00+00:00\n",
- "2001-10-23 00:00:00+00:00 2001-10-23 19:59:00+00:00\n",
- "2001-10-24 00:00:00+00:00 2001-10-24 19:59:00+00:00\n",
- "2001-10-25 00:00:00+00:00 2001-10-25 19:59:00+00:00\n",
- "2001-10-26 00:00:00+00:00 2001-10-26 19:59:00+00:00\n",
- " ... \n",
- "2022-10-17 00:00:00+00:00 2022-10-17 19:59:00+00:00\n",
- "2022-10-18 00:00:00+00:00 2022-10-18 19:59:00+00:00\n",
- "2022-10-19 00:00:00+00:00 2022-10-19 19:59:00+00:00\n",
- "2022-10-20 00:00:00+00:00 2022-10-20 19:59:00+00:00\n",
- "2022-10-21 00:00:00+00:00 2022-10-21 19:59:00+00:00\n",
- "Freq: C, Name: last_minutes, Length: 5289, dtype: datetime64[ns, UTC]"
+ "2002-06-10 2002-06-10 19:59:00+00:00\n",
+ "2002-06-11 2002-06-11 19:59:00+00:00\n",
+ "2002-06-12 2002-06-12 19:59:00+00:00\n",
+ "2002-06-13 2002-06-13 19:59:00+00:00\n",
+ "2002-06-14 2002-06-14 19:59:00+00:00\n",
+ " ... \n",
+ "2023-06-05 2023-06-05 19:59:00+00:00\n",
+ "2023-06-06 2023-06-06 19:59:00+00:00\n",
+ "2023-06-07 2023-06-07 19:59:00+00:00\n",
+ "2023-06-08 2023-06-08 19:59:00+00:00\n",
+ "2023-06-09 2023-06-09 19:59:00+00:00\n",
+ "Freq: C, Name: last_minutes, Length: 5288, dtype: datetime64[ns, UTC]"
]
},
- "execution_count": 26,
+ "execution_count": 29,
"metadata": {},
"output_type": "execute_result"
}
@@ -927,27 +1038,27 @@
},
{
"cell_type": "code",
- "execution_count": 27,
+ "execution_count": 30,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "2001-10-22 00:00:00+00:00 2001-10-22 15:59:00-04:00\n",
- "2001-10-23 00:00:00+00:00 2001-10-23 15:59:00-04:00\n",
- "2001-10-24 00:00:00+00:00 2001-10-24 15:59:00-04:00\n",
- "2001-10-25 00:00:00+00:00 2001-10-25 15:59:00-04:00\n",
- "2001-10-26 00:00:00+00:00 2001-10-26 15:59:00-04:00\n",
- " ... \n",
- "2022-10-17 00:00:00+00:00 2022-10-17 15:59:00-04:00\n",
- "2022-10-18 00:00:00+00:00 2022-10-18 15:59:00-04:00\n",
- "2022-10-19 00:00:00+00:00 2022-10-19 15:59:00-04:00\n",
- "2022-10-20 00:00:00+00:00 2022-10-20 15:59:00-04:00\n",
- "2022-10-21 00:00:00+00:00 2022-10-21 15:59:00-04:00\n",
- "Freq: C, Name: last_minutes, Length: 5289, dtype: datetime64[ns, America/New_York]"
+ "2002-06-10 2002-06-10 15:59:00-04:00\n",
+ "2002-06-11 2002-06-11 15:59:00-04:00\n",
+ "2002-06-12 2002-06-12 15:59:00-04:00\n",
+ "2002-06-13 2002-06-13 15:59:00-04:00\n",
+ "2002-06-14 2002-06-14 15:59:00-04:00\n",
+ " ... \n",
+ "2023-06-05 2023-06-05 15:59:00-04:00\n",
+ "2023-06-06 2023-06-06 15:59:00-04:00\n",
+ "2023-06-07 2023-06-07 15:59:00-04:00\n",
+ "2023-06-08 2023-06-08 15:59:00-04:00\n",
+ "2023-06-09 2023-06-09 15:59:00-04:00\n",
+ "Freq: C, Name: last_minutes, Length: 5288, dtype: datetime64[ns, America/New_York]"
]
},
- "execution_count": 27,
+ "execution_count": 30,
"metadata": {},
"output_type": "execute_result"
}
@@ -959,87 +1070,82 @@
},
{
"cell_type": "code",
- "execution_count": 28,
+ "execution_count": 31,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "2020-12-23 00:00:00+00:00 2020-12-23 03:59:00+00:00\n",
- "2020-12-24 00:00:00+00:00 NaT\n",
- "2020-12-28 00:00:00+00:00 2020-12-28 03:59:00+00:00\n",
+ "2021-12-23 2021-12-23 03:59:00+00:00\n",
+ "2021-12-24 NaT\n",
+ "2021-12-28 2021-12-28 03:59:00+00:00\n",
"Freq: C, Name: last_am_minutes, dtype: datetime64[ns, UTC]"
]
},
- "execution_count": 28,
+ "execution_count": 31,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# last pre-break minute of am subsession\n",
- "hkg.last_am_minutes[\"2020-12-23\":\"2020-12-28\"]"
+ "hkg.last_am_minutes[\"2021-12-23\":\"2021-12-28\"]"
]
},
{
"cell_type": "code",
- "execution_count": 29,
+ "execution_count": 32,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "2020-12-23 00:00:00+00:00 2020-12-23 05:00:00+00:00\n",
- "2020-12-24 00:00:00+00:00 NaT\n",
- "2020-12-28 00:00:00+00:00 2020-12-28 05:00:00+00:00\n",
+ "2021-12-23 2021-12-23 05:00:00+00:00\n",
+ "2021-12-24 NaT\n",
+ "2021-12-28 2021-12-28 05:00:00+00:00\n",
"Freq: C, Name: first_pm_minutes, dtype: datetime64[ns, UTC]"
]
},
- "execution_count": 29,
+ "execution_count": 32,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# first post-break minute of pm subsession\n",
- "hkg.first_pm_minutes.loc[\"2020-12-23\":\"2020-12-28\"]"
+ "hkg.first_pm_minutes.loc[\"2021-12-23\":\"2021-12-28\"]"
]
},
{
"cell_type": "code",
- "execution_count": 30,
+ "execution_count": 33,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "2020-12-23 00:00:00+00:00 2020-12-23 13:00:00+08:00\n",
- "2020-12-24 00:00:00+00:00 NaT\n",
- "2020-12-28 00:00:00+00:00 2020-12-28 13:00:00+08:00\n",
+ "2021-12-23 2021-12-23 13:00:00+08:00\n",
+ "2021-12-24 NaT\n",
+ "2021-12-28 2021-12-28 13:00:00+08:00\n",
"Freq: C, Name: first_pm_minutes, dtype: datetime64[ns, Asia/Hong_Kong]"
]
},
- "execution_count": 30,
+ "execution_count": 33,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# in local time...\n",
- "hkg.first_pm_minutes.loc[\"2020-12-23\":\"2020-12-28\"].dt.tz_convert(hkg.tz)"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "#### Nanos"
+ "hkg.first_pm_minutes.loc[\"2021-12-23\":\"2021-12-28\"].dt.tz_convert(hkg.tz)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
+ "#### Nanos\n",
+ "\n",
"Many sessions/minutes properties that return a `DatetimeIndex` have a 'nanos' equivalent that returns a numpy ndarray of integers.\n",
"\n",
"Why? Internally `ExchangeCalendar` uses these nano arrays because they are faster to operate on than `DatetimeIndex`. Indeed, for some operations, working with nanos can be **much** faster."
@@ -1047,21 +1153,21 @@
},
{
"cell_type": "code",
- "execution_count": 31,
+ "execution_count": 34,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "(array([1003708800000000000, 1003795200000000000, 1003881600000000000, ...,\n",
- " 1666137600000000000, 1666224000000000000, 1666310400000000000],\n",
+ "(array([1023667200000000000, 1023753600000000000, 1023840000000000000, ...,\n",
+ " 1686096000000000000, 1686182400000000000, 1686268800000000000],\n",
" dtype=int64),\n",
- " array([1003716000000000000, 1003716060000000000, 1003716120000000000, ...,\n",
- " 1666339020000000000, 1666339080000000000, 1666339140000000000],\n",
+ " array([1023674400000000000, 1023674460000000000, 1023674520000000000, ...,\n",
+ " 1686297420000000000, 1686297480000000000, 1686297540000000000],\n",
" dtype=int64))"
]
},
- "execution_count": 31,
+ "execution_count": 34,
"metadata": {},
"output_type": "execute_result"
}
@@ -1072,21 +1178,21 @@
},
{
"cell_type": "code",
- "execution_count": 32,
+ "execution_count": 35,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "(array([1003716000000000000, 1003802400000000000, 1003888800000000000, ...,\n",
- " 1666143000000000000, 1666229400000000000, 1666315800000000000],\n",
+ "(array([1023674400000000000, 1023760800000000000, 1023847200000000000, ...,\n",
+ " 1686101400000000000, 1686187800000000000, 1686274200000000000],\n",
" dtype=int64),\n",
- " array([1003737600000000000, 1003824000000000000, 1003910400000000000, ...,\n",
- " 1666166400000000000, 1666252800000000000, 1666339200000000000],\n",
+ " array([1023696000000000000, 1023782400000000000, 1023868800000000000, ...,\n",
+ " 1686124800000000000, 1686211200000000000, 1686297600000000000],\n",
" dtype=int64))"
]
},
- "execution_count": 32,
+ "execution_count": 35,
"metadata": {},
"output_type": "execute_result"
}
@@ -1097,21 +1203,21 @@
},
{
"cell_type": "code",
- "execution_count": 33,
+ "execution_count": 36,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "(array([1003723200000000000, 1003809600000000000, 1003896000000000000, ...,\n",
- " 1666152000000000000, 1666238400000000000, 1666324800000000000],\n",
+ "(array([1023681600000000000, 1023768000000000000, 1023854400000000000, ...,\n",
+ " 1686110400000000000, 1686196800000000000, 1686283200000000000],\n",
" dtype=int64),\n",
- " array([1003726800000000000, 1003813200000000000, 1003899600000000000, ...,\n",
- " 1666155600000000000, 1666242000000000000, 1666328400000000000],\n",
+ " array([1023685200000000000, 1023771600000000000, 1023858000000000000, ...,\n",
+ " 1686114000000000000, 1686200400000000000, 1686286800000000000],\n",
" dtype=int64))"
]
},
- "execution_count": 33,
+ "execution_count": 36,
"metadata": {},
"output_type": "execute_result"
}
@@ -1122,21 +1228,21 @@
},
{
"cell_type": "code",
- "execution_count": 34,
+ "execution_count": 37,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "(array([1003716000000000000, 1003802400000000000, 1003888800000000000, ...,\n",
- " 1666143000000000000, 1666229400000000000, 1666315800000000000],\n",
+ "(array([1023674400000000000, 1023760800000000000, 1023847200000000000, ...,\n",
+ " 1686101400000000000, 1686187800000000000, 1686274200000000000],\n",
" dtype=int64),\n",
- " array([1003737540000000000, 1003823940000000000, 1003910340000000000, ...,\n",
- " 1666166340000000000, 1666252740000000000, 1666339140000000000],\n",
+ " array([1023695940000000000, 1023782340000000000, 1023868740000000000, ...,\n",
+ " 1686124740000000000, 1686211140000000000, 1686297540000000000],\n",
" dtype=int64))"
]
},
- "execution_count": 34,
+ "execution_count": 37,
"metadata": {},
"output_type": "execute_result"
}
@@ -1147,21 +1253,21 @@
},
{
"cell_type": "code",
- "execution_count": 35,
+ "execution_count": 38,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "(array([1003723140000000000, 1003809540000000000, 1003895940000000000, ...,\n",
- " 1666151940000000000, 1666238340000000000, 1666324740000000000],\n",
+ "(array([1023681540000000000, 1023767940000000000, 1023854340000000000, ...,\n",
+ " 1686110340000000000, 1686196740000000000, 1686283140000000000],\n",
" dtype=int64),\n",
- " array([1003726800000000000, 1003813200000000000, 1003899600000000000, ...,\n",
- " 1666155600000000000, 1666242000000000000, 1666328400000000000],\n",
+ " array([1023685200000000000, 1023771600000000000, 1023858000000000000, ...,\n",
+ " 1686114000000000000, 1686200400000000000, 1686286800000000000],\n",
" dtype=int64))"
]
},
- "execution_count": 35,
+ "execution_count": 38,
"metadata": {},
"output_type": "execute_result"
}
@@ -1173,9 +1279,9 @@
],
"metadata": {
"kernelspec": {
- "display_name": "xcals 3.7",
+ "display_name": "Python38 xcals",
"language": "python",
- "name": "xcals"
+ "name": "py38_xcals"
},
"language_info": {
"codemirror_mode": {
@@ -1187,7 +1293,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.7.0"
+ "version": "3.8.10"
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
diff --git a/docs/tutorials/minutes.ipynb b/docs/tutorials/minutes.ipynb
index ca1b84bb..fc4f3460 100644
--- a/docs/tutorials/minutes.ipynb
+++ b/docs/tutorials/minutes.ipynb
@@ -9,7 +9,7 @@
},
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
@@ -38,7 +38,7 @@
},
{
"cell_type": "code",
- "execution_count": 3,
+ "execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
@@ -64,18 +64,18 @@
},
{
"cell_type": "code",
- "execution_count": 4,
+ "execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"DatetimeIndex(['2021-06-15 14:33:00+00:00', '2021-06-15 14:34:00+00:00',\n",
- " '2021-06-15 14:35:00+00:00', '2021-06-15 14:36:00+00:00'],\n",
+ " '2021-06-15 14:35:00+00:00'],\n",
" dtype='datetime64[ns, UTC]', freq=None)"
]
},
- "execution_count": 4,
+ "execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
@@ -88,8 +88,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "this isn't...\n",
- ""
+ "but this isn't..."
]
},
{
@@ -98,21 +97,20 @@
"metadata": {},
"outputs": [],
"source": [
- "lon.minutes_window(\"2021-06-15 22:30\", count=3)\n",
- "# run cell for full traceback"
+ "lon.minutes_window(\"2021-06-15 22:30\", count=3)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "```python\n",
+ "```\n",
"---------------------------------------------------------------------------\n",
"NotTradingMinuteError Traceback (most recent call last)\n",
- "~\\AppData\\Local\\Temp/ipykernel_2716/1911368640.py in