module JpStockRule

Constants

PRICE_LIMITS

www.jpx.co.jp/equities/trading/domestic/06.html

TICK_SIZES

www.jpx.co.jp/equities/trading/domestic/07.html

VERSION

Public Class Methods

price_limit(base_price) click to toggle source

Returns the limit of price change in a day.

# File lib/jp_stock_rule.rb, line 44
def self.price_limit(base_price)
  PRICE_LIMITS.detect { |upper_limit, | base_price < upper_limit }[1]
end
round_price(price, topix100: false) click to toggle source

Rounds the price to the tick.

JpStockRule.round_price(3001) # => 3000
# File lib/jp_stock_rule.rb, line 76
def self.round_price(price, topix100: false)
  tick = tick_size(price, topix100: topix100)
  (price / tick).to_i * tick
end
tick_size(base_price, topix100: false) click to toggle source

Returns the tick size.

# File lib/jp_stock_rule.rb, line 69
def self.tick_size(base_price, topix100: false)
  TICK_SIZES.detect { |upper_limit, | base_price <= upper_limit }[topix100 ? 1 : 2]
end