Class: DhanHQ::Risk::Checks::MarketHours

Inherits:
Object
  • Object
show all
Defined in:
lib/DhanHQ/risk/checks/market_hours.rb

Overview

Blocks orders outside Indian market hours (9:15 AM - 3:30 PM IST).

Constant Summary collapse

TIMEZONE_OFFSET =
"+05:30"
OPEN_HOUR =
9
OPEN_MINUTE =
15
CLOSE_HOUR =
15
CLOSE_MINUTE =
30

Class Method Summary collapse

Class Method Details

.run!(now: Time.now, **_unused) ⇒ Object



14
15
16
17
18
19
# File 'lib/DhanHQ/risk/checks/market_hours.rb', line 14

def self.run!(now: Time.now, **_unused)
  market_now = now.getlocal(TIMEZONE_OFFSET)
  return if market_open?(market_now)

  raise DhanHQ::RiskViolation, "Market is closed"
end