Files
OpenBB/notebooks/templates/econ_data.ipynb
DidierRLopes c2197a7375 Big Code Refactoring with contexts vs category division (#644)
* big-refactoring

* add terminal_helper

* fix tests

* remove init modules

Co-authored-by: jmaslek <jmaslek11@gmail.com>
2021-08-06 12:50:29 -04:00

521 lines
12 KiB
Plaintext
Vendored

{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "another-behalf",
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import importlib\n",
"import pathlib\n",
"import os\n",
"import sys\n",
"from datetime import datetime\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": "racial-graduation",
"metadata": {
"collapsed": true,
"tags": [
"parameters"
]
},
"outputs": [],
"source": [
"report_name=f\"economy_data_{datetime.now().strftime('%Y%m%d_%H%M%S')}\"\n",
"base_path=os.path.abspath(os.path.join('../..'))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "commercial-cargo",
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"display(Markdown(f\"# Economy Data - {datetime.now().strftime('%Y/%m/%d %H:%M:%S')}\"))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "alive-borough",
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"report_cache_dir = pathlib.Path(base_path, \"notebooks\", \"reports\", report_name)\n",
"if not os.path.isdir(report_cache_dir):\n",
" print(\"Reports data directory not found.\")\n",
" print(f\"Creating {report_cache_dir}\")\n",
" os.mkdir(report_cache_dir);\n",
"else:\n",
" print(f\"Found reports directory {cache_dir}\")\n",
" print(os.listdir(report_cache_dir))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "orange-merit",
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"from gamestonk_terminal.economy.report import econ_data_helper as edh"
]
},
{
"cell_type": "markdown",
"id": "informative-behavior",
"metadata": {},
"source": [
"## Dow Jones - 2 year trend with 20, 50 and 200 day SMA"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "stylish-elite",
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"edh.draw_graph(\"^DJI\", report_cache_dir, line_type=\"line\", draw_mas=(20,50,200), draw_volume=True, time_delta=720, low_trend=False)"
]
},
{
"cell_type": "markdown",
"id": "fifty-happiness",
"metadata": {},
"source": [
"## Dow Jones - 1 year trend with 20, 50 and 200 day SMA"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "identical-classification",
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"edh.draw_graph(\"^DJI\", report_cache_dir, line_type=\"line\", draw_mas=(20,50,200), draw_volume=True, time_delta=360, low_trend=True)"
]
},
{
"cell_type": "markdown",
"id": "boxed-turning",
"metadata": {},
"source": [
"## S&P 500 - 2 year trend with 20, 50 and 200 day SMA"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "threaded-language",
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"edh.draw_graph(\"^GSPC\", report_cache_dir, line_type=\"line\", draw_mas=(20,50,200), draw_volume=True, time_delta=720, low_trend=False)"
]
},
{
"cell_type": "markdown",
"id": "fleet-transparency",
"metadata": {},
"source": [
"## Market Volatility (VIX) - 2 year trend with 20, 50 and 200 day SMA"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "disturbed-workstation",
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"edh.draw_graph(\"^VIX\", report_cache_dir, line_type=\"line\", draw_mas=(20,50,200), draw_volume=False, time_delta=720, high_trend=False, low_trend=False)"
]
},
{
"cell_type": "markdown",
"id": "civilian-november",
"metadata": {},
"source": [
"## Market Volatility (VIX) - 1 year trend with 20, 50 and 200 day SMA"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "several-inventory",
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"edh.draw_graph(\"^VIX\", report_cache_dir, line_type=\"line\", draw_mas=(20,50,200), draw_volume=False, time_delta=360, high_trend=False, low_trend=False)"
]
},
{
"cell_type": "markdown",
"id": "bizarre-record",
"metadata": {},
"source": [
"## Yield on 5-Year US Treasury Notes - 2 year trend with 20, 50 and 200 day SMA"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "military-temperature",
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"edh.draw_graph(\"^FVX\", report_cache_dir, line_type=\"line\", draw_mas=(20,50,200), draw_volume=False, time_delta=720, low_trend=False, high_trend=False)"
]
},
{
"cell_type": "markdown",
"id": "greater-party",
"metadata": {},
"source": [
"## Yield on 10-Year US Treasury Notes - 2 year trend with 20, 50 and 200 day SMA"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "aboriginal-violin",
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"edh.draw_graph(\"^TNX\", report_cache_dir, line_type=\"line\", draw_mas=(20,50,200), draw_volume=False, time_delta=720, low_trend=False, high_trend=False)"
]
},
{
"cell_type": "markdown",
"id": "continent-sally",
"metadata": {},
"source": [
"## Yield on 30-Year US Treasury Notes - 2 year trend with 20, 50 and 200 day SMA"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "formed-heating",
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"edh.draw_graph(\"^TYX\", report_cache_dir, line_type=\"line\", draw_mas=(20,50,200), draw_volume=False, time_delta=720, low_trend=False, high_trend=False)"
]
},
{
"cell_type": "markdown",
"id": "handled-insurance",
"metadata": {},
"source": [
"## Gold - 2 year trend with 20, 50 and 200 day SMA"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "advisory-johnston",
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"edh.draw_graph(\"GLD\", report_cache_dir, line_type=\"line\", draw_mas=(20,50,200), draw_volume=True, time_delta=720)"
]
},
{
"cell_type": "markdown",
"id": "played-writer",
"metadata": {},
"source": [
"## Silver - 2 year trend with 20, 50 and 200 day SMA"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "light-harvest",
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"edh.draw_graph(\"SLV\", report_cache_dir, line_type=\"line\", draw_mas=(20,50,200), draw_volume=True, time_delta=720, low_trend=False)"
]
},
{
"cell_type": "markdown",
"id": "floral-giant",
"metadata": {},
"source": [
"## Euro vs US Dollar - 2 year trend with 20, 50 and 200 day SMA"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "corrected-estimate",
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"edh.draw_graph(\"FXE\", report_cache_dir, line_type=\"line\", draw_mas=(20,50,200), draw_volume=True, time_delta=720, low_trend=True)"
]
},
{
"cell_type": "markdown",
"id": "neither-montana",
"metadata": {},
"source": [
"## Yen vs US Dollar - 2 year trend with 20, 50 and 200 day SMA"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "middle-geneva",
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"edh.draw_graph(\"FXY\", report_cache_dir, line_type=\"line\", draw_mas=(20,50,200), draw_volume=True, time_delta=720, low_trend=True)"
]
},
{
"cell_type": "markdown",
"id": "theoretical-grammar",
"metadata": {},
"source": [
"## Energy - 2 year trend with 20, 50 and 200 day SMA"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "swedish-thickness",
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"edh.draw_graph(\"XLE\", report_cache_dir, line_type=\"line\", draw_mas=(20,50,200), draw_volume=True, time_delta=720)"
]
},
{
"cell_type": "markdown",
"id": "gentle-humor",
"metadata": {},
"source": [
"## Crude Oil - 2 year trend with 20, 50 and 200 day SMA"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "instructional-serve",
"metadata": {
"collapsed": true,
"scrolled": false
},
"outputs": [],
"source": [
"edh.draw_graph(\"CL=F\", report_cache_dir, line_type=\"line\", draw_mas=(20,50,200), draw_volume=True, time_delta=720, low_trend=False)"
]
},
{
"cell_type": "markdown",
"id": "classical-listening",
"metadata": {},
"source": [
"## Real Estate - 2 year trend with 20, 50 and 200 day SMA"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "enclosed-administration",
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"edh.draw_graph(\"XLRE\", report_cache_dir, line_type=\"line\", draw_mas=(20,50,200), draw_volume=True, time_delta=720, low_trend=False)"
]
},
{
"cell_type": "markdown",
"id": "turned-percentage",
"metadata": {},
"source": [
"## Real Estate - 1 year trend with 20, 50 and 200 day SMA"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "sharing-removal",
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"edh.draw_graph(\"VNQ\", report_cache_dir, line_type=\"line\", draw_mas=(20,50,200), draw_volume=True, time_delta=360, low_trend=True)"
]
},
{
"cell_type": "markdown",
"id": "swedish-happiness",
"metadata": {},
"source": [
"## Financials - 2 year trend with 20, 50 and 200 day SMA"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "beginning-aspect",
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"edh.draw_graph(\"XLF\", report_cache_dir, line_type=\"line\", draw_mas=(20,50,200), draw_volume=True, time_delta=720, low_trend=False)"
]
},
{
"cell_type": "markdown",
"id": "restricted-glucose",
"metadata": {},
"source": [
"## Financials - 1 year trend with 20, 50 and 200 day SMA"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "personal-whole",
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"edh.draw_graph(\"XLF\", report_cache_dir, line_type=\"line\", draw_mas=(20,50,200), draw_volume=True, time_delta=360, low_trend=True)"
]
},
{
"cell_type": "markdown",
"id": "detailed-strike",
"metadata": {},
"source": [
"## Materials - 2 year trend with 20, 50 and 200 day SMA"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "negative-mitchell",
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"edh.draw_graph(\"XLB\", report_cache_dir, line_type=\"line\", draw_mas=(20,50,200), draw_volume=True, time_delta=720, low_trend=False)"
]
},
{
"cell_type": "markdown",
"id": "boolean-rotation",
"metadata": {},
"source": [
"## Materials - 1 year trend with 20, 50 and 200 day SMA"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "settled-orange",
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"edh.draw_graph(\"XLB\", report_cache_dir, line_type=\"line\", draw_mas=(20,50,200), draw_volume=True, time_delta=360, low_trend=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "premium-transportation",
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"!jupyter nbconvert {os.path.join(\"notebooks\", \"reports\", report_name + \".ipynb\")} --to html --no-input"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.6.8"
}
},
"nbformat": 4,
"nbformat_minor": 5
}