Skip to main content

pyhood

pyhood logo

Let your AI agent work your Robinhood account, with a preview before every order.

CI PyPI Docs Python 3.10+ License: MIT Security

pyhood lets an AI agent read your Robinhood account and place orders for you. You ask in plain language. The agent runs pyhood. Before anything is sent to Robinhood, you see exactly what it will be and say yes or no.

It works with any agent that can run commands on your computer.

pyhood is an unofficial client and is not affiliated with Robinhood. Use responsibly. This project is not financial advice.

What you can ask

Once it is set up, talk to your agent the way you would to a person:

You say What happens
"What do I own, and how is it doing?" It lists your positions with cost, value and profit or loss
"What did I buy this month?" It lists your orders, with what filled and at what price
"How much can I spend?" It reads your buying power
"What's in my Roth IRA?" It shows that account's positions
"When does Apple report earnings, and what do analysts think?" It gives the date, the ratings and the price targets
"Show me AAPL calls expiring next month" It shows the contracts near the stock's price, with bid, ask and delta
"Buy 10 shares of AAPL at $350 or better" It shows you a preview and waits for your yes
"Buy one of those $350 calls for $2.50" It shows you a preview and waits for your yes
"Sell my AAPL if it drops to $340" It previews a stop order and waits for your yes
"Sell my AAPL if it falls 10% from its high" It previews a trailing stop and waits for your yes
"Put $50 into Apple" It previews a $50 order and waits for your yes
"Move $500 to my bank" It previews the withdrawal and waits for your yes
"Buy $50 of bitcoin... how much is that?" then "buy 0.0008 BTC" It previews the order with Robinhood's fee and waits for your yes
"Cancel that order" It cancels it and tells you what happened
"Save my latest statement" It saves the PDF into a folder only you can read

Get started

There are three steps. Your agent does the first, you do the second.

1. Ask your agent to install it

Paste this into your agent:

Install pyhood for me. Follow the install steps in https://raw.githubusercontent.com/jamestford/pyhood/main/AGENTS.md

That file is written for AI agents. It tells yours to put pyhood in a folder of its own, ~/pyhood, to stop and hand you the login, and not to install anything else.

What the file tells your agent to do
  1. If ~/pyhood/bin/pyhood already exists, say so and skip the install.
  2. Check that uv is installed, and stop to ask you if it is not.
  3. Run uv venv --managed-python --python 3.14 ~/pyhood
  4. Run uv pip install --python ~/pyhood/bin/python pyhood
  5. Run ~/pyhood/bin/pyhood version to check it.
  6. Ask you to log in yourself. It must never ask for your password or type it.
  7. Run ~/pyhood/bin/pyhood verify, which reads live prices and changes nothing.
  8. Read ~/pyhood/AGENTS.md, the instructions that came with the install.

It is also told not to use pip, sudo or --break-system-packages, and not to install anything but pyhood. You can read the file yourself, or follow the same steps by hand.

The install creates one folder, ~/pyhood, with pyhood in it. uv is a free tool for installing Python programs (brew install uv on macOS). It also downloads a copy of Python for pyhood to run on, which it keeps in its own folder. Nothing is installed system-wide, and your other Python setups are not touched.

2. Log in yourself

Your agent will stop and ask you to run this in your own terminal:

~/pyhood/bin/pyhood setup login

It asks for your Robinhood username and password, then waits for you to approve the login in the Robinhood app on your phone. Your password is not stored and your agent never sees it. What is saved is a session, in ~/.pyhood/session.json, readable only by you. pyhood renews that session on its own, so you should rarely need to log in again.

Then tell your agent you are logged in.

3. Open your agent in the pyhood folder

From now on, start your agent in ~/pyhood:

cd ~/pyhood

The install put a file called AGENTS.md in that folder. Many agents read a file of that name when they start, and this one tells them how to use pyhood. There is nothing else to configure.

If your agent reads a different file, such as CLAUDE.md, or you want to work from another folder, put this one line in the file it does read:

pyhood is installed at ~/pyhood. Run `~/pyhood/bin/pyhood guide` before using it.

What an order looks like

You:    buy 1 share of F with a limit price of $5

