webull-openapi-python-sdk 3.0.2__py3-none-any.whl → 3.0.4__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.
Files changed (44) hide show
  1. samples/__init__.py +1 -1
  2. samples/data/community.py +62 -0
  3. samples/data/data_client.py +79 -0
  4. samples/data/data_client_event.py +7 -0
  5. webull/__init__.py +1 -1
  6. webull/core/__init__.py +1 -1
  7. webull/data/__init__.py +1 -1
  8. webull/data/data_client.py +4 -0
  9. webull/data/quotes/community.py +105 -0
  10. webull/data/quotes/crypto_market_data.py +6 -1
  11. webull/data/quotes/event_market_data.py +6 -1
  12. webull/data/quotes/fundamentals.py +99 -0
  13. webull/data/quotes/futures_market_data.py +6 -1
  14. webull/data/quotes/news.py +70 -0
  15. webull/data/quotes/option_market_data.py +6 -1
  16. webull/data/quotes/screener.py +34 -0
  17. webull/data/request/create_comment_request.py +33 -0
  18. webull/data/request/create_post_request.py +39 -0
  19. webull/data/request/get_crypto_historical_bars_request.py +8 -0
  20. webull/data/request/get_economic_calendar_request.py +39 -0
  21. webull/data/request/get_event_bars_request.py +9 -1
  22. webull/data/request/get_futures_historical_bars_request.py +9 -1
  23. webull/data/request/get_insider_holdings_request.py +35 -0
  24. webull/data/request/get_insider_transactions_request.py +39 -0
  25. webull/data/request/get_institution_holding_changes_request.py +39 -0
  26. webull/data/request/get_institution_holdings_request.py +31 -0
  27. webull/data/request/get_institution_search_request.py +31 -0
  28. webull/data/request/get_news_detail_request.py +27 -0
  29. webull/data/request/get_news_search_request.py +39 -0
  30. webull/data/request/get_option_bars_request.py +21 -0
  31. webull/data/request/get_post_request.py +29 -0
  32. webull/data/request/get_stock_news_request.py +39 -0
  33. webull/data/request/list_hot_stocks_request.py +25 -0
  34. webull/data/request/list_my_posts_request.py +30 -0
  35. webull/data/request/list_posts_by_symbol_request.py +43 -0
  36. webull/data/request/screener/get_fear_and_greed_index_request.py +27 -0
  37. webull/data/request/screener/get_stock_unusual_activities_request.py +43 -0
  38. webull/trade/__init__.py +1 -1
  39. {webull_openapi_python_sdk-3.0.2.dist-info → webull_openapi_python_sdk-3.0.4.dist-info}/METADATA +1 -1
  40. {webull_openapi_python_sdk-3.0.2.dist-info → webull_openapi_python_sdk-3.0.4.dist-info}/RECORD +44 -24
  41. {webull_openapi_python_sdk-3.0.2.dist-info → webull_openapi_python_sdk-3.0.4.dist-info}/WHEEL +0 -0
  42. {webull_openapi_python_sdk-3.0.2.dist-info → webull_openapi_python_sdk-3.0.4.dist-info}/licenses/LICENSE +0 -0
  43. {webull_openapi_python_sdk-3.0.2.dist-info → webull_openapi_python_sdk-3.0.4.dist-info}/licenses/NOTICE +0 -0
  44. {webull_openapi_python_sdk-3.0.2.dist-info → webull_openapi_python_sdk-3.0.4.dist-info}/top_level.txt +0 -0
