Skip to content

Commit 0e43586

Browse files
author
方佳
committed
Merge branch 'main_merge_260704' into 'main'
[OpenAPI&FIX-260704 version]: Trading API新增接口:Get Account Cash Activities (支持connect 第三方客户需求) See merge request webull/webull-openapi-java-sdk!37
2 parents fc0aaf3 + ecbeff5 commit 0e43586

8 files changed

Lines changed: 238 additions & 4 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.14</version>
24+
<version>1.1.15</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.14</version>
22+
<version>1.1.15</version>
2323
</parent>
2424
<modelVersion>4.0.0</modelVersion>
2525

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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.Activity;
12+
13+
import java.util.List;
14+
15+
public class CashActivityClient {
16+
17+
private static final Logger logger = LoggerFactory.getLogger(CashActivityClient.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+
.build();
25+
TradeClientV3 apiService = new TradeClientV3(apiConfig);
26+
27+
// Get account
28+
List<Account> accounts = apiService.listAccount();
29+
logger.info("Accounts: {}", accounts);
30+
String accountId = null;
31+
if (CollectionUtils.isNotEmpty(accounts)) {
32+
accountId = accounts.get(0).getAccountId();
33+
}
34+
if (StringUtils.isBlank(accountId)) {
35+
logger.info("Account id is empty.");
36+
return;
37+
}
38+
39+
// Get all cash activities with default page size
40+
List<Activity> activities = apiService.getCashActivities(accountId, null, null, null, null, null);
41+
logger.info("cashActivities: {}", activities);
42+
43+
// Get cash activities filtered by type and time range
44+
List<Activity> filteredActivities = apiService.getCashActivities(
45+
accountId, "TRADE", "2026-06-30T12:00:00.000Z", "2026-07-03T12:00:00.000Z", null, 20);
46+
logger.info("filteredCashActivities: {}", filteredActivities);
47+
48+
// Cursor-based pagination example
49+
if (CollectionUtils.isNotEmpty(activities)) {
50+
String lastId = activities.get(activities.size() - 1).getId();
51+
List<Activity> nextPage = apiService.getCashActivities(
52+
accountId, null, null, null, lastId, 10);
53+
logger.info("nextPageCashActivities: {}", nextPage);
54+
}
55+
}
56+
}

