Skip to main content

pyetrade (Python E-Trade API Wrapper)

PyPI PyPI PyPI Build Status codecov

Completed

  • Authorization API (OAuth)

    • get_request_token
    • get_access_token
    • renew_access_token
    • revoke_access_token
  • Alerts API

    • list_alerts
    • list_alert_details
    • delete_alert
  • Accounts API

    • list_accounts
    • get_account_balance
    • get_account_portfolio
    • get_portfolio_position_lot
    • list_transactions
    • list_transaction_details
  • Order API

    • list_orders
    • list_order_details
    • find_option_orders
    • preview_equity_order
    • change_preview_equity_order
    • place_equity_order
    • place_changed_equity_order
    • place_option_order
    • place_changed_option_order
    • cancel_order
  • Market API

    • look_up_product
    • get_quote
    • get_option_chains
    • get_option_expire_date

Install

pip install pyetrade

OR

git clone https://github.com/jessecooper/pyetrade.git
cd pyetrade
sudo make init
sudo make install

Example Usage

To create the OAuth tokens:

import pyetrade

consumer_key = "<CONSUMER_KEY>"
consumer_secret = "<SECRET_KEY>"

oauth = pyetrade.ETradeOAuth(consumer_key, consumer_secret)
print(oauth.get_request_token())  # Use the printed URL

verifier_code = input("Enter verification code: ")
tokens = oauth.get_access_token(verifier_code)

print(tokens)

And then on the example code:

import pyetrade

consumer_key = "<CONSUMER_KEY>"
consumer_secret = "<SECRET_KEY>"
tokens = {'oauth_token': '<TOKEN FROM THE SCRIPT ABOVE>',
          'oauth_token_secret': '<TOKEN FROM THE SCRIPT ABOVE>'}

accounts = pyetrade.ETradeAccounts(
    consumer_key,
    consumer_secret,
    tokens['oauth_token'],
    tokens['oauth_token_secret']
)

print(accounts.list_accounts())

Documentation

PyEtrade Documentation

Contribute to pyetrade

ETrade API Docs

Development Setup:

  • Fork pyetrade
  • Setup development environment
make init
make devel

OR

pip install -r requirements.txt
pip install -r requirements_dev.txt
pip install -e .
pre-commit install --hook-type pre-commit --hook-type pre-push --install-hooks -t post-checkout -t post-merge
  • Lint (Run analysis - pre-commit-config)
make analysis
  • Test (Coverage >= 90%)
make test
  • Push Changes

    • Push changes to a branch on your forked repo
  • Create pull request

    • Open a pull request on pyetrade and put your fork as the source of your changes

Release files for pyetrade 2.1.1

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

Source distribution (sdist)

Source distribution for pyetrade 2.1.1
File Size Uploaded
pyetrade-2.1.1.tar.gz 34.6 kB Details

Release files / pyetrade-2.1.1.tar.gz

Download URL pyetrade-2.1.1.tar.gz
Size 34.6 kB
Tags Source
SHA-256 checksum
How to use checksums
b231e92c0e1909facc1545e286bb735066bd06c3829384e7da636e42ac8d5959
BLAKE2b-256 checksum
How to use checksums
ecccd7e99f3c5baf4d987e08b41153b0df63661c528d8b0fd0164168fce08127
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.7

Release history Release notifications | RSS feed

This release

2.1.1 This release

1 release file

2.1.0

1 release file

2.0.1

1 release file

1.4.1

1 release file

1.3.6

1 release file

1.3.4

1 release file

1.2.2

1 release file

1.2.1

1 release file

1.2.0

1 release file

1.1.0

1 release file

1.0.0

1 release file

0.8.0

1 release file

0.7.0

1 release file

0.6.0

1 release file

0.5.0

1 release file

0.3.0

1 release file

0.2.0

1 release file

0.1.3

1 release file

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