Skip to content

Commit

Permalink
upload to pypi
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxxRK committed Oct 4, 2023
1 parent 20441b8 commit 7f3663f
Show file tree
Hide file tree
Showing 8 changed files with 161 additions and 3 deletions.
File renamed without changes.
Binary file added dist/firstrade-0.0.1.tar.gz
Binary file not shown.
120 changes: 120 additions & 0 deletions firstrade.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
Metadata-Version: 2.1
Name: firstrade
Version: 0.0.1
Summary: An unofficial API for Firstrade
Home-page: https://github.com/MaxxRK/firstrade-api
Download-URL: https://github.com/MaxxRK/firstrade-api/archive/refs/tags/v_001.tar.gz
Author: MaxxRK
Author-email: [email protected]
License: MIT
Keywords: FIRSTRADE,API
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Topic :: Internet :: WWW/HTTP :: Session
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Description-Content-Type: text/markdown
License-File: LICENSE

# 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 usses the Session class from requests to get authoriztion cookies. The rest is done with reverse engineered requests to Firstrade's API.

---

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

## Setup
Install using pypi:
```
pip install firstrade-api
```

## Quikstart
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

```
from firstrade import account
from firstrade import symbols
from firstrade import order

# Create a session
ft_ss = account.FTSession(username='', password='', pin='')

# Get account data
ft_accounts = account.FTAccountData(ft_ss)

# Print ALL account data
print(ft_accounts.all_accounts)

# Print 1st account number.
print(ft_accounts.account_numbers[0])

# Print ALL accounts market values.
print(ft_accounts.account_balances)

# Get quote for INTC
quote = symbols.SymbolQuote(ft_ss, 'INTC')
print(f"Symbol: {quote.symbol}")
print(f"Exchange: {quote.exchange}")
print(f"Bid: {quote.bid}")
print(f"Ask: {quote.ask}")
print(f"Last: {quote.last}")
print(f"Change: {quote.change}")
print(f"High: {quote.high}")
print(f"Low: {quote.low}")
print(f"Volume: {quote.volume}")
print(f"Company Name: {quote.company_name}")

ft_order = order.Order(ft_ss)
# Place order and print out order confirmation data.
ft_order.place_order(
ft_accounts.account_numbers[0],
symbol='INTC',
order_type=order.PriceType.MARKET,
quantity=1,
duration=order.Duration.DAY,
dry_run=False
)

# Print Order data Dict
print(ft_order.order_confirmation)

# Check if order was successful
if ft_order.order_confirmation['success'] == 'Yes':
print('Order placed successfully.')
# Print Order ID
print(ft_order.order_confirmation['orderid'])
else:
print('Failed to place order.')
# Print errormessage
print(ft_order.order_confirmation['actiondata'])
```
This code is also in test.py

---

## Implemented Features
- [x] Login
- [x] Get Quotes
- [x] Get Account Data
- [x] Place Orders and Receive order confirmation

## TO DO
- [ ] Get positions
- [ ] Check on placed order status.
- [ ] Cancel placed orders
- [ ] Options
- [ ] Give me some Ideas!
12 changes: 12 additions & 0 deletions firstrade.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
LICENSE
README.md
setup.py
firstrade/account.py
firstrade/order.py
firstrade/symbols.py
firstrade/urls.py
firstrade.egg-info/PKG-INFO
firstrade.egg-info/SOURCES.txt
firstrade.egg-info/dependency_links.txt
firstrade.egg-info/requires.txt
firstrade.egg-info/top_level.txt
1 change: 1 addition & 0 deletions firstrade.egg-info/dependency_links.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

3 changes: 3 additions & 0 deletions firstrade.egg-info/requires.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
requests
beautifulsoup4
lxml
1 change: 1 addition & 0 deletions firstrade.egg-info/top_level.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
firstrade
27 changes: 24 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
import setuptools

with open("README.md", "r") as f:
long_description = f.read()

setuptools.setup(
name="firstrade-api",
version="0.0.1",
name="firstrade",
version="0.0.2",
author="MaxxRK",
author_email="[email protected]",
description="An unofficial API for Firstrade",
long_description=long_description,
long_description_content_type="text/markdown",
license="MIT",
url='https://github.com/MaxxRK/firstrade-api',
download_url='https://github.com/MaxxRK/firstrade-api/archive/refs/tags/v_002.tar.gz',
keywords=['FIRSTRADE', 'API'],
install_requires=['requests', 'beautifulsoup4', 'lxml'],
packages=['firstrade'],
)
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'Topic :: Internet :: WWW/HTTP :: Session',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
],
)

0 comments on commit 7f3663f

Please sign in to comment.