Skip to content

Commit 7430f18

Browse files
committed
Clean up session manager and add documentation.
* Add autodoc and autosummary * Add API page to docs * Update poetry lock and pyproject.toml * Add SessionManager to __init__.py exports * Fix docstring issues with robinhood.py * Add examples to SessionManager * Add docs to SessionManager * Configure mypy local run * Ignore type hints on trade_history_downloader (temporary) * Remove autologin from file feature, explicit is better than implicit * Add flake8-docstrings
1 parent 49e61c3 commit 7430f18

16 files changed

+862
-494
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ repos:
2525
rev: 3.7.9
2626
hooks:
2727
- id: flake8
28+
additional_dependencies: ['flake8-docstrings']
2829
- repo: https://github.com/pre-commit/mirrors-mypy
2930
rev: v0.770
3031
hooks:

docs/api.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.. _api:
2+
3+
API Reference
4+
=============
5+
6+
.. currentmodule:: pyrh
7+
.. autosummary::
8+
:toctree: stubs
9+
10+
Robinhood
11+
SessionManager
12+
exceptions

docs/conf.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
# sys.path.append(curr_file.joinpath("../..").resolve())
2020

2121

22-
def get_version():
22+
def get_version() -> str:
2323
import toml
2424

2525
toml_path = Path(__file__).parent.joinpath("..", "pyproject.toml")
@@ -45,7 +45,13 @@ def get_version():
4545
# Add any Sphinx extension module names here, as strings. They can be
4646
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
4747
# ones.
48-
extensions = ["sphinx.ext.autodoc", "sphinx.ext.napoleon", "sphinx.ext.intersphinx"]
48+
extensions = [
49+
"sphinx.ext.autodoc",
50+
"sphinx.ext.napoleon",
51+
"sphinx.ext.intersphinx",
52+
"autodocsumm",
53+
"sphinx_autodoc_typehints",
54+
]
4955

5056
# Add any paths that contain templates here, relative to this directory.
5157
templates_path = ["_templates"]
@@ -75,3 +81,7 @@ def get_version():
7581
intersphinx_mapping = {
7682
"requests": ("https://requests.readthedocs.io/en/master/", None),
7783
}
84+
85+
# Autodoc
86+
autodoc_default_flags = ["members"]
87+
autosummary_generate = True

docs/index.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ Developers
99

1010
developers
1111

12+
API
13+
###
14+
15+
.. toctree::
16+
:maxdepth: 3
17+
18+
api
19+
20+
1221
Changelog
1322
#########
1423
.. toctree::

docs/stubs/pyrh.Robinhood.rst

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
pyrh.Robinhood
2+
==============
3+
4+
.. currentmodule:: pyrh
5+
6+
.. autoclass:: Robinhood
7+
8+
9+
.. automethod:: __init__
10+
11+
12+
.. rubric:: Methods
13+
14+
.. autosummary::
15+
16+
~Robinhood.__init__
17+
~Robinhood.adjusted_equity_previous_close
18+
~Robinhood.adjusted_previous_close
19+
~Robinhood.ask_price
20+
~Robinhood.ask_size
21+
~Robinhood.auth_method
22+
~Robinhood.bid_price
23+
~Robinhood.bid_size
24+
~Robinhood.cancel_order
25+
~Robinhood.dividends
26+
~Robinhood.equity
27+
~Robinhood.equity_previous_close
28+
~Robinhood.excess_margin
29+
~Robinhood.extended_hours_equity
30+
~Robinhood.extended_hours_market_value
31+
~Robinhood.fundamentals
32+
~Robinhood.generate_device_token
33+
~Robinhood.get_account
34+
~Robinhood.get_fundamentals
35+
~Robinhood.get_historical_quotes
36+
~Robinhood.get_mfa_token
37+
~Robinhood.get_news
38+
~Robinhood.get_open_orders
39+
~Robinhood.get_option_chainid
40+
~Robinhood.get_option_market_data
41+
~Robinhood.get_option_marketdata
42+
~Robinhood.get_option_quote
43+
~Robinhood.get_options
44+
~Robinhood.get_popularity
45+
~Robinhood.get_quote
46+
~Robinhood.get_quote_list
47+
~Robinhood.get_stock_marketdata
48+
~Robinhood.get_tickers_by_tag
49+
~Robinhood.get_url
50+
~Robinhood.instrument
51+
~Robinhood.instruments
52+
~Robinhood.investment_profile
53+
~Robinhood.last_core_equity
54+
~Robinhood.last_core_market_value
55+
~Robinhood.last_trade_price
56+
~Robinhood.last_updated_at
57+
~Robinhood.last_updated_at_datetime
58+
~Robinhood.login
59+
~Robinhood.login_required
60+
~Robinhood.logout
61+
~Robinhood.market_value
62+
~Robinhood.options_owned
63+
~Robinhood.order_history
64+
~Robinhood.place_buy_order
65+
~Robinhood.place_limit_buy_order
66+
~Robinhood.place_limit_sell_order
67+
~Robinhood.place_market_buy_order
68+
~Robinhood.place_market_sell_order
69+
~Robinhood.place_order
70+
~Robinhood.place_sell_order
71+
~Robinhood.place_stop_limit_buy_order
72+
~Robinhood.place_stop_limit_sell_order
73+
~Robinhood.place_stop_loss_buy_order
74+
~Robinhood.place_stop_loss_sell_order
75+
~Robinhood.portfolios
76+
~Robinhood.positions
77+
~Robinhood.previous_close
78+
~Robinhood.previous_close_date
79+
~Robinhood.print_quote
80+
~Robinhood.print_quotes
81+
~Robinhood.quote_data
82+
~Robinhood.quotes_data
83+
~Robinhood.relogin_oauth2
84+
~Robinhood.securities_owned
85+
~Robinhood.submit_buy_order
86+
~Robinhood.submit_sell_order
87+
~Robinhood.symbol
88+
~Robinhood.user
89+
90+
91+
92+
93+
94+
.. rubric:: Attributes
95+
96+
.. autosummary::
97+
98+
~Robinhood.auth_token
99+
~Robinhood.client_id
100+
~Robinhood.headers
101+
~Robinhood.password
102+
~Robinhood.refresh_token
103+
~Robinhood.session
104+
~Robinhood.username

