跳转到主要内容

eTrade API包装器

项目描述

pyetrade (Python E-Trade API包装器)

PyPI PyPI PyPI Build Status codecov

完成

  • 授权API (OAuth)

    • get_request_token
    • get_access_token
    • renew_access_token
    • revoke_access_token
  • 警报API

    • list_alerts
    • list_alert_details
    • delete_alert
  • 账户API

    • list_accounts
    • get_account_balance
    • get_account_portfolio
    • get_portfolio_position_lot
    • list_transactions
    • list_transaction_details
  • 订单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
  • 市场API

    • look_up_product
    • get_quote
    • get_option_chains
    • get_option_expire_date

安装

pip install pyetrade

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

示例用法

创建OAuth令牌

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)

然后在示例代码中

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())

文档

PyEtrade文档

为pyetrade做出贡献

ETrade API文档

开发设置

  • Fork pyetrade
  • 设置开发环境
make init
make devel

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
  • 代码检查 (运行分析 - pre-commit-config)
make analysis
  • 测试 (覆盖率 >= 90%)
make test
  • 推送更改

    • 将更改推送到您的分叉仓库上的分支
  • 创建拉取请求

    • 在pyetrade上打开拉取请求,并将您的分叉作为更改的源

项目详情


下载文件

下载适用于您平台的应用程序文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源分布

pyetrade-2.1.0.tar.gz (34.6 kB 查看散列值)

上传时间

支持者

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面