Skip to content

Commit

Permalink
docs: updated docs, new doc strings, and more examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
dgnsrekt committed Oct 10, 2020
1 parent 196d15b commit be9861b
Show file tree
Hide file tree
Showing 11 changed files with 237 additions and 24 deletions.
9 changes: 5 additions & 4 deletions docs/.generated-files.txt
@@ -1,6 +1,7 @@
md5 4deb21401513245e45fbac01d42e30f2 content/index.md
md5 c5541b9bc62ed11325a343e0861c3da0 content/examples/fuzzy-search-examples.md
md5 7ed154d81f590361b8bdf6326fd1abc9 content/examples/summary-page-examples.md
md5 8f4abb86458fc4ff472cb3db1c3bb3f4 content/examples/statistics-page-examples.md
md5 0fd30b6ee3cff55191c51abdaa9d176d content/examples/summary-page-examples.md
md5 3c44810fd6388485f5dfcfe11824c291 content/examples/extra-watchlist-example.md
md5 9aca642a4c7ae57fc013b511f5adbb98 content/api/asset-types-module.md
md5 2cd0fb7f1da540d5cf5f2b4ec4256c96 content/api/cleaner-module.md
Expand All @@ -10,6 +11,6 @@ md5 8de0b2ed81019487fb61f5d25766bff9 content/api/options-module.md
md5 80d66b978c197b4d6cf80407811829d4 content/api/paths-module.md
md5 50823497f27ea40488fc4b77b9700568 content/api/quote-module.md
md5 f67b337a8064aff69ad310cc5455e5fc content/api/requestor-module.md
md5 9834951c714f87ba75f89e1648a48ac0 content/api/statistics-module.md
md5 46a90fb44975cd7862081e1eb58ba58f content/api/summary-module.md
md5 970129e5b920bf7c8462fa05f665e715 mkdocs.yml
md5 730eb4649fdc866f96a84e57d989a78c content/api/statistics-module.md
md5 f7f833c4cbcf89d6272f32edffcc8c0e content/api/summary-module.md
md5 1d1d67d1741574c79247d249a63152dc mkdocs.yml
93 changes: 89 additions & 4 deletions docs/content/api/statistics-module.md
Expand Up @@ -232,6 +232,15 @@ def parse_trading_information_table(html: HTML) -> Optional[TradingInformation]
> - `.json()` - Serialize to a JSON object.
> - `.dict()` - Serialize to a dictionary.

<a name="statistics.StatisticsPage.__lt__"></a>
#### `__lt__`

```python
| def __lt__(other) -> bool
```

> Compare StatisticsPage objects to allow ordering by symbol.

<a name="statistics.StatisticsPageGroup"></a>
## `StatisticsPageGroup`

Expand All @@ -250,6 +259,37 @@ def parse_trading_information_table(html: HTML) -> Optional[TradingInformation]
> - `.json()` - Serialize to a JSON object.
> - `.dict()` - Serialize to a dictionary.

<a name="statistics.StatisticsPageGroup.append"></a>
#### `append`

```python
| def append(page: StatisticsPage) -> None
```

> Append a StatisticsPage to the StatisticsPageGroup.
>
> **Arguments**:
>
> - `page` _StatisticsPage_ - A StatisticsPage object to add to the group.

<a name="statistics.StatisticsPageGroup.symbols"></a>
#### `symbols`

```python
| def symbols() -> List[str]
```

> List of symbols in the StatisticsPageGroup.

<a name="statistics.StatisticsPageGroup.sort"></a>
#### `sort`

```python
| def sort() -> None
```

> Sort StatisticsPage objects by symbol.

<a name="statistics.StatisticsPageGroup.dataframe"></a>
#### `dataframe`

Expand All @@ -259,10 +299,23 @@ def parse_trading_information_table(html: HTML) -> Optional[TradingInformation]

> Return a dataframe of multiple statistics pages.

<a name="statistics.StatisticsPageNotFound"></a>
## `StatisticsPageNotFound`
<a name="statistics.StatisticsPageGroup.__iter__"></a>
#### `__iter__`

```python
| def __iter__() -> Iterable
```

> Iterate over StatisticsPage objects.

> Raised when statistics page data is not found.
<a name="statistics.StatisticsPageGroup.__len__"></a>
#### `__len__`

```python
| def __len__() -> int
```

> Length of StatisticsPage objects.

