firstrade 0.0.21__py3-none-any.whl → 0.0.32__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- firstrade/account.py +294 -164
- firstrade/exceptions.py +55 -0
- firstrade/order.py +163 -187
- firstrade/symbols.py +146 -51
- firstrade/urls.py +58 -24
- {firstrade-0.0.21.dist-info → firstrade-0.0.32.dist-info}/METADATA +39 -15
- firstrade-0.0.32.dist-info/RECORD +11 -0
- {firstrade-0.0.21.dist-info → firstrade-0.0.32.dist-info}/WHEEL +1 -1
- firstrade-0.0.21.dist-info/RECORD +0 -10
- {firstrade-0.0.21.dist-info → firstrade-0.0.32.dist-info}/LICENSE +0 -0
- {firstrade-0.0.21.dist-info → firstrade-0.0.32.dist-info}/top_level.txt +0 -0
firstrade/urls.py
CHANGED
|
@@ -1,46 +1,80 @@
|
|
|
1
|
-
def
|
|
2
|
-
return "https://
|
|
1
|
+
def login():
|
|
2
|
+
return "https://api3x.firstrade.com/sess/login"
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
def
|
|
6
|
-
return "https://
|
|
5
|
+
def request_code():
|
|
6
|
+
return "https://api3x.firstrade.com/sess/request_code"
|
|
7
|
+
|
|
7
8
|
|
|
9
|
+
def verify_pin():
|
|
10
|
+
return "https://api3x.firstrade.com/sess/verify_pin"
|
|
8
11
|
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
|
|
13
|
+
def user_info():
|
|
14
|
+
return "https://api3x.firstrade.com/private/userinfo"
|
|
11
15
|
|
|
12
16
|
|
|
13
17
|
def account_list():
|
|
14
|
-
return "https://
|
|
18
|
+
return "https://api3x.firstrade.com/private/acct_list"
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def account_balances(account):
|
|
22
|
+
return f"https://api3x.firstrade.com/private/balances?account={account}"
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def account_positions(account):
|
|
26
|
+
return (
|
|
27
|
+
f"https://api3x.firstrade.com/private/positions?account={account}&per_page=200"
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def quote(account, symbol):
|
|
32
|
+
return f"https://api3x.firstrade.com/public/quote?account={account}&q={symbol}"
|
|
15
33
|
|
|
16
34
|
|
|
17
|
-
def
|
|
18
|
-
return
|
|
35
|
+
def order():
|
|
36
|
+
return "https://api3x.firstrade.com/private/stock_order"
|
|
19
37
|
|
|
20
38
|
|
|
21
|
-
def
|
|
22
|
-
return "https://
|
|
39
|
+
def order_list(account):
|
|
40
|
+
return f"https://api3x.firstrade.com/private/order_status?account={account}"
|
|
23
41
|
|
|
24
42
|
|
|
25
|
-
def
|
|
26
|
-
|
|
43
|
+
def account_history(account, date_range, custom_range):
|
|
44
|
+
if custom_range is None:
|
|
45
|
+
return f"https://api3x.firstrade.com/private/account_history?range={date_range}&page=1&account={account}&per_page=1000"
|
|
46
|
+
return f"https://api3x.firstrade.com/private/account_history?range={date_range}&range_arr[]={custom_range[0]}&range_arr[]={custom_range[1]}&page=1&account={account}&per_page=1000"
|
|
27
47
|
|
|
28
|
-
def order_list():
|
|
29
|
-
return "https://invest.firstrade.com/cgi-bin/orderstatus"
|
|
30
48
|
|
|
49
|
+
def cancel_order():
|
|
50
|
+
return "https://api3x.firstrade.com/private/cancel_order"
|
|
31
51
|
|
|
32
|
-
|
|
33
|
-
|
|
52
|
+
|
|
53
|
+
def option_dates(symbol):
|
|
54
|
+
return f"https://api3x.firstrade.com/public/oc?m=get_exp_dates&root_symbol={symbol}"
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def option_quotes(symbol, date):
|
|
58
|
+
return f"https://api3x.firstrade.com/public/oc?m=get_oc&root_symbol={symbol}&exp_date={date}&chains_range=A"
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def greek_options():
|
|
62
|
+
return "https://api3x.firstrade.com/private/greekoptions/analytical"
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def option_order():
|
|
66
|
+
return "https://api3x.firstrade.com/private/option_order"
|
|
34
67
|
|
|
35
68
|
|
|
36
69
|
def session_headers():
|
|
37
70
|
headers = {
|
|
38
|
-
"Accept": "
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"Referer": "https://invest.firstrade.com/cgi-bin/main",
|
|
43
|
-
"Connection": "keep-alive",
|
|
44
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 Edg/116.0.1938.81",
|
|
71
|
+
"Accept-Encoding": "gzip",
|
|
72
|
+
"Connection": "Keep-Alive",
|
|
73
|
+
"Host": "api3x.firstrade.com",
|
|
74
|
+
"User-Agent": "okhttp/4.9.2",
|
|
45
75
|
}
|
|
46
76
|
return headers
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def access_token():
|
|
80
|
+
return "833w3XuIFycv18ybi"
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: firstrade
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.32
|
|
4
4
|
Summary: An unofficial API for Firstrade
|
|
5
5
|
Home-page: https://github.com/MaxxRK/firstrade-api
|
|
6
|
-
Download-URL: https://github.com/MaxxRK/firstrade-api/archive/refs/tags/
|
|
6
|
+
Download-URL: https://github.com/MaxxRK/firstrade-api/archive/refs/tags/0032.tar.gz
|
|
7
7
|
Author: MaxxRK
|
|
8
8
|
Author-email: maxxrk@pm.me
|
|
9
9
|
License: MIT
|
|
@@ -17,11 +17,24 @@ Classifier: Programming Language :: Python :: 3.8
|
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.9
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.10
|
|
19
19
|
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
22
|
Description-Content-Type: text/markdown
|
|
21
23
|
License-File: LICENSE
|
|
22
24
|
Requires-Dist: requests
|
|
23
25
|
Requires-Dist: beautifulsoup4
|
|
24
26
|
Requires-Dist: lxml
|
|
27
|
+
Dynamic: author
|
|
28
|
+
Dynamic: author-email
|
|
29
|
+
Dynamic: classifier
|
|
30
|
+
Dynamic: description
|
|
31
|
+
Dynamic: description-content-type
|
|
32
|
+
Dynamic: download-url
|
|
33
|
+
Dynamic: home-page
|
|
34
|
+
Dynamic: keywords
|
|
35
|
+
Dynamic: license
|
|
36
|
+
Dynamic: requires-dist
|
|
37
|
+
Dynamic: summary
|
|
25
38
|
|
|
26
39
|
# firstrade-api
|
|
27
40
|
|
|
@@ -37,7 +50,10 @@ In order to use Fractional shares you must accept the agreement on the website b
|
|
|
37
50
|
|
|
38
51
|
## Contribution
|
|
39
52
|
|
|
40
|
-
|
|
53
|
+
Please feel free to contribute to this project. If you find any bugs, please open an issue.
|
|
54
|
+
|
|
55
|
+
## Disclaimer
|
|
56
|
+
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.
|
|
41
57
|
|
|
42
58
|
## Setup
|
|
43
59
|
|
|
@@ -49,33 +65,41 @@ pip install firstrade
|
|
|
49
65
|
|
|
50
66
|
## Quikstart
|
|
51
67
|
|
|
52
|
-
`
|
|
53
|
-
|
|
54
|
-
This code will:
|
|
68
|
+
The code in `test.py` will:
|
|
55
69
|
- Login and print account info.
|
|
56
70
|
- Get a quote for 'INTC' and print out the information
|
|
57
|
-
- Place a market order for 'INTC' on the first account in the `account_numbers` list
|
|
71
|
+
- Place a dry run market order for 'INTC' on the first account in the `account_numbers` list
|
|
58
72
|
- Print out the order confirmation
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
73
|
+
- Contains a cancel order example
|
|
74
|
+
- Get an option Dates, Quotes, and Greeks
|
|
75
|
+
- Place a dry run option order
|
|
62
76
|
---
|
|
63
77
|
|
|
64
78
|
## Implemented Features
|
|
65
79
|
|
|
66
|
-
- [x] Login
|
|
80
|
+
- [x] Login (With all 2FA methods now supported!)
|
|
67
81
|
- [x] Get Quotes
|
|
68
82
|
- [x] Get Account Data
|
|
69
83
|
- [x] Place Orders and Receive order confirmation
|
|
70
84
|
- [x] Get Currently Held Positions
|
|
71
85
|
- [x] Fractional Trading support (thanks to @jiak94)
|
|
72
86
|
- [x] Check on placed order status. (thanks to @Cfomodz)
|
|
87
|
+
- [x] Cancel placed orders
|
|
88
|
+
- [x] Options (Orders, Quotes, Greeks)
|
|
89
|
+
- [x] Order History
|
|
73
90
|
|
|
74
91
|
## TO DO
|
|
75
92
|
|
|
76
|
-
- [ ]
|
|
77
|
-
- [ ] Options
|
|
93
|
+
- [ ] Test options fully
|
|
78
94
|
- [ ] Give me some Ideas!
|
|
79
95
|
|
|
96
|
+
## Options
|
|
97
|
+
|
|
98
|
+
### I am very new to options trading and have not fully tested this feature.
|
|
99
|
+
|
|
100
|
+
Please:
|
|
101
|
+
- USE THIS FEATURE LIKE IT IS A ALPHA/BETA
|
|
102
|
+
- PUT IN A GITHUB ISSUE IF YOU FIND ANY PROBLEMS
|
|
103
|
+
|
|
80
104
|
## If you would like to support me, you can do so here:
|
|
81
|
-
[](https://github.com/sponsors/maxxrk)
|
|
105
|
+
[](https://github.com/sponsors/maxxrk)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
firstrade/__init__.py,sha256=fNiWYgSTjElY1MNv0Ug-sVLMTR2z_Ngri_FY7Pekdrw,95
|
|
2
|
+
firstrade/account.py,sha256=wLPlQOzgaaBwb8tvYPcWdhfTtaUEtM54iPBl5dPpVHY,14129
|
|
3
|
+
firstrade/exceptions.py,sha256=OrWB83rc33LSxrI7WxXo4o7FcIfmvPSC9bAY8K1pn7U,1886
|
|
4
|
+
firstrade/order.py,sha256=_b1SnqagwBu7KUmvzSUcp8iMOC3I3k-QDjiDLhlVk7E,8710
|
|
5
|
+
firstrade/symbols.py,sha256=EOGVdLl1MzvO0yUt7KRqbSM9vHeinqn8IU0FnZzcExo,7906
|
|
6
|
+
firstrade/urls.py,sha256=Iw10isyvoqKwiSl3TVuIbos5INZzIEwpln3HcZ7P5aw,2125
|
|
7
|
+
firstrade-0.0.32.dist-info/LICENSE,sha256=wPEQjDqm5zMBmEcZp219Labmq_YIjhudpZiUzyVKaFA,1057
|
|
8
|
+
firstrade-0.0.32.dist-info/METADATA,sha256=R1hQzM3IBPemvLRR81wUgGiEcilURKjdkGLnLB5R1bs,3345
|
|
9
|
+
firstrade-0.0.32.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
10
|
+
firstrade-0.0.32.dist-info/top_level.txt,sha256=tdA8v-KDxU1u4VV6soiNWGBlni4ojv_t_j2wFn5nZcs,10
|
|
11
|
+
firstrade-0.0.32.dist-info/RECORD,,
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
firstrade/__init__.py,sha256=fNiWYgSTjElY1MNv0Ug-sVLMTR2z_Ngri_FY7Pekdrw,95
|
|
2
|
-
firstrade/account.py,sha256=xDgTMXDy2UWUNi4kboXAKKBrbmZGpXLJ11MCHlMvzB0,9218
|
|
3
|
-
firstrade/order.py,sha256=bvqO06BzrtWQNP8PAWbPR3Ypnu9LEAwq4BWn1-joScY,9105
|
|
4
|
-
firstrade/symbols.py,sha256=tZD7jexvyvh1rTaOdAKv_vyZWzpjffvl_nPwBe1QaiA,3633
|
|
5
|
-
firstrade/urls.py,sha256=OrfXGDsNpA2rTm4o55KAQzpeigG_pxufWyTDBlbhJYQ,1248
|
|
6
|
-
firstrade-0.0.21.dist-info/LICENSE,sha256=wPEQjDqm5zMBmEcZp219Labmq_YIjhudpZiUzyVKaFA,1057
|
|
7
|
-
firstrade-0.0.21.dist-info/METADATA,sha256=Krhj7olyyZ4ylGtU7yRZ7_F7h9FgIzM5MX13Ipi7Q6k,2399
|
|
8
|
-
firstrade-0.0.21.dist-info/WHEEL,sha256=Wyh-_nZ0DJYolHNn1_hMa4lM7uDedD_RGVwbmTjyItk,91
|
|
9
|
-
firstrade-0.0.21.dist-info/top_level.txt,sha256=tdA8v-KDxU1u4VV6soiNWGBlni4ojv_t_j2wFn5nZcs,10
|
|
10
|
-
firstrade-0.0.21.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|