Skip to content

Commit 4cfa6f5

Browse files
author
方佳
committed
Merge branch 'main_merge_250920' into 'main'
feat: Added an interface for querying pending orders See merge request webull/webull-openapi-python-sdk!2
2 parents 9553c0d + 7afd9c7 commit 4cfa6f5

3 files changed

Lines changed: 54 additions & 0 deletions

File tree

samples/trade/trade_client_v2.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@
107107
if res.status_code == 200:
108108
print("order_history_res=" + json.dumps(res.json(), indent=4))
109109

110+
res = trade_client.order_v2.get_order_open(account_id=account_id)
111+
if res.status_code == 200:
112+
print("order_open_res=" + json.dumps(res.json(), indent=4))
113+
110114
# order detail
111115
res = trade_client.order_v2.get_order_detail(account_id=account_id, client_order_id=client_order_id)
112116
if res.status_code == 200:
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Copyright 2022 Webull
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from webull.core.request import ApiRequest
16+
17+
18+
class OrderOpenRequest(ApiRequest):
19+
def __init__(self):
20+
ApiRequest.__init__(self, "/openapi/account/orders/open", version='v2', method="GET", query_params={})
21+
22+
def set_account_id(self, account_id):
23+
self.add_query_param("account_id", account_id)
24+
25+
def set_page_size(self, page_size):
26+
self.add_query_param("page_size", page_size)
27+
28+
def set_last_order_id(self, last_order_id):
29+
self.add_query_param("last_order_id", last_order_id)

webull/trade/trade/v2/order_operation_v2.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from webull.trade.request.v2.cancel_order_request import CancelOrderRequest
1818
from webull.trade.request.v2.get_order_detail_request import OrderDetailRequest
1919
from webull.trade.request.v2.get_order_history_request import OrderHistoryRequest
20+
from webull.trade.request.v2.get_order_open_request import OrderOpenRequest
2021
from webull.trade.request.v2.palce_order_request import PlaceOrderRequest
2122
from webull.trade.request.v2.place_option_request import PlaceOptionRequest
2223
from webull.trade.request.v2.preview_option_request import PreviewOptionRequest
@@ -118,6 +119,26 @@ def get_order_history_request(self, account_id, page_size=None, start_date=None,
118119
order_history_request.set_last_client_order_id(last_client_order_id=last_client_order_id)
119120
response = self.client.get_response(order_history_request)
120121
return response
122+
123+
def get_order_open(self, account_id, page_size=None, last_order_id=None):
124+
"""
125+
Paging query pending orders.
126+
127+
:param account_id: Account ID
128+
:param page_size: Limit the number of records per query to 10 by default.
129+
:param start_date: Start date (if empty, the default is the last 7 days), in the format of yyyy-MM-dd.
130+
:param last_client_order_id: The last order ID from the previous response. For the first page query,
131+
this parameter is not required.
132+
"""
133+
order_open_request = OrderOpenRequest()
134+
order_open_request.set_account_id(account_id=account_id)
135+
if page_size:
136+
order_open_request.set_page_size(page_size=page_size)
137+
if last_order_id:
138+
order_open_request.set_last_order_id(last_order_id=last_order_id)
139+
response = self.client.get_response(order_open_request)
140+
return response
141+
121142
def query_order_detail(self, account_id, client_order_id):
122143
"""
123144
This interface is currently available only to individual and institutional clients

0 commit comments

Comments
 (0)