webull-openapi-python-sdk 2.0.4__py3-none-any.whl → 2.0.6__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.
- samples/__init__.py +1 -1
- samples/data/data_client.py +33 -1
- samples/screener/__init__.py +15 -0
- samples/screener/screener_client.py +118 -0
- samples/watchlist/__init__.py +13 -0
- samples/watchlist/watchlist_client.py +87 -0
- webull/__init__.py +1 -1
- webull/core/__init__.py +1 -1
- webull/core/utils/common.py +3 -1
- webull/data/__init__.py +1 -1
- webull/data/data_client.py +4 -0
- webull/data/quotes/instrument.py +77 -4
- webull/data/quotes/market_data.py +65 -3
- webull/data/quotes/screener.py +116 -0
- webull/data/quotes/watchlist.py +148 -0
- webull/data/request/get_analyst_rating_request.py +38 -0
- webull/data/request/get_analyst_target_price_request.py +38 -0
- webull/data/request/get_batch_historical_bars_request.py +19 -1
- webull/data/request/get_company_profile_request.py +38 -0
- webull/data/request/get_futures_instruments_request.py +6 -0
- webull/data/request/get_futures_product_class.py +24 -0
- webull/data/request/get_futures_products_request.py +3 -0
- webull/data/request/get_historical_bars_request.py +18 -0
- webull/data/request/get_noii_bars_request.py +55 -0
- webull/data/request/get_noii_snapshot_request.py +59 -0
- webull/data/request/screener/__init__.py +15 -0
- webull/data/request/screener/get_gainers_losers_request.py +109 -0
- webull/data/request/screener/get_most_active_request.py +110 -0
- webull/data/request/watchlist/__init__.py +13 -0
- webull/data/request/watchlist/add_watchlist_instruments_request.py +41 -0
- webull/data/request/watchlist/create_watchlist_request.py +39 -0
- webull/data/request/watchlist/delete_watchlist_request.py +30 -0
- webull/data/request/watchlist/get_watchlist_instruments_request.py +30 -0
- webull/data/request/watchlist/get_watchlist_request.py +22 -0
- webull/data/request/watchlist/remove_watchlist_instruments_request.py +40 -0
- webull/data/request/watchlist/update_watchlist_instruments_request.py +41 -0
- webull/data/request/watchlist/update_watchlist_request.py +48 -0
- webull/trade/__init__.py +1 -1
- {webull_openapi_python_sdk-2.0.4.dist-info → webull_openapi_python_sdk-2.0.6.dist-info}/METADATA +1 -1
- {webull_openapi_python_sdk-2.0.4.dist-info → webull_openapi_python_sdk-2.0.6.dist-info}/RECORD +44 -20
- {webull_openapi_python_sdk-2.0.4.dist-info → webull_openapi_python_sdk-2.0.6.dist-info}/WHEEL +0 -0
- {webull_openapi_python_sdk-2.0.4.dist-info → webull_openapi_python_sdk-2.0.6.dist-info}/licenses/LICENSE +0 -0
- {webull_openapi_python_sdk-2.0.4.dist-info → webull_openapi_python_sdk-2.0.6.dist-info}/licenses/NOTICE +0 -0
- {webull_openapi_python_sdk-2.0.4.dist-info → webull_openapi_python_sdk-2.0.6.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,116 @@
|
|
|
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
|
+
|
|
17
|
+
from webull.data.request.screener.get_gainers_losers_request import GetGainersLosersRequest
|
|
18
|
+
from webull.data.request.screener.get_most_active_request import GetMostActiveRequest
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class Screener:
|
|
22
|
+
"""
|
|
23
|
+
Screener class provides access to stock screening and ranking APIs.
|
|
24
|
+
|
|
25
|
+
This class includes methods for:
|
|
26
|
+
- Top gainers/losers ranking by price change over various time periods
|
|
27
|
+
- Most active stocks ranking by volume, turnover, and other activity metrics
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
def __init__(self, api_client):
|
|
31
|
+
self.client = api_client
|
|
32
|
+
|
|
33
|
+
def get_gainers_losers(self, rank_type, category, sort_by, page_index=None, page_size=None, direction=None):
|
|
34
|
+
"""
|
|
35
|
+
Get stock top gainers or losers ranking by price change percentage.
|
|
36
|
+
|
|
37
|
+
This API returns stocks ranked by price change over different time periods.
|
|
38
|
+
Use direction='DESC' for gainers (top performers) and direction='ASC' for losers.
|
|
39
|
+
|
|
40
|
+
:param rank_type: Time period for ranking. Required.
|
|
41
|
+
Enum values:
|
|
42
|
+
- PRE_MARKET: Pre-market session
|
|
43
|
+
- AFTER_MARKET: After-market session
|
|
44
|
+
- MIN_3: 3 minutes
|
|
45
|
+
- MIN_5: 5 minutes
|
|
46
|
+
- DAY_1: 1 day
|
|
47
|
+
- DAY_5: 5 days
|
|
48
|
+
- MONTH_1: 1 month
|
|
49
|
+
- MONTH_3: 3 months
|
|
50
|
+
- WEEK_52: 52 weeks
|
|
51
|
+
:param category: Security market category. Required. (e.g., 'US_STOCK')
|
|
52
|
+
:param sort_by: Secondary sort field. Required.
|
|
53
|
+
Enum values: CHANGE_RATIO, RELATIVE_VOLUME_10D, MARKET_VALUE, CLOSE,
|
|
54
|
+
PRICE, PE_TTM, HIGH, LOW, AMPLITUDE, TURNOVER, VOLUME
|
|
55
|
+
:param page_index: Page number, starting from 1. Optional.
|
|
56
|
+
:param page_size: Number of records per page. Optional.
|
|
57
|
+
:param direction: Sort direction. Optional.
|
|
58
|
+
- ASC: Ascending (for losers)
|
|
59
|
+
- DESC: Descending (for gainers)
|
|
60
|
+
:return: Response containing has_more flag and list of ranked stocks with
|
|
61
|
+
instrument_id, symbol, name, exchange_code, currency_code, pre_close,
|
|
62
|
+
open, high, low, close, price, change, change_ratio, volume,
|
|
63
|
+
turnover, turnover_rate, market_value, amplitude.
|
|
64
|
+
"""
|
|
65
|
+
request = GetGainersLosersRequest()
|
|
66
|
+
request.set_rank_type(rank_type)
|
|
67
|
+
request.set_category(category)
|
|
68
|
+
request.set_sort_by(sort_by)
|
|
69
|
+
request.set_page_index(page_index)
|
|
70
|
+
request.set_page_size(page_size)
|
|
71
|
+
request.set_direction(direction)
|
|
72
|
+
response = self.client.get_response(request)
|
|
73
|
+
return response
|
|
74
|
+
|
|
75
|
+
def get_most_active(self, category, rank_type=None, sort_by=None, page_index=None, page_size=None, direction=None):
|
|
76
|
+
"""
|
|
77
|
+
Get most actively traded stocks ranking.
|
|
78
|
+
|
|
79
|
+
This API returns stocks ranked by trading activity metrics such as volume,
|
|
80
|
+
relative volume, turnover amount, turnover rate, or amplitude.
|
|
81
|
+
|
|
82
|
+
Default sort: rank_type=VOLUME, sort_by=VOLUME, direction=DESC
|
|
83
|
+
|
|
84
|
+
The relative_volume_10d field is unique to this endpoint compared to
|
|
85
|
+
the gainers/losers endpoint.
|
|
86
|
+
|
|
87
|
+
:param category: Security market category. Required. (e.g., 'US_STOCK')
|
|
88
|
+
:param rank_type: Activity metric for ranking. Optional (defaults to VOLUME).
|
|
89
|
+
Enum values:
|
|
90
|
+
- VOLUME: Trading volume
|
|
91
|
+
- RELATIVE_VOLUME_10D: 10-day relative volume
|
|
92
|
+
- TURNOVER: Turnover amount
|
|
93
|
+
- TURNOVER_RATE: Turnover rate
|
|
94
|
+
- AMPLITUDE: Price amplitude
|
|
95
|
+
:param sort_by: Secondary sort field. Optional.
|
|
96
|
+
Enum values: CHANGE_RATIO, RELATIVE_VOLUME_10D, MARKET_VALUE, CLOSE,
|
|
97
|
+
PRICE, PE_TTM, HIGH, LOW, AMPLITUDE, TURNOVER, VOLUME
|
|
98
|
+
:param page_index: Page number, starting from 1. Optional.
|
|
99
|
+
:param page_size: Number of records per page. Optional.
|
|
100
|
+
:param direction: Sort direction. Optional (defaults to DESC).
|
|
101
|
+
- ASC: Ascending order
|
|
102
|
+
- DESC: Descending order
|
|
103
|
+
:return: Response containing has_more flag and list of ranked stocks with
|
|
104
|
+
instrument_id, symbol, name, exchange_code, currency_code, pre_close,
|
|
105
|
+
open, high, low, close, price, change, change_ratio, volume,
|
|
106
|
+
turnover, turnover_rate, market_value, amplitude, relative_volume_10d.
|
|
107
|
+
"""
|
|
108
|
+
request = GetMostActiveRequest()
|
|
109
|
+
request.set_category(category)
|
|
110
|
+
request.set_rank_type(rank_type)
|
|
111
|
+
request.set_sort_by(sort_by)
|
|
112
|
+
request.set_page_index(page_index)
|
|
113
|
+
request.set_page_size(page_size)
|
|
114
|
+
request.set_direction(direction)
|
|
115
|
+
response = self.client.get_response(request)
|
|
116
|
+
return response
|
|
@@ -0,0 +1,148 @@
|
|
|
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
|
+
|
|
17
|
+
from webull.data.request.watchlist.create_watchlist_request import CreateWatchlistRequest
|
|
18
|
+
from webull.data.request.watchlist.delete_watchlist_request import DeleteWatchlistRequest
|
|
19
|
+
from webull.data.request.watchlist.update_watchlist_request import UpdateWatchlistRequest
|
|
20
|
+
from webull.data.request.watchlist.get_watchlist_request import GetWatchlistRequest
|
|
21
|
+
from webull.data.request.watchlist.add_watchlist_instruments_request import AddWatchlistInstrumentsRequest
|
|
22
|
+
from webull.data.request.watchlist.remove_watchlist_instruments_request import RemoveWatchlistInstrumentsRequest
|
|
23
|
+
from webull.data.request.watchlist.update_watchlist_instruments_request import UpdateWatchlistInstrumentsRequest
|
|
24
|
+
from webull.data.request.watchlist.get_watchlist_instruments_request import GetWatchlistInstrumentsRequest
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class Watchlist:
|
|
28
|
+
def __init__(self, api_client):
|
|
29
|
+
self.client = api_client
|
|
30
|
+
|
|
31
|
+
def create_watchlist(self, name, sort=None):
|
|
32
|
+
"""
|
|
33
|
+
Create a new watchlist.
|
|
34
|
+
Maximum 20 watchlists can be created (shared with retail).
|
|
35
|
+
|
|
36
|
+
:param name: Watchlist name. Maximum 20 watchlists can be created.
|
|
37
|
+
:param sort: Sort order number (optional).
|
|
38
|
+
:return: Response containing the new watchlist_id.
|
|
39
|
+
"""
|
|
40
|
+
request = CreateWatchlistRequest()
|
|
41
|
+
request.set_name(name)
|
|
42
|
+
request.set_sort(sort)
|
|
43
|
+
response = self.client.get_response(request)
|
|
44
|
+
return response
|
|
45
|
+
|
|
46
|
+
def delete_watchlist(self, watchlist_id):
|
|
47
|
+
"""
|
|
48
|
+
Delete a watchlist and all instruments in it. This operation is irreversible.
|
|
49
|
+
|
|
50
|
+
:param watchlist_id: Watchlist unique identifier.
|
|
51
|
+
:return: Response containing success status.
|
|
52
|
+
"""
|
|
53
|
+
request = DeleteWatchlistRequest()
|
|
54
|
+
request.set_watchlist_id(watchlist_id)
|
|
55
|
+
response = self.client.get_response(request)
|
|
56
|
+
return response
|
|
57
|
+
|
|
58
|
+
def update_watchlist(self, watchlist_id, name=None, sort=None):
|
|
59
|
+
"""
|
|
60
|
+
Update an existing watchlist's properties such as name or sort order.
|
|
61
|
+
Only provided fields will be updated; unprovided fields remain unchanged.
|
|
62
|
+
|
|
63
|
+
:param watchlist_id: Watchlist unique identifier.
|
|
64
|
+
:param name: New watchlist name (optional).
|
|
65
|
+
:param sort: New sort order number (optional).
|
|
66
|
+
:return: Response containing success status.
|
|
67
|
+
"""
|
|
68
|
+
request = UpdateWatchlistRequest()
|
|
69
|
+
request.set_watchlist_id(watchlist_id)
|
|
70
|
+
request.set_name(name)
|
|
71
|
+
request.set_sort(sort)
|
|
72
|
+
response = self.client.get_response(request)
|
|
73
|
+
return response
|
|
74
|
+
|
|
75
|
+
def get_watchlist(self):
|
|
76
|
+
"""
|
|
77
|
+
Get all watchlists for the current user, sorted by sort order in descending order.
|
|
78
|
+
|
|
79
|
+
:return: List of watchlists containing watchlist_id, name, sort, create_time, update_time.
|
|
80
|
+
"""
|
|
81
|
+
request = GetWatchlistRequest()
|
|
82
|
+
response = self.client.get_response(request)
|
|
83
|
+
return response
|
|
84
|
+
|
|
85
|
+
def add_instruments(self, watchlist_id, instruments):
|
|
86
|
+
"""
|
|
87
|
+
Add one or more instruments to an existing watchlist.
|
|
88
|
+
Currently does not support EC contracts, futures, or options.
|
|
89
|
+
Maximum 1000 instruments total across all watchlists.
|
|
90
|
+
|
|
91
|
+
:param watchlist_id: Watchlist unique identifier.
|
|
92
|
+
:param instruments: List of instruments to add. Each instrument should contain:
|
|
93
|
+
- symbol: Instrument symbol (e.g., AAPL)
|
|
94
|
+
- category: Instrument category (e.g., US_STOCK, US_CRYPTO)
|
|
95
|
+
- sort: Sort order number
|
|
96
|
+
:return: Response containing success status.
|
|
97
|
+
"""
|
|
98
|
+
request = AddWatchlistInstrumentsRequest()
|
|
99
|
+
request.set_watchlist_id(watchlist_id)
|
|
100
|
+
request.set_instruments(instruments)
|
|
101
|
+
response = self.client.get_response(request)
|
|
102
|
+
return response
|
|
103
|
+
|
|
104
|
+
def remove_instruments(self, watchlist_id, instruments):
|
|
105
|
+
"""
|
|
106
|
+
Remove one or more instruments from a watchlist by symbol and category.
|
|
107
|
+
|
|
108
|
+
:param watchlist_id: Watchlist unique identifier.
|
|
109
|
+
:param instruments: List of instruments to remove. Each instrument should contain:
|
|
110
|
+
- symbol: Instrument symbol (e.g., AAPL)
|
|
111
|
+
- category: Instrument category (e.g., US_STOCK)
|
|
112
|
+
:return: Response containing success status.
|
|
113
|
+
"""
|
|
114
|
+
request = RemoveWatchlistInstrumentsRequest()
|
|
115
|
+
request.set_watchlist_id(watchlist_id)
|
|
116
|
+
request.set_instruments(instruments)
|
|
117
|
+
response = self.client.get_response(request)
|
|
118
|
+
return response
|
|
119
|
+
|
|
120
|
+
def update_instruments(self, watchlist_id, instruments):
|
|
121
|
+
"""
|
|
122
|
+
Update the sort order of instruments in a watchlist.
|
|
123
|
+
|
|
124
|
+
:param watchlist_id: Watchlist unique identifier.
|
|
125
|
+
:param instruments: List of instruments to update. Each instrument should contain:
|
|
126
|
+
- symbol: Instrument symbol (for locating)
|
|
127
|
+
- category: Instrument category (for locating)
|
|
128
|
+
- sort: New sort order number
|
|
129
|
+
:return: Response containing success status.
|
|
130
|
+
"""
|
|
131
|
+
request = UpdateWatchlistInstrumentsRequest()
|
|
132
|
+
request.set_watchlist_id(watchlist_id)
|
|
133
|
+
request.set_instruments(instruments)
|
|
134
|
+
response = self.client.get_response(request)
|
|
135
|
+
return response
|
|
136
|
+
|
|
137
|
+
def get_instruments(self, watchlist_id):
|
|
138
|
+
"""
|
|
139
|
+
Get all instruments in a watchlist, sorted by sort_order in descending order.
|
|
140
|
+
|
|
141
|
+
:param watchlist_id: Watchlist unique identifier.
|
|
142
|
+
:return: Response containing watchlist_id and list of instruments with
|
|
143
|
+
instrument_id, symbol, name, exchange_code, sort, added_time.
|
|
144
|
+
"""
|
|
145
|
+
request = GetWatchlistInstrumentsRequest()
|
|
146
|
+
request.set_watchlist_id(watchlist_id)
|
|
147
|
+
response = self.client.get_response(request)
|
|
148
|
+
return response
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
|
|
17
|
+
from webull.core.request import ApiRequest
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class GetAnalystRatingRequest(ApiRequest):
|
|
21
|
+
def __init__(self):
|
|
22
|
+
ApiRequest.__init__(self, "/openapi/instrument/analyst/rating", version="v2", method="GET", query_params={})
|
|
23
|
+
|
|
24
|
+
def set_symbol(self, symbol):
|
|
25
|
+
"""
|
|
26
|
+
Set the security symbol.
|
|
27
|
+
|
|
28
|
+
:param symbol: Security symbol, e.g., AAPL
|
|
29
|
+
"""
|
|
30
|
+
self.add_query_param("symbol", symbol)
|
|
31
|
+
|
|
32
|
+
def set_category(self, category):
|
|
33
|
+
"""
|
|
34
|
+
Set the security type.
|
|
35
|
+
|
|
36
|
+
:param category: Security type. Possible values: US_STOCK
|
|
37
|
+
"""
|
|
38
|
+
self.add_query_param("category", category)
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
|
|
17
|
+
from webull.core.request import ApiRequest
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class GetAnalystTargetPriceRequest(ApiRequest):
|
|
21
|
+
def __init__(self):
|
|
22
|
+
ApiRequest.__init__(self, "/openapi/instrument/analyst/target-price", version="v2", method="GET", query_params={})
|
|
23
|
+
|
|
24
|
+
def set_symbol(self, symbol):
|
|
25
|
+
"""
|
|
26
|
+
Set the security symbol.
|
|
27
|
+
|
|
28
|
+
:param symbol: Security symbol, e.g., AAPL
|
|
29
|
+
"""
|
|
30
|
+
self.add_query_param("symbol", symbol)
|
|
31
|
+
|
|
32
|
+
def set_category(self, category):
|
|
33
|
+
"""
|
|
34
|
+
Set the security type.
|
|
35
|
+
|
|
36
|
+
:param category: Security type. Possible values: US_STOCK
|
|
37
|
+
"""
|
|
38
|
+
self.add_query_param("category", category)
|
|
@@ -40,4 +40,22 @@ class BatchHistoricalBarsRequest(ApiRequest):
|
|
|
40
40
|
if isinstance(trading_sessions, list):
|
|
41
41
|
self.add_body_params("trading_sessions", ','.join(trading_sessions))
|
|
42
42
|
else:
|
|
43
|
-
self.add_body_params("trading_sessions", trading_sessions)
|
|
43
|
+
self.add_body_params("trading_sessions", trading_sessions)
|
|
44
|
+
|
|
45
|
+
def set_start_time(self, start_time):
|
|
46
|
+
"""
|
|
47
|
+
Set the start time for querying bars.
|
|
48
|
+
|
|
49
|
+
:param start_time: Timestamp in milliseconds (Long).
|
|
50
|
+
"""
|
|
51
|
+
if start_time is not None:
|
|
52
|
+
self.add_body_params("start_time", start_time)
|
|
53
|
+
|
|
54
|
+
def set_end_time(self, end_time):
|
|
55
|
+
"""
|
|
56
|
+
Set the end time for querying bars. Delayed permission will auto-offset time.
|
|
57
|
+
|
|
58
|
+
:param end_time: Timestamp in milliseconds (Long).
|
|
59
|
+
"""
|
|
60
|
+
if end_time is not None:
|
|
61
|
+
self.add_body_params("end_time", end_time)
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
|
|
17
|
+
from webull.core.request import ApiRequest
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class GetCompanyProfileRequest(ApiRequest):
|
|
21
|
+
def __init__(self):
|
|
22
|
+
ApiRequest.__init__(self, "/openapi/instrument/company/profile", version="v2", method="GET", query_params={})
|
|
23
|
+
|
|
24
|
+
def set_symbol(self, symbol):
|
|
25
|
+
"""
|
|
26
|
+
Set the security symbol.
|
|
27
|
+
|
|
28
|
+
:param symbol: Security symbol, e.g., AAPL
|
|
29
|
+
"""
|
|
30
|
+
self.add_query_param("symbol", symbol)
|
|
31
|
+
|
|
32
|
+
def set_category(self, category):
|
|
33
|
+
"""
|
|
34
|
+
Set the security type.
|
|
35
|
+
|
|
36
|
+
:param category: Security type. Possible values: US_STOCK
|
|
37
|
+
"""
|
|
38
|
+
self.add_query_param("category", category)
|
|
@@ -29,3 +29,9 @@ class GetFuturesInstrumentsRequest(ApiRequest):
|
|
|
29
29
|
|
|
30
30
|
def set_category(self, category):
|
|
31
31
|
self.add_query_param("category", category)
|
|
32
|
+
|
|
33
|
+
def set_code(self, code):
|
|
34
|
+
self.add_query_param("code", code)
|
|
35
|
+
|
|
36
|
+
def set_status(self, status):
|
|
37
|
+
self.add_query_param("status", status)
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
|
|
17
|
+
from webull.core.request import ApiRequest
|
|
18
|
+
|
|
19
|
+
class GetFuturesProductClassRequest(ApiRequest):
|
|
20
|
+
def __init__(self):
|
|
21
|
+
ApiRequest.__init__(self, "/openapi/instrument/futures/product-classes", version='v2', method="GET", query_params={})
|
|
22
|
+
|
|
23
|
+
def set_category(self, category):
|
|
24
|
+
self.add_query_param("category", category)
|
|
@@ -41,3 +41,21 @@ class GetHistoricalBarsRequest(ApiRequest):
|
|
|
41
41
|
self.add_query_param("trading_sessions", ','.join(trading_sessions))
|
|
42
42
|
else:
|
|
43
43
|
self.add_query_param("trading_sessions", trading_sessions)
|
|
44
|
+
|
|
45
|
+
def set_start_time(self, start_time):
|
|
46
|
+
"""
|
|
47
|
+
Set the start time for querying bars.
|
|
48
|
+
|
|
49
|
+
:param start_time: Timestamp in milliseconds (Long).
|
|
50
|
+
"""
|
|
51
|
+
if start_time is not None:
|
|
52
|
+
self.add_query_param("start_time", start_time)
|
|
53
|
+
|
|
54
|
+
def set_end_time(self, end_time):
|
|
55
|
+
"""
|
|
56
|
+
Set the end time for querying bars. Delayed permission will auto-offset time.
|
|
57
|
+
|
|
58
|
+
:param end_time: Timestamp in milliseconds (Long).
|
|
59
|
+
"""
|
|
60
|
+
if end_time is not None:
|
|
61
|
+
self.add_query_param("end_time", end_time)
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
|
|
17
|
+
from webull.core.request import ApiRequest
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class GetNoiiBarsRequest(ApiRequest):
|
|
21
|
+
"""
|
|
22
|
+
Request class for Stock NOII Bars API.
|
|
23
|
+
|
|
24
|
+
NOII (Net Order Imbalance Indicator) data provides insight into market supply
|
|
25
|
+
and demand during NASDAQ opening and closing auctions.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
def __init__(self):
|
|
29
|
+
ApiRequest.__init__(self, "/openapi/market-data/stock/noii/bars", version="v2", method="GET", query_params={})
|
|
30
|
+
|
|
31
|
+
def set_symbol(self, symbol):
|
|
32
|
+
"""
|
|
33
|
+
Set the security symbol. Only single symbol query is supported.
|
|
34
|
+
|
|
35
|
+
:param symbol: Security symbol, e.g., AAPL
|
|
36
|
+
"""
|
|
37
|
+
self.add_query_param("symbol", symbol)
|
|
38
|
+
|
|
39
|
+
def set_category(self, category):
|
|
40
|
+
"""
|
|
41
|
+
Set the security category. Currently only US_STOCK is supported.
|
|
42
|
+
|
|
43
|
+
:param category: Security category, e.g., US_STOCK
|
|
44
|
+
"""
|
|
45
|
+
self.add_query_param("category", category)
|
|
46
|
+
|
|
47
|
+
def set_imbalance_action_type(self, imbalance_action_type):
|
|
48
|
+
"""
|
|
49
|
+
Set the imbalance action type.
|
|
50
|
+
|
|
51
|
+
:param imbalance_action_type: Imbalance action type.
|
|
52
|
+
- PRE_OPEN: Opening imbalance
|
|
53
|
+
- PRE_CLOSE: Closing imbalance
|
|
54
|
+
"""
|
|
55
|
+
self.add_query_param("imbalance_action_type", imbalance_action_type)
|
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
|
|
17
|
+
from webull.core.request import ApiRequest
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class GetNoiiSnapshotRequest(ApiRequest):
|
|
21
|
+
"""
|
|
22
|
+
Request class for Stock NOII Snapshot API.
|
|
23
|
+
|
|
24
|
+
Provides the latest NOII snapshot during US stock auction phases (opening/closing).
|
|
25
|
+
NOII data is published only during call auction periods and updates every 5 seconds.
|
|
26
|
+
|
|
27
|
+
Opening auction: 9:28 - 9:30 AM ET (2 minutes)
|
|
28
|
+
Closing auction: 3:50 - 4:00 PM ET (10 minutes)
|
|
29
|
+
Outside these periods, historical data is returned.
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
def __init__(self):
|
|
33
|
+
ApiRequest.__init__(self, "/openapi/market-data/stock/noii/snapshot", version="v2", method="GET", query_params={})
|
|
34
|
+
|
|
35
|
+
def set_symbol(self, symbol):
|
|
36
|
+
"""
|
|
37
|
+
Set the security symbol. Only single symbol query is supported.
|
|
38
|
+
|
|
39
|
+
:param symbol: Security symbol, e.g., AAPL
|
|
40
|
+
"""
|
|
41
|
+
self.add_query_param("symbol", symbol)
|
|
42
|
+
|
|
43
|
+
def set_category(self, category):
|
|
44
|
+
"""
|
|
45
|
+
Set the security category. Currently only US_STOCK is supported.
|
|
46
|
+
|
|
47
|
+
:param category: Security category, e.g., US_STOCK
|
|
48
|
+
"""
|
|
49
|
+
self.add_query_param("category", category)
|
|
50
|
+
|
|
51
|
+
def set_imbalance_action_type(self, imbalance_action_type):
|
|
52
|
+
"""
|
|
53
|
+
Set the imbalance action type.
|
|
54
|
+
|
|
55
|
+
:param imbalance_action_type: Imbalance action type.
|
|
56
|
+
- PRE_OPEN: Opening imbalance
|
|
57
|
+
- PRE_CLOSE: Closing imbalance
|
|
58
|
+
"""
|
|
59
|
+
self.add_query_param("imbalance_action_type", imbalance_action_type)
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|