Skip to content

An unofficial wrapper for the TradeStation API.

License

Notifications You must be signed in to change notification settings

pattertj/ts-api

Repository files navigation


ts-api

PyPI - Downloads

An unofficial Python wrapper for the TradeStation API.

DescriptionInstallationUsageFeaturesContributingCreditsLicense

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:

  1. Simplify the OAuth authentication procedure. This includes initial registration, refresh tokens, and automatic re-authorization of access tokens
  2. 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

MIT License


GitHub @pattertj

Releases

No releases published

Sponsor this project

 

Languages