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

Quikstart

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

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

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.38.tar.gz (14.9 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.38-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: firstrade-0.0.38.tar.gz
  • Upload date:
  • Size: 14.9 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.38.tar.gz
Algorithm Hash digest
SHA256 1f700604859f9da0bbb620cbcff7077f3147ec0a880ed0d4cc129201d6849540
MD5 4210e5949e97f8168787c9e5c64a2edb
BLAKE2b-256 68d7305e72e99d37094b3264a5f8602d3194f3fb1535e792eb41a373d4768cd4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: firstrade-0.0.38-py3-none-any.whl
  • Upload date:
  • Size: 14.8 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.38-py3-none-any.whl
Algorithm Hash digest
SHA256 9d0e49f578c06d9e10a0f5de55e5e55b39755d9add96b7f9c76e83222737361b
MD5 22e2ec61af0bccae7eeffa5d253332e8
BLAKE2b-256 f6bb83f85e5bc23e70d13e333ab627bb1602da79e668a0fdba0acd7c15c43825

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