Class: DhanHQ::Models::MarketFeed
- Defined in:
- lib/DhanHQ/models/market_feed.rb
Overview
**Rate Limits**: You can fetch up to 1000 instruments in a single API request with a rate limit of 1 request per second. The client’s internal rate limiter automatically throttles calls to prevent exceeding limits.
Model for fetching real-time market snapshots for multiple instruments.
The Market Feed API provides snapshots of multiple instruments at once. You can fetch LTP (Last Traded Price), OHLC (Open, High, Low, Close), or Market Depth (quote) data for instruments via a single API request. Data is returned in real-time at the time of the API request.
Constant Summary
Constants included from ResponseHelper
ResponseHelper::STATUS_ERROR_FALLBACK
Instance Attribute Summary
Attributes inherited from BaseModel
Class Method Summary collapse
-
.ltp(params) ⇒ HashWithIndifferentAccess
Fetches Last Traded Price (LTP) snapshots for multiple instruments.
-
.ohlc(params) ⇒ HashWithIndifferentAccess
Fetches OHLC (Open, High, Low, Close) data along with LTP for specified instruments.
-
.quote(params) ⇒ HashWithIndifferentAccess
Fetches full market depth data including OHLC, Open Interest, Volume, and order book depth.
-
.resource ⇒ DhanHQ::Resources::MarketFeed
Provides a shared instance of the MarketFeed resource.
-
.validation_contract ⇒ Class
Returns the validation contract for MarketFeed requests.
Methods inherited from BaseModel
all, api, api_type, #assign_attributes, attributes, create, #delete, #destroy, find, #id, #initialize, #new_record?, #optionchain_api?, parse_collection_response, #persisted?, resource_path, #save, #save!, #to_request_params, #update, #valid?, validate_attributes, #validation_contract, where
Methods included from APIHelper
Methods included from AttributeHelper
#camelize_keys, #inspect, #normalize_keys, #snake_case, #titleize_keys
Methods included from ValidationHelper
#valid?, #validate!, #validate_params!
Methods included from RequestHelper
Constructor Details
This class inherits a constructor from DhanHQ::BaseModel
Class Method Details
.ltp(params) ⇒ HashWithIndifferentAccess
Fetches Last Traded Price (LTP) snapshots for multiple instruments.
Retrieves the last traded price for a list of instruments with a single API request. Supports up to 1000 instruments per request, organized by exchange segment.
94 95 96 97 |
# File 'lib/DhanHQ/models/market_feed.rb', line 94 def ltp(params) validated_params = validate_params!(params, validation_contract) resource.ltp(validated_params) end |
.ohlc(params) ⇒ HashWithIndifferentAccess
For newly listed instruments or instruments without trading activity, OHLC values may be 0. The close price typically represents the previous day’s closing price during the current trading session.
Fetches OHLC (Open, High, Low, Close) data along with LTP for specified instruments.
Retrieves the open, high, low, and close prices along with the last traded price for a list of instruments. Supports up to 1000 instruments per request.
138 139 140 141 |
# File 'lib/DhanHQ/models/market_feed.rb', line 138 def ohlc(params) validated_params = validate_params!(params, validation_contract) resource.ohlc(validated_params) end |
.quote(params) ⇒ HashWithIndifferentAccess
This endpoint uses a separate quote API with stricter rate limits (1 request per second). The client automatically handles rate limiting for quote requests.
Fetches full market depth data including OHLC, Open Interest, Volume, and order book depth.
Retrieves comprehensive market data including market depth (buy/sell orders), OHLC data, Open Interest (for derivatives), Volume, circuit limits, and other trading analytics for specified instruments. Supports up to 1000 instruments per request.
209 210 211 212 |
# File 'lib/DhanHQ/models/market_feed.rb', line 209 def quote(params) validated_params = validate_params!(params, validation_contract) resource.quote(validated_params) end |
.resource ⇒ DhanHQ::Resources::MarketFeed
Provides a shared instance of the MarketFeed resource.
58 59 60 |
# File 'lib/DhanHQ/models/market_feed.rb', line 58 def resource @resource ||= DhanHQ::Resources::MarketFeed.new end |
.validation_contract ⇒ Class
Returns the validation contract for MarketFeed requests.
50 51 52 |
# File 'lib/DhanHQ/models/market_feed.rb', line 50 def validation_contract DhanHQ::Contracts::MarketFeedContract end |