Module: DhanHQ::WS

Defined in:
lib/DhanHQ/ws.rb,
lib/DhanHQ/ws/client.rb,
lib/DhanHQ/ws/orders.rb,
lib/DhanHQ/ws/cmd_bus.rb,
lib/DhanHQ/ws/decoder.rb,
lib/DhanHQ/ws/registry.rb,
lib/DhanHQ/ws/segments.rb,
lib/DhanHQ/ws/sub_state.rb,
lib/DhanHQ/ws/connection.rb,
lib/DhanHQ/ws/market_depth.rb,
lib/DhanHQ/ws/orders/client.rb,
lib/DhanHQ/ws/packets/header.rb,
lib/DhanHQ/ws/singleton_lock.rb,
lib/DhanHQ/ws/base_connection.rb,
lib/DhanHQ/ws/orders/connection.rb,
lib/DhanHQ/ws/packets/oi_packet.rb,
lib/DhanHQ/ws/market_depth/client.rb,
lib/DhanHQ/ws/packets/full_packet.rb,
lib/DhanHQ/ws/market_depth/decoder.rb,
lib/DhanHQ/ws/packets/index_packet.rb,
lib/DhanHQ/ws/packets/quote_packet.rb,
lib/DhanHQ/ws/packets/ticker_packet.rb,
lib/DhanHQ/ws/websocket_packet_parser.rb,
lib/DhanHQ/ws/packets/disconnect_packet.rb,
lib/DhanHQ/ws/packets/prev_close_packet.rb,
lib/DhanHQ/ws/packets/depth_delta_packet.rb,
lib/DhanHQ/ws/packets/market_depth_level.rb,
lib/DhanHQ/ws/packets/market_status_packet.rb

Overview

WebSocket registry for managing connections and subscriptions

Defined Under Namespace

Modules: MarketDepth, Orders, Packets, Segments Classes: BaseConnection, Client, CmdBus, Connection, Decoder, Registry, SingletonLock, SubState, WebsocketPacketParser

Class Method Summary collapse

Class Method Details

.connect(mode: :ticker) {|tick| ... } ⇒ DhanHQ::WS::Client

Establishes a WebSocket connection and yields decoded ticks.

Examples:

Subscribe to ticker updates

DhanHQ::WS.connect(mode: :ticker) do |tick|
  puts tick.inspect
end

Parameters:

  • mode (Symbol) (defaults to: :ticker)

    Desired feed mode (:ticker, :quote, :full).

Yields:

  • (tick)

Yield Parameters:

  • tick (Hash)

    A decoded tick emitted by the streaming API.

Returns:



24
25
26
# File 'lib/DhanHQ/ws.rb', line 24

def self.connect(mode: :ticker, &on_tick)
  Client.new(mode: mode).start.on(:tick, &on_tick)
end

.disconnect_all_local!Object

convenience API



34
35
36
# File 'lib/DhanHQ/ws.rb', line 34

def self.disconnect_all_local!
  Registry.stop_all
end