Skip to content

New feature for robot.py #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions pyrobot/robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,45 @@ def delete_trade(self, index: int) -> None:

if index in self.trades:
del self.trades[index]


def grab_any_live_quote(self, symbol: str) -> dict:
"""Grabs the current quote for any symbol.

Makes a call to the TD Ameritrade Get Quotes endpoint with the
symbol you send as an argument. Returns a dictionary.

Usage:
----
>>> trading_robot = PyRobot(
client_id=CLIENT_ID,
redirect_uri=REDIRECT_URI,
credentials_path=CREDENTIALS_PATH
)

>>> current_quote = trading_robot.grab_any_live_quote(symbol = 'MSFT')
>>> current_quote
{
"MSFT": {
"assetType": "EQUITY",
"assetMainType": "EQUITY",
"cusip": "594918104",
...
"regularMarketPercentChangeInDouble": 0,
"delayed": true
}
}

Returns:
----
dict -- A dictionary containing the quote for the symbol provided.

"""

# Grab the quote.
quote = self.session.get_quotes(symbol)


def grab_current_quotes(self) -> dict:
"""Grabs the current quotes for all positions in the portfolio.

Expand Down