samples/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = '3.0.2'
1
+ __version__ = '3.0.4'
@@ -0,0 +1,62 @@
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.client import ApiClient
18
+ from webull.data.common.category import Category
19
+ from webull.data.data_client import DataClient
20
+
21
+ optional_api_endpoint = "<api_endpoint>"
22
+ your_app_key = "<your_app_key>"
23
+ your_app_secret = "<your_app_secret>"
24
+ region_id = "<region_id>"
25
+
26
+ api_client = ApiClient(your_app_key, your_app_secret, region_id)
27
+ api_client.add_endpoint(region_id, optional_api_endpoint)
28
+
29
+
30
+ if __name__ == '__main__':
31
+ data_client = DataClient(api_client)
32
+
33
+ response = data_client.community.create_post(
34
+ "Hello, this is a test post from OpenAPI!",
35
+ symbol="NVDA",
36
+ category=Category.US_STOCK.name,
37
+ )
38
+ if response.status_code == 200:
39
+ print('create_post:', response.json())
40
+
41
+ response = data_client.community.create_comment(
42
+ "995005758239301632",
43
+ "Hello, this is a test comment from OpenAPI!",
44
+ )
45
+ if response.status_code == 200:
46
+ print('create_comment:', response.json())
47
+
48
+ response = data_client.community.list_hot_stocks()
49
+ if response.status_code == 200:
50
+ print('list_hot_stocks:', response.json())
51
+
52
+ response = data_client.community.list_posts_by_symbol("NVDA", Category.US_STOCK.name)
53
+ if response.status_code == 200:
54
+ print('list_posts_by_symbol:', response.json())
55
+
56
+ response = data_client.community.get_post("995005758239301632")
57
+ if response.status_code == 200:
58
+ print('get_post:', response.json())
59
+
60
+ response = data_client.community.list_my_posts()
61
+ if response.status_code == 200:
62
+ print('list_my_posts:', response.json())
@@ -59,6 +59,13 @@ if __name__ == '__main__':
59
59
  if res.status_code == 200:
60
60
  print('get_crypto_history_bar:', res.json())
61
61
 
62
+ # Crypto historical bars within a time range using start_time and end_time (timestamps in milliseconds).
63
+ res = data_client.crypto_market_data.get_crypto_history_bar(
64
+ "BTCUSD", Category.US_CRYPTO.name, Timespan.M1.name,
65
+ start_time=1711262998500, end_time=1711349398500)
66
+ if res.status_code == 200:
67
+ print('get_crypto_history_bar with time range:', res.json())
68
+
62
69
  res = data_client.market_data.get_snapshot('AAPL', Category.US_STOCK.name, extend_hour_required=True, overnight_required=True)
63
70
  if res.status_code == 200:
64
71
  print('get_snapshot:', res.json())
@@ -94,6 +101,13 @@ if __name__ == '__main__':
94
101
  if res.status_code == 200:
95
102
  print('get_futures_history_bars:', res.json())
96
103
 
104
+ # Futures historical bars within a time range using start_time and end_time (timestamps in milliseconds).
105
+ res = data_client.futures_market_data.get_futures_history_bars(
106
+ 'SILZ5,6BM6', Category.US_FUTURES.name, Timespan.M1.name,
107
+ start_time=1711262998500, end_time=1711349398500)
108
+ if res.status_code == 200:
109
+ print('get_futures_history_bars with time range:', res.json())
110
+
97
111
  res = data_client.futures_market_data.get_futures_tick("SILZ5", Category.US_FUTURES.name, count=10)
98
112
  if res.status_code == 200:
99
113
  print('get_futures_tick:', res.json())
@@ -156,6 +170,13 @@ if __name__ == '__main__':
156
170
  if res.status_code == 200:
157
171
  print('get_option_history_bars:', res.json())
158
172
 
173
+ # Option historical bars within a time range using start_time and end_time (timestamps in milliseconds).
174
+ res = data_client.option_market_data.get_option_history_bars(
175
+ 'AAPL260522C00300000', Category.US_OPTION.name, Timespan.M1.name,
176
+ start_time=1711262998500, end_time=1711349398500)
177
+ if res.status_code == 200:
178
+ print('get_option_history_bars with time range:', res.json())
179
+
159
180
  # Option market data - Tick
160
181
  # Rate limit: 60 requests per minute
161
182
  res = data_client.option_market_data.get_option_tick("AAPL260522C00300000", Category.US_OPTION.name, count=30)
