Skip to main content

wetrade: An E-Trade Python library built for automated stock trading

wetrade overview

wetrade is an unofficial E-Trade API library initially created for use in headless trading systems. It provides a lot of helpful built-in functionality, and was designed to be flexible and extensible and to accommodate a wide variety of stock trading needs.

Features include:

  • Automated login and authentication supporting 2FA

  • Easy setup and configuration

  • Quotes, account info, and custom ordering

  • Callback functionality for order and quote updates

  • Convenient tools to check and localize trading hours

  • Easy deployment with Docker template

  • Robust logging with optional Google Cloud integration

wetrade documentation

For our full documentation, check out: https://wetrade.readthedocs.io/en/latest/.

Getting started with wetrade

In order to access the E-Trade API, you’ll need to follow the 4 steps detailed on the E-Trade developer getting started page then request an API key through the linked page. It’s also recommended that you enable real-time data in the the subscription center so that you don’t receive delayed quotes.

Install wetrade:

It’s a good idea to create a new virtual environment for a new Python project

# create venv
python3 -m venv venv
# enter venv
source venv/bin/activate

We can then install wetrade into our venv. For automatic login, we’ll also need to install our browser.

pip install wetrade
playwright install firefox

Next, you’ll get going in no time using our automated new project script!

python -m wetrade new-project

You’ll now see a handful of files in your project directory including a settings.py file where you’ll enter your user and API info and have the option to configure various wetrade settings.

In addition to settings.py , we’ve also created a Dockerfile for easy deployment as well as a requirements.txt and an example file main.py which demonstrates some basic wetrade usage:

main.py

from wetrade.api import APIClient
from wetrade.account import Account
from wetrade.quote import Quote
from wetrade.order import LimitOrder
from wetrade.utils import setup_cloud_logging


def main():
  # Setup cloud logging (optional) and APIClient
  setup_cloud_logging()
  client = APIClient()

  # Check out your account
  account = Account(client=client)
  print('My Account Key: ', account.account_key)
  print('My Balance: ', account.check_balance())

  # Get a stock quote
  quote = Quote(client=client, symbol='IBM')
  print(f'Last {quote.symbol} Quote Price: ', quote.get_last_price())

  # Place some orders and stuff
  order1 = LimitOrder(
      client = client,
      account_key = account.account_key,
      symbol = 'NVDA',
      action = 'BUY',
      quantity = 1,
      price = 50.00)
  order1.place_order()
  order1.run_when_status(
      'CANCELLED',
      func = print,
      func_args = ['Test message'])

  order2 = LimitOrder(
      client = client,
      account_key = account.account_key,
      symbol = 'NFLX',
      action = 'BUY',
      quantity = 1,
      price = 50.00)
  order2.place_order()
  order2.run_when_status(
      'CANCELLED',
      order1.cancel_order)

  order2.cancel_order()


if __name__ == '__main__':
  main()

Other info

wetrade was initially designed to run headlessly and has built-in handling for most expected brokerage, server, and API errors. This and the majority of other wetrade functionality is entirely optional to use, and our modular structure allows you to utilize as much or as little of the library as you’d like. Our goal is to consistently add new functionality to support additional use cases. If you have any comments or suggestions for new features, don’t hesitate to create an issue or reach out to: wetrade.inbox@gmail.com. We’ve also created a Discord server where you can get help or just chat with other wetrade users.

Disclaimer: wetrade is an unofficial API library and comes with no warranty of any kind. It is in no way endorsed by or affiliated with E*TRADE Financial or any associated organization. Make sure to read and understand the terms of service of the underlying API before using this package. The authors accept no responsibility for any damage that might stem from use of this package. See the LICENSE file for more details.

Metadata

Release files for wetrade 1.0.6

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

Source distribution (sdist)

Source distribution for wetrade 1.0.6
File Size Uploaded
wetrade-1.0.6.tar.gz 32.1 kB Details

Built distribution (wheel)

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

Total release size: 74.1 kB

Release files / wetrade-1.0.6.tar.gz

Download URL wetrade-1.0.6.tar.gz
Size 32.1 kB
Tags Source
SHA-256 checksum
How to use checksums
18032434f3f8825e3944462a2ce5f243424b0629c2ce79cdf09655bb7654b624
BLAKE2b-256 checksum
How to use checksums
2d3bb1882d770b67a9c543b3ce57576c0c4b7ded15d6608ea261925c2b2a1777
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release files / wetrade-1.0.6-py3-none-any.whl

Download URL wetrade-1.0.6-py3-none-any.whl
Size 42.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
57fe58c81ca3c65d13b7f8cacfe8d9144cbba3768c62c4b2c2bf04b0a5850c00
BLAKE2b-256 checksum
How to use checksums
df570216a6eca918467fc9b305fbef07f7ff9363580fa860f9e967aa23ab8bcc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release history Release notifications | RSS feed

This release

1.0.6 This release

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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