hist
- Model
- Chart
Get historical prices for all comparison stocks
Source Code: [link]
openbb.stocks.ca.hist(similar: List[str], start_date: Optional[str] = None, end_date: Optional[str] = None, candle_type: str = "a")
Parameters
| Name | Type | Description | Default | Optional |
|---|---|---|---|---|
| similar | List[str] | List of similar tickers. Comparable companies can be accessed through finnhub_peers(), finviz_peers(), polygon_peers(). | None | False |
| start_date | Optional[str] | Initial date (e.g., 2021-10-01). Defaults to 1 year back | None | True |
| end_date | Optional[str] | End date (e.g., 2023-01-01). None defaults to today | None | True |
| candle_type | str | Candle variable to compare, by default "a" for Adjusted Close. Possible values are: o, h, l, c, a, v, r | a | True |
Returns
| Type | Description |
|---|---|
| pd.DataFrame | Dataframe of historical prices for all comparison stocks |
Examples
from openbb_terminal.sdk import openbb
Start by getting similar tickers from finviz for AAPL
similar = openbb.stocks.comparison_analysis.finviz_peers("AAPL")
hist_df = openbb.stocks.ca.hist(similar)
We can specify a start date and an end date
hist_df_2022 = openbb.stocks.ca.hist(similar, start_date="2022-01-01", end_date="2022-12-31")
Display historical stock prices. [Source: Yahoo Finance]
Source Code: [link]
openbb.stocks.ca.hist_chart(similar: List[str], start_date: Optional[str] = None, end_date: Optional[str] = None, candle_type: str = "a", normalize: bool = True, export: str = "", external_axes: Optional[List[matplotlib.axes._axes.Axes]] = None)
Parameters
| Name | Type | Description | Default | Optional |
|---|---|---|---|---|
| similar | List[str] | List of similar tickers. Comparable companies can be accessed through finnhub_peers(), finviz_peers(), polygon_peers(). | None | False |
| start_date | Optional[str] | Initial date (e.g., 2021-10-01). Defaults to 1 year back | None | True |
| end_date | Optional[str] | End date (e.g., 2023-01-01) | None | True |
| candle_type | str | OHLCA column to use or R to use daily returns calculated from Adjusted Close, by default "a" for Adjusted Close | a | True |
| normalize | bool | Boolean to normalize all stock prices using MinMax defaults True | True | True |
| export | str | Format to export historical prices, by default "" | True | |
| external_axes | Optional[List[plt.Axes]] | External axes (1 axis is expected in the list), by default None | None | True |
Returns
This function does not return anything