Agent:  Here is the preview:

          Buy 1 F, limit $5.00, good for day
          Estimated cost:  $5.00
          F now:           $11.95 (bid $11.92, ask $11.95)
          Buying power:    $500.00

        Your limit is 58% below the current price, so this is unlikely
        to fill. Want me to place it?

You:    yes

Agent:  Placed. Buy 1 F at a $5.00 limit, status: queued.

You:    cancel that order

Agent:  Cancelled: buy 1 F, limit $5.00.

The agent did not work that preview out for itself. pyhood produced it, from your live account, and the agent passed it on.

How you stay in control

Every order and every transfer is previewed first. When the agent asks pyhood to buy or sell, pyhood sends nothing. It replies with what the order would be, what it would cost, the current price, and anything that looks wrong: a cost above your buying power, a sale of more than you hold, or a price far from the market.

An order can only be placed with a code from its preview. The preview ends with a short code. The order goes through only when the agent repeats the same request with that code. The code belongs to that exact order: change the stock, the amount or the price, and it stops working. So what gets placed is what you were shown.

Nothing is assumed. An order needs a price, or an explicit instruction to buy at the market. Options need every term spelled out. Orders last for the day unless you say otherwise.

You log in, not the agent. The agent never needs your password.

Cancelling is immediate. When you say cancel, it cancels. Getting out of an order should not take two steps.

What this does not protect against

These are guardrails against mistakes. They are not a lock.

  • An agent that ignores its instructions can still place an order. The code makes it produce a preview first. It does not force the agent to show you the preview or to wait for your answer. That part depends on the agent following the instructions pyhood gives it.
  • Your saved login is a file on your computer. An agent that can run commands can read it. In testing, a model that had been given no instructions printed that file to look at it.

So give this only to an agent you would trust with the account, and start with small orders.

What it covers

From your agent or the command line From Python
Positions, orders, buying power, quotes Yes Yes
IRA and other accounts Yes Yes
Price history, earnings dates, analyst ratings, news, movers Yes Yes
Dividends, transfer history, statements and tax forms Yes Yes
Watchlists Yes Yes
Option expirations and contracts Yes Yes
Buy and sell stock, including stop orders and trailing stops Yes, with a preview Yes
Buy and sell single options Yes, with a preview Yes
Cancel an order Yes Yes
Orders by dollar amount, and option spreads Yes, with a preview Yes
Crypto prices, holdings, and buying and selling Yes, with a preview Yes
Futures quotes, contracts, orders and profit and loss Yes Yes
Preview a futures order: margin, fees and whether Robinhood would accept it Yes Yes
Deposits and withdrawals to a linked bank Yes, with a preview Yes

Everything here is a command, so the agent rarely needs to write code. For something no command covers, such as a calculation across several results, it writes a short script, and pyhood guide python tells it how.

Futures can be read and previewed, but not traded. pyhood futures buy and sell show the margin an order ties up, its fees, and whether Robinhood would accept it, all as Robinhood reports them. They cannot place the order: pyhood has not seen the request that submits one, and will not guess at it with your money.

What has been run against Robinhood for real. Tests that pass against made-up responses are not proof, and three of the orders below were refused by Robinhood the first time they were sent, with every test passing. So here is what has actually been placed, by a local model, with a real account:

Placed for real, then cancelled Not placed yet
Buy and sell stock at a limit Any order in an IRA
Buy stock at market, and by dollar amount Selling an option
Stop orders, at market and with a limit A trailing stop that buys
A trailing stop that sells Selling crypto, and crypto at market
Buy an option to open A withdrawal, and cancelling a transfer
An option spread
Buy crypto at a limit
A deposit from a bank

Every read command has been run for real too, and so has saving a statement. The orders on the right go through the same code as those on the left, but until one has been sent, treat its first use as a test: start small, and far from the market price.

What it has been tested with: a local model, Qwen3.6 35B, running in the Pi agent. Given the one-line install request above and nothing else, it fetched the instructions and installed pyhood with no errors. Asked to buy, it previewed and waited.

Using it without an agent

Everything the agent does, you can do yourself. To type pyhood instead of ~/pyhood/bin/pyhood, link it into a folder on your PATH:

