Module: DhanHQ::WS::MarketDepth
- Defined in:
- lib/DhanHQ/ws/market_depth.rb,
lib/DhanHQ/ws/market_depth/client.rb,
lib/DhanHQ/ws/market_depth/decoder.rb
Defined Under Namespace
Class Method Summary collapse
-
.client(symbols: []) ⇒ Client
Create a new Market Depth client with advanced features.
-
.connect(symbols: []) ⇒ Client
Connect to Market Depth WebSocket with a simple callback.
-
.connect_with_handlers(symbols: [], handlers: {}) ⇒ Client
Quick connection with multiple event handlers.
-
.snapshot(symbols:) ⇒ Client
Get market depth snapshot for symbols.
-
.subscribe(symbols:) ⇒ Client
Subscribe to market depth for specific symbols.
Class Method Details
.client(symbols: []) ⇒ Client
Create a new Market Depth client with advanced features
31 32 33 |
# File 'lib/DhanHQ/ws/market_depth.rb', line 31 def client(symbols: [], **) Client.new(symbols: symbols, **) end |
.connect(symbols: []) ⇒ Client
Connect to Market Depth WebSocket with a simple callback
20 21 22 23 24 |
# File 'lib/DhanHQ/ws/market_depth.rb', line 20 def connect(symbols: [], **, &) client = Client.new(symbols: symbols, **) client.on(:depth_update, &) if block_given? client.start end |
.connect_with_handlers(symbols: [], handlers: {}) ⇒ Client
Quick connection with multiple event handlers
41 42 43 44 45 46 47 48 49 |
# File 'lib/DhanHQ/ws/market_depth.rb', line 41 def connect_with_handlers(symbols: [], handlers: {}, **) client = Client.new(symbols: symbols, **).start handlers.each do |event, handler| client.on(event, &handler) end client end |
.snapshot(symbols:) ⇒ Client
Get market depth snapshot for symbols
67 68 69 70 71 |
# File 'lib/DhanHQ/ws/market_depth.rb', line 67 def snapshot(symbols:, **, &) client = Client.new(symbols: symbols, **) client.on(:depth_snapshot, &) if block_given? client.start end |
.subscribe(symbols:) ⇒ Client
Subscribe to market depth for specific symbols
57 58 59 |
# File 'lib/DhanHQ/ws/market_depth.rb', line 57 def subscribe(symbols:, **, &) connect(symbols: symbols, **, &) end |