mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-27 12:40:35 +00:00
Run papermill kernel from python. (#563)
* initialize notebook automatically * Update papermill readme * kill process after papermill use * allow to run notebook on selected port * Update README.md * deprecate marketwatch
This commit is contained in:
@@ -13,7 +13,6 @@ from gamestonk_terminal.fundamental_analysis.financial_modeling_prep import (
|
||||
fmp_view,
|
||||
)
|
||||
from gamestonk_terminal.fundamental_analysis import finviz_view
|
||||
from gamestonk_terminal.fundamental_analysis import market_watch_view
|
||||
from gamestonk_terminal.fundamental_analysis import yahoo_finance_view
|
||||
from gamestonk_terminal import feature_flags as gtff
|
||||
from gamestonk_terminal.helper_funcs import get_flair, parse_known_args_and_warn
|
||||
@@ -95,7 +94,7 @@ class FundamentalAnalysisController:
|
||||
" score investing score from Warren Buffett, Joseph Piotroski and Benjamin Graham [FMP]"
|
||||
)
|
||||
print("")
|
||||
print("Market Watch API")
|
||||
print("Market Watch API - DEPRECATED")
|
||||
print(" income income statement of the company")
|
||||
print(" balance balance sheet of the company")
|
||||
print(" cash cash flow statement of the company")
|
||||
@@ -167,17 +166,26 @@ class FundamentalAnalysisController:
|
||||
"""Process score command"""
|
||||
fmp_view.valinvest_score(other_args, self.ticker)
|
||||
|
||||
def call_income(self, other_args: List[str]):
|
||||
def call_income(self, _):
|
||||
"""Process income command"""
|
||||
market_watch_view.income(other_args, self.ticker)
|
||||
print(
|
||||
"MarketWatch is now deprecated because to scrape the data, the user needs to be a subscriber.",
|
||||
"\n",
|
||||
)
|
||||
|
||||
def call_balance(self, other_args: List[str]):
|
||||
def call_balance(self, _):
|
||||
"""Process balance command"""
|
||||
market_watch_view.balance(other_args, self.ticker)
|
||||
print(
|
||||
"MarketWatch is now deprecated because to scrape the data, the user needs to be a subscriber.",
|
||||
"\n",
|
||||
)
|
||||
|
||||
def call_cash(self, other_args: List[str]):
|
||||
def call_cash(self, _):
|
||||
"""Process cash command"""
|
||||
market_watch_view.cash(other_args, self.ticker)
|
||||
print(
|
||||
"MarketWatch is now deprecated because to scrape the data, the user needs to be a subscriber.",
|
||||
"\n",
|
||||
)
|
||||
|
||||
def call_info(self, other_args: List[str]):
|
||||
"""Process info command"""
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
""" Fundamental Analysis Market Watch View """
|
||||
""" Fundamental Analysis Market Watch View. LEGACY.
|
||||
|
||||
MarketWatch now requires a user to be a subscriber in order to have access to the financials...
|
||||
So this code is not being used for the time being, it may be at a later stage.
|
||||
"""
|
||||
__docformat__ = "numpy"
|
||||
|
||||
import argparse
|
||||
|
||||
8
gamestonk_terminal/papermill/README.md
vendored
8
gamestonk_terminal/papermill/README.md
vendored
@@ -12,13 +12,13 @@ Command | Template | Example
|
||||
|
||||
## How to run the report
|
||||
|
||||
1. Before running the terminal, on the main directory "GamestonkTerminal" start a new notebook kernel with: `jupyter notebook`
|
||||
1. In [config_terminal](/gamestonk_terminal/config_terminal.py) you may need to change your `PAPERMILL_NOTEBOOK_REPORT_PORT` from `8888`. If the notebook generation fails, it is likely that the port selected is not the correct one.
|
||||
|
||||
2. Now you can start the terminal with `python terminal.py`
|
||||
2. Start the terminal with `python terminal.py`
|
||||
|
||||
3. Select `mill` and select one of the available reports generation
|
||||
3. Select `mill` and select one of the available reports generation, e.g. `econ`
|
||||
|
||||
4. This should prompt you with a filled notebok with name: `report_name_date_time.ipynb`
|
||||
4. This should prompt you with a filled notebok with name: `report_name_date_time.ipynb`. E.g. `econ_data_20210725_193517.ipynb`
|
||||
|
||||
5. You can now write your own personal notes on the notebook. By doing:
|
||||
* Click on the notebook cell that you are interested in writing your notes
|
||||
|
||||
@@ -4,11 +4,15 @@ __docformat__ = "numpy"
|
||||
import argparse
|
||||
import os
|
||||
from typing import List
|
||||
import subprocess
|
||||
|
||||
from gamestonk_terminal.papermill import due_diligence_view
|
||||
from gamestonk_terminal.papermill import econ_data_view
|
||||
|
||||
from gamestonk_terminal.helper_funcs import get_flair
|
||||
from gamestonk_terminal import config_terminal
|
||||
|
||||
# pylint: disable=R1732
|
||||
|
||||
|
||||
class PapermillController:
|
||||
@@ -24,9 +28,16 @@ class PapermillController:
|
||||
choices=["cls", "?", "help", "q", "quit", "dd", "econ"],
|
||||
)
|
||||
|
||||
def switch(self, an_input: str):
|
||||
def switch(self, an_input: str, proc: subprocess.Popen):
|
||||
"""Process and dispatch input
|
||||
|
||||
Parameters
|
||||
-------
|
||||
an_input : str
|
||||
string with input arguments
|
||||
proc : subprocess.Popen
|
||||
subprocess that calls jupyter notebook for report generation
|
||||
|
||||
Returns
|
||||
-------
|
||||
True, False or None
|
||||
@@ -56,25 +67,27 @@ class PapermillController:
|
||||
|
||||
return getattr(
|
||||
self, "call_" + known_args.cmd, lambda: "Command not recognized!"
|
||||
)(other_args)
|
||||
)(other_args, proc)
|
||||
|
||||
def call_help(self, _):
|
||||
"""Process Help command"""
|
||||
print_papermill()
|
||||
|
||||
def call_q(self, _):
|
||||
def call_q(self, _, proc):
|
||||
"""Process Q command - quit the menu"""
|
||||
proc.kill()
|
||||
return False
|
||||
|
||||
def call_quit(self, _):
|
||||
def call_quit(self, _, proc):
|
||||
"""Process Quit command - quit the program"""
|
||||
proc.kill()
|
||||
return True
|
||||
|
||||
def call_dd(self, other_args: List[str]):
|
||||
def call_dd(self, other_args: List[str], _):
|
||||
"""Process DD command"""
|
||||
due_diligence_view.due_diligence(other_args)
|
||||
|
||||
def call_econ(self, other_args: List[str]):
|
||||
def call_econ(self, other_args: List[str], _):
|
||||
"""Process Econ command"""
|
||||
econ_data_view.econ_data(other_args)
|
||||
|
||||
@@ -94,22 +107,24 @@ def print_papermill():
|
||||
print(" econ run papermill to generate economic data summary")
|
||||
print("")
|
||||
|
||||
return
|
||||
|
||||
|
||||
def papermill_menu():
|
||||
"""Papermill Menu"""
|
||||
|
||||
pc = PapermillController()
|
||||
|
||||
print_papermill()
|
||||
|
||||
# Initialize jupyter notebook
|
||||
cmd = f"jupyter notebook --port={config_terminal.PAPERMILL_NOTEBOOK_REPORT_PORT}"
|
||||
proc = subprocess.Popen(
|
||||
cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT
|
||||
)
|
||||
|
||||
while True:
|
||||
# Get input command from user
|
||||
an_input = input(f"{get_flair()} (mill)> ")
|
||||
|
||||
try:
|
||||
process_input = pc.switch(an_input)
|
||||
process_input = pc.switch(an_input, proc)
|
||||
except SystemExit:
|
||||
print("The command selected doesn't exist\n")
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user