An unofficial wrapper for the TradeStation API.
Project description
ts-api
An unofficial Python wrapper for the TradeStation API.
Description • Installation • Usage • Features • Contributing • Credits • License
Description
ts-api is an unofficial wrapper for the TradeStation API. It aims to be as light and unopinionated as possible, offering an elegant programmatic interface over each endpoint. Notable functionality includes:
- Login and authentication
- MarketData, Brokerage, and Order Execution endpoints
- Options chains
- Trades and trade management
- Account info and preferences
ts-api is very much a work in progress and is currently not feature complete. See the Issues to make a suggestion.
In-flight features include:
- Streaming Client endpoints
- Helpers for complicated dictionary request endpoints
Why ts-api?
ts-api has two core goals:
- Simplify the OAuth authentication procedure. This includes initial registration, refresh tokens, and automatic re-authorization of access tokens
- Be as lightweight as possible. ts-api takes in the base datatypes and returns the raw responses. No heavy logic or validation. Optional assistance with building orders and complex order groups is in the roadmap for this rather complex task.
Installation
# Install ts-api
pip install ts-api
Usage
# Import the TradeStation auth package
import ts.auth as a
# Establish your client
client = a.easy_client("key", "secret", "redirect")
# Call your endpoint
account = client.user_accounts("user_id")
Features
Currently ts-api supports all non-streaming routes found in the TradeStation API Specification. Details for each route can be found below.
Documentation for Supported API Endpoints
All URIs are relative to https://api.tradestation.com
Class | Method | HTTP request | Description |
---|---|---|---|
BrokerageApi | get_accounts | GET /v3/brokerage/accounts | Get Accounts |
BrokerageApi | get_balances | GET /v3/brokerage/accounts/{accounts}/balances | Get Balances |
BrokerageApi | get_balances_bod | GET /v3/brokerage/accounts/{accounts}/bodbalances | Get Balances BOD |
BrokerageApi | get_historical_orders | GET /v3/brokerage/accounts/{accounts}/historicalorders | Get Historical Orders |
BrokerageApi | get_orders | GET /v3/brokerage/accounts/{accounts}/orders | Get Orders |
BrokerageApi | get_positions | GET /v3/brokerage/accounts/{accounts}/positions | Get Positions |
BrokerageApi | get_wallets | GET /v3/brokerage/accounts/{account}/wallets | Get Wallets |
MarketDataApi | get_bars | GET /v3/marketdata/barcharts/{symbol} | Get Bars |
MarketDataApi | get_crypto_symbol_names | GET /v3/marketdata/symbollists/cryptopairs/symbolnames | Get Crypto Symbol Names |
MarketDataApi | get_option_expirations | GET /v3/marketdata/options/expirations/{underlying} | Get Option Expirations |
MarketDataApi | get_option_risk_reward | POST /v3/marketdata/options/riskreward | Get Option Risk Reward |
MarketDataApi | get_option_spread_types | GET /v3/marketdata/options/spreadtypes | Get Option Spread Types |
MarketDataApi | get_option_strikes | GET /v3/marketdata/options/strikes/{underlying} | Get Option Strikes |
MarketDataApi | get_quote_snapshots | GET /v3/marketdata/quotes/{symbols} | Get Quote Snapshots |
MarketDataApi | get_symbol_details | GET /v3/marketdata/symbols/{symbols} | Get Symbol Details |
OrderExecutionApi | cancel_order | DELETE /v3/orderexecution/orders/{orderID} | Cancel Order |
OrderExecutionApi | confirm_group_order | POST /v3/orderexecution/ordergroupconfirm | Confirm Group Order |
OrderExecutionApi | confirm_order | POST /v3/orderexecution/orderconfirm | Confirm Order |
OrderExecutionApi | get_activation_triggers | GET /v3/orderexecution/activationtriggers | Get Activation Triggers |
OrderExecutionApi | place_group_order | POST /v3/orderexecution/ordergroups | Place Group Order |
OrderExecutionApi | place_order | POST /v3/orderexecution/orders | Place Order |
OrderExecutionApi | replace_order | PUT /v3/orderexecution/orders/{orderID} | Replace Order |
OrderExecutionApi | routes | GET /v3/orderexecution/routes | Get Routes |
Not-yet Supported API Endpoints
All URIs are relative to https://api.tradestation.com
Class | Method | HTTP request | Description |
---|---|---|---|
BrokerageApi | stream_orders | GET /v3/brokerage/stream/accounts/{accountIds}/orders | Stream Orders |
BrokerageApi | stream_orders_by_order_id | GET /v3/brokerage/stream/accounts/{accountIds}/orders/{ordersIds} | Stream Orders by Order Id |
BrokerageApi | stream_positions | GET /v3/brokerage/stream/accounts/{accountIds}/positions | Stream Positions |
BrokerageApi | stream_wallets | GET /v3/brokerage/stream/accounts/{account}/wallets | Stream Wallets |
MarketDataApi | get_option_chain | GET /v3/marketdata/stream/options/chains/{underlying} | Stream Option Chain |
MarketDataApi | get_option_quotes | GET /v3/marketdata/stream/options/quotes | Stream Option Quotes |
MarketDataApi | stream_bars | GET /v3/marketdata/stream/barcharts/{symbol} | Stream Bars |
MarketDataApi | stream_market_depth_aggregates | GET /v3/marketdata/stream/marketdepth/aggregates/{symbol} | Stream Market Depth Aggregates |
MarketDataApi | stream_market_depth_quotes | GET /v3/marketdata/stream/marketdepth/quotes/{symbol} | Stream Market Depth Quotes |
MarketdataApi | search_symbols | GET /v2/data/symbols/search/{criteria} | Search for Symbols |
MarketdataApi | suggestsymbols | GET /v2/data/symbols/suggest/{text} | Suggest Symbols |
MarketDataApi | get_quote_change_stream | GET /v3/marketdata/stream/quotes/{symbols} | Stream Quotes |
Contributing
Start contributing right now
Open an issue
If you've found a problem, you can open an issue!
Solve an issue
If you have a solution to one of the open issues, you will need to fork the repository and submit a pull request.
Credits
Big thanks to the great people on Discord. You know who you are.
License
GitHub @pattertj
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ts_api-0.2.3.tar.gz
.
File metadata
- Download URL: ts_api-0.2.3.tar.gz
- Upload date:
- Size: 18.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.4 Darwin/22.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d5c8a86a8047ffdaf2b702a2ff3c62ce7b6034cfe9c32adfb45ff55f0c62af8 |
|
MD5 | 7b8804564ebe75beddb6a47244f8d049 |
|
BLAKE2b-256 | a446641ffde5a0695f1031598f73d23eef996eef65e3b95f602fb9a85558c058 |
File details
Details for the file ts_api-0.2.3-py3-none-any.whl
.
File metadata
- Download URL: ts_api-0.2.3-py3-none-any.whl
- Upload date:
- Size: 17.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.4 Darwin/22.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 73cde1ab34ec3e4b861a9107344f3ce30f9c04036606f3969af246f5e2f9a58e |
|
MD5 | f901c724b7b6cfc4695cf885be97a38c |
|
BLAKE2b-256 | 4499a49e3419d3a441ba0365381a5cb5076cf8730869c45738f0f7ab310dfbbc |