@@ -292,3 +313,61 @@ if __name__ == '__main__':
292
313
  res = data_client.screener.get_52whl(Category.US_STOCK.name, rank_type="NEW_HIGH")
293
314
  if res.status_code == 200:
294
315
  print('get_52whl:', res.json())
316
+
317
+ # ==================== Screeners ====================
318
+ # Market sentiment (fear & greed) index
319
+ sentiment_res = data_client.screener.get_fear_and_greed_index(Category.US_STOCK.name)
320
+ if sentiment_res.status_code == 200:
321
+ print('get_fear_and_greed_index:', sentiment_res.json())
322
+
323
+ # Stock unusual activities
324
+ unusual_res = data_client.screener.get_stock_unusual_activities("NVDA", Category.US_STOCK.name, count=10)
325
+ if unusual_res.status_code == 200:
326
+ print('get_stock_unusual_activities:', unusual_res.json())
327
+
328
+ # ==================== Fundamentals ====================
329
+ # Macro economic calendar
330
+ calendar_res = data_client.fundamentals.get_economic_calendars("US", "2026-09-01", "2026-09-08")
331
+ if calendar_res.status_code == 200:
332
+ print('get_economic_calendars:', calendar_res.json())
333
+
334
+ # Institution search -> 13F holdings -> holding changes
335
+ institutions_res = data_client.fundamentals.get_institution_search("Bridgewater")
336
+ if institutions_res.status_code == 200:
337
+ print('get_institution_search:', institutions_res.json())
338
+
339
+ holdings_res = data_client.fundamentals.get_institution_holdings("0001738828")
340
+ if holdings_res.status_code == 200:
341
+ print('get_institution_holdings:', holdings_res.json())
342
+
343
+ holding_changes_res = data_client.fundamentals.get_institution_holding_changes("0001738828", "OPEN", count=10)
344
+ if holding_changes_res.status_code == 200:
345
+ print('get_institution_holding_changes:', holding_changes_res.json())
346
+
347
+ # Insider transactions and holdings overview
348
+ insider_tx_res = data_client.fundamentals.get_insider_transactions("NVDA", Category.US_STOCK.name)
349
+ if insider_tx_res.status_code == 200:
350
+ print('get_insider_transactions:', insider_tx_res.json())
351
+
352
+ insider_overview_res = data_client.fundamentals.get_insider_holdings(
353
+ "NVDA", Category.US_STOCK.name, compare_months=1)
354
+ if insider_overview_res.status_code == 200:
355
+ print('get_insider_holdings:', insider_overview_res.json())
356
+
357
+ # ==================== News ====================
358
+ # Search news by keyword
359
+ search_news_res = data_client.news.get_news_search("Starlink")
360
+ if search_news_res.status_code == 200:
361
+ print('get_news_search:', search_news_res.json())
362
+
363
+ # Stock news list
364
+ stock_news_res = data_client.news.get_stock_news("TSLA", Category.US_STOCK.name)
365
+ if stock_news_res.status_code == 200:
366
+ print('get_stock_news:', stock_news_res.json())
367
+
368
+ # News detail (use a news_id returned by the list/search APIs)
369
+ news_items = (stock_news_res.json().get('data') or []) if stock_news_res.status_code == 200 else []
370
+ if news_items:
371
+ news_detail_res = data_client.news.get_news_detail(news_items[0].get('news_id'))
372
+ if news_detail_res.status_code == 200:
373
+ print('get_news_detail:', news_detail_res.json())
@@ -64,6 +64,13 @@ if __name__ == '__main__':
64
64
  if res.status_code == 200:
65
65
  print('get_event_bars:', res.json())
66
66
 
