I need to get current hourly candlestick OHLC data using java. I am new to API and not sure how to connect. I have my api key and secret key. Can anyone tell me how to connect and get the OHLC data?
@padalasubbu81, The getOHLC is day's data. You will need historical data to get hourly candles. You can know more about historical data API here.
Historical data API is for backtesting purpose only. We don't recommend using this for live strategies. For live strategies, we recommend you to use Websocket data to build candles. You can get started here.
https://kite.trade/docs/connect/v3/user/
For candles,
https://kite.trade/docs/connect/v3/historical/
You can also use Websocket and generate live candles at your end:
https://kite.trade/docs/connect/v3/websocket/
I am able to connect now get the OHLC data. I am using the follwoing code.
double openPrice = kiteSdk.getOHLC(instruments).get("NSE:INFY").ohlc.open;
double lowPrice = kiteSdk.getOHLC(instruments).get("NSE:INFY").ohlc.low;
double highPrice = kiteSdk.getOHLC(instruments).get("NSE:INFY").ohlc.high;
double lastPrice = kiteSdk.getOHLC(instruments).get("NSE:INFY").lastPrice;
This is giving me daily candlestick data. How to get the hourly data?
Thank you
You can know in detail about javakiteconnect here:
https://github.com/zerodha/javakiteconnect
The getOHLC is day's data. You will need historical data to get hourly candles.
You can know more about historical data API here.
Historical data API is for backtesting purpose only. We don't recommend using this for live strategies.
For live strategies, we recommend you to use Websocket data to build candles. You can get started here.