# 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 <a href='https://tradier.com/'>Tradier.com</a>.
* 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: <br>
`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: <br>
`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: <br>
`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:
```python
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:
```python
tradier.market.get_chains(symbol, expiration, greeks=True)
```
- Get Options Expirations:
```python
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`
- Add the original repository as a remote:
`git remote add upstream https://github.com/Lumiwealth/lumiwealth-tradier`
- Confirm the remote has been added:
`git remote -v`
- Create a new branch for your feature:
`git checkout -b feature_branch_name`
- If you need to be careful about dependencies, create a new Python virtual environment and activate it:
`python -m venv venv`
`venv\Scripts\activate`
- Install the required dev dependencies:
`pip install -r requirements_dev.txt`
- Install the package in editable mode:
`pip install -e .`
- Create a `.env` file in the root directory and add your Tradier account number and access token.
- Add the following vars for testing:
`TRADIER_ACCOUNT_NUMBER=<YOUR_ACCOUNT_NUMBER_FROM_TRADIER_DASHBOARD>`
`TRADIER_PAPER_TOKEN=<YOUR_PAPER_ACCESS_TOKEN_FROM_TRADIER_DASHBOARD>`
- Finally, run the tests:
`pytest`
## Questions?
Happy to help! Feel free to contact Robert Grzesik by email at <EMAIL?>. <br>
Thanks much in advance for your interest in using the package.
## License
`lumiwealth-tradier` is licensed under the Apache License 2.0
Raw data
{
"_id": null,
"home_page": "https://github.com/Lumiwealth/lumiwealth-tradier",
"name": "lumiwealth-tradier",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "tradier finance api",
"author": "David MacLeod and Robert Grzesik",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/72/d1/ee562e881b09022586a87297c69dee5c534a336209ee7c1f7d2b69c2ed8a/lumiwealth-tradier-0.1.14.tar.gz",
"platform": null,
"description": "# lumiwealth-tradier\n\n`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.\n\nThe package was originally developed by data science graduate students at the University of Virginia.\n\n## Features\n\n- **Account Management**: Retrieve profile, balance, gain/loss, orders, and positions related to a trading account.\n- **Trading**: Place, modify, and cancel equity and option orders.\n- **Market Data**: Access real-time and historical market data for equities and options.\n- **Options Data**: Retrieve options chains, strikes, and expiration dates.\n\n## Installation\n\nTo install `lumiwealth-tradier`, you can use `pip`:\n\n`pip install lumiwealth-tradier`\n\n## Hello World\n\nSteps to get started:\n * Create an account with <a href='https://tradier.com/'>Tradier.com</a>.\n * Grab Account Number and Access Token from your Tradier dashboard.\n * Log into Tradier > Preferences (gear icon) > API Access (left panel) > Sandbox Account Access (section).\n * Create a `.env` file in the appropriate working directory on your computer.\n * Launch text editor application.\n * Save the file as `.env`.\n * In the file, add the following lines, replacing the appropriate placeholder fields: <br>\n `tradier_acct=<YOUR_ACCOUNT_NUMBER_FROM_TRADIER_DASHBOARD>`\n\n `tradier_token=<YOUR_ACCESS_TOKEN_FROM_TRADIER_DASHBOARD>`\n * Within the aforementioned working directory, initiate a new python session (interactive python, jupyter notebook, etc.).\n * To authenticate yourself, add the following lines of code to the top of your python script or jupyter notebook: <br> \n `import os, dotenv`\n\n `from lumiwealth_tradier import Tradier`\n \n `dotenv.load_dotenv()`\n \n `tradier_acct = os.getenv('tradier_acct')`\n \n `tradier_token = os.getenv('tradier_token')`\n \n * To instantiate the class objects, use: <br>\n `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`\n\n## Usage\n\nThis section provides example functionality of the existing codebase. Additional sample code demonstrating usage can be found in the `/examples/` directory.\n\n### Account Management\n\n- Get User Profile:\n\n `user_profile = tradier.account.get_user_profile()`\n\n- Get Account Balance:\n\n `account_balance = tradier.account.get_account_balance()`\n\n- Get Gain/Loss:\n\n `gain_loss = tradier.account.get_gainloss()`\n\n- Get Orders:\n\n `orders = tradier.orders.get_orders()`\n\n- Get Positions:\n\n `positions = tradier.account.get_positions()`\n\n### Trading\n\n- Place Equity Order:\n\n `order_response = tradier.orders.order('AAPL', 'buy', 1, 'limit', 150)`\n\n- Place Options Order:\n\n `order_response = tradier.orders.order('AAPL210917C00125000', 'buy_to_open', 1, 'limit', 3.5)`\n\n### Market Data\n\n- Get Last Price:\n\n `last_price = tradier.market.get_last_price('SPY')`\n\n- Get Quotes:\n\n `quotes_data = tradier.market.get_quotes([\"AAPL\", \"MSFT\", \"SPY\"])`\n\n- Get Historical Quotes and Get Time Sales:\n\n ```python\n from datetime import datetime, timedelta\n\n start_date = datetime.now() - timedelta(days=10)\n end_date = datetime.now()\n\n historical_data = tradier.market.get_historical_quotes(\n \"AAPL\",\n interval=\"daily\", # Can be \"daily\", \"weekly\", or \"monthly\"\n start_date=start_date,\n end_date=end_date,\n session_filter=\"all\", # Can be \"all\" or \"open\"\n )\n\n timesales = tradier.market.get_timesales(\n \"MSFT\",\n interval=1, # Can be 1, 5 or 15\n start_date=start_date,\n end_date=end_date,\n session_filter=\"all\", # Can be \"all\" or \"open\"\n )\n ```\n\n - Get Options Chains:\n\n ```python\n tradier.market.get_chains(symbol, expiration, greeks=True)\n ```\n\n - Get Options Expirations:\n \n ```python\n tradier.market.get_options_expirations(symbol, strikes=True)\n ```\n\n## Development\n\nTo 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:\n\n- Clone the forked branch to your local machine:\n\n `git clone https://github.com/YOUR_USERNAME/lumiwealth-tradier.git`\n\n- Navigate to the directory where the relevant code is kept: \n\n `cd lumiwealth-tradier`\n\n- Add the original repository as a remote:\n\n `git remote add upstream https://github.com/Lumiwealth/lumiwealth-tradier`\n\n- Confirm the remote has been added:\n\n `git remote -v`\n\n- Create a new branch for your feature:\n\n `git checkout -b feature_branch_name`\n\n- If you need to be careful about dependencies, create a new Python virtual environment and activate it:\n\n `python -m venv venv`\n `venv\\Scripts\\activate`\n\n- Install the required dev dependencies:\n\n `pip install -r requirements_dev.txt`\n\n- Install the package in editable mode:\n\n `pip install -e .`\n\n- Create a `.env` file in the root directory and add your Tradier account number and access token.\n\n- Add the following vars for testing:\n\n `TRADIER_ACCOUNT_NUMBER=<YOUR_ACCOUNT_NUMBER_FROM_TRADIER_DASHBOARD>`\n `TRADIER_PAPER_TOKEN=<YOUR_PAPER_ACCESS_TOKEN_FROM_TRADIER_DASHBOARD>`\n\n- Finally, run the tests:\n\n `pytest`\n\n## Questions?\n\nHappy to help! Feel free to contact Robert Grzesik by email at <EMAIL?>. <br>\nThanks much in advance for your interest in using the package.\n\n## License\n\n`lumiwealth-tradier` is licensed under the Apache License 2.0\n",
"bugtrack_url": null,
"license": null,
"summary": "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.",
"version": "0.1.14",
"project_urls": {
"Bug Tracker": "https://github.com/Lumiwealth/lumiwealth-tradier/issues",
"Homepage": "https://github.com/Lumiwealth/lumiwealth-tradier"
},
"split_keywords": [
"tradier",
"finance",
"api"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "64b02595ada1799926e46069c42f376105eac3cc949448575fc3eb93a1600d77",
"md5": "603994503fb1446a3a04dbf97242de83",
"sha256": "27f8397d7718e26b8df4ad9c1faa8e449cc0e0edb26286994b0920549603028d"
},
"downloads": -1,
"filename": "lumiwealth_tradier-0.1.14-py3-none-any.whl",
"has_sig": false,
"md5_digest": "603994503fb1446a3a04dbf97242de83",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 27322,
"upload_time": "2024-11-25T19:56:04",
"upload_time_iso_8601": "2024-11-25T19:56:04.900792Z",
"url": "https://files.pythonhosted.org/packages/64/b0/2595ada1799926e46069c42f376105eac3cc949448575fc3eb93a1600d77/lumiwealth_tradier-0.1.14-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "72d1ee562e881b09022586a87297c69dee5c534a336209ee7c1f7d2b69c2ed8a",
"md5": "64491b707913116e7125ed6828d4a264",
"sha256": "549ae71803f21593ae936e6eaf9e1322ca3092ffbcbb66a8b32782aff64402de"
},
"downloads": -1,
"filename": "lumiwealth-tradier-0.1.14.tar.gz",
"has_sig": false,
"md5_digest": "64491b707913116e7125ed6828d4a264",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 26446,
"upload_time": "2024-11-25T19:56:06",
"upload_time_iso_8601": "2024-11-25T19:56:06.458665Z",
"url": "https://files.pythonhosted.org/packages/72/d1/ee562e881b09022586a87297c69dee5c534a336209ee7c1f7d2b69c2ed8a/lumiwealth-tradier-0.1.14.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-25 19:56:06",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Lumiwealth",
"github_project": "lumiwealth-tradier",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "pandas",
"specs": []
},
{
"name": "requests",
"specs": []
},
{
"name": "numpy",
"specs": []
}
],
"lcname": "lumiwealth-tradier"
}