67
+ # Query bars within a time range using start_time and end_time (timestamps in milliseconds).
68
+ res = data_client.event_market_data.get_event_bars(
69
+ "KXRATECUTCOUNT-25DEC31-T10", Timespan.M1, Category.US_EVENT.name, 200, False,
70
+ start_time=1711262998500, end_time=1711349398500)
71
+ if res.status_code == 200:
72
+ print('get_event_bars with time range:', res.json())
73
+
67
74
  res = data_client.event_market_data.get_event_tick("KXRATECUTCOUNT-25DEC31-T10", Category.US_EVENT.name, 30)
68
75
  if res.status_code == 200:
69
76
  print('get_event_tick:', res.json())
webull/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = '3.0.2'
1
+ __version__ = '3.0.4'
webull/core/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
- __version__ = '3.0.2'
1
+ __version__ = '3.0.4'
2
2
 
3
3
  import logging
4
4
 
webull/data/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  # coding=utf-8
2
2
 
3
- __version__ = '3.0.2'
3
+ __version__ = '3.0.4'
@@ -27,6 +27,8 @@ from webull.data.quotes.option_market_data import OptionMarketData
27
27
  from webull.data.quotes.fundamentals import Fundamentals
28
28
  from webull.data.quotes.screener import Screener
29
29
  from webull.data.quotes.watchlist import Watchlist
30
+ from webull.data.quotes.news import News
31
+ from webull.data.quotes.community import Community
30
32
 
31
33
 
32
34
  class DataClient:
@@ -42,6 +44,8 @@ class DataClient:
42
44
  self.fundamentals = Fundamentals(api_client)
43
45
  self.screener = Screener(api_client)
44
46
  self.watchlist = Watchlist(api_client)
47
+ self.community = Community(api_client)
48
+ self.news = News(api_client)
45
49
 
46
50
  def _init_logger(self, api_client):
47
51
  # No logger configured, using default console and local file logging.
@@ -0,0 +1,105 @@
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.create_comment_request import CreateCommentRequest
18
+ from webull.data.request.create_post_request import CreatePostRequest
19
+ from webull.data.request.get_post_request import GetPostRequest
20
+ from webull.data.request.list_hot_stocks_request import ListHotStocksRequest
21
+ from webull.data.request.list_my_posts_request import ListMyPostsRequest
22
+ from webull.data.request.list_posts_by_symbol_request import ListPostsBySymbolRequest
23
+
24
+
25
+ class Community:
26
+ """Community API operations."""
27
+
28
+ def __init__(self, api_client):
29
+ self.client = api_client
30
+
31
+ def create_post(self, text, symbol=None, category=None):
32
+ """
33
+ Create a plain-text community post.
34
+
35
+ :param text: Post content.
36
+ :param symbol: Optional ticker symbol. Provide it with category.
37
+ :param category: Optional ticker market category. Provide it with symbol.
38
+ :return: Response containing the created post identifier.
39
+ """
40
+ request = CreatePostRequest()
41
+ request.set_text(text)
42
+ request.set_symbol(symbol)
43
+ request.set_category(category)
44
+ return self.client.get_response(request)
45
+
46
+ def create_comment(self, post_id, text):
47
+ """
48
+ Create a plain-text comment on an existing community post.
49
+
50
+ :param post_id: Parent post identifier.
51
+ :param text: Comment content.
52
+ :return: Response containing the created comment identifier.
53
+ """
54
+ request = CreateCommentRequest()
55
+ request.set_post_id(post_id)
56
+ request.set_text(text)
57
+ return self.client.get_response(request)
58
+
59
+ def list_hot_stocks(self):
60
+ """
61
+ List stocks ranked by community activity.
62
+
63
+ :return: Response containing hot stock ranking entries.
64
+ """
65
+ request = ListHotStocksRequest()
66
+ return self.client.get_response(request)
67
+
68
+ def list_posts_by_symbol(self, symbol, category, keyword=None, pagination_key=None):
69
+ """
70
+ List community posts associated with a symbol.
71
+
72
+ :param symbol: Stock symbol.
73
+ :param category: Market category.
74
+ :param keyword: Optional search keyword.
75
+ :param pagination_key: Optional key from the previous response.
76
+ :return: Paginated post list response.
77
+ """
78
+ request = ListPostsBySymbolRequest()
79
+ request.set_symbol(symbol)
80
+ request.set_category(category)
81
+ request.set_keyword(keyword)
82
+ request.set_pagination_key(pagination_key)
83
+ return self.client.get_response(request)
84
+
85
+ def get_post(self, post_id):
86
+ """
87
+ Get detailed information for a community post.
88
+
89
+ :param post_id: Post identifier.
90
+ :return: Post detail response.
91
+ """
92
+ request = GetPostRequest()
93
+ request.set_post_id(post_id)
94
+ return self.client.get_response(request)
95
+
96
+ def list_my_posts(self, pagination_key=None):
97
+ """
98
+ List posts created by the current user.
99
+
100
+ :param pagination_key: Optional key from the previous response.
101
+ :return: Paginated post list response.
102
+ """
103
+ request = ListMyPostsRequest()
104
+ request.set_pagination_key(pagination_key)
105
+ return self.client.get_response(request)
@@ -20,7 +20,8 @@ class CryptoMarketData:
20
20
  def __init__(self, api_client):
