<a id="readme-top"></a>
# fidelity-api
<!-- ABOUT THE PROJECT -->
## About The Project
This project aims to create an easy to use API for Fidelity.
Utilizing Playwright, a controlled browser is created through the api allowing users to place order,
gather account positions, nickname accounts, etc.
Supports 2FA!
## Disclaimer
I am not a financial advisor and not affiliated with Fidelity in any way. Use this tool at your own risk. I am
not responsible for any losses or damages you may incur by using this project. This tool is provided as-is
with no warranty.
## Donations
If you feel this project has saved you time or provided value to you, you can send me a donation using the badge below!
[![ko-fi](https://img.shields.io/badge/Ko--fi-F16061?style=for-the-badge&logo=ko-fi&logoColor=white
)](https://ko-fi.com/kenny18067)
<!-- GETTING STARTED -->
## Getting Started
Install using pypi:
```sh
pip install fidelity-api
```
This package requires playwright. After installing fidelity-api, you will need to finish the install of playwright. You can do this in most cases by running the command:
```sh
playwright install
```
If you would like some more information on this, you can find it [here](https://playwright.dev/python/docs/intro).
## Quickstart
The example below will:
- login to fidelity
- gather account holdings
- place an order for the first account number found
```py
from fidelity import fidelity
browser = fidelity.FidelityAutomation(headless=False, save_state=False)
# Login
step_1, step_2 = browser.login(username="USER", password="PASS", save_device=True)
if step_1 and step_2:
print("Logged in")
elif step_1 and not step_2:
print("2FA code needed")
code = input("Enter the code\n")
if browser.login_2FA(code):
print("Logged in")
else:
print("Browser not logged in")
exit(1)
# Get accounts
account_info = browser.getAccountInfo()
accounts = account_info.keys()
# Test the transaction
success, errormsg = browser.transaction("INTC", 1, 'buy', accounts[0], True)
if success:
print("Successfully tested transaction")
else:
print(errormsg)
# Print withdrawal balance from each account
acc_dict = browser.get_list_of_accounts(set_flag=True, get_withdrawal_bal=True)
for account in acc_dict:
print(f"{acc_dict[account]['nickname']}: {account}: {acc_dict[account]['withdrawal_balance']}")
browser.close_browser()
```
Raw data
{
"_id": null,
"home_page": "https://github.com/kennyboy106/fidelity-api",
"name": "fidelity-api",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "FIDELITY, API",
"author": "Kenneth Tang",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/23/07/fcd7bd27530bf9a3e38bdfd4fcf174b084d0531c72d89989fb352be4f915/fidelity-api-0.0.5.tar.gz",
"platform": null,
"description": "<a id=\"readme-top\"></a>\r\n# fidelity-api\r\n\r\n<!-- ABOUT THE PROJECT -->\r\n## About The Project\r\nThis project aims to create an easy to use API for Fidelity.\r\n\r\nUtilizing Playwright, a controlled browser is created through the api allowing users to place order, \r\ngather account positions, nickname accounts, etc.\r\n\r\nSupports 2FA!\r\n\r\n## Disclaimer\r\nI am not a financial advisor and not affiliated with Fidelity in any way. Use this tool at your own risk. I am \r\nnot responsible for any losses or damages you may incur by using this project. This tool is provided as-is \r\nwith no warranty.\r\n\r\n## Donations\r\nIf you feel this project has saved you time or provided value to you, you can send me a donation using the badge below!\r\n\r\n[![ko-fi](https://img.shields.io/badge/Ko--fi-F16061?style=for-the-badge&logo=ko-fi&logoColor=white\r\n)](https://ko-fi.com/kenny18067)\r\n\r\n<!-- GETTING STARTED -->\r\n## Getting Started\r\n\r\nInstall using pypi:\r\n```sh\r\npip install fidelity-api\r\n```\r\n\r\nThis package requires playwright. After installing fidelity-api, you will need to finish the install of playwright. You can do this in most cases by running the command:\r\n```sh\r\nplaywright install\r\n```\r\n\r\nIf you would like some more information on this, you can find it [here](https://playwright.dev/python/docs/intro).\r\n\r\n## Quickstart\r\nThe example below will:\r\n- login to fidelity\r\n- gather account holdings\r\n- place an order for the first account number found\r\n```py\r\nfrom fidelity import fidelity\r\n\r\nbrowser = fidelity.FidelityAutomation(headless=False, save_state=False)\r\n\r\n# Login\r\nstep_1, step_2 = browser.login(username=\"USER\", password=\"PASS\", save_device=True)\r\nif step_1 and step_2:\r\n print(\"Logged in\")\r\nelif step_1 and not step_2:\r\n print(\"2FA code needed\")\r\n code = input(\"Enter the code\\n\")\r\nif browser.login_2FA(code):\r\n print(\"Logged in\")\r\nelse:\r\n print(\"Browser not logged in\")\r\n exit(1)\r\n\r\n# Get accounts\r\naccount_info = browser.getAccountInfo()\r\naccounts = account_info.keys()\r\n\r\n# Test the transaction\r\nsuccess, errormsg = browser.transaction(\"INTC\", 1, 'buy', accounts[0], True)\r\nif success:\r\n print(\"Successfully tested transaction\")\r\nelse:\r\n print(errormsg)\r\n\r\n# Print withdrawal balance from each account\r\nacc_dict = browser.get_list_of_accounts(set_flag=True, get_withdrawal_bal=True)\r\nfor account in acc_dict:\r\n print(f\"{acc_dict[account]['nickname']}: {account}: {acc_dict[account]['withdrawal_balance']}\")\r\n\r\nbrowser.close_browser()\r\n```\r\n",
"bugtrack_url": null,
"license": "GPL",
"summary": "An unofficial API for Fidelity",
"version": "0.0.5",
"project_urls": {
"Homepage": "https://github.com/kennyboy106/fidelity-api"
},
"split_keywords": [
"fidelity",
" api"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "eb443ac591caedc0383f72650a64b761a5099ce4dcb0470da84486d843d9632a",
"md5": "5cbbe3cd22cb0cdef65e34c8660fbe66",
"sha256": "e03729392a4dee2c5a953f20d00632233ed19a5cfdb2f4f3e869e8a5a2bb32d8"
},
"downloads": -1,
"filename": "fidelity_api-0.0.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5cbbe3cd22cb0cdef65e34c8660fbe66",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 28877,
"upload_time": "2024-11-12T02:45:44",
"upload_time_iso_8601": "2024-11-12T02:45:44.088115Z",
"url": "https://files.pythonhosted.org/packages/eb/44/3ac591caedc0383f72650a64b761a5099ce4dcb0470da84486d843d9632a/fidelity_api-0.0.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "2307fcd7bd27530bf9a3e38bdfd4fcf174b084d0531c72d89989fb352be4f915",
"md5": "13a672561baf6ca74b0919b49d560ffa",
"sha256": "43c75483b1e63f614c6c4e03982234f688e2657653e00a05cc180cda39d848c8"
},
"downloads": -1,
"filename": "fidelity-api-0.0.5.tar.gz",
"has_sig": false,
"md5_digest": "13a672561baf6ca74b0919b49d560ffa",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 29526,
"upload_time": "2024-11-12T02:45:45",
"upload_time_iso_8601": "2024-11-12T02:45:45.288796Z",
"url": "https://files.pythonhosted.org/packages/23/07/fcd7bd27530bf9a3e38bdfd4fcf174b084d0531c72d89989fb352be4f915/fidelity-api-0.0.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-12 02:45:45",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "kennyboy106",
"github_project": "fidelity-api",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "fidelity-api"
}