update readme + add test

This commit is contained in:
Jamie
2021-04-20 15:42:44 -04:00
parent b7feb17d59
commit 2c304a1b65
3 changed files with 64 additions and 1 deletions

View File

@@ -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"

View File

@@ -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 <a name="exp"></a>
@@ -88,3 +91,18 @@ Display options chains. [Source: Tradier]
<img width="948" alt="chains" src="https://user-images.githubusercontent.com/25267873/115161876-f708ff80-a097-11eb-8073-195979862a45.png">
## info <a name="info"></a>
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)

View File

@@ -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()