21
21
  self.client = api_client
22
22
 
23
- def get_crypto_history_bar(self, symbols, category, timespan, count='200', real_time_required=None):
23
+ def get_crypto_history_bar(self, symbols, category, timespan, count='200', real_time_required=None,
24
+ start_time=None, end_time=None):
24
25
  """
25
26
  Returns to Instrument in the window aggregated data.
26
27
  According to the last N K-lines of the stock code, it supports various granularity K-lines such as m1 and m5.
@@ -33,6 +34,8 @@ class CryptoMarketData:
33
34
  :param count: The number of lines: the default is 200, and the maximum limit is 1200
34
35
  :param real_time_required: Returns the latest trade quote data. By default, the most recent market data is returned.
35
36
  By default, only intraday candlestick data is returned.
37
+ :param start_time: Optional start time as a timestamp in milliseconds, used to specify the beginning of the time range for bar data.
38
+ :param end_time: Optional end time as a timestamp in milliseconds, used to specify the end of the time range for bar data.
36
39
  """
37
40
  crypto_history_bar_request = GetCryptoHistoricalBarsRequest()
38
41
  crypto_history_bar_request.set_symbols(symbols)
@@ -40,6 +43,8 @@ class CryptoMarketData:
40
43
  crypto_history_bar_request.set_timespan(timespan)
41
44
  crypto_history_bar_request.set_count(count)
42
45
  crypto_history_bar_request.set_real_time_required(real_time_required)
46
+ crypto_history_bar_request.set_start_time(start_time)
47
+ crypto_history_bar_request.set_end_time(end_time)
43
48
  response = self.client.get_response(crypto_history_bar_request)
44
49
  return response
45
50
 
@@ -52,7 +52,8 @@ class EventMarketData:
52
52
  response = self.client.get_response(quote_request)
53
53
  return response
54
54
 
55
- def get_event_bars(self, symbols, timespan, category=Category.US_EVENT.name, count=200, real_time_required=False):
55
+ def get_event_bars(self, symbols, timespan, category=Category.US_EVENT.name, count=200, real_time_required=False,
56
+ start_time=None, end_time=None):
56
57
  """
57
58
  Get the current order book for a specific event instrument.
58
59
  The order book shows all active bid orders for both yes and no sides of a binary market.
@@ -63,6 +64,8 @@ class EventMarketData:
63
64
  :param category: default is US_EVENT, currently only US_EVENT is supported.
64
65
  :param count: Number of entries, default 200 entries, maximum 1200 entries.
65
66
  :param real_time_required: Does it include the latest data? The k-line that has not been finalized is not included by default. It is false and only used for minutes.
67
+ :param start_time: Optional start time as a timestamp in milliseconds, used to specify the beginning of the time range for bar data.
68
+ :param end_time: Optional end time as a timestamp in milliseconds, used to specify the end of the time range for bar data.
66
69
  """
