Skip to content

Commit 0a09394

Browse files
author
方佳
committed
Merge branch 'main_merge_260725' into 'main'
feat:Add option event subscribe See merge request webull/webull-openapi-python-sdk!38
2 parents be977b9 + 57bbbe2 commit 0a09394

20 files changed

Lines changed: 85 additions & 82 deletions

‎.github/workflows/pypi-ci.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
name: PyPI-CI
22

3-
# 点击star即可构建
3+
# star build
44

55
# on:
66
# watch:
77
# types: started
88

9-
# push 到main分支才会构建,忽略docs/**和LICENSE等目录
9+
# push to main branch for build, ignore docs/** and LICENSE dir
1010
on:
1111
push:
1212
branches:

‎.kiro/steering/sdk-development.md‎

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Webull SDK Development Specification
2+
3+
## New API Interface Development Process
4+
5+
When adding a new API interface, the following steps must be completed:
6+
7+
### 1. Request Class (Request)
8+
- File path: `webull/data/request/` or `webull/trade/request/`
9+
- Inherit from `ApiRequest`
10+
- Define the API path, version, and HTTP method in `__init__`
11+
- **Must specify the `version='v2'` parameter**
12+
- Provide `set_xxx()` methods to set parameters
13+
- Use `add_query_param()` for GET requests
14+
- Use `add_body_params()` for POST requests
15+
16+
#### Request Class Example
17+
```python
18+
class GetExampleRequest(ApiRequest):
19+
def __init__(self):
20+
ApiRequest.__init__(self, "/openapi/xxx/example", version="v2", method="GET", query_params={})
21+
```
22+
23+
### 2. Business Implementation Class
24+
- File path: `webull/data/quotes/` or `webull/trade/trade/`
25+
- Accept `api_client` as a constructor parameter
26+
- Each method corresponds to one API interface
27+
- Create the corresponding Request object, set its parameters, and call `self.client.get_response(request)`
28+
- Write detailed docstring documentation
29+
30+
### 3. Client Registration
31+
- Register the new business class in `DataClient` or `TradeClient`
32+
- Add the corresponding import statement
33+
34+
### 4. Sample Code (Required)
35+
- File path: the corresponding module folder under `samples/`
36+
- Include a complete usage example
37+
- Include necessary comments and explanations
38+
39+
### 5. Commit Code (Required)
40+
- After completing all the steps above, the code must be committed as a git commit
41+
- The commit message must be written in English
42+
43+
## Code Style
44+
45+
- Use the Apache 2.0 license header
46+
- `# coding=utf-8` encoding declaration
47+
- Detailed docstring documentation
48+
- Perform parameter validation in the set methods
49+
- **Code comments must be in English; Chinese comments are not allowed**
50+
51+
## Module Organization Principles
52+
53+
- Related interfaces should be placed in the same business class
54+
- Different types of interfaces (e.g., news, quotes, trading) should be managed separately
55+
- When creating a new module, also create the corresponding sample code directory

‎samples/__init__.py‎

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

‎samples/trade/activities_client.py‎

Lines changed: 0 additions & 59 deletions
This file was deleted.

‎samples/trade/trade_event_client.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import logging
1616

1717
from webull.trade.events.types import ORDER_STATUS_CHANGED, EVENT_TYPE_ORDER, EVENT_TYPE_POSITION, \
18-
POSITION_STATUS_CHANGED
18+
POSITION_STATUS_CHANGED, EVENT_TYPE_OPTION, OPTION_STATUS_CHANGED
1919
from webull.trade.trade_events_client import TradeEventsClient
2020

2121
your_app_key = "<your_app_key>"
@@ -35,6 +35,8 @@ def my_on_events_message(event_type, subscribe_type, payload, raw_message):
3535
print(payload)
3636
if EVENT_TYPE_POSITION == event_type and POSITION_STATUS_CHANGED == subscribe_type:
3737
print('event payload:%s' % payload)
38+
if EVENT_TYPE_OPTION == event_type and OPTION_STATUS_CHANGED == subscribe_type:
39+
print('option payload:%s' % payload)
3840

3941
if __name__ == '__main__':
4042

‎webull/__init__.py‎

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

‎webull/core/__init__.py‎

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

33
import logging
44

‎webull/core/utils/desensitize.py‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,9 @@ def desensitize_token(token, keep_length=6, mask_length=6):
2121

2222
total_length = len(token)
2323

24-
# 如果字符串长度不足需要保留长度的两倍,则返回全部内容
2524
if total_length <= keep_length * 2:
2625
return token
2726

28-
# 提取前保留部分、后保留部分,并用星号连接
2927
front_part = token[:keep_length]
3028
rear_part = token[-keep_length:] if keep_length > 0 else ''
3129
mask = '*' * mask_length

‎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__ = '2.0.14'
3+
__version__ = '2.0.15'

‎webull/data/quotes/market_streaming_data.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def subscribe(self, session_id, symbols, category, sub_types, depth=None, overni
2727
:param session_id: Create the sessionId used for the connection
2828
:param symbols: Such as: [AAPL,TSLA]
2929
:param category: Security type, enumeration
30-
:param sub_types: Unsubscribe data type, such as: [SNAPSHOT]、SubType Required when unsubscribe_all is empty
30+
:param sub_types: Unsubscribe data type, such as: [SNAPSHOT] SubType Required when unsubscribe_all is empty
3131
or not true
3232
:param depth: Level 2 subscription levels.
3333
10 levels by default, up to 50 levels for U.S. stocks.
@@ -51,7 +51,7 @@ def unsubscribe(self, session_id, symbols=None, category=None, sub_types=None, u
5151
:param session_id: Create the sessionId used for the connection
5252
:param symbols: Such as: [AAPL,TSLA]
5353
:param category: Security type, enumeration
54-
:param sub_types: Unsubscribe data type, such as: [SNAPSHOT]、SubType Required when unsubscribe_all is empty
54+
:param sub_types: Unsubscribe data type, such as: [SNAPSHOT] SubType Required when unsubscribe_all is empty
5555
or not true
5656
:param unsubscribe_all: boolean false (true means canceling all real-time market subscriptions.
5757
When unsubscribe_all is true, symbols, category, sub_types can be empty)

0 commit comments

Comments
 (0)