/
summary_examples.py
38 lines (22 loc) · 1.09 KB
/
summary_examples.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# SummaryPage Examples
from yfs import get_summary_page
## How to get a single summary page.
result = get_summary_page("TSLA")
print(result.json(indent=4))
# Note: get_summary_page returns a single SummaryPage object.
# You can serialize a SummaryPage object to .json or a .dict()
## How to a list of quotes from the summary page without threads.
from yfs import get_multiple_summary_pages
COLUMNS = ["open", "high", "low", "close", "volume"]
search_items = ["TSLA", "GOOGLE", "appl", "aapl"]
results = get_multiple_summary_pages(search_items)
print(results.dataframe[COLUMNS])
# Note: You can pass company names too.
# This function will do a symbol look up for you.
# The get_multiple_summary_pages returns a SummaryPageGroup which is serializable to a pandas dataframe.
## How to a list of quotes from the summary page with threads.
from yfs import get_multiple_summary_pages
COLUMNS = ["open", "high", "low", "close", "volume"]
search_items = ["TSLA", "GOOGLE", "appl", "aapl"]
results = get_multiple_summary_pages(search_items, with_threads=True, thread_count=5)
print(results.dataframe[COLUMNS])