67
70
  quote_request = GetEventBarsRequest()
68
71
  quote_request.set_symbols(symbols)
@@ -70,6 +73,8 @@ class EventMarketData:
70
73
  quote_request.set_timespan(timespan)
71
74
  quote_request.set_count(count)
72
75
  quote_request.set_real_time_required(real_time_required)
76
+ quote_request.set_start_time(start_time)
77
+ quote_request.set_end_time(end_time)
73
78
  response = self.client.get_response(quote_request)
74
79
  return response
75
80
 
@@ -36,6 +36,12 @@ from webull.data.request.get_financials_cashflow_request import GetFinancialsCas
36
36
  from webull.data.request.get_financials_balance_sheet_request import GetFinancialsBalanceSheetRequest
37
37
  from webull.data.request.get_financials_alert_request import GetFinancialsAlertRequest
38
38
  from webull.data.request.get_forecast_eps_request import GetForecastEpsRequest
39
+ from webull.data.request.get_institution_search_request import GetInstitutionSearchRequest
40
+ from webull.data.request.get_institution_holdings_request import GetInstitutionHoldingsRequest
41
+ from webull.data.request.get_institution_holding_changes_request import GetInstitutionHoldingChangesRequest
42
+ from webull.data.request.get_insider_transactions_request import GetInsiderTransactionsRequest
43
+ from webull.data.request.get_insider_holdings_request import GetInsiderHoldingsRequest
44
+ from webull.data.request.get_economic_calendar_request import GetEconomicCalendarRequest
39
45
 
40
46
 
41
47
  class Fundamentals:
@@ -352,3 +358,96 @@ class Fundamentals:
352
358
  request.set_category(category)
353
359
  response = self.client.get_response(request)
354
360
  return response
361
+
362
+ def get_institution_search(self, keyword, pagination_key=None):
363
+ """
364
+ Search US institutional investors by name or SEC CIK number. US only.
365
+
366
+ :param keyword: Search keyword (institution name or CIK), required.
367
+ :param pagination_key: Pagination key from the previous page response; not returned on the last page.
368
+ """
369
+ request = GetInstitutionSearchRequest()
370
+ request.set_keyword(keyword)
371
+ request.set_pagination_key(pagination_key)
372
+ response = self.client.get_response(request)
373
+ return response
374
+
375
+ def get_institution_holdings(self, cik, pagination_key=None):
376
+ """
377
+ Query a US institution's 13F holdings. US only.
378
+
379
+ :param cik: Institution CIK number, required.
380
+ :param pagination_key: Pagination key from the previous page response; not returned on the last page.
381
+ """
382
+ request = GetInstitutionHoldingsRequest()
383
+ request.set_cik(cik)
384
+ request.set_pagination_key(pagination_key)
385
+ response = self.client.get_response(request)
386
+ return response
387
+
388
+ def get_institution_holding_changes(self, cik, position, count=None, pagination_key=None):
389
+ """
390
+ Query US institutional holding changes filtered by position type. US only.
391
+
392
+ :param cik: Fund CIK number, required.
393
+ :param position: Position type: OPEN, CLOSE, or CHANGE, required.
394
+ :param count: Page size, optional, default 10, max 50.
395
+ :param pagination_key: Pagination key from the previous page response; not returned on the last page.
396
+ """
397
+ request = GetInstitutionHoldingChangesRequest()
398
+ request.set_cik(cik)
399
+ request.set_position(position)
400
+ request.set_count(count)
401
+ request.set_pagination_key(pagination_key)
402
+ response = self.client.get_response(request)
403
+ return response
404
+
405
+ def get_insider_transactions(self, symbol, category=Category.US_STOCK.name, side=None, pagination_key=None):
406
+ """
407
+ Query insider transaction records for a stock.
408
+
409
+ :param symbol: Stock symbol, e.g. NVDA, required.
410
+ :param category: Market category. Supported: US_STOCK (default), HK_STOCK.
411
+ :param side: Transaction side filter: BUY or SELL, None to return all.
412
+ :param pagination_key: Pagination key from the previous page response; not returned on the last page.
413
+ """
414
+ request = GetInsiderTransactionsRequest()
415
+ request.set_symbol(symbol)
416
+ request.set_category(category)
417
+ request.set_side(side)
418
+ request.set_pagination_key(pagination_key)
419
+ response = self.client.get_response(request)
420
+ return response
421
+
422
+ def get_insider_holdings(self, symbol, category=Category.US_STOCK.name, compare_months=None):
423
+ """
424
+ Query the insider ownership statistics overview for a stock.
425
+
426
+ :param symbol: Stock symbol, e.g. NVDA, required.
427
+ :param category: Market category. Supported: US_STOCK (default), HK_STOCK.
428
+ :param compare_months: Comparison period in months: 1 (default) or 3.
429
+ """
430
+ request = GetInsiderHoldingsRequest()
431
+ request.set_symbol(symbol)
432
+ request.set_category(category)
433
+ request.set_compare_months(compare_months)
434
+ response = self.client.get_response(request)
435
+ return response
436
+
437
+ def get_economic_calendars(self, region=None, start_date=None, end_date=None, pagination_key=None):
438
+ """
439
+ Query the macroeconomic event calendar for an optional region and date range.
440
+ Results are cursor-paginated, up to 30 events per page.
441
+
442
+ :param region: Region code: US (default), CN, EU, JP, GB.
443
+ :param start_date: Start date in yyyy-MM-dd format, None defaults to today.
444
+ :param end_date: End date in yyyy-MM-dd format, None defaults to start date + 7 days.
445
+ :param pagination_key: Pagination key from the previous page response; not returned on the last page.
446
+ """
447
+ request = GetEconomicCalendarRequest()
448
+ request.set_region(region)
449
+ request.set_start_date(start_date)
450
+ request.set_end_date(end_date)
451
+ request.set_pagination_key(pagination_key)
452
+ response = self.client.get_response(request)
453
+ return response
@@ -22,7 +22,8 @@ class FuturesMarketData:
22
22
  def __init__(self, api_client):
