@@ -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
0 commit comments