Skip to content

Instantly share code, notes, and snippets.

@andrewkim316
Last active August 28, 2019 16:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewkim316/e4356308629e59a2aa8451612f376301 to your computer and use it in GitHub Desktop.
Save andrewkim316/e4356308629e59a2aa8451612f376301 to your computer and use it in GitHub Desktop.
# 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