Files
OpenBB/examples/loadHistoricalPriceData.ipynb
Danglewood c047cfeddd docs/new-working-docs: New working docs branch (#5768)
* move old example notebooks to v3 folder, update loadHistoricalPriceData and add findSymbols

* Create README.md

* Update README.md

* Update README.md

* Update README.md

* Vertical diagram instead

* important classes

* core dependencies

* folder structure

* devtools

* swap order

* fix github pages deploy issue

* development index

* delete expectations for developers

* devtools

* obbject stuff

* add

* installation

* hub sync

* idk if i committed already

* add usage page for financial statements

* add link to reference page

* syntax

* numbers

* nearly --> more than

* easier to read code blocks

* codespell

* removing mention to provider

* add 'orientation' for to_dict

* info card for output user preference

* put it in a code block

* correct user_settings.json example

* syntax corrections

* fix sentence

* get rid of floating point mathc

* get rid of other floating point math

* add companion example notebook for financial statements, and new section

* historical prices usage page

* codespell

* add commitment of traders section to usage

* add a note

* codespell

* get rid of equals sign

* Cleanup docs. with @the-praxs

* install

* obbject extend

* spell

* HeadTitle thingies

* Update obbject_extensions.md

* Update obbject_extensions.md

* typo

* Update architectural_considerations.md

* point to the TET pattern

* optional vs required

* reviewing the  patterns. removed the --pre flag under the assumption this will be the final docs for the release cc @deeleeramone

* add a walkthrough

* spelling

* Add more in the introduction

* validator examples

* update Copper-to-Gold notebook example for V4

* Update README.md

* QA Caveats w @the-praxs

* info on class outputs

* merge add data sources and add data points

* disclaimer on cookiecutter

* add missing import to example

* slight syntax change

* missing code block

* missing import

* update intrinio example syntax

* intrinio syntax update

* urls

* core and provider merged

* example syntax

* grammar

* Update API banner link

* quick-fix-docs cc @minhhoang1023

* Update pip install command for v3

* remove --pre note block

* update landing image

---------

Co-authored-by: Henrique Joaquim <h.joaquim@campus.fct.unl.pt>
Co-authored-by: Luqman <luqazino@gmail.com>
Co-authored-by: James Maslek <jmaslek11@gmail.com>
Co-authored-by: Igor Radovanovic <74266147+IgorWounds@users.noreply.github.com>
Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com>
Co-authored-by: Theodore Aptekarev <aptekarev@gmail.com>
Co-authored-by: Pratyush Shukla <ps4534@nyu.edu>
2023-12-01 01:09:25 +00:00

2040 lines
69 KiB
Plaintext
Vendored
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"# Historical Prices With the OpenBB Platform\n",
"\n",
"This notebook demonstrates some of the ways to approach loading historical price data using the OpenBB Platform. The action is in the Equity module; but first, we need to initialize the notebook with the import statements block.\n",
"\n",
"## Import Statements"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"from datetime import datetime, timedelta\n",
"\n",
"import pandas as pd\n",
"from openbb import obb\n"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## The Equity Module\n",
"\n",
"Historical market prices typically come in the form of OHLC+V - open, high, low, close, volume. There may be additional fields returned by a provider, but those are the expected columns. Granularity and amount of historical data will vary by provider and subscription status. Visit their websites to understand what your entitlements are.\n",
"\n",
"### openbb.equity.price.historical()\n",
"\n",
"- This endpoint has the most number of providers out of any function. At the time of writing, choices are:\n",
"\n",
"['alpha_vantage', 'cboe', 'fmp', 'intrinio', 'polygon', 'tiingo', 'yfinance']\n",
"\n",
"- Common parameters have been standardized across all souces, `start_date`, `end_date`, `interval`.\n",
"\n",
"- The default interval will be `1d`.\n",
"\n",
"- The depth of historical data and choices for granularity will vary by provider and subscription status. Refer to the website and documentation of each source understand your specific entitlements.\n",
"\n",
"- For demonstration purposes, we will use the `openbb-yfinance` data extension."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>open</th>\n",
" <th>high</th>\n",
" <th>low</th>\n",
" <th>close</th>\n",
" <th>volume</th>\n",
" <th>dividends</th>\n",
" <th>stock splits</th>\n",
" <th>capital gains</th>\n",
" </tr>\n",
" <tr>\n",
" <th>date</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>2022-11-22</th>\n",
" <td>396.63</td>\n",
" <td>400.07</td>\n",
" <td>395.15</td>\n",
" <td>399.9</td>\n",
" <td>60429000</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" open high low close volume dividends stock splits \\\n",
"date \n",
"2022-11-22 396.63 400.07 395.15 399.9 60429000 0.0 0.0 \n",
"\n",
" capital gains \n",
"date \n",
"2022-11-22 0.0 "
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df_daily = obb.equity.price.historical(symbol = \"spy\", provider=\"yfinance\")\n",
"df_daily.to_df().head(1)\n"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"To load the entire history available from a source, pick a starting date well beyond what it might be. For example, `1900-01-01`"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>open</th>\n",
" <th>high</th>\n",
" <th>low</th>\n",
" <th>close</th>\n",
" <th>volume</th>\n",
" <th>dividends</th>\n",
" <th>stock splits</th>\n",
" <th>capital gains</th>\n",
" </tr>\n",
" <tr>\n",
" <th>date</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1993-01-29</th>\n",
" <td>43.97</td>\n",
" <td>43.97</td>\n",
" <td>43.75</td>\n",
" <td>43.94</td>\n",
" <td>1003200</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" open high low close volume dividends stock splits \\\n",
"date \n",
"1993-01-29 43.97 43.97 43.75 43.94 1003200 0.0 0.0 \n",
"\n",
" capital gains \n",
"date \n",
"1993-01-29 0.0 "
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df_daily = obb.equity.price.historical(symbol = \"spy\", start_date = \"1990-01-01\", provider=\"yfinance\").to_df()\n",
"df_daily.head(1)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Intervals\n",
"\n",
"The intervals are entered according to this pattern:\n",
"\n",
"- `1m` = One Minute\n",
"- `1h` = One Hour\n",
"- `1d` = One Day\n",
"- `1W` = One Week\n",
"- `1M` = One Month\n",
"\n",
"The date for monthly value is the first or last, depending on the provider. This can be easily resampled from daily data."
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>open</th>\n",
" <th>high</th>\n",
" <th>low</th>\n",
" <th>close</th>\n",
" <th>volume</th>\n",
" <th>dividends</th>\n",
" <th>stock splits</th>\n",
" <th>capital gains</th>\n",
" </tr>\n",
" <tr>\n",
" <th>date</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>2023-10-01</th>\n",
" <td>426.62</td>\n",
" <td>438.14</td>\n",
" <td>409.21</td>\n",
" <td>418.20</td>\n",
" <td>1999149700</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2023-11-01</th>\n",
" <td>419.20</td>\n",
" <td>456.38</td>\n",
" <td>418.65</td>\n",
" <td>455.02</td>\n",
" <td>1161239576</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" open high low close volume dividends \\\n",
"date \n",
"2023-10-01 426.62 438.14 409.21 418.20 1999149700 0.0 \n",
"2023-11-01 419.20 456.38 418.65 455.02 1161239576 0.0 \n",
"\n",
" stock splits capital gains \n",
"date \n",
"2023-10-01 0.0 0.0 \n",
"2023-11-01 0.0 0.0 "
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df_monthly = obb.equity.price.historical(\"spy\", start_date=\"1990-01-01\", interval=\"1M\", provider=\"yfinance\").to_df()\n",
"df_monthly.tail(2)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Resample a Time Series\n",
"\n",
"`yfinance` returns the monthly data for the first day of each month. Let's resample it to take from the last, using the daily information captured in the previous cells."
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>open</th>\n",
" <th>high</th>\n",
" <th>low</th>\n",
" <th>close</th>\n",
" <th>volume</th>\n",
" </tr>\n",
" <tr>\n",
" <th>date</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1993-01-31</th>\n",
" <td>43.97</td>\n",
" <td>43.97</td>\n",
" <td>43.75</td>\n",
" <td>43.94</td>\n",
" <td>1003200</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1993-02-28</th>\n",
" <td>43.97</td>\n",
" <td>45.12</td>\n",
" <td>42.81</td>\n",
" <td>44.41</td>\n",
" <td>5417600</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1993-03-31</th>\n",
" <td>44.56</td>\n",
" <td>45.84</td>\n",
" <td>44.22</td>\n",
" <td>45.19</td>\n",
" <td>3019200</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1993-04-30</th>\n",
" <td>45.25</td>\n",
" <td>45.25</td>\n",
" <td>43.28</td>\n",
" <td>44.03</td>\n",
" <td>2697200</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1993-05-31</th>\n",
" <td>44.09</td>\n",
" <td>45.66</td>\n",
" <td>43.84</td>\n",
" <td>45.22</td>\n",
" <td>1808000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2023-07-31</th>\n",
" <td>442.92</td>\n",
" <td>459.44</td>\n",
" <td>437.06</td>\n",
" <td>457.79</td>\n",
" <td>1374632400</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2023-08-31</th>\n",
" <td>456.27</td>\n",
" <td>457.25</td>\n",
" <td>433.01</td>\n",
" <td>450.35</td>\n",
" <td>1754764700</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2023-09-30</th>\n",
" <td>453.17</td>\n",
" <td>453.67</td>\n",
" <td>422.29</td>\n",
" <td>427.48</td>\n",
" <td>1588673200</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2023-10-31</th>\n",
" <td>426.62</td>\n",
" <td>438.14</td>\n",
" <td>409.21</td>\n",
" <td>418.20</td>\n",
" <td>1999149700</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2023-11-30</th>\n",
" <td>419.20</td>\n",
" <td>456.38</td>\n",
" <td>418.65</td>\n",
" <td>455.02</td>\n",
" <td>1214703500</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>371 rows × 5 columns</p>\n",
"</div>"
],
"text/plain": [
" open high low close volume\n",
"date \n",
"1993-01-31 43.97 43.97 43.75 43.94 1003200\n",
"1993-02-28 43.97 45.12 42.81 44.41 5417600\n",
"1993-03-31 44.56 45.84 44.22 45.19 3019200\n",
"1993-04-30 45.25 45.25 43.28 44.03 2697200\n",
"1993-05-31 44.09 45.66 43.84 45.22 1808000\n",
"... ... ... ... ... ...\n",
"2023-07-31 442.92 459.44 437.06 457.79 1374632400\n",
"2023-08-31 456.27 457.25 433.01 450.35 1754764700\n",
"2023-09-30 453.17 453.67 422.29 427.48 1588673200\n",
"2023-10-31 426.62 438.14 409.21 418.20 1999149700\n",
"2023-11-30 419.20 456.38 418.65 455.02 1214703500\n",
"\n",
"[371 rows x 5 columns]"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"(\n",
" df_daily[[\"open\", \"high\", \"low\", \"close\", \"volume\"]]\n",
" .resample(\"M\")\n",
" .agg(\n",
" {\"open\": \"first\", \"high\": \"max\", \"low\": \"min\", \"close\": \"last\", \"volume\": \"sum\"}\n",
" )\n",
")\n"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"The block below packs an object with most intervals."
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"dict_keys(['one', 'five', 'fifteen', 'thirty', 'sixty', 'daily', 'weekly', 'monthly'])"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>open</th>\n",
" <th>high</th>\n",
" <th>low</th>\n",
" <th>close</th>\n",
" <th>volume</th>\n",
" <th>dividends</th>\n",
" <th>stock splits</th>\n",
" <th>capital gains</th>\n",
" </tr>\n",
" <tr>\n",
" <th>date</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>2023-11-13</th>\n",
" <td>439.23</td>\n",
" <td>451.42</td>\n",
" <td>438.42</td>\n",
" <td>450.79</td>\n",
" <td>376539600</td>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2023-11-20</th>\n",
" <td>450.53</td>\n",
" <td>456.38</td>\n",
" <td>450.52</td>\n",
" <td>455.02</td>\n",
" <td>233751276</td>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" open high low close volume dividends \\\n",
"date \n",
"2023-11-13 439.23 451.42 438.42 450.79 376539600 0.0 \n",
"2023-11-20 450.53 456.38 450.52 455.02 233751276 0.0 \n",
"\n",
" stock splits capital gains \n",
"date \n",
"2023-11-13 0 0 \n",
"2023-11-20 0 0 "
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"class HistoricalPrices:\n",
" def __init__(self, symbol, start_date, end_date, provider, **kwargs) -> None:\n",
" self.one: pd.DataFrame = obb.equity.price.historical(\n",
" symbol=symbol, start_date=start_date, end_date=end_date, interval = \"1m\", provider=provider, **kwargs\n",
" ).to_df().convert_dtypes()\n",
" self.five: pd.DataFrame = obb.equity.price.historical(\n",
" symbol=symbol, start_date=start_date, end_date=end_date, interval = \"5m\", provider=provider, **kwargs\n",
" ).to_df().convert_dtypes()\n",
" self.fifteen: pd.DataFrame = obb.equity.price.historical(\n",
" symbol=symbol, start_date=start_date, end_date=end_date, interval = \"15m\", provider=provider, **kwargs\n",
" ).to_df().convert_dtypes()\n",
" self.thirty: pd.DataFrame = obb.equity.price.historical(\n",
" symbol=symbol, start_date=start_date, end_date=end_date, interval = \"30m\", provider=provider, **kwargs\n",
" ).to_df().convert_dtypes()\n",
" self.sixty: pd.DataFrame = obb.equity.price.historical(\n",
" symbol=symbol, start_date=start_date, end_date=end_date, interval = \"60m\", provider=provider, **kwargs\n",
" ).to_df().convert_dtypes()\n",
" self.daily: pd.DataFrame = obb.equity.price.historical(\n",
" symbol=symbol, start_date=start_date, end_date=end_date, interval = \"1d\", provider=provider, **kwargs\n",
" ).to_df().convert_dtypes()\n",
" self.weekly: pd.DataFrame = obb.equity.price.historical(\n",
" symbol=symbol, start_date=start_date, end_date=end_date, interval = \"1W\", provider=provider, **kwargs\n",
" ).to_df().convert_dtypes()\n",
" self.monthly: pd.DataFrame = obb.equity.price.historical(\n",
" symbol=symbol, start_date=start_date, end_date=end_date, interval = \"1M\", provider=provider, **kwargs\n",
" ).to_df().convert_dtypes()\n",
"\n",
"def load_historical(\n",
" symbol: str = \"\",\n",
" start_date = None,\n",
" end_date = None,\n",
" provider = None,\n",
" **kwargs\n",
") -> HistoricalPrices:\n",
"\n",
" if symbol == \"\":\n",
" display(\"Please enter a ticker symbol\")\n",
" if provider is None:\n",
" provider = \"yfinance\"\n",
" prices = HistoricalPrices(symbol, start_date, end_date, provider, **kwargs)\n",
"\n",
" return prices\n",
"\n",
"prices = load_historical(\"spy\")\n",
"display(prices.__dict__.keys())\n",
"prices.weekly.tail(2)\n"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"To demonstrate the difference between sources, let's compare values for daily volume from several sources."
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>AV Volume</th>\n",
" <th>FMP Volume</th>\n",
" <th>Intrinio Volume</th>\n",
" <th>Yahoo Volume</th>\n",
" </tr>\n",
" <tr>\n",
" <th>date</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>2023-11-09</th>\n",
" <td>83174417.0</td>\n",
" <td>83071417</td>\n",
" <td>83174417.0</td>\n",
" <td>83174400</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2023-11-10</th>\n",
" <td>89558054.0</td>\n",
" <td>89558054</td>\n",
" <td>89558054.0</td>\n",
" <td>89462200</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2023-11-13</th>\n",
" <td>52236068.0</td>\n",
" <td>52192568</td>\n",
" <td>52236068.0</td>\n",
" <td>52236100</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2023-11-14</th>\n",
" <td>97176935.0</td>\n",
" <td>97130503</td>\n",
" <td>97176935.0</td>\n",
" <td>97176900</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2023-11-15</th>\n",
" <td>77327573.0</td>\n",
" <td>77327573</td>\n",
" <td>77327573.0</td>\n",
" <td>77327600</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2023-11-16</th>\n",
" <td>66665797.0</td>\n",
" <td>66654468</td>\n",
" <td>66665797.0</td>\n",
" <td>66665800</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2023-11-17</th>\n",
" <td>83193902.0</td>\n",
" <td>83193902</td>\n",
" <td>83193902.0</td>\n",
" <td>83133200</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2023-11-20</th>\n",
" <td>70055633.0</td>\n",
" <td>69614633</td>\n",
" <td>70055633.0</td>\n",
" <td>69936200</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2023-11-21</th>\n",
" <td>49244639.0</td>\n",
" <td>49244639</td>\n",
" <td>49244639.0</td>\n",
" <td>49244600</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2023-11-22</th>\n",
" <td>59446573.0</td>\n",
" <td>59313820</td>\n",
" <td>58205780.0</td>\n",
" <td>59394900</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" AV Volume FMP Volume Intrinio Volume Yahoo Volume\n",
"date \n",
"2023-11-09 83174417.0 83071417 83174417.0 83174400\n",
"2023-11-10 89558054.0 89558054 89558054.0 89462200\n",
"2023-11-13 52236068.0 52192568 52236068.0 52236100\n",
"2023-11-14 97176935.0 97130503 97176935.0 97176900\n",
"2023-11-15 77327573.0 77327573 77327573.0 77327600\n",
"2023-11-16 66665797.0 66654468 66665797.0 66665800\n",
"2023-11-17 83193902.0 83193902 83193902.0 83133200\n",
"2023-11-20 70055633.0 69614633 70055633.0 69936200\n",
"2023-11-21 49244639.0 49244639 49244639.0 49244600\n",
"2023-11-22 59446573.0 59313820 58205780.0 59394900"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Collect the data\n",
"\n",
"yahoo = obb.equity.price.historical(\"spy\", provider=\"yfinance\").to_df()\n",
"alphavantage = obb.equity.price.historical(\"spy\", provider = \"alpha_vantage\").to_df()\n",
"intrinio = obb.equity.price.historical(\"spy\", provider=\"intrinio\").to_df()\n",
"fmp = obb.equity.price.historical(\"spy\", provider=\"fmp\").to_df()\n",
"\n",
"# Make a new DataFrame with just the volume columns\n",
"compare = pd.DataFrame()\n",
"compare[\"AV Volume\"] = alphavantage[\"volume\"].tail(10)\n",
"compare[\"FMP Volume\"] = fmp[\"volume\"].tail(10)\n",
"compare[\"Intrinio Volume\"] = intrinio[\"volume\"].tail(10)\n",
"compare[\"Yahoo Volume\"] = yahoo[\"volume\"].tail(10)\n",
"\n",
"compare\n"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Other Types of Symbols\n",
"\n",
"Other types of assets and ticker symbols can be loaded from `obb.equity.price.historical()`, below are some examples but not an exhaustive list.\n",
"\n",
"### Share Classes\n",
"\n",
"Some sources use `-` as the distinction between a share class, e.g., `BRK-A` and `BRK-B`. Other formats include:\n",
"\n",
"- A period: `BRK.A`\n",
"- A slash: `BRK/A`\n",
"- No separator, the share class becomes the fourth or fifth letter.\n",
"\n",
"```python\n",
"obb.equity.price.historical(\"brk.b\", provider=\"polygon\")\n",
"```\n",
"\n",
"```python\n",
"obb.equity.price.historical(\"brk-b\", provider=\"fmp\")\n",
"```\n",
"\n",
"While some providers handle the different formats on their end, others do not. This is something to consider when no results are returned from one source. Some may even use a combination, or accept multiple variations. Sometimes there is no real logic behind the additional characters, `GOOGL` vs. `GOOG`. These are known unknown variables of ticker symbology, what's good for one source may return errors from another. \n",
"\n",
"### Regional Identifiers\n",
"\n",
"With providers supporting market data from multiple jurisdictions, the most common method for requesting data outside of US-listings is to append a suffix to the ticker symbol (e.g., `RELIANCE.NS` for Indian equities). Formats may be unique to a provider, so it is best to review the source's documentation for an overview of their specific conventions. [This page](https://help.yahoo.com/kb/SLN2310.html) on Yahoo describes how they format symbols, which many others follow to some degree.\n",
"\n",
"### Indexes\n",
"\n",
"Sources will have their own treatment of these symbols, some examples are:\n",
"\n",
"- YahooFinance/FMP/CBOE: ^RUT\n",
"- Polygon: I:NDX\n",
"\n",
"### Currencies\n",
"\n",
"FX symbols face the same dilemna as share classes, there are several variations of the same symbol.\n",
"\n",
"- YahooFinance: `EURUSD=X`\n",
"- Polygon: `C:EURUSD`\n",
"- AlphaVantage/FMP: `EURUSD`\n",
"\n",
"**The symbol prefixes are handled internally when `obb.currency.price.historical()` is used to enter a pair with no extra characters.**\n",
"\n",
"### Crypto\n",
"\n",
"Similar, but different to FX tickers.\n",
"\n",
"- YahooFinance: `BTC-USD`\n",
"- Polygon: `X:BTCUSD`\n",
"- AlphaVantage/FMP: `BTCUSD`\n",
"\n",
"**The symbol prefixes are handled internally when `obb.crypto.price.historical()` is used to enter a pair with no extra characters and placing the fiat currency second.**\n",
"\n",
"### Futures\n",
"\n",
"Historical prices for active contracts, and the continuation chart, can be fetched via `yfinance`.\n",
"\n",
"- Continuous front-month: `CL=F`\n",
"- December 2023 contract: `CLZ24.NYM`\n",
"- March 2024 contract: `CLH24.NYM`\n",
"\n",
"Individual contracts will require knowing which of the CME venues the future is listed on. `[\"NYM\", \"NYB\", \"CME\", \"CBT\"]`.\n",
"\n",
"### Options\n",
"\n",
"Individual options contracts are also loadable from `openbb.equity.price.historical()`.\n",
"\n",
"- YahooFinance: `SPY241220P00400000`\n",
"- Polygon: `O:SPY241220P00400000`"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"These examples represent only a few methods for fetching historical price data. Explore the contents of each module to find more!"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>open</th>\n",
" <th>high</th>\n",
" <th>low</th>\n",
" <th>close</th>\n",
" <th>volume</th>\n",
" <th>dividends</th>\n",
" <th>stock splits</th>\n",
" </tr>\n",
" <tr>\n",
" <th>date</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>2022-11-22</th>\n",
" <td>43.08</td>\n",
" <td>44.24</td>\n",
" <td>43.00</td>\n",
" <td>43.00</td>\n",
" <td>287</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2022-11-23</th>\n",
" <td>41.58</td>\n",
" <td>42.45</td>\n",
" <td>39.00</td>\n",
" <td>39.00</td>\n",
" <td>6</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2022-11-28</th>\n",
" <td>42.50</td>\n",
" <td>42.90</td>\n",
" <td>42.50</td>\n",
" <td>42.90</td>\n",
" <td>18</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2022-11-30</th>\n",
" <td>41.00</td>\n",
" <td>41.00</td>\n",
" <td>41.00</td>\n",
" <td>41.00</td>\n",
" <td>1</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2022-12-01</th>\n",
" <td>40.73</td>\n",
" <td>40.81</td>\n",
" <td>39.85</td>\n",
" <td>40.25</td>\n",
" <td>42</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2023-11-16</th>\n",
" <td>11.41</td>\n",
" <td>11.88</td>\n",
" <td>11.27</td>\n",
" <td>11.70</td>\n",
" <td>264</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2023-11-17</th>\n",
" <td>11.50</td>\n",
" <td>11.50</td>\n",
" <td>11.19</td>\n",
" <td>11.40</td>\n",
" <td>0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2023-11-20</th>\n",
" <td>11.00</td>\n",
" <td>11.10</td>\n",
" <td>10.50</td>\n",
" <td>10.76</td>\n",
" <td>121</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2023-11-21</th>\n",
" <td>10.90</td>\n",
" <td>10.95</td>\n",
" <td>10.75</td>\n",
" <td>10.75</td>\n",
" <td>17</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2023-11-22</th>\n",
" <td>10.50</td>\n",
" <td>10.82</td>\n",
" <td>10.25</td>\n",
" <td>10.61</td>\n",
" <td>77</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>239 rows × 7 columns</p>\n",
"</div>"
],
"text/plain": [
" open high low close volume dividends stock splits\n",
"date \n",
"2022-11-22 43.08 44.24 43.00 43.00 287 0.0 0.0\n",
"2022-11-23 41.58 42.45 39.00 39.00 6 0.0 0.0\n",
"2022-11-28 42.50 42.90 42.50 42.90 18 0.0 0.0\n",
"2022-11-30 41.00 41.00 41.00 41.00 1 0.0 0.0\n",
"2022-12-01 40.73 40.81 39.85 40.25 42 0.0 0.0\n",
"... ... ... ... ... ... ... ...\n",
"2023-11-16 11.41 11.88 11.27 11.70 264 0.0 0.0\n",
"2023-11-17 11.50 11.50 11.19 11.40 0 0.0 0.0\n",
"2023-11-20 11.00 11.10 10.50 10.76 121 0.0 0.0\n",
"2023-11-21 10.90 10.95 10.75 10.75 17 0.0 0.0\n",
"2023-11-22 10.50 10.82 10.25 10.61 77 0.0 0.0\n",
"\n",
"[239 rows x 7 columns]"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"obb.equity.price.historical(\"SPY241220P00400000\", provider=\"yfinance\").to_df()\n"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>open</th>\n",
" <th>high</th>\n",
" <th>low</th>\n",
" <th>close</th>\n",
" <th>volume</th>\n",
" </tr>\n",
" <tr>\n",
" <th>date</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>2020-11-27</th>\n",
" <td>1846.26</td>\n",
" <td>1855.27</td>\n",
" <td>1845.50</td>\n",
" <td>1855.27</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2020-11-30</th>\n",
" <td>1854.87</td>\n",
" <td>1854.87</td>\n",
" <td>1813.56</td>\n",
" <td>1819.82</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2020-12-01</th>\n",
" <td>1822.92</td>\n",
" <td>1848.02</td>\n",
" <td>1822.92</td>\n",
" <td>1836.05</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2020-12-02</th>\n",
" <td>1833.08</td>\n",
" <td>1842.53</td>\n",
" <td>1817.02</td>\n",
" <td>1838.03</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2020-12-03</th>\n",
" <td>1838.52</td>\n",
" <td>1860.35</td>\n",
" <td>1838.52</td>\n",
" <td>1848.70</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2023-11-16</th>\n",
" <td>1797.00</td>\n",
" <td>1797.00</td>\n",
" <td>1767.42</td>\n",
" <td>1773.76</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2023-11-17</th>\n",
" <td>1784.86</td>\n",
" <td>1798.44</td>\n",
" <td>1784.86</td>\n",
" <td>1797.77</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2023-11-20</th>\n",
" <td>1798.56</td>\n",
" <td>1809.21</td>\n",
" <td>1794.71</td>\n",
" <td>1807.08</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2023-11-21</th>\n",
" <td>1799.33</td>\n",
" <td>1799.33</td>\n",
" <td>1783.26</td>\n",
" <td>1783.26</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2023-11-22</th>\n",
" <td>1796.37</td>\n",
" <td>1804.96</td>\n",
" <td>1785.93</td>\n",
" <td>1792.92</td>\n",
" <td>0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>752 rows × 5 columns</p>\n",
"</div>"
],
"text/plain": [
" open high low close volume\n",
"date \n",
"2020-11-27 1846.26 1855.27 1845.50 1855.27 0\n",
"2020-11-30 1854.87 1854.87 1813.56 1819.82 0\n",
"2020-12-01 1822.92 1848.02 1822.92 1836.05 0\n",
"2020-12-02 1833.08 1842.53 1817.02 1838.03 0\n",
"2020-12-03 1838.52 1860.35 1838.52 1848.70 0\n",
"... ... ... ... ... ...\n",
"2023-11-16 1797.00 1797.00 1767.42 1773.76 0\n",
"2023-11-17 1784.86 1798.44 1784.86 1797.77 0\n",
"2023-11-20 1798.56 1809.21 1794.71 1807.08 0\n",
"2023-11-21 1799.33 1799.33 1783.26 1783.26 0\n",
"2023-11-22 1796.37 1804.96 1785.93 1792.92 0\n",
"\n",
"[752 rows x 5 columns]"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"obb.equity.price.historical(\"^RUT\", provider=\"cboe\").to_df()\n"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>open</th>\n",
" <th>high</th>\n",
" <th>low</th>\n",
" <th>close</th>\n",
" <th>volume</th>\n",
" <th>vwap</th>\n",
" <th>label</th>\n",
" <th>adj_close</th>\n",
" <th>unadjusted_volume</th>\n",
" <th>change</th>\n",
" <th>change_percent</th>\n",
" <th>change_over_time</th>\n",
" </tr>\n",
" <tr>\n",
" <th>date</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>2022-11-22</th>\n",
" <td>1843.869995</td>\n",
" <td>1861.079956</td>\n",
" <td>1840.040039</td>\n",
" <td>1860.439941</td>\n",
" <td>3887990000</td>\n",
" <td>1853.85</td>\n",
" <td>November 22, 22</td>\n",
" <td>1860.439941</td>\n",
" <td>3.887990e+09</td>\n",
" <td>16.56995</td>\n",
" <td>0.89865</td>\n",
" <td>0.008986</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2022-11-23</th>\n",
" <td>1857.589966</td>\n",
" <td>1868.920044</td>\n",
" <td>1851.680054</td>\n",
" <td>1863.520020</td>\n",
" <td>3279720000</td>\n",
" <td>1861.37</td>\n",
" <td>November 23, 22</td>\n",
" <td>1863.520020</td>\n",
" <td>3.279720e+09</td>\n",
" <td>5.93005</td>\n",
" <td>0.31923</td>\n",
" <td>0.003192</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2022-11-25</th>\n",
" <td>1862.920044</td>\n",
" <td>1873.589966</td>\n",
" <td>1861.000000</td>\n",
" <td>1869.189941</td>\n",
" <td>1706460000</td>\n",
" <td>1867.93</td>\n",
" <td>November 25, 22</td>\n",
" <td>1869.189941</td>\n",
" <td>1.706460e+09</td>\n",
" <td>6.26990</td>\n",
" <td>0.33656</td>\n",
" <td>0.003366</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2022-11-28</th>\n",
" <td>1857.180054</td>\n",
" <td>1857.520020</td>\n",
" <td>1827.079956</td>\n",
" <td>1830.959961</td>\n",
" <td>3615430000</td>\n",
" <td>1838.52</td>\n",
" <td>November 28, 22</td>\n",
" <td>1830.959961</td>\n",
" <td>3.615430e+09</td>\n",
" <td>-26.22009</td>\n",
" <td>-1.41000</td>\n",
" <td>-0.014100</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2022-11-29</th>\n",
" <td>1832.520020</td>\n",
" <td>1846.069946</td>\n",
" <td>1832.520020</td>\n",
" <td>1836.550049</td>\n",
" <td>3546040000</td>\n",
" <td>1838.38</td>\n",
" <td>November 29, 22</td>\n",
" <td>1836.550049</td>\n",
" <td>3.546040e+09</td>\n",
" <td>4.03003</td>\n",
" <td>0.21992</td>\n",
" <td>0.002199</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2023-11-16</th>\n",
" <td>1797.000000</td>\n",
" <td>1797.000000</td>\n",
" <td>1767.420040</td>\n",
" <td>1773.760010</td>\n",
" <td>3964520000</td>\n",
" <td>1783.80</td>\n",
" <td>November 16, 23</td>\n",
" <td>1773.760010</td>\n",
" <td>3.964520e+09</td>\n",
" <td>-23.23999</td>\n",
" <td>-1.29000</td>\n",
" <td>-0.012900</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2023-11-17</th>\n",
" <td>1784.859990</td>\n",
" <td>1798.439940</td>\n",
" <td>1784.859990</td>\n",
" <td>1797.770020</td>\n",
" <td>3777240000</td>\n",
" <td>1791.48</td>\n",
" <td>November 17, 23</td>\n",
" <td>1797.770020</td>\n",
" <td>3.777240e+09</td>\n",
" <td>12.91003</td>\n",
" <td>0.72331</td>\n",
" <td>0.007233</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2023-11-20</th>\n",
" <td>1798.560060</td>\n",
" <td>1809.209960</td>\n",
" <td>1794.709960</td>\n",
" <td>1807.079960</td>\n",
" <td>3644790000</td>\n",
" <td>1802.39</td>\n",
" <td>November 20, 23</td>\n",
" <td>1807.079960</td>\n",
" <td>3.644790e+09</td>\n",
" <td>8.51990</td>\n",
" <td>0.47371</td>\n",
" <td>0.004737</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2023-11-21</th>\n",
" <td>1799.329960</td>\n",
" <td>1799.329960</td>\n",
" <td>1783.260010</td>\n",
" <td>1783.260010</td>\n",
" <td>3511080000</td>\n",
" <td>1791.29</td>\n",
" <td>November 21, 23</td>\n",
" <td>1783.260010</td>\n",
" <td>3.511080e+09</td>\n",
" <td>-16.06995</td>\n",
" <td>-0.89311</td>\n",
" <td>-0.008931</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2023-11-22</th>\n",
" <td>1792.511480</td>\n",
" <td>1803.116700</td>\n",
" <td>1789.876830</td>\n",
" <td>1795.540410</td>\n",
" <td>0</td>\n",
" <td>1796.18</td>\n",
" <td>November 22, 23</td>\n",
" <td>1795.540410</td>\n",
" <td>0.000000e+00</td>\n",
" <td>3.02893</td>\n",
" <td>0.16898</td>\n",
" <td>0.001690</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>252 rows × 12 columns</p>\n",
"</div>"
],
"text/plain": [
" open high low close volume \\\n",
"date \n",
"2022-11-22 1843.869995 1861.079956 1840.040039 1860.439941 3887990000 \n",
"2022-11-23 1857.589966 1868.920044 1851.680054 1863.520020 3279720000 \n",
"2022-11-25 1862.920044 1873.589966 1861.000000 1869.189941 1706460000 \n",
"2022-11-28 1857.180054 1857.520020 1827.079956 1830.959961 3615430000 \n",
"2022-11-29 1832.520020 1846.069946 1832.520020 1836.550049 3546040000 \n",
"... ... ... ... ... ... \n",
"2023-11-16 1797.000000 1797.000000 1767.420040 1773.760010 3964520000 \n",
"2023-11-17 1784.859990 1798.439940 1784.859990 1797.770020 3777240000 \n",
"2023-11-20 1798.560060 1809.209960 1794.709960 1807.079960 3644790000 \n",
"2023-11-21 1799.329960 1799.329960 1783.260010 1783.260010 3511080000 \n",
"2023-11-22 1792.511480 1803.116700 1789.876830 1795.540410 0 \n",
"\n",
" vwap label adj_close unadjusted_volume \\\n",
"date \n",
"2022-11-22 1853.85 November 22, 22 1860.439941 3.887990e+09 \n",
"2022-11-23 1861.37 November 23, 22 1863.520020 3.279720e+09 \n",
"2022-11-25 1867.93 November 25, 22 1869.189941 1.706460e+09 \n",
"2022-11-28 1838.52 November 28, 22 1830.959961 3.615430e+09 \n",
"2022-11-29 1838.38 November 29, 22 1836.550049 3.546040e+09 \n",
"... ... ... ... ... \n",
"2023-11-16 1783.80 November 16, 23 1773.760010 3.964520e+09 \n",
"2023-11-17 1791.48 November 17, 23 1797.770020 3.777240e+09 \n",
"2023-11-20 1802.39 November 20, 23 1807.079960 3.644790e+09 \n",
"2023-11-21 1791.29 November 21, 23 1783.260010 3.511080e+09 \n",
"2023-11-22 1796.18 November 22, 23 1795.540410 0.000000e+00 \n",
"\n",
" change change_percent change_over_time \n",
"date \n",
"2022-11-22 16.56995 0.89865 0.008986 \n",
"2022-11-23 5.93005 0.31923 0.003192 \n",
"2022-11-25 6.26990 0.33656 0.003366 \n",
"2022-11-28 -26.22009 -1.41000 -0.014100 \n",
"2022-11-29 4.03003 0.21992 0.002199 \n",
"... ... ... ... \n",
"2023-11-16 -23.23999 -1.29000 -0.012900 \n",
"2023-11-17 12.91003 0.72331 0.007233 \n",
"2023-11-20 8.51990 0.47371 0.004737 \n",
"2023-11-21 -16.06995 -0.89311 -0.008931 \n",
"2023-11-22 3.02893 0.16898 0.001690 \n",
"\n",
"[252 rows x 12 columns]"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"obb.equity.price.historical(\"^RUT\", provider=\"fmp\").to_df()\n"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>open</th>\n",
" <th>high</th>\n",
" <th>low</th>\n",
" <th>close</th>\n",
" <th>volume</th>\n",
" <th>dividends</th>\n",
" <th>stock splits</th>\n",
" </tr>\n",
" <tr>\n",
" <th>date</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>2022-11-22</th>\n",
" <td>72.00</td>\n",
" <td>72.50</td>\n",
" <td>71.70</td>\n",
" <td>71.91</td>\n",
" <td>6101</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2022-11-23</th>\n",
" <td>72.01</td>\n",
" <td>72.12</td>\n",
" <td>70.53</td>\n",
" <td>71.33</td>\n",
" <td>10513</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2022-11-25</th>\n",
" <td>71.21</td>\n",
" <td>72.21</td>\n",
" <td>70.55</td>\n",
" <td>70.66</td>\n",
" <td>5609</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2022-11-28</th>\n",
" <td>70.50</td>\n",
" <td>71.53</td>\n",
" <td>69.26</td>\n",
" <td>71.21</td>\n",
" <td>12409</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2022-11-29</th>\n",
" <td>70.80</td>\n",
" <td>72.53</td>\n",
" <td>70.61</td>\n",
" <td>71.77</td>\n",
" <td>14418</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2023-11-16</th>\n",
" <td>73.94</td>\n",
" <td>74.10</td>\n",
" <td>70.94</td>\n",
" <td>71.34</td>\n",
" <td>58159</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2023-11-17</th>\n",
" <td>71.37</td>\n",
" <td>73.69</td>\n",
" <td>71.21</td>\n",
" <td>73.58</td>\n",
" <td>36644</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2023-11-20</th>\n",
" <td>73.05</td>\n",
" <td>75.39</td>\n",
" <td>73.05</td>\n",
" <td>74.98</td>\n",
" <td>38285</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2023-11-21</th>\n",
" <td>74.65</td>\n",
" <td>75.05</td>\n",
" <td>74.39</td>\n",
" <td>74.98</td>\n",
" <td>26277</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2023-11-22</th>\n",
" <td>74.07</td>\n",
" <td>74.07</td>\n",
" <td>73.41</td>\n",
" <td>73.61</td>\n",
" <td>611</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>252 rows × 7 columns</p>\n",
"</div>"
],
"text/plain": [
" open high low close volume dividends stock splits\n",
"date \n",
"2022-11-22 72.00 72.50 71.70 71.91 6101 0.0 0.0\n",
"2022-11-23 72.01 72.12 70.53 71.33 10513 0.0 0.0\n",
"2022-11-25 71.21 72.21 70.55 70.66 5609 0.0 0.0\n",
"2022-11-28 70.50 71.53 69.26 71.21 12409 0.0 0.0\n",
"2022-11-29 70.80 72.53 70.61 71.77 14418 0.0 0.0\n",
"... ... ... ... ... ... ... ...\n",
"2023-11-16 73.94 74.10 70.94 71.34 58159 0.0 0.0\n",
"2023-11-17 71.37 73.69 71.21 73.58 36644 0.0 0.0\n",
"2023-11-20 73.05 75.39 73.05 74.98 38285 0.0 0.0\n",
"2023-11-21 74.65 75.05 74.39 74.98 26277 0.0 0.0\n",
"2023-11-22 74.07 74.07 73.41 73.61 611 0.0 0.0\n",
"\n",
"[252 rows x 7 columns]"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"obb.equity.price.historical(\"CLZ24.NYM\", provider=\"yfinance\").to_df()\n"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>open</th>\n",
" <th>high</th>\n",
" <th>low</th>\n",
" <th>close</th>\n",
" <th>volume</th>\n",
" <th>vwap</th>\n",
" <th>label</th>\n",
" <th>adj_close</th>\n",
" <th>unadjusted_volume</th>\n",
" <th>change</th>\n",
" <th>change_percent</th>\n",
" <th>change_over_time</th>\n",
" </tr>\n",
" <tr>\n",
" <th>date</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>2022-11-22</th>\n",
" <td>80.22</td>\n",
" <td>82.36</td>\n",
" <td>79.85</td>\n",
" <td>80.95</td>\n",
" <td>269615</td>\n",
" <td>81.05</td>\n",
" <td>November 22, 22</td>\n",
" <td>80.949997</td>\n",
" <td>269615.0</td>\n",
" <td>0.73</td>\n",
" <td>0.91000</td>\n",
" <td>0.009100</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2022-11-23</th>\n",
" <td>81.08</td>\n",
" <td>81.95</td>\n",
" <td>76.83</td>\n",
" <td>77.94</td>\n",
" <td>379145</td>\n",
" <td>78.91</td>\n",
" <td>November 23, 22</td>\n",
" <td>77.940002</td>\n",
" <td>379145.0</td>\n",
" <td>-3.14</td>\n",
" <td>-3.87000</td>\n",
" <td>-0.038700</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2022-11-25</th>\n",
" <td>77.51</td>\n",
" <td>79.90</td>\n",
" <td>76.22</td>\n",
" <td>76.28</td>\n",
" <td>266451</td>\n",
" <td>77.47</td>\n",
" <td>November 25, 22</td>\n",
" <td>76.279999</td>\n",
" <td>266451.0</td>\n",
" <td>-1.23</td>\n",
" <td>-1.59000</td>\n",
" <td>-0.015900</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2022-11-28</th>\n",
" <td>75.93</td>\n",
" <td>77.84</td>\n",
" <td>73.60</td>\n",
" <td>77.24</td>\n",
" <td>405033</td>\n",
" <td>76.23</td>\n",
" <td>November 28, 22</td>\n",
" <td>77.239998</td>\n",
" <td>405033.0</td>\n",
" <td>1.31</td>\n",
" <td>1.73000</td>\n",
" <td>0.017300</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2022-11-29</th>\n",
" <td>76.54</td>\n",
" <td>79.65</td>\n",
" <td>76.29</td>\n",
" <td>78.20</td>\n",
" <td>381869</td>\n",
" <td>78.05</td>\n",
" <td>November 29, 22</td>\n",
" <td>78.199997</td>\n",
" <td>381869.0</td>\n",
" <td>1.66</td>\n",
" <td>2.17000</td>\n",
" <td>0.021700</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2023-11-17</th>\n",
" <td>72.97</td>\n",
" <td>75.99</td>\n",
" <td>72.75</td>\n",
" <td>75.89</td>\n",
" <td>101484</td>\n",
" <td>74.88</td>\n",
" <td>November 17, 23</td>\n",
" <td>75.890000</td>\n",
" <td>101484.0</td>\n",
" <td>2.92</td>\n",
" <td>4.00000</td>\n",
" <td>0.040000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2023-11-19</th>\n",
" <td>75.65</td>\n",
" <td>75.80</td>\n",
" <td>75.65</td>\n",
" <td>75.80</td>\n",
" <td>10</td>\n",
" <td>75.75</td>\n",
" <td>November 19, 23</td>\n",
" <td>75.800000</td>\n",
" <td>10.0</td>\n",
" <td>0.15</td>\n",
" <td>0.19828</td>\n",
" <td>0.001983</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2023-11-20</th>\n",
" <td>75.65</td>\n",
" <td>78.22</td>\n",
" <td>75.65</td>\n",
" <td>77.60</td>\n",
" <td>270638</td>\n",
" <td>77.16</td>\n",
" <td>November 20, 23</td>\n",
" <td>77.600000</td>\n",
" <td>270638.0</td>\n",
" <td>1.95</td>\n",
" <td>2.58000</td>\n",
" <td>0.025800</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2023-11-21</th>\n",
" <td>77.65</td>\n",
" <td>77.92</td>\n",
" <td>76.92</td>\n",
" <td>77.77</td>\n",
" <td>270638</td>\n",
" <td>77.54</td>\n",
" <td>November 21, 23</td>\n",
" <td>77.770000</td>\n",
" <td>270638.0</td>\n",
" <td>0.12</td>\n",
" <td>0.15454</td>\n",
" <td>0.001545</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2023-11-22</th>\n",
" <td>77.77</td>\n",
" <td>77.97</td>\n",
" <td>73.79</td>\n",
" <td>76.78</td>\n",
" <td>368686</td>\n",
" <td>76.18</td>\n",
" <td>November 22, 23</td>\n",
" <td>76.780000</td>\n",
" <td>368686.0</td>\n",
" <td>-0.99</td>\n",
" <td>-1.27000</td>\n",
" <td>-0.012700</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>277 rows × 12 columns</p>\n",
"</div>"
],
"text/plain": [
" open high low close volume vwap label \\\n",
"date \n",
"2022-11-22 80.22 82.36 79.85 80.95 269615 81.05 November 22, 22 \n",
"2022-11-23 81.08 81.95 76.83 77.94 379145 78.91 November 23, 22 \n",
"2022-11-25 77.51 79.90 76.22 76.28 266451 77.47 November 25, 22 \n",
"2022-11-28 75.93 77.84 73.60 77.24 405033 76.23 November 28, 22 \n",
"2022-11-29 76.54 79.65 76.29 78.20 381869 78.05 November 29, 22 \n",
"... ... ... ... ... ... ... ... \n",
"2023-11-17 72.97 75.99 72.75 75.89 101484 74.88 November 17, 23 \n",
"2023-11-19 75.65 75.80 75.65 75.80 10 75.75 November 19, 23 \n",
"2023-11-20 75.65 78.22 75.65 77.60 270638 77.16 November 20, 23 \n",
"2023-11-21 77.65 77.92 76.92 77.77 270638 77.54 November 21, 23 \n",
"2023-11-22 77.77 77.97 73.79 76.78 368686 76.18 November 22, 23 \n",
"\n",
" adj_close unadjusted_volume change change_percent \\\n",
"date \n",
"2022-11-22 80.949997 269615.0 0.73 0.91000 \n",
"2022-11-23 77.940002 379145.0 -3.14 -3.87000 \n",
"2022-11-25 76.279999 266451.0 -1.23 -1.59000 \n",
"2022-11-28 77.239998 405033.0 1.31 1.73000 \n",
"2022-11-29 78.199997 381869.0 1.66 2.17000 \n",
"... ... ... ... ... \n",
"2023-11-17 75.890000 101484.0 2.92 4.00000 \n",
"2023-11-19 75.800000 10.0 0.15 0.19828 \n",
"2023-11-20 77.600000 270638.0 1.95 2.58000 \n",
"2023-11-21 77.770000 270638.0 0.12 0.15454 \n",
"2023-11-22 76.780000 368686.0 -0.99 -1.27000 \n",
"\n",
" change_over_time \n",
"date \n",
"2022-11-22 0.009100 \n",
"2022-11-23 -0.038700 \n",
"2022-11-25 -0.015900 \n",
"2022-11-28 0.017300 \n",
"2022-11-29 0.021700 \n",
"... ... \n",
"2023-11-17 0.040000 \n",
"2023-11-19 0.001983 \n",
"2023-11-20 0.025800 \n",
"2023-11-21 0.001545 \n",
"2023-11-22 -0.012700 \n",
"\n",
"[277 rows x 12 columns]"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"obb.equity.price.historical(\"CL=F\", provider=\"fmp\").to_df()\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "obb",
"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.11.4"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}