Giter VIP home page Giter VIP logo

tradestation-python-api's Introduction

Tradestation Python API

A Python Client library for the TradeStation API.

Table of Contents

Overview

The unofficial Python API client library for TradeStation allows individuals with TradeStation accounts to manage trades, pull historical and real-time data, manage their accounts, create and modify orders all using the Python programming language.

To learn more about the TradeStation API, please refer to the official documentation.

What's in the API

  • Authentication - access tokens, refresh tokens, request authentication.
  • Accounts & Trading
  • Symbols
  • Index
  • Orders
  • Paper Trading
  • Quotes
  • Transaction History

Requirements

The following requirements must be met to use this API:

  • A TradeStation account, you'll need your account password and account number to use the API.
  • A TradeStation Developer API Key
  • A Redirect URI, sometimes called Redirect URL
  • Python 3.8 or later.

API Key and Credentials

Each TradeStation API request requires a TradeStation Developer API Key, a consumer ID, an account password, an account number, and a redirect URI. API Keys, consumer IDs, and redirect URIs are generated from the TradeStation developer portal. To set up and create your TradeStation developer account, please refer to the official documentation.

Additionally, to authenticate yourself using this library, you will need to provide your account number and password for your main TradeStation account.

Important: Your account number, an account password, consumer ID, and API key should be kept secret.

Installation

pip install -e .

Usage

This example demonstrates how to login to the API and demonstrates sending a request using the quotes, and stream_bars_start_date endpoint, using your API key.

# Import the client
from ts.client import TradeStationClient

# Create the Client.
ts_client = TradeStationClient(
    username="USERNAME",
    client_id="CLIENT_ID",
    client_secret="CLIENT_SECRET",
    redirect_uri="REDIRECT_URI",
    paper_trading="PAPER_TRADING"
)

# Get quotes for Oil Futures.
ts_client.quotes(symbols=['@CL'])

# Stream quotes for Amazon.
ts_client.stream_quotes_changes(symbols=['AMZN'])

# Stream bars for a certain date.
ts_client.stream_bars_start_date(
    symbol='AMZN',
    interval=5,
    unit='Minute',
    start_date='02-25-2020',
    session='USEQPreAndPost'
)

Features

Authentication Workflow Support

Automatically will handle the authentication workflow for new users, returning users, and users with expired tokens (refresh token or access token).

Request Validation

For certain requests, in a limited fashion, it will help validate your request when possible. For example, when using the get_bars endpoint, it will automatically validate that the market you're requesting data from is one of the valid options.

Documentation and Resources

Support these Projects

Patreon: Help support this project and future projects by donating to my Patreon Page. I'm always looking to add more content for individuals like yourself, unfortuantely some of the APIs I would require me to pay monthly fees.

YouTube: If you'd like to watch more of my content, feel free to visit my YouTube channel Sigma Coding.

Hire Me: If you have a project, you think I can help you with feel free to reach out at [email protected]

tradestation-python-api's People

Contributors

areed1192 avatar ecourreges-orange avatar

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.