Skip to main content

dhan_rs/api/
historical.rs

1//! Historical Data endpoints — Daily and Intraday candle data.
2
3use crate::client::DhanClient;
4use crate::error::Result;
5use crate::types::historical::*;
6
7impl DhanClient {
8    /// Retrieve daily OHLCV candle data for an instrument.
9    ///
10    /// Data is available back to the instrument's inception date.
11    ///
12    /// **Endpoint:** `POST /v2/charts/historical`
13    pub async fn get_daily_historical(&self, req: &HistoricalDataRequest) -> Result<CandleData> {
14        self.post("/v2/charts/historical", req).await
15    }
16
17    /// Retrieve intraday OHLCV candle data for an instrument.
18    ///
19    /// Supports 1, 5, 15, 25, and 60-minute intervals.
20    /// Only 90 days of data can be polled per request.
21    ///
22    /// **Endpoint:** `POST /v2/charts/intraday`
23    pub async fn get_intraday_historical(&self, req: &IntradayDataRequest) -> Result<CandleData> {
24        self.post("/v2/charts/intraday", req).await
25    }
26}