ln -s ~/pyhood/bin/pyhood ~/.local/bin/pyhood
pyhood positions             # what you hold, with profit and loss
pyhood orders                # orders from the last 30 days
pyhood buying-power          # cash available to trade with
pyhood quote AAPL MSFT       # current prices
pyhood options AAPL          # option expiration dates
pyhood earnings AAPL         # next earnings date
pyhood buy AAPL 10 --limit 350    # preview; add the code it prints to place it
pyhood cancel ORDER_ID       # cancel an open order

Add --json to any of the first six for exact values, and --account roth to work in another account. The command line page covers every command and option.

To upgrade pyhood later:

uv pip install --python ~/pyhood/bin/python --upgrade pyhood

For developers

pyhood is also a typed Python library, and the command line is a thin layer over it.

import pyhood
from pyhood.client import PyhoodClient

client = PyhoodClient(pyhood.login())  # uses the saved session; no credentials in code

quote = client.get_quote("AAPL")
print(f"AAPL: ${quote.price:.2f} ({quote.change_pct:+.1f}%)")

for position in client.get_positions():
    print(position.symbol, position.quantity, position.unrealized_pl)

Save that as script.py and run it with pyhood run script.py, which uses the Python pyhood is installed in. To add pyhood to a project that has its own environment, pip install pyhood there. It needs Python 3.10 or newer.

What sets it apart from other Robinhood libraries:

  • It stays logged in. After the first approved login, pyhood renews the session with a refresh token: no password, no approval prompt, nobody at the keyboard. Unattended scripts do not die when a session expires.
  • Typed results. Methods return dataclasses, not raw dictionaries. A value Robinhood does not send is None, never a made-up 0. A wrong field name raises an error that lists the right ones.
  • Checked against the live API. The tests mock Robinhood, so a script in the repository also runs every parser against a real account and reports any field Robinhood does not send. That audit has found and fixed more than a dozen fields that were silently empty.
  • Session stored as JSON, owner-only, not as a pickle.

Against robin_stocks and its maintained fork robin_stocks_v2:

Capability pyhood robin_stocks robin_stocks_v2
Command line an AI agent can drive, with order previews Yes No No
Silent session refresh without credentials Yes No No
JSON session storage Yes No, uses pickle Yes
IRA / retirement accounts Yes No No
Official Crypto Trading API Yes No No
Futures contracts and quotes Yes No Yes
Futures positions Yes No Stubbed
IPO access Yes No Yes
Typed dataclass responses Yes No Partial
Index options: SPX, NDX, VIX, RUT, XSP Yes Partial Yes
Minimum Python version 3.10 3.9 3.10

Moving from another library? There are function-by-function guides for robin_stocks and pyrh.

Documentation

Contributing

Contributions are welcome, especially reports of how pyhood behaves with different agents and models, endpoint coverage, and tests for behaviour verified against the live API.

Please do not open pull requests whose tests place real trades.

Acknowledgments

pyhood stands on the work of the community that mapped Robinhood's unofficial API:

License

MIT

Metadata

Release files for pyhood 0.22.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyhood 0.22.0
File Size Uploaded Provenance Actions
pyhood-0.22.0.tar.gz 214.2 kB With provenance Details for pyhood-0.22.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyhood 0.22.0
File Interpreter ABI Platform Actions
pyhood-0.22.0-py3-none-any.whl Python 3 none any Details for pyhood-0.22.0-py3-none-any.whl

Total release size: 334.6 kB

Release files / pyhood-0.22.0.tar.gz

Download URL pyhood-0.22.0.tar.gz
Size 214.2 kB
Tags Source
SHA-256 checksum
How to use checksums
0f1217bbbab6d11e989ee5512c5fc019c18eecdd3c703ec61bd7124eff19929a
BLAKE2b-256 checksum
How to use checksums
015fc98859e467d676cbd0285d01ed15716e61898cca0ddaf7b8ebf5148a596f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Release files / pyhood-0.22.0-py3-none-any.whl

Download URL pyhood-0.22.0-py3-none-any.whl
Size 120.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
283aa378124be3c09d1917fc924f7c7fea90c85ff88ea316edab5c50aaac5535
BLAKE2b-256 checksum
How to use checksums
1ba4df74c42c44b4d4730b570219b8a201756b2a71f85a0903348c330aea0731
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Security for pyhood 0.22.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pyhood-0.22.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.22.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page