Skip to content

Commit fa8dfc4

Browse files
author
方佳
committed
Merge branch 'main_merge_260808_1' into 'main'
[20260808日常发布]: 【Market Data API】Instrument接口优化(增加标的sub_category) (link) See merge request webull/webull-openapi-java-sdk!42
2 parents e37beb0 + 5f5cb6a commit fa8dfc4

14 files changed

Lines changed: 384 additions & 7 deletions

File tree

‎pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<groupId>com.webull.openapi</groupId>
2222
<artifactId>webull-openapi-java-sdk-parent</artifactId>
2323
<packaging>pom</packaging>
24-
<version>1.1.18</version>
24+
<version>1.1.19</version>
2525

2626
<name>webull-openapi-java-sdk-parent</name>
2727
<url>https://github.com/webull-inc/webull-openapi-java-sdk/</url>

‎webull-openapi-java-sdk-samples/pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<parent>
2020
<groupId>com.webull.openapi</groupId>
2121
<artifactId>webull-openapi-java-sdk-parent</artifactId>
22-
<version>1.1.18</version>
22+
<version>1.1.19</version>
2323
</parent>
2424
<modelVersion>4.0.0</modelVersion>
2525

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package com.webull.openapi.samples.trade;
2+
3+
import com.webull.openapi.core.http.HttpApiConfig;
4+
import com.webull.openapi.core.logger.Logger;
5+
import com.webull.openapi.core.logger.LoggerFactory;
6+
import com.webull.openapi.core.utils.CollectionUtils;
7+
import com.webull.openapi.core.utils.StringUtils;
8+
import com.webull.openapi.samples.config.Env;
9+
import com.webull.openapi.trade.TradeClientV3;
10+
import com.webull.openapi.trade.response.v3.Account;
11+
import com.webull.openapi.trade.response.v3.OrderExecution;
12+
13+
import java.util.List;
14+
15+
public class OrderExecutionClient {
16+
17+
private static final Logger logger = LoggerFactory.getLogger(OrderExecutionClient.class);
18+
19+
public static void main(String[] args) {
20+
HttpApiConfig apiConfig = HttpApiConfig.builder()
21+
.appKey(Env.APP_KEY)
22+
.appSecret(Env.APP_SECRET)
23+
.regionId(Env.REGION_ID)
24+
// .endpoint("<optional_api_endpoint>")
25+
.build();
26+
TradeClientV3 apiService = new TradeClientV3(apiConfig);
27+
28+
// Get account
29+
List<Account> accounts = apiService.listAccount();
30+
logger.info("Accounts: {}", accounts);
31+
String accountId = null;
32+
if (CollectionUtils.isNotEmpty(accounts)) {
33+
accountId = accounts.get(0).getAccountId();
34+
}
35+
if (StringUtils.isBlank(accountId)) {
36+
logger.info("Account id is empty.");
37+
return;
38+
}
39+
40+
// Get order executions filtered by date range
41+
List<OrderExecution> filteredExecutions = apiService.getOrderExecutions(
42+
accountId, null, "2026-06-20", "2026-06-22", null, null);
43+
logger.info("filteredOrderExecutions: {}", filteredExecutions);
44+
45+
// Get order executions for a specific order
46+
List<OrderExecution> orderSpecific = apiService.getOrderExecutions(
47+
accountId, "<your_client_order_id>", null, null, null, null);
48+
logger.info("orderSpecificExecutions: {}", orderSpecific);
49+
50+
// Cursor-based pagination example
51+
if (CollectionUtils.isNotEmpty(filteredExecutions)) {
52+
String lastId = filteredExecutions.get(filteredExecutions.size() - 1).getExecutionId();
53+
List<OrderExecution> nextPage = apiService.getOrderExecutions(
54+
accountId, null, null, null, lastId, 10);
55+
logger.info("nextPageOrderExecutions: {}", nextPage);
56+
}
57+
}
58+
}

‎webull-openapi-java-sdk/pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>com.webull.openapi</groupId>
99
<artifactId>webull-openapi-java-sdk-parent</artifactId>
10-
<version>1.1.18</version>
10+
<version>1.1.19</version>
1111
</parent>
1212

1313
<artifactId>webull-openapi-java-sdk</artifactId>

