Skip to content

Commit 37511b1

Browse files
author
方佳
committed
Merge branch 'main_merge_25081501' into 'main'
feat: updated HK market and JP asset interfaces See merge request webull/openapi-java-sdk!24
2 parents e852372 + a95c0f9 commit 37511b1

File tree

27 files changed

+1151
-93
lines changed

27 files changed

+1151
-93
lines changed

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-java-sdk</artifactId>
2323
<packaging>pom</packaging>
24-
<version>0.2.14</version>
24+
<version>0.2.15</version>
2525

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

webull-java-sdk-core/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-java-sdk</artifactId>
22-
<version>0.2.14</version>
22+
<version>0.2.15</version>
2323
</parent>
2424

2525
<modelVersion>4.0.0</modelVersion>

webull-java-sdk-core/src/main/java/com/webull/openapi/common/dict/Category.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,16 @@ public enum Category {
6060
/**
6161
* Stock/ETF CFDs
6262
*/
63-
US_CFDONSTOCK
63+
US_CFDONSTOCK,
64+
65+
/**
66+
* Japan stock
67+
*/
68+
JP_STOCK,
69+
70+
/**
71+
* Japan etf
72+
*/
73+
JP_ETF;
74+
6475
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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.common.dict;
17+
18+
public enum TradingSession {
19+
20+
/** Pre-Market */
21+
PRE,
22+
23+
/** Regular Trading Hours */
24+
RTH,
25+
26+
/** After-Trading Hours */
27+
ATH,
28+
29+
/** Overnight */
30+
OVN,
31+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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.common.dict;
17+
18+
public enum YesOrNo {
19+
20+
/** Yes */
21+
Y,
22+
23+
/** No */
24+
N,
25+
}

webull-java-sdk-core/src/main/java/com/webull/openapi/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 = "0.2.14";
27+
private static final String DEFAULT_APPLICATION_VERSION = "0.2.15";
2828

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

webull-java-sdk-example/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-java-sdk</artifactId>
22-
<version>0.2.14</version>
22+
<version>0.2.15</version>
2323
</parent>
2424

2525
<modelVersion>4.0.0</modelVersion>

webull-java-sdk-example/src/main/java/com/webull/openapi/example/quotes/QuotesGrpcApi.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import com.google.api.client.util.Lists;
44
import com.webull.openapi.common.dict.Category;
55
import com.webull.openapi.common.dict.Timespan;
6+
import com.webull.openapi.common.dict.TradingSession;
7+
import com.webull.openapi.common.dict.YesOrNo;
68
import com.webull.openapi.example.config.Env;
79
import com.webull.openapi.execption.ClientException;
810
import com.webull.openapi.execption.ServerException;
@@ -17,6 +19,7 @@
1719
import com.webull.openapi.quotes.domain.Tick;
1820
import com.webull.openapi.serialize.JsonSerializer;
1921

22+
import java.util.ArrayList;
2023
import java.util.HashSet;
2124
import java.util.List;
2225
import java.util.Set;
@@ -39,6 +42,12 @@ public static void main(String[] args) {
3942
symbols.add("AAPL");
4043
symbols.add("TSLA");
4144

45+
List<String> tradingSessions = new ArrayList<>();
46+
tradingSessions.add(TradingSession.PRE.name());
47+
tradingSessions.add(TradingSession.RTH.name());
48+
tradingSessions.add(TradingSession.ATH.name());
49+
tradingSessions.add(TradingSession.OVN.name());
50+
4251
List<Instrument> instruments = quotesApiClient.getInstruments(symbols, Category.US_STOCK.name());
4352
logger.info("Instruments: {}", JsonSerializer.toJson(instruments));
4453

@@ -50,6 +59,14 @@ public static void main(String[] args) {
5059
BatchBarResponse batchBars = quotesApiClient.getBatchBars(Lists.newArrayList(symbols), Category.US_STOCK.name(), Timespan.M1.name(), 2);
5160
logger.info("Batch bars: {}", JsonSerializer.toJson(batchBars));
5261

62+
// get bars. Only supports HK.
63+
bars = quotesApiClient.getBars(symbol, Category.US_STOCK.name(), Timespan.M5.name(), 10, YesOrNo.N.name() , tradingSessions);
64+
logger.info("Bars: {}", JsonSerializer.toJson(bars));
65+
66+
// get bars with symbols. Only supports HK.
67+
batchBars = quotesApiClient.getBatchBars(Lists.newArrayList(symbols), Category.US_STOCK.name(), Timespan.M15.name(), 2, YesOrNo.N.name() , tradingSessions);
68+
logger.info("Batch bars: {}", JsonSerializer.toJson(batchBars));
69+
5370
// get quote
5471
Quote quote = quotesApiClient.getQuote(symbol, Category.US_STOCK.name());
5572
logger.info("Quote: {}", JsonSerializer.toJson(quote));

webull-java-sdk-example/src/main/java/com/webull/openapi/example/quotes/QuotesHttpApi.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import com.webull.openapi.common.dict.Category;
44
import com.webull.openapi.common.dict.EventType;
55
import com.webull.openapi.common.dict.Timespan;
6+
import com.webull.openapi.common.dict.TradingSession;
7+
import com.webull.openapi.common.dict.YesOrNo;
68
import com.webull.openapi.example.config.Env;
79
import com.webull.openapi.execption.ClientException;
810
import com.webull.openapi.execption.ServerException;
@@ -36,6 +38,12 @@ public static void main(String[] args) {
3638
eventTypes.add(EventType.Reverse_Stock_Split.getCode());
3739
eventTypes.add(EventType.Stock_Split.getCode());
3840

41+
List<String> tradingSessions = new ArrayList<>();
42+
tradingSessions.add(TradingSession.PRE.name());
43+
tradingSessions.add(TradingSession.RTH.name());
44+
tradingSessions.add(TradingSession.ATH.name());
45+
tradingSessions.add(TradingSession.OVN.name());
46+
3947
HttpApiConfig apiConfig = HttpApiConfig.builder()
4048
.appKey(Env.APP_KEY)
4149
.appSecret(Env.APP_SECRET)
@@ -52,6 +60,14 @@ public static void main(String[] args) {
5260
BatchBarResponse batchBars = quotesApiClient.getBatchBars(new ArrayList<>(symbols), Category.US_STOCK.name(), Timespan.D.name(), 2);
5361
logger.info("Batch bars: {}", JsonSerializer.toJson(batchBars));
5462

63+
// get bars. Only supports HK.
64+
bars = quotesApiClient.getBars("AAPL", Category.US_STOCK.name(), Timespan.D.name(), 10, YesOrNo.N.name() , tradingSessions);
65+
logger.info("Bars: {}", bars);
66+
67+
// get bars with symbols. Only supports HK.
68+
batchBars = quotesApiClient.getBatchBars(new ArrayList<>(symbols), Category.US_STOCK.name(), Timespan.D.name(), 2, YesOrNo.N.name() , tradingSessions);
69+
logger.info("Batch bars: {}", JsonSerializer.toJson(batchBars));
70+
5571
// get snapshots
5672
List<Snapshot> snapshots = quotesApiClient.getSnapshots(symbols, Category.US_STOCK.name());
5773
logger.info("Snapshots: {}", snapshots);

webull-java-sdk-example/src/main/java/com/webull/openapi/example/trade/TradeApi.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,7 @@
2222
import com.webull.openapi.trade.api.request.v2.OptionOrder;
2323
import com.webull.openapi.trade.api.request.v2.OptionOrderItem;
2424
import com.webull.openapi.trade.api.request.v2.OptionOrderItemLeg;
25-
import com.webull.openapi.trade.api.response.Account;
26-
import com.webull.openapi.trade.api.response.AccountDetail;
27-
import com.webull.openapi.trade.api.response.AccountPositions;
28-
import com.webull.openapi.trade.api.response.BalanceBase;
29-
import com.webull.openapi.trade.api.response.InstrumentInfo;
30-
import com.webull.openapi.trade.api.response.Order;
31-
import com.webull.openapi.trade.api.response.OrderResponse;
32-
import com.webull.openapi.trade.api.response.Orders;
33-
import com.webull.openapi.trade.api.response.TradableInstruments;
34-
import com.webull.openapi.trade.api.response.TradeCalendar;
25+
import com.webull.openapi.trade.api.response.*;
3526
import com.webull.openapi.trade.api.response.v2.PreviewOrderResponse;
3627
import com.webull.openapi.trade.api.response.v2.TradeOrderResponse;
3728
import com.webull.openapi.utils.CollectionUtils;
@@ -209,6 +200,10 @@ public static void main(String[] args) {
209200
TradeOrderResponse cancelOptionResponse = apiService.cancelOption(accountId, cancelTradeOption);
210201
logger.info("cancelOptionResponse: {}", cancelOptionResponse);
211202

203+
String tickerId = "", startId = "";
204+
Integer size = 10;
205+
OAuthCommonPositionContractVO contractVO = apiService.getCommonPositionDetail(accountId, tickerId, startId, size);
206+
logger.info("OAuthCommonPositionContractVO: {}", contractVO);
212207
} catch (ClientException ex) {
213208
logger.error("Client error", ex);
214209
} catch (ServerException ex) {

0 commit comments

Comments
 (0)