23
23
  self.client = api_client
24
24
 
25
- def get_futures_history_bars(self, symbols, category, timespan, count='200', real_time_required=None):
25
+ def get_futures_history_bars(self, symbols, category, timespan, count='200', real_time_required=None,
26
+ start_time=None, end_time=None):
26
27
  """
27
28
  Batch query K-line data for multiple futures symbols, returning aggregated data within the window.
28
29
  According to the last N K-lines of the futures code, it supports various granularity K-lines such as m1 and m5.
@@ -32,6 +33,8 @@ class FuturesMarketData:
32
33
  :param timespan: K-line interval
33
34
  :param count: Number of K-lines to return, default is 200, maximum is 1200
34
35
  :param real_time_required: Returns the latest trade quote data. By default, the most recent market data is returned.
36
+ :param start_time: Optional start time as a timestamp in milliseconds, used to specify the beginning of the time range for bar data.
37
+ :param end_time: Optional end time as a timestamp in milliseconds, used to specify the end of the time range for bar data.
35
38
  """
36
39
  history_bar_request = GetFuturesHistoricalBarsRequest()
37
40
  history_bar_request.set_symbols(symbols)
@@ -39,6 +42,8 @@ class FuturesMarketData:
39
42
  history_bar_request.set_timespan(timespan)
40
43
  history_bar_request.set_count(count)
41
44
  history_bar_request.set_real_time_required(real_time_required)
45
+ history_bar_request.set_start_time(start_time)
46
+ history_bar_request.set_end_time(end_time)
42
47
  response = self.client.get_response(history_bar_request)
43
48
  return response
44
49
 