‎webull-openapi-java-sdk/src/main/java/com/webull/openapi/core/config/ProjectReaderHelper.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ private ProjectReaderHelper() {
2424

2525
private static final String APPLICATION_VERSION = "application.version";
2626

27-
private static final String DEFAULT_APPLICATION_VERSION = "1.1.18";
27+
private static final String DEFAULT_APPLICATION_VERSION = "1.1.19";
2828

2929
private static final String APPLICATION_NAME = "application.name";
3030

‎webull-openapi-java-sdk/src/main/java/com/webull/openapi/data/DataClient.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,7 @@ public List<StockInstrumentDetail> getInstrumentsV1(InstrumentQueryParam param)
515515
String status = param.getStatus();
516516
String lastInstrumentId = param.getLastInstrumentId();
517517
int pageSize = param.getPageSize();
518+
String subCategory = param.getSubCategory();
518519
Assert.notBlank(ArgNames.CATEGORY, category);
519520
HttpRequest request = new HttpRequest("/openapi/instrument/stock/list", Versions.V2, HttpMethod.GET);
520521
Map<String, Object> params = new HashMap<>();
@@ -525,6 +526,9 @@ public List<StockInstrumentDetail> getInstrumentsV1(InstrumentQueryParam param)
525526
if(StringUtils.isNotEmpty(status)){
526527
params.put(ArgNames.STATUS, status);
527528
}
529+
if(StringUtils.isNotEmpty(subCategory)){
530+
params.put(ArgNames.SUB_CATEGORY, subCategory);
531+
}
528532
if(StringUtils.isNotEmpty(lastInstrumentId)){
529533
params.put(ArgNames.LAST_INSTRUMENT_ID, lastInstrumentId);
530534
}

‎webull-openapi-java-sdk/src/main/java/com/webull/openapi/data/common/ArgNames.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ private ArgNames() {
5353
public static final String EXPIRATION_DATE_AFTER = "expiration_date_after";
5454
public static final String LAST_SERIES_ID = "last_series_id";
5555
public static final String PRODUCT_CLASS_ID = "product_class_id";
56+
public static final String SUB_CATEGORY = "sub_category";
5657

5758
// Watchlist related
5859
public static final String WATCHLIST_ID = "watchlist_id";

‎webull-openapi-java-sdk/src/main/java/com/webull/openapi/data/quotes/domain/InstrumentQueryParam.java‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public class InstrumentQueryParam {
2424
private String status;
2525
private String lastInstrumentId;
2626
private int pageSize = 1000;
27+
private String subCategory;
2728

2829
public String getCategory() {
2930
return category;
@@ -64,4 +65,12 @@ public int getPageSize() {
6465
public void setPageSize(int pageSize) {
6566
this.pageSize = pageSize;
6667
}
68+
69+
public String getSubCategory() {
70+
return subCategory;
71+
}
72+
73+
public void setSubCategory(String subCategory) {
74+
this.subCategory = subCategory;
75+
}
6776
}

‎webull-openapi-java-sdk/src/main/java/com/webull/openapi/data/quotes/domain/StockInstrumentDetail.java‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
package com.webull.openapi.data.quotes.domain;
1717

18-
public class StockInstrumentDetail extends Instrument{
18+
public class StockInstrumentDetail extends Instrument {
1919

2020
private String category;
2121

@@ -37,6 +37,8 @@ public class StockInstrumentDetail extends Instrument{
3737

3838
private String lotSize;
3939

40+
private String subCategory;
41+
4042
public Boolean getFractionable() {
4143
return fractionable;
4244
}
@@ -117,11 +119,20 @@ public void setLotSize(String lotSize) {
117119
this.lotSize = lotSize;
118120
}
119121

122+
public String getSubCategory() {
123+
return subCategory;
124+
}
125+
126+
public void setSubCategory(String subCategory) {
127+
this.subCategory = subCategory;
128+
}
129+
120130
@Override
121131
public String toString() {
122132
return "StockInstrumentDetail{" +
123133
"instrumentId='" + getInstrumentId() + '\'' +
124134
", category='" + category + '\'' +
135+
", subCategory='" + subCategory + '\'' +
125136
", symbol='" + getSymbol() + '\'' +
126137
", name='" + getName() + '\'' +
127138
", exchangeCode='" + getExchangeCode() + '\'' +
@@ -138,4 +149,3 @@ public String toString() {
138149
'}';
139150
}
140151
}
141-

‎webull-openapi-java-sdk/src/main/java/com/webull/openapi/trade/TradeClientV3.java‎

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ public class TradeClientV3 implements ITradeV3Client {
5252
private static final String END_TIME_ACTIVITY_PARAM = "end_time";
5353
private static final String LAST_ACTIVITY_ID_PARAM = "last_activity_id";
5454

55+
private static final String LAST_EXECUTION_ID_PARAM = "last_execution_id";
56+
5557
private final Region region;
5658
private final HttpApiClient apiClient;
5759

@@ -283,7 +285,32 @@ public List<Activity> getCashActivities(String accountId, String activityTypes,
283285
}.getType()).doAction();
284286
}
285287

286-
private void addCustomHeadersFromOrder(HttpRequest request, List<TradeOrderItem> orders) {
288+
@Override
289+
public List<OrderExecution> getOrderExecutions(String accountId, String clientOrderId, String startDate, String endDate, String lastExecutionId, Integer pageSize) {
290+
Assert.notBlank(ACCOUNT_ID_ARG, accountId);
291+
292+
HttpRequest request = new HttpRequest("/trading/orders/executions/list", Versions.V2, HttpMethod.GET);
293+
Map<String, Object> params = new HashMap<>();
294+
params.put(ACCOUNT_ID_PARAM, accountId);
295+
params.put(PAGE_SIZE_PARAM, pageSize == null ? 20 : pageSize);
296+
if (StringUtils.isNotBlank(startDate)) {
297+
params.put(START_TIME_PARAM, startDate);
298+
}
299+
if (StringUtils.isNotBlank(endDate)) {
300+
params.put(END_TIME_PARAM, endDate);
301+
}
302+
if (StringUtils.isNotBlank(lastExecutionId)){
303+
params.put(LAST_EXECUTION_ID_PARAM, lastExecutionId);
304+
}
305+
if (StringUtils.isNotBlank(clientOrderId)){
306+
params.put(CLIENT_ORDER_ID_PARAM, clientOrderId);
307+
}
308+
request.setQuery(params);
309+
return apiClient.request(request).responseType(new TypeToken<List<OrderExecution>>() {
310+
}.getType()).doAction();
311+
}
312+
313+
private void addCustomHeadersFromOrder(HttpRequest request, List<TradeOrderItem> orders) {
287314
if (CollectionUtils.isEmpty(orders)
288315
|| Objects.isNull(orders.get(0))) {
289316
return;

0 commit comments

Comments
 (0)