‎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.14</version>
10+
<version>1.1.15</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.14";
27+
private static final String DEFAULT_APPLICATION_VERSION = "1.1.15";
2828

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

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ public class TradeClientV3 implements ITradeV3Client {
4747
private static final String BATCH_ORDERS_PARAM = "batch_orders";
4848
private static final String MODIFY_ORDERS_PARAM = "modify_orders";
4949

50+
private static final String ACTIVITY_TYPES_PARAM = "activity_types";
51+
private static final String START_TIME_ACTIVITY_PARAM = "start_time";
52+
private static final String END_TIME_ACTIVITY_PARAM = "end_time";
53+
private static final String LAST_ACTIVITY_ID_PARAM = "last_activity_id";
54+
5055
private final Region region;
5156
private final HttpApiClient apiClient;
5257

@@ -253,6 +258,31 @@ public List<TradeCalendar> getTradeCalendar(String market, String start, String
253258
return Collections.emptyList();
254259
}
255260

261+
@Override
262+
public List<Activity> getCashActivities(String accountId, String activityTypes, String startTime, String endTime,
263+
String lastActivityId, Integer pageSize) {
264+
Assert.notBlank(ACCOUNT_ID_ARG, accountId);
265+
HttpRequest request = new HttpRequest("/openapi/trade/activities/cash", Versions.V2, HttpMethod.GET);
266+
Map<String, Object> params = new HashMap<>();
267+
params.put(ACCOUNT_ID_PARAM, accountId);
268+
params.put(PAGE_SIZE_PARAM, pageSize == null ? 10 : pageSize);
269+
if (StringUtils.isNotEmpty(activityTypes)) {
270+
params.put(ACTIVITY_TYPES_PARAM, activityTypes);
271+
}
272+
if (StringUtils.isNotEmpty(startTime)) {
273+
params.put(START_TIME_ACTIVITY_PARAM, startTime);
274+
}
275+
if (StringUtils.isNotEmpty(endTime)) {
276+
params.put(END_TIME_ACTIVITY_PARAM, endTime);
277+
}
278+
if (StringUtils.isNotEmpty(lastActivityId)) {
279+
params.put(LAST_ACTIVITY_ID_PARAM, lastActivityId);
280+
}
281+
request.setQuery(params);
282+
return apiClient.request(request).responseType(new TypeToken<List<Activity>>() {
283+
}.getType()).doAction();
284+
}
285+
256286
private void addCustomHeadersFromOrder(HttpRequest request, List<TradeOrderItem> orders) {
257287
if (CollectionUtils.isEmpty(orders)
258288
|| Objects.isNull(orders.get(0))) {

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,12 @@ List<OrderHistory> listOrders(String accountId, Integer pageSize, String startDa
8787
*/
8888
List<TradeCalendar> getTradeCalendar(String market, String start, String end);
8989

90+
/**
91+
* Get cash activities for an account with optional filters.
92+
* This interface is currently supported only for Webull US.
93+
* Support for other regions will be available in future updates.
94+
*/
95+
List<Activity> getCashActivities(String accountId, String activityTypes, String startTime, String endTime,
96+
String lastActivityId, Integer pageSize);
97+
9098
}
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
/*
2+
* Copyright 2022 Webull
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.webull.openapi.trade.response.v3;
17+
18+
import java.io.Serializable;
19+
20+
public class Activity implements Serializable {
21+
22+
private static final long serialVersionUID = 7773597979831220774L;
23+
24+
private String id;
25+
private String accountId;
26+
private String accountNumber;
27+
private String activityType;
28+
private String activitySubType;
29+
private String currency;
30+
private String market;
31+
private String symbol;
32+
private String tradeDate;
33+
private String netAmount;
34+
private String bizTime;
35+
36+
public String getId() {
37+
return id;
38+
}
39+
40+
public void setId(String id) {
41+
this.id = id;
42+
}
43+
44+
public String getAccountId() {
45+
return accountId;
46+
}
47+
48+
public void setAccountId(String accountId) {
49+
this.accountId = accountId;
50+
}
51+
52+
public String getAccountNumber() {
53+
return accountNumber;
54+
}
55+
56+
public void setAccountNumber(String accountNumber) {
57+
this.accountNumber = accountNumber;
58+
}
59+
60+
public String getActivityType() {
61+
return activityType;
62+
}
63+
64+
public void setActivityType(String activityType) {
65+
this.activityType = activityType;
66+
}
67+
68+
public String getActivitySubType() {
69+
return activitySubType;
70+
}
71+
72+
public void setActivitySubType(String activitySubType) {
73+
this.activitySubType = activitySubType;
74+
}
75+
76+
public String getCurrency() {
77+
return currency;
78+
}
79+
80+
public void setCurrency(String currency) {
81+
this.currency = currency;
82+
}
83+
84+
public String getMarket() {
85+
return market;
86+
}
87+
88+
public void setMarket(String market) {
89+
this.market = market;
90+
}
91+
92+
public String getSymbol() {
93+
return symbol;
94+
}
95+
96+
public void setSymbol(String symbol) {
97+
this.symbol = symbol;
98+
}
99+
100+
public String getTradeDate() {
101+
return tradeDate;
102+
}
103+
104+
public void setTradeDate(String tradeDate) {
105+
this.tradeDate = tradeDate;
106+
}
107+
108+
public String getNetAmount() {
109+
return netAmount;
110+
}
111+
112+
public void setNetAmount(String netAmount) {
113+
this.netAmount = netAmount;
114+
}
115+
116+
public String getBizTime() {
117+
return bizTime;
118+
}
119+
120+
public void setBizTime(String bizTime) {
121+
this.bizTime = bizTime;
122+
}
123+
124+
@Override
125+
public String toString() {
126+
return "Activity{" +
127+
"id='" + id + '\'' +
128+
", accountId='" + accountId + '\'' +
129+
", accountNumber='" + accountNumber + '\'' +
130+
", activityType='" + activityType + '\'' +
131+
", activitySubType='" + activitySubType + '\'' +
132+
", currency='" + currency + '\'' +
133+
", market='" + market + '\'' +
134+
", symbol='" + symbol + '\'' +
135+
", tradeDate='" + tradeDate + '\'' +
136+
", netAmount='" + netAmount + '\'' +
137+
", bizTime='" + bizTime + '\'' +
138+
'}';
139+
}
140+
}

0 commit comments

Comments
 (0)