Skip to content

Commit c1cb76e

Browse files
author
方佳
committed
Merge branch 'main_260117_merge' into 'main'
feat: Add footprint interface See merge request webull/webull-openapi-python-sdk!13
2 parents 9d9830c + 5ac6628 commit c1cb76e

11 files changed

Lines changed: 149 additions & 11 deletions

File tree

‎samples/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '1.0.8'
1+
__version__ = '1.0.9'

‎samples/data/data_client.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@
7070
if res.status_code == 200:
7171
print('get_batch_history_bar:', res.json())
7272

73-
res = data_client.market_data.get_tick("AAPL", Category.US_STOCK.name, trading_sessions=trading_sessions)
73+
res = data_client.market_data.get_footprint("AAPL", Category.US_STOCK.name, Timespan.S5.name)
7474
if res.status_code == 200:
75-
print('get_tick:', res.json())
75+
print('get_footprint:', res.json())
7676

7777
res = data_client.market_data.get_quotes("AAPL", Category.US_STOCK.name, depth=1, overnight_required=True)
7878
if res.status_code == 200:
@@ -90,9 +90,9 @@
9090
if res.status_code == 200:
9191
print('get_futures_tick:', res.json())
9292

93-
res = data_client.futures_market_data.get_futures_snapshot("SILZ5,6BM6", Category.US_FUTURES.name)
93+
res = data_client.futures_market_data.get_futures_footprint("SILZ5,6BM6", Category.US_FUTURES.name, Timespan.S5.name)
9494
if res.status_code == 200:
95-
print('get_futures_snapshot:', res.json())
95+
print('get_futures_footprint:', res.json())
9696

9797
res = data_client.instrument.get_futures_products(Category.US_FUTURES.name)
9898
if res.status_code == 200:

‎webull/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '1.0.8'
1+
__version__ = '1.0.9'

‎webull/core/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = '1.0.8'
1+
__version__ = '1.0.9'
22

33
import logging
44

‎webull/data/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# coding=utf-8
22

3-
__version__ = '1.0.8'
3+
__version__ = '1.0.9'

‎webull/data/common/timespan.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
from webull.core.common.easy_enum import EasyEnum
1818
class Timespan(EasyEnum):
19+
S5 = (12, "5 Second")
20+
S15= (13, "15 Second")
1921
M1 = (1, "1 minute")
2022
M5 = (2, "5 minute")
2123
M15 = (3, "15 minute")

‎webull/data/quotes/futures_market_data.py‎

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
15-
14+
from webull.data.common.category import Category
15+
from webull.data.request.get_futures_footprint_request import GetFuturesFootprintRequest
1616
from webull.data.request.get_futures_historical_bars_request import GetFuturesHistoricalBarsRequest
1717
from webull.data.request.get_futures_snapshot_request import GetFuturesSnapshotRequest
1818
from webull.data.request.get_futures_depth_request import GetFuturesDepthRequest
@@ -86,4 +86,26 @@ def get_futures_tick(self, symbol, category, count='200'):
8686
tick_request.set_category(category)
8787
tick_request.set_count(count)
8888
response = self.client.get_response(tick_request)
89+
return response
90+
91+
def get_futures_footprint(self, symbols, category, timespan, count=None,
92+
real_time_required=None, trading_sessions=None):
93+
"""
94+
Search the futures footprint based on the list of futures codes and futures types.
95+
96+
:param symbols: Futures Securities symbol, such as: BITH6,BITF26.
97+
:param category: Security type, enumeration.
98+
:param timespan: Time granularity.
99+
:param count: Number of entries: 200 by default, maximum 1200.
100+
:param real_time_required: Whether to include the latest data or candlestick charts that are not yet finalized. The default is false, meaning they are not included. This option is only used for minute candlestick charts.
101+
:param trading_sessions: RTH: During trading hours, PRE: Before trading hours, ATH: After trading hours. Default: RTH.
102+
"""
103+
footprint_request = GetFuturesFootprintRequest()
104+
footprint_request.set_symbols(symbols)
105+
footprint_request.set_category(category)
106+
footprint_request.set_timespan(timespan)
107+
footprint_request.set_count(count)
108+
footprint_request.set_real_time_required(real_time_required)
109+
footprint_request.set_trading_sessions(trading_sessions)
110+
response = self.client.get_response(footprint_request)
89111
return response

