mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-07 09:52:13 +00:00
* refactor load command * fix reports based on code changes * Fixing tests : stocks > dd > business insider * Fixing tests : stocks > dd > controller * add start to load * fix minor bug * fix bug for exchanges * minor improvs * add load to technical analysis * fix bug for exchanges * minor enhancement Co-authored-by: Chavithra PARANA <chavithra@gmail.com>
361 lines
8.6 KiB
Plaintext
Vendored
361 lines
8.6 KiB
Plaintext
Vendored
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "phantom-facility",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Import most generic modules\n",
|
|
"import importlib\n",
|
|
"import pathlib\n",
|
|
"import os\n",
|
|
"import sys\n",
|
|
"from datetime import datetime, timedelta\n",
|
|
"import pandas as pd\n",
|
|
"from IPython.display import display, Markdown\n",
|
|
"import warnings\n",
|
|
"warnings.filterwarnings('ignore')\n",
|
|
"module_path = os.path.abspath(os.path.join('../..'))\n",
|
|
"\n",
|
|
"if module_path not in sys.path:\n",
|
|
" sys.path.append(module_path)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "compact-count",
|
|
"metadata": {
|
|
"tags": [
|
|
"parameters"
|
|
]
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Parameters that will be replaced when calling this notebook\n",
|
|
"ticker=\"TSLA\"\n",
|
|
"\n",
|
|
"report_name=f\"{datetime.now().strftime('%Y%m%d_%H%M%S')}_comparison_{ticker.upper()}\""
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "possible-constraint",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"display(Markdown(f\"# {ticker.upper()} - Comparison - {datetime.now().strftime('%Y/%m/%d %H:%M:%S')}\"))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "b9eaca4a-a46d-45a3-9306-e80e74234f12",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"from gamestonk_terminal.stocks.comparison_analysis import finviz_compare_model, yahoo_finance_model\n",
|
|
"\n",
|
|
"ticker = ticker.upper()\n",
|
|
"finviz_similar = finviz_compare_model.get_similar_companies(ticker, [\"Sector\", \"Industry\", \"Country\"])[0]"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "ffea4266-e801-4a4e-8cac-3d60e735aa4e",
|
|
"metadata": {},
|
|
"source": [
|
|
"### Similar companies and descriptions"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "21122245-457b-4347-b89f-d4aabb5bdc9a",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"from gamestonk_terminal.stocks.fundamental_analysis import yahoo_finance_model\n",
|
|
"\n",
|
|
"df_info = yahoo_finance_model.get_info(ticker)\n",
|
|
"if \"Long business summary\" in df_info.index:\n",
|
|
" summary = df_info.loc[\"Long business summary\"].values[0]\n",
|
|
"if \"Website\" in df_info.index:\n",
|
|
" website = df_info.loc[\"Website\"].values[0]\n",
|
|
" \n",
|
|
"if finviz_similar:\n",
|
|
" print(f\"{ticker}: {website}\")\n",
|
|
" print(summary)\n",
|
|
" \n",
|
|
" for symbol in finviz_similar:\n",
|
|
" df_info = yahoo_finance_model.get_info(symbol)\n",
|
|
" if \"Long business summary\" in df_info.index:\n",
|
|
" summary = df_info.loc[\"Long business summary\"].values[0]\n",
|
|
" if \"Website\" in df_info.index:\n",
|
|
" website = df_info.loc[\"Website\"].values[0]\n",
|
|
" \n",
|
|
" print(\"\")\n",
|
|
" print(f\"{symbol}: {website}\")\n",
|
|
" print(summary)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "temporal-clerk",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"source": [
|
|
"### Historical prices"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "1fdfac4c-62cd-4bd3-b7df-41ba67263798",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import math\n",
|
|
"from gamestonk_terminal.stocks.comparison_analysis import yahoo_finance_view\n",
|
|
"\n",
|
|
"for i in range(math.ceil(len(finviz_similar)/4)):\n",
|
|
" yahoo_finance_view.display_historical(\n",
|
|
" similar_tickers=finviz_similar[4*(i):4*(i+1)],\n",
|
|
" )"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "2a07f866-7939-4fb7-8b14-c0701087a8ae",
|
|
"metadata": {},
|
|
"source": [
|
|
"### Historical correlation"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "eb1850dc-1d62-4ad4-971f-1bbce6209726",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"from matplotlib import pyplot as plt\n",
|
|
"\n",
|
|
"plt.figure(figsize=(25,10))\n",
|
|
"yahoo_finance_view.display_correlation(\n",
|
|
" similar_tickers=finviz_similar,\n",
|
|
" )"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "21005668-7f21-4884-a231-846130695602",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"source": [
|
|
"### Historical volumes"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "a7bf528c-427c-4d84-8cb9-ec5656f920e1",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"for i in range(math.ceil(len(finviz_similar)/4)):\n",
|
|
" yahoo_finance_view.display_volume(\n",
|
|
" similar_tickers=finviz_similar[4*(i):4*(i+1)],\n",
|
|
" )"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "6e370470-8014-4e97-95f2-13b4f66645c5",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"source": [
|
|
"### Overview"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "f82b7162-f7e5-4d5c-8ca9-50466f789f48",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"from gamestonk_terminal.stocks.comparison_analysis import finviz_compare_view\n",
|
|
"\n",
|
|
"finviz_compare_view.screener(\n",
|
|
" similar=finviz_similar,\n",
|
|
" data_type=\"overview\",\n",
|
|
" )"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "5277ae24-b7d7-48e6-b46c-fcffdf84631f",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"source": [
|
|
"### Valuation"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "caed21ad-a31d-4063-a4cb-f5b6fd1c63ed",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"from gamestonk_terminal.stocks.comparison_analysis import finviz_compare_view\n",
|
|
"\n",
|
|
"finviz_compare_view.screener(\n",
|
|
" similar=finviz_similar,\n",
|
|
" data_type=\"valuation\",\n",
|
|
" )"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "98030d12-9a77-4f08-b4ad-2c558d9ad225",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"source": [
|
|
"### Financial"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "e98bf90d-bf2b-4eea-b533-08211e8eec47",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"from gamestonk_terminal.stocks.comparison_analysis import finviz_compare_view\n",
|
|
"\n",
|
|
"finviz_compare_view.screener(\n",
|
|
" similar=finviz_similar,\n",
|
|
" data_type=\"financial\",\n",
|
|
" )"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "f7cf8774-5162-47ea-8bfe-5005ed2fb9d9",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"source": [
|
|
"### Ownership"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "d3f90d1f-7a40-403f-bf3e-17703e151f4b",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"from gamestonk_terminal.stocks.comparison_analysis import finviz_compare_view\n",
|
|
"\n",
|
|
"finviz_compare_view.screener(\n",
|
|
" similar=finviz_similar,\n",
|
|
" data_type=\"ownership\",\n",
|
|
" )"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "c1833238-5ea8-486b-a6e7-6043e7c0aa0e",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"source": [
|
|
"### Performance"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "62057b47-2364-49ed-80e7-7d6938f2819d",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"from gamestonk_terminal.stocks.comparison_analysis import finviz_compare_view\n",
|
|
"\n",
|
|
"finviz_compare_view.screener(\n",
|
|
" similar=finviz_similar,\n",
|
|
" data_type=\"performance\",\n",
|
|
" )"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "6d0494c0-e66a-414a-ba2d-89e4072e1a8f",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"source": [
|
|
"### Technical"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "1178a080-83ce-4170-a355-9faa8cf9abe6",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"from gamestonk_terminal.stocks.comparison_analysis import finviz_compare_view\n",
|
|
"\n",
|
|
"finviz_compare_view.screener(\n",
|
|
" similar=finviz_similar,\n",
|
|
" data_type=\"technical\",\n",
|
|
" )"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "sought-phase",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"!jupyter nbconvert {report_name + \".ipynb\"} --to html --no-input"
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"celltoolbar": "Tags",
|
|
"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.8.6"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|