Last active
August 28, 2019 16:59
-
-
Save andrewkim316/e4356308629e59a2aa8451612f376301 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Gets basic account info. Takes no arguments. | |
@app.route("/account_info", methods=["POST"]) | |
def account_info_handler(): | |
args = request.form.get("text").split(" ") | |
if(len(args) != 0 and not (len(args) == 1 and args[0].strip() == "")): | |
return WRONG_NUM_ARGS | |
try: | |
account = api.get_account() | |
text = f'Account info...\nBuying power = {account.buying_power}\nEquity = {account.equity}\nPortfolio value = {account.portfolio_value}\nShorting enabled? = {account.shorting_enabled}' | |
return text | |
except Exception as e: | |
return f"ERROR: {str(e)}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment