|
| 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 |
0 commit comments