Skip to content

Commit a7ce915

Browse files
author
方佳
committed
Merge branch 'main_merge_260916' into 'main'
[API-1623]: route getBars to batch stocks/bars/list endpoint and deprecate... See merge request webull/webull-openapi-java-sdk!47
2 parents 1ed8393 + 1f144ac commit a7ce915

6 files changed

Lines changed: 38 additions & 25 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>2.0.0</version>
24+
<version>2.0.1</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>2.0.0</version>
22+
<version>2.0.1</version>
2323
</parent>
2424
<modelVersion>4.0.0</modelVersion>
2525

‎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>2.0.0</version>
10+
<version>2.0.1</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 = "2.0.0";
27+
private static final String DEFAULT_APPLICATION_VERSION = "2.0.1";
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: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -96,30 +96,25 @@ public List<Bar> getBars(String symbol, String category, String timespan, int co
9696
return getBars(symbol, category, timespan, count, realTimeRequired, tradingSessions, null, null);
9797
}
9898

99+
/**
100+
* @deprecated The endpoint /market-data/stocks/bars/get is no longer available.
101+
* This method now delegates to {@link #getBatchBars} which calls the batch
102+
* endpoint /market-data/stocks/bars/list. Prefer getBatchBars directly.
103+
*/
104+
@Deprecated
99105
@Override
100106
public List<Bar> getBars(String symbol, String category, String timespan, int count, Boolean realTimeRequired, List<String> tradingSessions, Long startTime, Long endTime) {
101107
Assert.notBlank(Arrays.asList(ArgNames.SYMBOL, ArgNames.CATEGORY, ArgNames.TIMESPAN), symbol, category, timespan);
102-
HttpRequest request = new HttpRequest("/market-data/stocks/bars/get", Versions.V3, HttpMethod.GET);
103-
Map<String, Object> params = new HashMap<>();
104-
params.put(ArgNames.SYMBOL, symbol);
105-
params.put(ArgNames.CATEGORY, category);
106-
params.put(ArgNames.TIMESPAN, timespan);
107-
params.put(ArgNames.COUNT, count);
108-
if(Objects.nonNull(realTimeRequired)){
109-
params.put(ArgNames.REAL_TIME_REQUIRED, realTimeRequired);
110-
}
111-
if(CollectionUtils.isNotEmpty(tradingSessions)){
112-
params.put(ArgNames.TRADING_SESSIONS, String.join(",", tradingSessions));
113-
}
114-
if(Objects.nonNull(startTime)){
115-
params.put(ArgNames.START_TIME, startTime);
116-
}
117-
if(Objects.nonNull(endTime)){
118-
params.put(ArgNames.END_TIME, endTime);
119-
}
120-
request.setQuery(params);
121-
addCustomHeaders(request);
122-
return apiClient.request(request).responseType(new TypeToken<List<Bar>>() {}.getType()).doAction();
108+
BatchBarResponse response = getBatchBars(Collections.singletonList(symbol), category, timespan, count,
109+
realTimeRequired, tradingSessions, startTime, endTime);
110+
if (Objects.isNull(response) || CollectionUtils.isEmpty(response.getResult())) {
111+
return Collections.emptyList();
112+
}
113+
return response.getResult().stream()
114+
.filter(nBar -> symbol.equals(nBar.getSymbol()))
115+
.findFirst()
116+
.map(NBar::getResult)
117+
.orElse(Collections.emptyList());
123118
}
124119

125120
@Override

‎webull-openapi-java-sdk/src/main/java/com/webull/openapi/data/quotes/api/IDataClient.java‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,32 @@ public interface IDataClient {
2525

2626
List<Instrument> getInstruments(Set<String> symbols, String category);
2727

28+
/**
29+
* @deprecated The endpoint /market-data/stocks/bars/get is no longer available.
30+
* Use {@link #getBatchBars(List, String, String, int)} instead.
31+
*/
32+
@Deprecated
2833
default List<Bar> getBars(String symbol, String category, String timespan) {
2934
return getBars(symbol, category, timespan, 200);
3035
}
3136

37+
/**
38+
* @deprecated The endpoint /market-data/stocks/bars/get is no longer available.
39+
* Use {@link #getBatchBars(List, String, String, int)} instead.
40+
*/
41+
@Deprecated
3242
List<Bar> getBars(String symbol, String category, String timespan, int count);
3343

3444
/**
3545
* Get batch bars for multiple symbols.
3646
*/
3747
BatchBarResponse getBatchBars(List<String> symbols, String category, String timespan, int count);
3848

49+
/**
50+
* @deprecated The endpoint /market-data/stocks/bars/get is no longer available.
51+
* Use {@link #getBatchBars(List, String, String, int, Boolean, List)} instead.
52+
*/
53+
@Deprecated
3954
List<Bar> getBars(String symbol, String category, String timespan, int count, Boolean realTimeRequired, List<String> tradingSessions);
4055

4156
/**
@@ -50,7 +65,10 @@ default List<Bar> getBars(String symbol, String category, String timespan) {
5065
* @param startTime Start time in milliseconds timestamp (optional)
5166
* @param endTime End time in milliseconds timestamp (optional)
5267
* @return List of bars
68+
* @deprecated The endpoint /market-data/stocks/bars/get is no longer available.
69+
* Use {@link #getBatchBars(List, String, String, int, Boolean, List, Long, Long)} instead.
5370
*/
71+
@Deprecated
5472
List<Bar> getBars(String symbol, String category, String timespan, int count, Boolean realTimeRequired, List<String> tradingSessions, Long startTime, Long endTime);
5573

5674
/**

0 commit comments

Comments
 (0)