-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2182 from ranaroussi/dev
dev -> main
- Loading branch information
Showing
12 changed files
with
281 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import yfinance as yf | ||
|
||
# get list of quotes | ||
quotes = yf.Search("AAPL", max_results=10).quotes | ||
|
||
# get list of news | ||
news = yf.Search("Google", news_count=10).news |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
===================== | ||
Search & News | ||
===================== | ||
|
||
.. currentmodule:: yfinance | ||
|
||
|
||
Class | ||
------------ | ||
The `Search` module, allows you to access search data in a Pythonic way. | ||
|
||
.. autosummary:: | ||
:toctree: api/ | ||
|
||
Search | ||
|
||
Search Sample Code | ||
------------------ | ||
The `Search` module, allows you to access search data in a Pythonic way. | ||
|
||
.. literalinclude:: examples/search.py | ||
:language: python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import unittest | ||
|
||
from tests.context import yfinance as yf | ||
|
||
|
||
class TestSearch(unittest.TestCase): | ||
def test_valid_query(self): | ||
search = yf.Search(query="AAPL", max_results=5, news_count=3) | ||
|
||
self.assertEqual(len(search.quotes), 5) | ||
self.assertEqual(len(search.news), 3) | ||
self.assertIn("AAPL", search.quotes[0]['symbol']) | ||
|
||
def test_invalid_query(self): | ||
search = yf.Search(query="XYZXYZ") | ||
|
||
self.assertEqual(len(search.quotes), 0) | ||
self.assertEqual(len(search.news), 0) | ||
|
||
def test_empty_query(self): | ||
search = yf.Search(query="") | ||
|
||
self.assertEqual(len(search.quotes), 0) | ||
self.assertEqual(len(search.news), 0) | ||
|
||
def test_fuzzy_query(self): | ||
search = yf.Search(query="Appel", enable_fuzzy_query=True) | ||
|
||
# Check if the fuzzy search retrieves relevant results despite the typo | ||
self.assertGreater(len(search.quotes), 0) | ||
self.assertIn("AAPL", search.quotes[0]['symbol']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.