@@ -72,8 +72,16 @@ public static void main(String[] args) {
7272 cryptoInstruments = dataClient .getCryptoInstrument (instrumentQueryParam );
7373 logger .info ("Crypto instruments: {}" , cryptoInstruments );
7474
75- // get crypto bars
76- List <NBar > cryptoBars = dataClient .getCryptoBars (cryptoSymbols ,Category .US_CRYPTO .name (), Timespan .M1 .name (), 100 , true );
75+ // get crypto bars (startTime/endTime are optional timestamps in milliseconds; leave them null to omit the time range)
76+ BarsQueryParam cryptoBarsParam = new BarsQueryParam ();
77+ cryptoBarsParam .setSymbols (new ArrayList <>(cryptoSymbols ));
78+ cryptoBarsParam .setCategory (Category .US_CRYPTO .name ());
79+ cryptoBarsParam .setTimespan (Timespan .M1 .name ());
80+ cryptoBarsParam .setCount (100 );
81+ cryptoBarsParam .setRealTimeRequired (true );
82+ cryptoBarsParam .setStartTime (1711262998500L );
83+ cryptoBarsParam .setEndTime (1711349398500L );
84+ List <NBar > cryptoBars = dataClient .getCryptoBars (cryptoBarsParam );
7785 logger .info ("Crypto bars: {}" , cryptoBars );
7886
7987 //get crypto snapshot
@@ -115,7 +123,16 @@ public static void main(String[] args) {
115123 List <Snapshot > futureSnapshots = dataClient .getFuturesSnapshots (futuresSymbols , Category .US_FUTURES .name ());
116124 logger .info ("Futures Snapshots: {}" , futureSnapshots );
117125
118- List <NBar > futureBars = dataClient .getFuturesBars (new ArrayList <>(futuresSymbols ), Category .US_FUTURES .name (), Timespan .M1 .name (), 10 , false );
126+ // get futures bars (startTime/endTime are optional timestamps in milliseconds; leave them null to omit the time range)
127+ BarsQueryParam futuresBarsParam = new BarsQueryParam ();
128+ futuresBarsParam .setSymbols (new ArrayList <>(futuresSymbols ));
129+ futuresBarsParam .setCategory (Category .US_FUTURES .name ());
130+ futuresBarsParam .setTimespan (Timespan .M1 .name ());
131+ futuresBarsParam .setCount (10 );
132+ futuresBarsParam .setRealTimeRequired (false );
133+ futuresBarsParam .setStartTime (1711262998500L );
134+ futuresBarsParam .setEndTime (1711349398500L );
135+ List <NBar > futureBars = dataClient .getFuturesBars (futuresBarsParam );
119136 logger .info ("Futures Bars: {}" , futureBars );
120137
121138 List <FuturesProduct > futuresProducts = dataClient .getFuturesProducts (Category .US_FUTURES .name ());
@@ -163,7 +180,16 @@ public static void main(String[] args) {
163180 List <OptionSnapshot > optionSnapshots = dataClient .getOptionSnapshots (optionSymbols , Category .US_OPTION .name ());
164181 logger .info ("Option Snapshots: {}" , optionSnapshots );
165182
166- List <OptionBars > optionBars = dataClient .getOptionBars (new ArrayList <>(optionSymbols ), Category .US_OPTION .name (), Timespan .M1 .name (), 10 , false );
183+ // get option bars (startTime/endTime are optional timestamps in milliseconds; leave them null to omit the time range)
184+ BarsQueryParam optionBarsParam = new BarsQueryParam ();
185+ optionBarsParam .setSymbols (new ArrayList <>(optionSymbols ));
186+ optionBarsParam .setCategory (Category .US_OPTION .name ());
187+ optionBarsParam .setTimespan (Timespan .M1 .name ());
188+ optionBarsParam .setCount (10 );
189+ optionBarsParam .setRealTimeRequired (false );
190+ optionBarsParam .setStartTime (1711262998500L );
191+ optionBarsParam .setEndTime (1711349398500L );
192+ List <OptionBars > optionBars = dataClient .getOptionBars (optionBarsParam );
167193 logger .info ("Option Bars: {}" , optionBars );
168194
169195 OptionTick OptionTicks = dataClient .getOptionTicks ("AAPL260522C00300000" , Category .US_OPTION .name (), 30 );
0 commit comments