Skip to main content

lumiwealth-tradier is a Python package that serves as a wrapper for the Tradier brokerage API. This package simplifies the process of making API requests, handling responses, and performing various trading and account management operations.

Project description

lumiwealth-tradier

lumiwealth-tradier is a Python package that serves as a wrapper for the Tradier brokerage API. This package simplifies the process of making API requests, handling responses, and performing various trading and account management operations.

The package was originally developed by data science graduate students at the University of Virginia.

Features

  • Account Management: Retrieve profile, balance, gain/loss, orders, and positions related to a trading account.
  • Trading: Place, modify, and cancel equity and option orders.
  • Market Data: Access real-time and historical market data for equities and options.
  • Options Data: Retrieve options chains, strikes, and expiration dates.

Installation

To install lumiwealth-tradier, you can use pip:

pip install lumiwealth-tradier

Hello World

Steps to get started:

  • Create an account with Tradier.com.

  • Grab Account Number and Access Token from your Tradier dashboard.

    • Log into Tradier > Preferences (gear icon) > API Access (left panel) > Sandbox Account Access (section).
  • Create a .env file in the appropriate working directory on your computer.

    • Launch text editor application.

    • Save the file as .env.

    • In the file, add the following lines, replacing the appropriate placeholder fields:
      tradier_acct=<YOUR_ACCOUNT_NUMBER_FROM_TRADIER_DASHBOARD>

      tradier_token=<YOUR_ACCESS_TOKEN_FROM_TRADIER_DASHBOARD>

  • Within the aforementioned working directory, initiate a new python session (interactive python, jupyter notebook, etc.).

  • To authenticate yourself, add the following lines of code to the top of your python script or jupyter notebook:

    import os, dotenv

    from lumiwealth_tradier import Tradier

    dotenv.load_dotenv()

    tradier_acct = os.getenv('tradier_acct')

    tradier_token = os.getenv('tradier_token')

  • To instantiate the class objects, use:
    tradier = Tradier(tradier_acct, tradier_token, is_paper=True) # is_paper=True for sandbox environment, if you have a real money account, set to False

Usage

This section provides example functionality of the existing codebase. Additional sample code demonstrating usage can be found in the /examples/ directory.

Account Management

  • Get User Profile:

    user_profile = tradier.account.get_user_profile()

  • Get Account Balance:

    account_balance = tradier.account.get_account_balance()

  • Get Gain/Loss:

    gain_loss = tradier.account.get_gainloss()

  • Get Orders:

    orders = tradier.orders.get_orders()

  • Get Positions:

    positions = tradier.account.get_positions()

Trading

  • Place Equity Order:

    order_response = tradier.orders.order('AAPL', 'buy', 1, 'limit', 150)

  • Place Options Order:

    order_response = tradier.orders.order('AAPL210917C00125000', 'buy_to_open', 1, 'limit', 3.5)

Market Data

  • Get Last Price:

    last_price = tradier.market.get_last_price('SPY')

  • Get Quotes:

    quotes_data = tradier.market.get_quotes(["AAPL", "MSFT", "SPY"])

  • Get Historical Quotes and Get Time Sales:

    from datetime import datetime, timedelta
    
    start_date = datetime.now() - timedelta(days=10)
    end_date = datetime.now()
    
    historical_data = tradier.market.get_historical_quotes(
        "AAPL",
        interval="daily",  # Can be "daily", "weekly", or "monthly"
        start_date=start_date,
        end_date=end_date,
        session_filter="all",  # Can be "all" or "open"
    )
    
    timesales = tradier.market.get_timesales(
        "MSFT",
        interval=1,  # Can be 1, 5 or 15
        start_date=start_date,
        end_date=end_date,
        session_filter="all",  # Can be "all" or "open"
    )
    
    • Get Options Chains:
    tradier.market.get_chains(symbol, expiration, greeks=True)
    
    • Get Options Expirations:

      tradier.market.get_options_expirations(symbol, strikes=True)
      

Development

To contribute or make changes to the lumiwealth-tradier package, feel free to create a fork, clone the fork, make some improvements and issue a pull request. From the terminal/command prompt:

  • Clone the forked branch to your local machine:

    git clone https://github.com/YOUR_USERNAME/lumiwealth-tradier.git

  • Navigate to the directory where the relevant code is kept:

    cd lumiwealth-tradier

  • If you need to be careful about dependencies, create a new Python virtual environment:

    python -m venv replace_this_with_desired_venv_name [Mac]

    venv\Scripts\activate [Windows]

Questions?

Happy to help! Feel free to contact Robert Grzesik by email at <EMAIL?>.
Thanks much in advance for your interest in using the package.

License

lumiwealth-tradier is licensed under the Apache License 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lumiwealth-tradier-0.1.12.tar.gz (24.2 kB view details)

Uploaded Source

Built Distribution

lumiwealth_tradier-0.1.12-py3-none-any.whl (24.9 kB view details)

Uploaded Python 3

File details

Details for the file lumiwealth-tradier-0.1.12.tar.gz.

File metadata

  • Download URL: lumiwealth-tradier-0.1.12.tar.gz
  • Upload date:
  • Size: 24.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.8

File hashes

Hashes for lumiwealth-tradier-0.1.12.tar.gz
Algorithm Hash digest
SHA256 3053f28ecc40a33ee7c52db9a40d7bb11995fe0ec9eed52a8135be1908030efa
MD5 2c285ffc027cf3a0b7d270164c47c29b
BLAKE2b-256 daae82a92087fef1237f9b364d3a9f9466af46e39281045bf70a2ab4f629bcbd

See more details on using hashes here.

File details

Details for the file lumiwealth_tradier-0.1.12-py3-none-any.whl.

File metadata

File hashes

Hashes for lumiwealth_tradier-0.1.12-py3-none-any.whl
Algorithm Hash digest
SHA256 5a558da63a69dc34212109ef7866bb13f5be79063fb8db30a4af2958fa3c385a
MD5 f6b9d3e35fcdc73ac7b04291a0c7e0a9
BLAKE2b-256 6fb12c933ef72dac4cb61bdc2b9d056d8e87dd6e4359aed517a592aa1463218c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page