<a name="statistics.get_statistics_page"></a>
#### `get_statistics_page`
Expand All @@ -289,5 +342,37 @@ def get_statistics_page(symbol: str, use_fuzzy_search: bool = True, page_not_fou
>
> **Raises**:
>
> - `StatisticsPageNotFound` - When a page is not found and the page_not_found_ok arg is false.
> - `AttributeError` - When a page is not found and the page_not_found_ok arg is false.

<a name="statistics.get_multiple_statistics_pages"></a>
#### `get_multiple_statistics_pages`

```python
def get_multiple_statistics_pages(symbols: List[str], use_fuzzy_search: bool = True, page_not_found_ok: bool = True, with_threads: bool = False, thread_count: int = 5, progress_bar: bool = True, **kwargs, ,) -> Optional[StatisticsPageGroup]
```

> Get multiple statistics pages.
>
> **Arguments**:
>
> - `symbols` _List[str]_ - Ticker symbols or company names.
> - `use_fuzzy_search` _bool_ - If True does a symbol lookup validation prior
> to requesting data.
> - `page_not_found_ok` _bool_ - If True Returns None when page is not found.
> - `with_threads` _bool_ - If True uses threading.
> - `thread_count` _int_ - Number of threads to use if with_threads is set to True.
> - `**kwargs` - Pass (session, proxies, and timeout) to the requestor function.
> - `progress_bar` _bool_ - If True shows the progress bar else the progress bar
> is not shown.
>
>
> **Returns**:
>
> - `StatisticsPageGroup` - When data is found.
> - `None` - No data is found and page_not_found_ok is True.
>
>
> **Raises**:
>
> - `AttributeError` - When a page is not found and the page_not_found_ok arg is false.

9 changes: 2 additions & 7 deletions docs/content/api/summary-module.md
Expand Up @@ -151,11 +151,6 @@ def parse_summary_table(html: HTML) -> Optional[Dict]

> Parse data from summary table HTML element.

<a name="summary.SummaryPageNotFound"></a>
## `SummaryPageNotFound`

> Raised when summary page data is not found.

<a name="summary.get_summary_page"></a>
#### `get_summary_page`

Expand All @@ -182,7 +177,7 @@ def get_summary_page(symbol: str, use_fuzzy_search: bool = True, page_not_found_
>
> **Raises**:
>
> - `SummaryPageNotFound` - When a page is not found and the page_not_found_ok arg is false.
> - `AttributeError` - When a page is not found and the page_not_found_ok arg is false.

<a name="summary.get_multiple_summary_pages"></a>
#### `get_multiple_summary_pages`
Expand Down Expand Up @@ -214,5 +209,5 @@ def get_multiple_summary_pages(symbols: List[str], use_fuzzy_search: bool = True
>
> **Raises**:
>
> - `SummaryPageNotFound` - When a page is not found and the page_not_found_ok arg is false.
> - `AttributeError` - When a page is not found and the page_not_found_ok arg is false.

31 changes: 31 additions & 0 deletions docs/content/examples/statistics-page-examples.md
@@ -0,0 +1,31 @@
# Statistics Page Examples

## How to get a single symbols statistics page.
```python
from yfs import get_statistics_page

result = get_statistics_page("AAPL")
print(result.json(indent=4))
```

## How to get multiple statistics pages without threads
```python
from yfs import get_multiple_statistics_pages

search_items = ["TSLA", "GOOGLE", "appl", "aapl"]

results = get_multiple_statistics_pages(search_items, with_threads=False)

print(results.dataframe)
```

## How to get multiple statistics pages with threads
```python
from yfs import get_multiple_statistics_pages

search_items = ["TSLA", "GOOGLE", "appl", "aapl"]

results = get_multiple_statistics_pages(search_items, with_threads=True, thread_count=5)

print(results.dataframe)
```
20 changes: 17 additions & 3 deletions docs/content/examples/summary-page-examples.md
Expand Up @@ -3,7 +3,7 @@
## How to get a single summary page.

```python
from yfs import get_summary_page, get_multiple_summary_pages
from yfs import get_summary_page

result = get_summary_page("TSLA")
print(result.json(indent=4))
Expand All @@ -12,10 +12,10 @@ print(result.json(indent=4))
!!! note
The get_summary_page function returns a single SummaryPage object. You can serialize the SummaryPage object to json or a dictionary with the .json() and .dict() methods.

## How to get multiple quotes from the summary page.
## How to get multiple quotes from the summary page without threads.

```python
from yfs import get_summary_page, get_multiple_summary_pages
from yfs import get_multiple_summary_pages

COLUMNS = ["open", "high", "low", "close", "volume"]

Expand All @@ -27,3 +27,17 @@ print(results.dataframe[COLUMNS])

!!! note
You can pass company names too. This function will do a symbol look up for you using fuzzy_search. The get_multiple_summary_pages returns a SummaryPageGroup which you can serialize to a pandas dataframe.

## How to get multiple quotes from the summary page with threads.

```python
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])
```
31 changes: 31 additions & 0 deletions docs/markdown/statistics_examples.md
@@ -0,0 +1,31 @@
# Statistics Page Examples

## How to get a single symbols statistics page.
```python
from yfs import get_statistics_page

result = get_statistics_page("AAPL")
print(result.json(indent=4))
```

## How to get multiple statistics pages without threads
```python
from yfs import get_multiple_statistics_pages

search_items = ["TSLA", "GOOGLE", "appl", "aapl"]

results = get_multiple_statistics_pages(search_items, with_threads=False)

print(results.dataframe)
```

## How to get multiple statistics pages with threads
```python
from yfs import get_multiple_statistics_pages

search_items = ["TSLA", "GOOGLE", "appl", "aapl"]

results = get_multiple_statistics_pages(search_items, with_threads=True, thread_count=5)

print(results.dataframe)
```
20 changes: 17 additions & 3 deletions docs/markdown/summary_examples.md
Expand Up @@ -3,7 +3,7 @@
## How to get a single summary page.

```python
from yfs import get_summary_page, get_multiple_summary_pages
from yfs import get_summary_page

result = get_summary_page("TSLA")
print(result.json(indent=4))
Expand All @@ -12,10 +12,10 @@ print(result.json(indent=4))
!!! note
The get_summary_page function returns a single SummaryPage object. You can serialize the SummaryPage object to json or a dictionary with the .json() and .dict() methods.

## How to get multiple quotes from the summary page.
## How to get multiple quotes from the summary page without threads.

```python
from yfs import get_summary_page, get_multiple_summary_pages
from yfs import get_multiple_summary_pages

COLUMNS = ["open", "high", "low", "close", "volume"]

Expand All @@ -27,3 +27,17 @@ print(results.dataframe[COLUMNS])

!!! note
You can pass company names too. This function will do a symbol look up for you using fuzzy_search. The get_multiple_summary_pages returns a SummaryPageGroup which you can serialize to a pandas dataframe.

## How to get multiple quotes from the summary page with threads.

```python
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])
```
1 change: 1 addition & 0 deletions docs/mkdocs.yml
Expand Up @@ -29,6 +29,7 @@ nav:
- Home: index.md
- Examples:
- Fuzzy Search Examples: examples/fuzzy-search-examples.md
- Statistics Page Examples: examples/statistics-page-examples.md
- Summary Page Examples: examples/summary-page-examples.md
- Extra Watchlist Example: examples/extra-watchlist-example.md
- API Documentation:
Expand Down
25 changes: 25 additions & 0 deletions examples/statistics_example.py
@@ -0,0 +1,25 @@
from yfs import get_statistics_page

# Scrape a single symbols statistics page.
result = get_statistics_page("AAPL")
print(result.json(indent=4))

# How to get multiple summary pages without threads

from yfs import get_multiple_statistics_pages

search_items = ["TSLA", "GOOGLE", "appl", "aapl"]

results = get_multiple_statistics_pages(search_items, with_threads=False)

print(results.dataframe)

# How to get multiple summary pages without threads

from yfs import get_multiple_statistics_pages

search_items = ["TSLA", "GOOGLE", "appl", "aapl"]

results = get_multiple_statistics_pages(search_items, with_threads=True, thread_count=5)

print(results.dataframe)
19 changes: 16 additions & 3 deletions summary_examples.py → examples/summary_examples.py
@@ -1,6 +1,6 @@
# SummaryPage Examples

from yfs import get_summary_page, get_multiple_summary_pages
from yfs import get_summary_page

## How to get a single summary page.
result = get_summary_page("TSLA")
Expand All @@ -9,8 +9,9 @@
# 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.
from yfs import get_summary_page, get_multiple_summary_pages
## 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"]

Expand All @@ -23,3 +24,15 @@
# 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])
3 changes: 3 additions & 0 deletions pydoc-markdown.yml
Expand Up @@ -43,6 +43,9 @@ renderer:
- title: "Fuzzy Search Examples"
source: ./docs/markdown/lookup_examples.md

- title: "Statistics Page Examples"
source: ./docs/markdown/statistics_examples.md

- title: "Summary Page Examples"
source: ./docs/markdown/summary_examples.md

Expand Down

0 comments on commit be9861b

Please sign in to comment.