diff --git a/gamestonk_terminal/config_terminal.py b/gamestonk_terminal/config_terminal.py index e73b5c2bee4..589da4b6e07 100644 --- a/gamestonk_terminal/config_terminal.py +++ b/gamestonk_terminal/config_terminal.py @@ -41,4 +41,4 @@ TRADIER_TOKEN = os.getenv("GT_TRADIER_TOKEN") or "REPLACE_ME" # Selenium Webbrowser drivers can be found at https://selenium-python.readthedocs.io/installation.html WEBDRIVER_TO_USE = "chrome" -PATH_TO_SELENIUM_DRIVER = None # Replace with "PATH" +PATH_TO_SELENIUM_DRIVER = None # Replace with "PATH" diff --git a/gamestonk_terminal/options/README.md b/gamestonk_terminal/options/README.md index 536ba329147..300574e5de9 100644 --- a/gamestonk_terminal/options/README.md +++ b/gamestonk_terminal/options/README.md @@ -14,6 +14,9 @@ This menu aims to give insight on options. Options can cause significant share p * Puts volume + open interest plot [Yahoo Finance] * [chains](#chains) * Display option chains [Source: Tradier] +* [info](#info) + * _**This requires selenium webdriver installed**_ + * Display option information [Source: Barchart.com] ## exp @@ -88,3 +91,18 @@ Display options chains. [Source: Tradier] chains + + +## info +This scrapes the options information from barchart.com/stocks overview. This includes information such as Historical Volatility and IV Rank. + +In order to run, the selenium webdriver must be installed. +Currently, this runs on either Chrome or Firefox. The path to the driver should be defined in [config_terminal.py](#config_terminal.py). + +Note this may take more time than other commands to process. +```` +usage: info [-d DRIVER] +```` +* -d/--driver : One of {chrome, firefox}. This indicates which driver you have installed. + +![im](https://user-images.githubusercontent.com/18151143/115454584-efa83a00-a1ee-11eb-9d0f-2558ffa31579.png) \ No newline at end of file diff --git a/tests/test_op_scrape_view.py b/tests/test_op_scrape_view.py new file mode 100644 index 00000000000..52253ec8026 --- /dev/null +++ b/tests/test_op_scrape_view.py @@ -0,0 +1,45 @@ +""" Simple test to make sure selenium installed. Taken from the docs""" +import unittest +from selenium import webdriver +from selenium.webdriver.common.keys import Keys +from selenium.webdriver.chrome.options import Options as cOpts +from selenium.webdriver.firefox.options import Options as fOpts + +from gamestonk_terminal.config_terminal import ( + PATH_TO_SELENIUM_DRIVER as path_to_driver, + WEBDRIVER_TO_USE as web, +) + + +class PythonOrgSearch(unittest.TestCase): + def setUp(self): + if path_to_driver is None: + raise FileNotFoundError("driver path not found in config_terminal.py") + if web == "firefox": + opts = fOpts() + opts.headless = True + self.driver = webdriver.Firefox( + options=opts, executable_path=path_to_driver + ) + elif web == "chrome": + opts = cOpts() + opts.headless = True + self.driver = webdriver.Chrome(options=opts, executable_path=path_to_driver) + else: + raise FileNotFoundError("Webbrowser not found in config_terminal.py") + + def test_search_in_python_org(self): + driver = self.driver + driver.get("http://www.python.org") + self.assertIn("Python", driver.title) + elem = driver.find_element_by_name("q") + elem.send_keys("pycon") + elem.send_keys(Keys.RETURN) + assert "No results found." not in driver.page_source + + def tearDown(self): + self.driver.close() + + +if __name__ == "__main__": + unittest.main()