GithubHelp home page GithubHelp logo

jessecooper / pyetrade Goto Github PK

View Code? Open in Web Editor NEW
194.0 32.0 94.0 442 KB

Python E-Trade API Wrapper

License: GNU General Public License v3.0

Makefile 0.39% Python 99.61%
etrade market stock api-client python

pyetrade's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.