Skip to content

Commit

Permalink
Add Schema loading capabilities to SessionManager get and post
Browse files Browse the repository at this point in the history
* Remove typing-extensions since it is no longer used
* move doc --> docs in pyproject.toml
* Re-factor SessionManager to leverage get / post method automatic
  Schema building.
* Add beginning of portfolio model.
  • Loading branch information
adithyabsk committed Apr 14, 2020
1 parent 7ccb517 commit 963b2ed
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 136 deletions.
76 changes: 38 additions & 38 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ python-dateutil = "^2.8"
pytz = "^2019.3"
requests = "^2.23"
yarl = "^1.4.2"
typing-extensions = "^3.7.4"
certifi = "^2020.4.5"

[tool.poetry.dev-dependencies]
Expand Down Expand Up @@ -67,7 +66,7 @@ xdoctest = "^0.11.0"
towncrier = "^19.2.0"

[tool.poetry.extras]
doc = ["sphinx", "sphinx-autodoc-typehints", "sphinx_rtd_theme", "autodocsumm", "tomlkit"]
docs = ["sphinx", "sphinx-autodoc-typehints", "sphinx_rtd_theme", "autodocsumm", "tomlkit"]

[tool.black]
include = '\.pyi?$'
Expand All @@ -86,7 +85,7 @@ exclude = '''

[tool.isort]
known_first_party = 'robinhood'
known_third_party = ["certifi", "dateutil", "freezegun", "marshmallow", "pytest", "pytz", "requests", "requests_mock", "typing_extensions", "yarl"]
known_third_party = ["certifi", "dateutil", "freezegun", "marshmallow", "pytest", "pytz", "requests", "requests_mock", "yarl"]
multi_line_output = 3
lines_after_imports = 2
force_grid_wrap = 0
Expand Down
16 changes: 13 additions & 3 deletions pyrh/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
"""pyrh models and schemas."""

from .oauth import Challenge, OAuth
from .sessionmanager import SessionManager
from .oauth import Challenge, ChallengeSchema, OAuth, OAuthSchema
from .portfolio import PortfolioSchema
from .sessionmanager import SessionManager, SessionManagerSchema


__all__ = ["OAuth", "Challenge", "SessionManager"]
__all__ = [
"OAuth",
"OAuthSchema",
"Challenge",
"ChallengeSchema",
"SessionManager",
"SessionManagerSchema",
"Portfolio",
"PortfolioSchema",
]
38 changes: 38 additions & 0 deletions pyrh/models/portfolio.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""Current portfolio."""

from marshmallow import fields

from .base import BaseModel, BaseSchema


class Portfolio(BaseModel):
"""Robinhood portfolio data class."""

pass


class PortfolioSchema(BaseSchema):
"""Robinhood portfolio schema data loader."""

__model__ = Portfolio

url = fields.URL()
account = fields.URL()
start_date = fields.NaiveDateTime()
market_value = fields.Float()
equity = fields.Float()
extended_hours_market_value = fields.Float()
extended_hours_equity = fields.Float()
extended_hours_portfolio_equity = fields.Float()
last_core_market_value = fields.Float()
last_core_equity = fields.Float()
last_core_portfolio_equity = fields.Float()
excess_margin = fields.Float()
excess_maintenance = fields.Float()
excess_margin_with_uncleared_deposits = fields.Float()
portfolio_equity_previous_close = fields.Float()
adjusted_equity_previous_close = fields.Float()
adjusted_portfolio_equity_previous_close = fields.Float()
withdrawable_amount = fields.Float()
unwithdrawable_deposits = fields.Float()
unwithdrawable_grants = fields.Float()
Loading

0 comments on commit 963b2ed

Please sign in to comment.