5252import com .webull .openapi .core .utils .Assert ;
5353import com .webull .openapi .core .utils .CollectionUtils ;
5454import com .webull .openapi .core .utils .StringUtils ;
55-
55+ import com . webull . openapi . trade . http . ITradeClient ;
5656import java .lang .reflect .Type ;
5757import java .util .Arrays ;
5858import java .util .HashMap ;
5959import java .util .List ;
6060import java .util .Map ;
6161import java .util .Objects ;
6262
63- public class TradeClient implements com .webull .openapi .trade .http .ITradeClient {
63+ /**
64+ * @deprecated As of 1.x, replaced by {@link TradeClientV3}.
65+ * This class will be removed in a future major release. New integrations should use {@link TradeClientV3}.
66+ */
67+ @ Deprecated
68+ public class TradeClient implements ITradeClient {
6469
6570 private static final String ACCOUNT_ID_ARG = "accountId" ;
6671 private static final String STOCK_ORDER_ARG = "stockOrder" ;
@@ -88,7 +93,7 @@ public class TradeClient implements com.webull.openapi.trade.http.ITradeClient {
8893 private static final String CLIENT_ORDER_ID_PARAM = "client_order_id" ;
8994 private static final String LAST_CLIENT_ORDER_ID_PARAM = "last_client_order_id" ;
9095 private static final String INSTRUMENT_ID_PARAM = "instrument_id" ;
91- private static final String LAST_SECURITY_ID = "last_security_id" ;
96+ private static final String LAST_SECURITY_ID_PARAM = "last_security_id" ;
9297 private static final String MARKET_PARAM = MARKET_ARG ;
9398 private static final String START_PARAM = START_ARG ;
9499 private static final String END_PARAM = END_ARG ;
@@ -98,6 +103,7 @@ public class TradeClient implements com.webull.openapi.trade.http.ITradeClient {
98103 private static final String STRIKE_PRICE_PARAM = "strike_price" ;
99104 private static final String INIT_EXP_DATE_PARAM = "init_exp_date" ;
100105 private static final String START_TIME_PARAM = "start_date" ;
106+ private static final int DEFAULT_PAGE_SIZE = 10 ;
101107
102108 private final Region region ;
103109 private final HttpApiClient apiClient ;
@@ -156,7 +162,7 @@ public AccountPositions getAccountPositions(String accountId, Integer pageSize,
156162 HttpRequest request = new HttpRequest ("/account/positions" , Versions .V2 , HttpMethod .GET );
157163 Map <String , Object > params = new HashMap <>();
158164 params .put (ACCOUNT_ID_PARAM , accountId );
159- params .put (PAGE_SIZE_PARAM , pageSize == null ? 10 : pageSize );
165+ params .put (PAGE_SIZE_PARAM , pageSize == null ? DEFAULT_PAGE_SIZE : pageSize );
160166 if (StringUtils .isNotEmpty (lastId )) {
161167 params .put (LAST_INSTRUMENT_ID_PARAM , lastId );
162168 }
@@ -169,7 +175,7 @@ public OrderResponse placeOrder(String accountId, StockOrder stockOrder) {
169175 Assert .notBlank (ACCOUNT_ID_ARG , accountId );
170176 Assert .notNull (STOCK_ORDER_ARG , stockOrder );
171177 HttpRequest request = new HttpRequest ("/trade/order/place" , Versions .V2 , HttpMethod .POST );
172- addCustomHeaderFromContext (request );
178+ addCustomHeadersFromContext (request );
173179 Map <String , Object > params = new HashMap <>();
174180 params .put (ACCOUNT_ID_PARAM , accountId );
175181 params .put (STOCK_ORDER_PARAM , stockOrder );
@@ -222,7 +228,7 @@ private <T extends Order> Orders<T> getOrders(String uri, String accountId, Inte
222228 HttpRequest request = new HttpRequest (uri , Versions .V2 , HttpMethod .GET );
223229 Map <String , Object > params = new HashMap <>();
224230 params .put (ACCOUNT_ID_PARAM , accountId );
225- params .put (PAGE_SIZE_PARAM , pageSize == null ? 10 : pageSize );
231+ params .put (PAGE_SIZE_PARAM , pageSize == null ? DEFAULT_PAGE_SIZE : pageSize );
226232 if (StringUtils .isNotEmpty (lastClientOrderId )) {
227233 params .put (LAST_CLIENT_ORDER_ID_PARAM , lastClientOrderId );
228234 }
@@ -260,9 +266,9 @@ public TradableInstruments getTradeableInstruments(String lastSecurityId, Intege
260266 HttpRequest request = new HttpRequest ("/trade/instrument/tradable/list" , Versions .V2 , HttpMethod .GET );
261267 Map <String , Object > params = new HashMap <>();
262268 if (StringUtils .isNotEmpty (lastSecurityId )){
263- params .put (LAST_SECURITY_ID , lastSecurityId );
269+ params .put (LAST_SECURITY_ID_PARAM , lastSecurityId );
264270 }
265- params .put (PAGE_SIZE_PARAM , pageSize == null ? 10 : pageSize );
271+ params .put (PAGE_SIZE_PARAM , pageSize == null ? DEFAULT_PAGE_SIZE : pageSize );
266272 request .setQuery (params );
267273 return apiClient .request (request ).responseType (TradableInstruments .class ).doAction ();
268274 }
@@ -283,7 +289,7 @@ public List<TradeCalendar> getTradeCalendar(String market, String start, String
283289 public InstrumentInfo getSecurityInfo (String symbol , String market , String instrumentSuperType , String instrumentType , String strikePrice , String initExpDate ) {
284290 Assert .notBlank (Arrays .asList (SYMBOL_ARG , MARKET_ARG , INSTRUMENT_SUPER_TYPE_ARG ) , symbol , market , instrumentSuperType );
285291 Map <String , Object > params = new HashMap <>();
286- if (instrumentSuperType . equals ( InstrumentSuperType .OPTION .name ())) {
292+ if (InstrumentSuperType .OPTION .name (). equals ( instrumentSuperType )) {
287293 Assert .notBlank (Arrays .asList (INSTRUMENT_TYPE_ARG , STRIKE_PRICE_ARG , INIT_EXP_DATE_ARG ), instrumentType , strikePrice , initExpDate );
288294 params .put (INSTRUMENT_TYPE_PARAM , instrumentType );
289295 params .put (STRIKE_PRICE_PARAM , strikePrice );
@@ -336,7 +342,7 @@ public TradeOrderResponse placeOption(String accountId, OptionOrder optionOrder)
336342 Assert .notEmpty (NEW_ORDERS_ARG , optionOrder .getNewOrders ());
337343 HttpRequest request = new HttpRequest ("/openapi/account/orders/option/place" , Versions .V2 , HttpMethod .POST );
338344 addCustomHeadersFromOrder (request , optionOrder );
339- addCustomHeaderFromContext (request );
345+ addCustomHeadersFromContext (request );
340346 Map <String , Object > queryMap = new HashMap <>();
341347 queryMap .put (ACCOUNT_ID_PARAM , accountId );
342348 request .setQuery (queryMap );
@@ -385,7 +391,7 @@ public void removeCustomHeaders() {
385391 RequestContextHolder .clear ();
386392 }
387393
388- private void addCustomHeaderFromContext (HttpRequest request ){
394+ private void addCustomHeadersFromContext (HttpRequest request ){
389395 try {
390396 Map <String , String > headersMap = RequestContextHolder .get ();
391397 if (Objects .isNull (headersMap ) || headersMap .isEmpty ()){
0 commit comments