Skip to content

tastyware/tradestation

Repository files navigation

Docs PyPI Downloads Release)

tradestation

A simple, unofficial, sync/async SDK for Tradestation built on their public API. This will allow you to create trading algorithms for whatever strategies you may have quickly and painlessly in Python.

Features

  • Up to 10x less code than using the API directly
  • Sync/async functions for all endpoints
  • Powerful websocket implementation for account alerts and data streaming, with support for auto-reconnection and reconnection callbacks
  • 100% typed, with Pydantic models for all JSON responses from the API
  • 95%+ unit test coverage
  • Comprehensive documentation
  • Utility functions for timezone calculations, futures monthly expiration dates, and more

Note

Do you use Tastytrade? We also built a SDK for Tastytrade users, with many of the same features!

Installation

$ pip install tradestation

Initial setup

Tradestation uses OAuth for secure authentication to the API. In order to obtain access tokens, you need to authenticate with OAuth 2's authorization code flow, which requires a local HTTP server running to handle the callback. Fortunately, the SDK makes doing this easy:

from tradestation.oauth import login
login()

This will let you authenticate in your local browser. Fortunately, this only needs to be done once, as afterwards you can use the refresh token to obtain new access tokens indefinitely.

Creating a session

A session object is required to authenticate your requests to the Tradestation API. You can create a simulation session by passing is_test=True.

from tradestation import Session
session = Session('api_key', 'secret_key', 'refresh_token')

About

An unofficial, sync/async Python SDK for TradeStation!

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published