@@ -0,0 +1,70 @@
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.common.category import Category
18
+ from webull.data.request.get_news_detail_request import GetNewsDetailRequest
19
+ from webull.data.request.get_stock_news_request import GetStockNewsRequest
20
+ from webull.data.request.get_news_search_request import GetNewsSearchRequest
21
+
22
+
23
+ class News:
24
+ def __init__(self, api_client):
25
+ self.client = api_client
26
+
27
+ def get_news_search(self, keyword, start_date=None, end_date=None, pagination_key=None):
28
+ """
29
+ Search US market news by keyword. US only.
30
+
31
+ :param keyword: Search keyword, max 100 characters, required.
32
+ :param start_date: Start date in yyyy-MM-dd format, None defaults to 7 days ago.
33
+ :param end_date: End date in yyyy-MM-dd format, None defaults to today.
34
+ :param pagination_key: Pagination key from the previous page response; not returned on the last page.
35
+ """
36
+ request = GetNewsSearchRequest()
37
+ request.set_keyword(keyword)
38
+ request.set_start_date(start_date)
39
+ request.set_end_date(end_date)
40
+ request.set_pagination_key(pagination_key)
41
+ response = self.client.get_response(request)
42
+ return response
43
+
44
+ def get_news_detail(self, news_id):
45
+ """
46
+ Query the full content of a US market news article by its ID. US only.
47
+
48
+ :param news_id: News unique identifier, required.
49
+ """
50
+ request = GetNewsDetailRequest()
51
+ request.set_news_id(news_id)
52
+ response = self.client.get_response(request)
53
+ return response
54
+
55
+ def get_stock_news(self, symbol, category=Category.US_STOCK.name, sentiment=None, pagination_key=None):
56
+ """
57
+ Query stock-related news list with optional sentiment filter.
58
+
59
+ :param symbol: Stock symbol, e.g. TSLA, required.
60
+ :param category: Market category. Supported: US_STOCK (default), HK_STOCK.
61
+ :param sentiment: Sentiment filter: POSITIVE, NEGATIVE or NEUTRAL, None to return all.
62
+ :param pagination_key: Pagination key from the previous page response; not returned on the last page.
63
+ """
64
+ request = GetStockNewsRequest()
65
+ request.set_symbol(symbol)
66
+ request.set_category(category)
67
+ request.set_sentiment(sentiment)
68
+ request.set_pagination_key(pagination_key)
69
+ response = self.client.get_response(request)
70
+ return response
@@ -21,7 +21,8 @@ class OptionMarketData:
21
21
  def __init__(self, api_client):
22
22
  self.client = api_client
23
23
 
24
- def get_option_history_bars(self, symbols, category, timespan, count='200', real_time_required=None):
24
+ def get_option_history_bars(self, symbols, category, timespan, count='200', real_time_required=None,
25
+ start_time=None, end_time=None):
25
26
  """
26
27
  Batch query K-line data for multiple option symbols, returning aggregated data within the window.
27
28
  According to the last N K-lines of the option code, it supports various granularity K-lines such as m1 and m5.
@@ -31,6 +32,8 @@ class OptionMarketData:
31
32
  :param timespan: K-line interval
32
33
  :param count: Number of K-lines to return, default is 200, maximum is 1200
33
34
  :param real_time_required: Returns the latest trade quote data. By default, the most recent market data is returned.
35
+ :param start_time: Optional start time as a timestamp in milliseconds, used to specify the beginning of the time range for bar data.
36
+ :param end_time: Optional end time as a timestamp in milliseconds, used to specify the end of the time range for bar data.
34
37
  """
35
38
  history_bar_request = GetOptionBarsRequest()
36
39
  history_bar_request.set_symbols(symbols)
@@ -38,6 +41,8 @@ class OptionMarketData:
38
41
  history_bar_request.set_timespan(timespan)
39
42
  history_bar_request.set_count(count)
40
43
  history_bar_request.set_real_time_required(real_time_required)
44
+ history_bar_request.set_start_time(start_time)
45
+ history_bar_request.set_end_time(end_time)
41
46
  response = self.client.get_response(history_bar_request)
42
47
  return response
43
48