chaseinvest-api


Namechaseinvest-api JSON
Version 0.1.6 PyPI version JSON
download
home_pagehttps://github.com/MaxxRK/chaseinvest-api
SummaryAn unofficial API for Chase Invest
upload_time2024-05-17 13:48:33
maintainerNone
docs_urlNone
authorMaxxRK
requires_pythonNone
licenseMIT
keywords chase api
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # chaseinvest-api
 A reverse-engineered python API to interact with the Chase Trading platform.

 This is not an official api! This api's functionality may change at any time.

 This api provides a means of buying and selling stocks through Chase. It uses playwright to scrape response data and to interact with the website.

 ---

## Contribution
I am new to coding and new to open-source. I would love any help and suggestions!

## Setup
Install using pypi:
```
pip install chaseinvest-api
```
This package requires playwright. After installing chaseinvest-api, you will need to finish the install of playwright. You can do this in most cases by running the command:
```
playwright install
```
If you would like some more information on this, you can find it [here](https://playwright.dev/python/docs/intro).

## Quickstart
The code below will: 
- Login and print account info. 
- Get a quote for 'INTC' and print out the information
- Place a market order for 'INTC' on the first account in the `account_numbers` list
- Print out the order confirmation

```
import sys

from chase import account as acc
from chase import order as och
from chase import session
from chase import symbols as sym

# create Session Headless does not work at the moment it must be set to false.
cs = session.ChaseSession(title="Title of your profile here", headless=False, profile_path='your/profile/path')

# Login to Chase.com
login_one = cs.login("your_username", "your_password", "last_four_of_your_cell_phone")

# Check if login succeeded without needing 2fa if not then prompt for 2fa code
if login_one == False:
    print('Login succeeded without needing 2fa...')
else:
    code = input('Please input code that was sent to your phone: ')
    login_two = cs.login_two(code)

# Make all account object
all_accounts = acc.AllAccount(cs)

if all_accounts.account_connectors is None:
    sys.exit("Failed to get account connectors exiting script...")

# Get Account Identifiers
print("====================================")
print(f"Account Identifiers: {all_accounts.account_connectors}")

# Get Base Account Details
account_ids = list(all_accounts.account_connectors.keys())

print("====================================")
print("ACCOUNT DETAILS")
print("====================================")
for account in account_ids:
    account = acc.AccountDetails(account, all_accounts)
    print(account.nickname, account.mask, account.account_value)
print("====================================")

# Get Holdings
print("====================================")
print("HOLDINGS")
for account in account_ids:
    print("====================================")
    print(f"Account: {all_accounts.account_connectors[account]}")
    symbols = sym.SymbolHoldings(account, cs)
    success = symbols.get_holdings()
    if success:
        for i, symbol in enumerate(symbols.positions):
            if symbols.positions[i]["instrumentLongName"] == "Cash and Sweep Funds":
                symbol = symbols.positions[i]["instrumentLongName"]
                value = symbols.positions[i]["marketValue"]["baseValueAmount"]
                print(f"Symbol: {symbol} Value: {value}")
            elif symbols.positions[i]["assetCategoryName"] == "EQUITY":
                try:
                    symbol = symbols.positions[i]["positionComponents"][0][
                        "securityIdDetail"
                    ][0]["symbolSecurityIdentifier"]
                    value = symbols.positions[i]["marketValue"]["baseValueAmount"]
                    quantity = symbols.positions[i]["tradedUnitQuantity"]
                    print(f"Symbol: {symbol} Value: {value} Quantity: {quantity}")
                except KeyError:
                    symbol = symbols.positions[i]["securityIdDetail"]["cusipIdentifier"]
                    value = symbols.positions[i]["marketValue"]["baseValueAmount"]
                    quantity = symbols.positions[i]["tradedUnitQuantity"]
                    print(f"Symbol: {symbol} Value: {value} Quantity: {quantity}")
    else:
        print(f"Failed to get holdings for account {account}")
print("====================================")

# Create Order Object
order = och.Order(cs)

# Get Order Statuses
print("====================================")
print("ORDER STATUSES")
for account in account_ids:
    order_statuses = order.get_order_statuses(account)
    print("====================================")
    print(f"Account: {all_accounts.account_connectors[account]}")
    for order_status in order_statuses["orderSummaries"]:
        order_number = order_status["orderIdentifier"]
        order_type = order_status["tradeActionCode"]
        order_status_code = order_status["orderStatusCode"]
        print(
            f"Order Number: {order_number} Side: {order_type} Status: {order_status_code}"
        )
print("====================================")

# Get quote for INTC
symbol_quote = sym.SymbolQuote(account_ids[0], cs, "INTC")
print("====================================")
print("SYMBOL QUOTE")
print(
    f"{symbol_quote.security_description} ask price {symbol_quote.ask_price}, @{symbol_quote.as_of_time} and the last trade was {symbol_quote.last_trade_price}."
)
print("====================================")

# Place dry run order for INTC
messages = order.place_order(
    account_ids[0],
    1,
    och.PriceType.MARKET,
    "INTC",
    och.Duration.DAY,
    och.OrderSide.BUY,
    dry_run=True,
)
if messages["ORDER CONFIRMATION"] != "":
    print(messages["ORDER CONFIRMATION"])
else:
    print(messages)
```

This code is also in test.py

---

 ## Implemented Features
 - [x] Login
 - [x] Login with MFA
 - [x] Get Quotes
 - [x] Get Account Data
 - [x] Place Orders and Receive order confirmation
 - [x] Get Currently Held Positions
 - [x] Get placed order status

## TO DO
 - [ ] Cancel placed orders
 - [ ] Options
 - [ ] Give me some Ideas!

## If you would like to support me, you can do so here:
[![GitHub Sponsors](https://img.shields.io/github/sponsors/maxxrk?style=social)](https://github.com/sponsors/maxxrk) 

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/MaxxRK/chaseinvest-api",
    "name": "chaseinvest-api",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "CHASE, API",
    "author": "MaxxRK",
    "author_email": "maxxrk@pm.me",
    "download_url": "https://files.pythonhosted.org/packages/87/59/0632b62774f44b4042ca9e9936b1c1e7d988bea4a4162797ab6b07f5704c/chaseinvest_api-0.1.6.tar.gz",
    "platform": null,
    "description": "# chaseinvest-api\n A reverse-engineered python API to interact with the Chase Trading platform.\n\n This is not an official api! This api's functionality may change at any time.\n\n This api provides a means of buying and selling stocks through Chase. It uses playwright to scrape response data and to interact with the website.\n\n ---\n\n## Contribution\nI am new to coding and new to open-source. I would love any help and suggestions!\n\n## Setup\nInstall using pypi:\n```\npip install chaseinvest-api\n```\nThis package requires playwright. After installing chaseinvest-api, you will need to finish the install of playwright. You can do this in most cases by running the command:\n```\nplaywright install\n```\nIf you would like some more information on this, you can find it [here](https://playwright.dev/python/docs/intro).\n\n## Quickstart\nThe code below will: \n- Login and print account info. \n- Get a quote for 'INTC' and print out the information\n- Place a market order for 'INTC' on the first account in the `account_numbers` list\n- Print out the order confirmation\n\n```\nimport sys\n\nfrom chase import account as acc\nfrom chase import order as och\nfrom chase import session\nfrom chase import symbols as sym\n\n# create Session Headless does not work at the moment it must be set to false.\ncs = session.ChaseSession(title=\"Title of your profile here\", headless=False, profile_path='your/profile/path')\n\n# Login to Chase.com\nlogin_one = cs.login(\"your_username\", \"your_password\", \"last_four_of_your_cell_phone\")\n\n# Check if login succeeded without needing 2fa if not then prompt for 2fa code\nif login_one == False:\n    print('Login succeeded without needing 2fa...')\nelse:\n    code = input('Please input code that was sent to your phone: ')\n    login_two = cs.login_two(code)\n\n# Make all account object\nall_accounts = acc.AllAccount(cs)\n\nif all_accounts.account_connectors is None:\n    sys.exit(\"Failed to get account connectors exiting script...\")\n\n# Get Account Identifiers\nprint(\"====================================\")\nprint(f\"Account Identifiers: {all_accounts.account_connectors}\")\n\n# Get Base Account Details\naccount_ids = list(all_accounts.account_connectors.keys())\n\nprint(\"====================================\")\nprint(\"ACCOUNT DETAILS\")\nprint(\"====================================\")\nfor account in account_ids:\n    account = acc.AccountDetails(account, all_accounts)\n    print(account.nickname, account.mask, account.account_value)\nprint(\"====================================\")\n\n# Get Holdings\nprint(\"====================================\")\nprint(\"HOLDINGS\")\nfor account in account_ids:\n    print(\"====================================\")\n    print(f\"Account: {all_accounts.account_connectors[account]}\")\n    symbols = sym.SymbolHoldings(account, cs)\n    success = symbols.get_holdings()\n    if success:\n        for i, symbol in enumerate(symbols.positions):\n            if symbols.positions[i][\"instrumentLongName\"] == \"Cash and Sweep Funds\":\n                symbol = symbols.positions[i][\"instrumentLongName\"]\n                value = symbols.positions[i][\"marketValue\"][\"baseValueAmount\"]\n                print(f\"Symbol: {symbol} Value: {value}\")\n            elif symbols.positions[i][\"assetCategoryName\"] == \"EQUITY\":\n                try:\n                    symbol = symbols.positions[i][\"positionComponents\"][0][\n                        \"securityIdDetail\"\n                    ][0][\"symbolSecurityIdentifier\"]\n                    value = symbols.positions[i][\"marketValue\"][\"baseValueAmount\"]\n                    quantity = symbols.positions[i][\"tradedUnitQuantity\"]\n                    print(f\"Symbol: {symbol} Value: {value} Quantity: {quantity}\")\n                except KeyError:\n                    symbol = symbols.positions[i][\"securityIdDetail\"][\"cusipIdentifier\"]\n                    value = symbols.positions[i][\"marketValue\"][\"baseValueAmount\"]\n                    quantity = symbols.positions[i][\"tradedUnitQuantity\"]\n                    print(f\"Symbol: {symbol} Value: {value} Quantity: {quantity}\")\n    else:\n        print(f\"Failed to get holdings for account {account}\")\nprint(\"====================================\")\n\n# Create Order Object\norder = och.Order(cs)\n\n# Get Order Statuses\nprint(\"====================================\")\nprint(\"ORDER STATUSES\")\nfor account in account_ids:\n    order_statuses = order.get_order_statuses(account)\n    print(\"====================================\")\n    print(f\"Account: {all_accounts.account_connectors[account]}\")\n    for order_status in order_statuses[\"orderSummaries\"]:\n        order_number = order_status[\"orderIdentifier\"]\n        order_type = order_status[\"tradeActionCode\"]\n        order_status_code = order_status[\"orderStatusCode\"]\n        print(\n            f\"Order Number: {order_number} Side: {order_type} Status: {order_status_code}\"\n        )\nprint(\"====================================\")\n\n# Get quote for INTC\nsymbol_quote = sym.SymbolQuote(account_ids[0], cs, \"INTC\")\nprint(\"====================================\")\nprint(\"SYMBOL QUOTE\")\nprint(\n    f\"{symbol_quote.security_description} ask price {symbol_quote.ask_price}, @{symbol_quote.as_of_time} and the last trade was {symbol_quote.last_trade_price}.\"\n)\nprint(\"====================================\")\n\n# Place dry run order for INTC\nmessages = order.place_order(\n    account_ids[0],\n    1,\n    och.PriceType.MARKET,\n    \"INTC\",\n    och.Duration.DAY,\n    och.OrderSide.BUY,\n    dry_run=True,\n)\nif messages[\"ORDER CONFIRMATION\"] != \"\":\n    print(messages[\"ORDER CONFIRMATION\"])\nelse:\n    print(messages)\n```\n\nThis code is also in test.py\n\n---\n\n ## Implemented Features\n - [x] Login\n - [x] Login with MFA\n - [x] Get Quotes\n - [x] Get Account Data\n - [x] Place Orders and Receive order confirmation\n - [x] Get Currently Held Positions\n - [x] Get placed order status\n\n## TO DO\n - [ ] Cancel placed orders\n - [ ] Options\n - [ ] Give me some Ideas!\n\n## If you would like to support me, you can do so here:\n[![GitHub Sponsors](https://img.shields.io/github/sponsors/maxxrk?style=social)](https://github.com/sponsors/maxxrk) \n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "An unofficial API for Chase Invest",
    "version": "0.1.6",
    "project_urls": {
        "Download": "https://github.com/MaxxRK/chaseinvest-api/archive/refs/tags/v0.1.6.tar.gz",
        "Homepage": "https://github.com/MaxxRK/chaseinvest-api"
    },
    "split_keywords": [
        "chase",
        " api"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2ab1f9c7b2ea3201b3e1fe2385a49d1f60dae1725853fd33c164728d3783a580",
                "md5": "c974fb27a0e55477c6bdb59ff676a2a6",
                "sha256": "25d93ae0bc1bca8065b4af4e9262f5ba98b8b28c27e4a2648c4720b92d9d6720"
            },
            "downloads": -1,
            "filename": "chaseinvest_api-0.1.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c974fb27a0e55477c6bdb59ff676a2a6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 15760,
            "upload_time": "2024-05-17T13:48:32",
            "upload_time_iso_8601": "2024-05-17T13:48:32.225648Z",
            "url": "https://files.pythonhosted.org/packages/2a/b1/f9c7b2ea3201b3e1fe2385a49d1f60dae1725853fd33c164728d3783a580/chaseinvest_api-0.1.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "87590632b62774f44b4042ca9e9936b1c1e7d988bea4a4162797ab6b07f5704c",
                "md5": "0eb03055db57e6c4dd2f83d0cb3982d5",
                "sha256": "3fcd59e329dd2c82c35274416e6955cc991031553c5899d59c911339efe1181c"
            },
            "downloads": -1,
            "filename": "chaseinvest_api-0.1.6.tar.gz",
            "has_sig": false,
            "md5_digest": "0eb03055db57e6c4dd2f83d0cb3982d5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 15849,
            "upload_time": "2024-05-17T13:48:33",
            "upload_time_iso_8601": "2024-05-17T13:48:33.917404Z",
            "url": "https://files.pythonhosted.org/packages/87/59/0632b62774f44b4042ca9e9936b1c1e7d988bea4a4162797ab6b07f5704c/chaseinvest_api-0.1.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-17 13:48:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "MaxxRK",
    "github_project": "chaseinvest-api",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "chaseinvest-api"
}
        
Elapsed time: 0.24620s