Skip to main content

An unofficial API for Firstrade

Project description

firstrade-api

A reverse-engineered python API to interact with the Firstrade 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 Firstrade. It uses the Session class from requests to get authorization cookies. The rest is done with reverse engineered requests to Firstrade's API.

In order to use Fractional shares you must accept the agreement on the website before using it in this API.


Contribution

Please feel free to contribute to this project. If you find any bugs, please open an issue.

Disclaimer

I am not a financial advisor and not affiliated with Firstrade 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.

Setup

Install using pypi:

pip install firstrade

Quickstart

The code in test.py will:

  • Login and print account info.
  • Get a quote for 'INTC' and print out the information
  • Place a dry run market order for 'INTC' on the first account in the account_numbers list
  • Print out the order confirmation
  • Contains a cancel order example
  • Get OHLC data
  • Get an option Dates, Quotes, and Greeks
  • Place a dry run option order
  • List watchlists, create one, add a symbol to it then delete it

Implemented Features

  • Login (With all 2FA methods now supported!)
  • Get Quotes
  • Get OHLC (timestamp, open, high, low, close, volume)
  • Get Account Data
  • Place Orders and Receive order confirmation
  • Get Currently Held Positions
  • Fractional Trading support (thanks to @jiak94)
  • Check on placed order status. (thanks to @Cfomodz)
  • Cancel placed orders
  • Options (Orders, Quotes, Greeks)
  • Order History
  • Manage watchlists

TO DO

  • Test options fully
  • Give me some Ideas!

Options

I am very new to options trading and have not fully tested this feature.

Please:

  • USE THIS FEATURE LIKE IT IS A ALPHA/BETA
  • PUT IN A GITHUB ISSUE IF YOU FIND ANY PROBLEMS

If you would like to support me, you can do so here:

GitHub Sponsors

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

firstrade-0.0.39.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

firstrade-0.0.39-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

Details for the file firstrade-0.0.39.tar.gz.

File metadata

  • Download URL: firstrade-0.0.39.tar.gz
  • Upload date:
  • Size: 16.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for firstrade-0.0.39.tar.gz
Algorithm Hash digest
SHA256 1d5dced6d48392d601a4dd5623757b98be5f03736491192cd920c55958f74f2e
MD5 3a342e3d5efe0a553f1a750132d17a9f
BLAKE2b-256 b6577f0074b79eca8d2e7f9881b6274c3318166bf8be2bb219c43019b96b30c7

See more details on using hashes here.

File details

Details for the file firstrade-0.0.39-py3-none-any.whl.

File metadata

  • Download URL: firstrade-0.0.39-py3-none-any.whl
  • Upload date:
  • Size: 16.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for firstrade-0.0.39-py3-none-any.whl
Algorithm Hash digest
SHA256 89fe64b82514bcc965daa584d0f4e45cb65106cfea6e3515bcdb7f6005f39257
MD5 6b9c8bc1b63983aa1ae4ab80828b2fa1
BLAKE2b-256 adcef8e8964cf5af61cc99784025c4c6aa8b49ee78d5dcc6a60b823ded603810

See more details on using hashes here.

Supported by

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