‎webull/data/quotes/market_data.py‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
from webull.data.common.category import Category
1415
from webull.data.request.get_batch_historical_bars_request import BatchHistoricalBarsRequest
1516
from webull.data.request.get_corp_action_request import GetCorpActionRequest
1617
from webull.data.request.get_eod_bars_request import GetEodBarsRequest
18+
from webull.data.request.get_footprint_request import GetFootprintRequest
1719
from webull.data.request.get_historical_bars_request import GetHistoricalBarsRequest
1820
from webull.data.request.get_quotes_request import GetQuotesRequest
1921
from webull.data.request.get_snapshot_request import GetSnapshotRequest
@@ -183,3 +185,25 @@ def get_corp_action(self, instrument_ids, event_types, start_date=None, end_date
183185
eod_corp_action_request.set_last_update_time(last_update_time)
184186
response = self.client.get_response(eod_corp_action_request)
185187
return response
188+
189+
def get_footprint(self, symbols, category, timespan, count=None,
190+
real_time_required=None, trading_sessions=None):
191+
"""
192+
Search the footprint based on the list of security codes and security types.
193+
194+
:param symbols: Securities symbol, such as: 00700,00981.
195+
:param category: Security type, enumeration.
196+
:param timespan: Time granularity.
197+
:param count: Number of entries: 200 by default, maximum 1200.
198+
:param real_time_required: Whether to include the latest data or candlestick charts that are not yet finalized. The default is false, meaning they are not included. This option is only used for minute candlestick charts.
199+
:param trading_sessions: RTH: During trading hours, PRE: Before trading hours, ATH: After trading hours. Default: RTH.
200+
"""
201+
footprint_request = GetFootprintRequest()
202+
footprint_request.set_symbols(symbols)
203+
footprint_request.set_category(category)
204+
footprint_request.set_timespan(timespan)
205+
footprint_request.set_count(count)
206+
footprint_request.set_real_time_required(real_time_required)
207+
footprint_request.set_trading_sessions(trading_sessions)
208+
response = self.client.get_response(footprint_request)
209+
return response
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
# coding=utf-8
16+
from webull.core.request import ApiRequest
17+
18+
class GetFootprintRequest(ApiRequest):
19+
def __init__(self):
20+
ApiRequest.__init__(self, "/openapi/market-data/stock/footprint", version='v2', method="GET", query_params={})
21+
22+
def set_symbols(self, symbols):
23+
if isinstance(symbols, str):
24+
self.add_query_param("symbols", symbols)
25+
elif isinstance(symbols, list):
26+
self.add_query_param("symbols", ",".join(symbols))
27+
28+
def set_category(self, category):
29+
self.add_query_param("category", category)
30+
31+
def set_timespan(self, timespan):
32+
if timespan:
33+
self.add_query_param("timespan", timespan)
34+
35+
def set_count(self, count):
36+
if count:
37+
self.add_query_param("count", count)
38+
39+
def set_real_time_required(self, real_time_required):
40+
if real_time_required:
41+
self.add_query_param("real_time_required", real_time_required)
42+
43+
def set_trading_sessions(self, trading_sessions):
44+
if trading_sessions:
45+
self.add_query_param("trading_sessions", trading_sessions)
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
# coding=utf-8
16+
from webull.core.request import ApiRequest
17+
18+
class GetFuturesFootprintRequest(ApiRequest):
19+
def __init__(self):
20+
ApiRequest.__init__(self, "/openapi/market-data/futures/footprint", version='v2', method="GET", query_params={})
21+
22+
def set_symbols(self, symbols):
23+
if isinstance(symbols, str):
24+
self.add_query_param("symbols", symbols)
25+
elif isinstance(symbols, list):
26+
self.add_query_param("symbols", ",".join(symbols))
27+
28+
def set_category(self, category):
29+
self.add_query_param("category", category)
30+
31+
def set_timespan(self, timespan):
32+
if timespan:
33+
self.add_query_param("timespan", timespan)
34+
35+
def set_count(self, count):
36+
if count:
37+
self.add_query_param("count", count)
38+
39+
def set_real_time_required(self, real_time_required):
40+
if real_time_required:
41+
self.add_query_param("real_time_required", real_time_required)
42+
43+
def set_trading_sessions(self, trading_sessions):
44+
if trading_sessions:
45+
self.add_query_param("trading_sessions", trading_sessions)

0 commit comments

Comments
 (0)