docs/stubs/pyrh.SessionManager.rst

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
pyrh.SessionManager
2+
===================
3+
4+
.. currentmodule:: pyrh
5+
6+
.. autoclass:: SessionManager
7+
8+
9+
.. automethod:: __init__
10+
11+
12+
.. rubric:: Methods
13+
14+
.. autosummary::
15+
16+
~SessionManager.__init__
17+
~SessionManager.from_json
18+
~SessionManager.get
19+
~SessionManager.login
20+
~SessionManager.logout
21+
~SessionManager.post
22+
~SessionManager.to_json
23+
24+
25+
26+
27+
28+
.. rubric:: Attributes
29+
30+
.. autosummary::
31+
32+
~SessionManager.authenticated
33+
~SessionManager.login_set

docs/stubs/pyrh.exceptions.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
pyrh.exceptions
2+
===============
3+
4+
.. automodule:: pyrh.exceptions
5+
6+
7+
8+
9+
10+
11+
12+
13+
14+
15+
16+
.. rubric:: Exceptions
17+
18+
.. autosummary::
19+
20+
AuthenticationError
21+
InvalidInstrumentId
22+
InvalidOptionId
23+
InvalidTickerSymbol
24+
LoginFailed
25+
RobinhoodException

poetry.lock

Lines changed: 20 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ python-dateutil = "^2.8"
3232
sphinx = { version = "^2.4.4", optional = true }
3333
sphinx-autodoc-typehints = { version = "^1.10.3", optional = true }
3434
sphinx_rtd_theme = { version = "^0.4.3", optional = true }
35+
autodocsumm = { version = "^0.1.13", optional = true }
3536
toml = { version = "^0.10.0", optional = true }
3637

3738
[tool.poetry.dev-dependencies]
@@ -55,7 +56,7 @@ xdoctest = "^0.11.0"
5556
towncrier = "^19.2.0"
5657

5758
[tool.poetry.extras]
58-
doc = ["sphinx", "sphinx_rtd_theme", "sphinx-autodoc-typehints"]
59+
doc = ["sphinx", "sphinx-autodoc-typehints", "sphinx_rtd_theme", "autodocsumm", "toml"]
5960

6061
[tool.black]
6162
include = '\.pyi?$'

pyrh/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from pyrh import exceptions
44
from pyrh.robinhood import Robinhood
5+
from pyrh.sessionmanager import SessionManager
56

67

7-
__all__ = ["Robinhood", "exceptions"]
8+
__all__ = ["Robinhood", "SessionManager", "exceptions"]

pyrh/cache.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Project config/cache files"""
1+
"""Project config/cache files."""
22

33
from pathlib import Path
44

0 commit comments

Comments
 (0)