Files
Dena/app/trading/matching/order_book_manager.rb
2026-08-13 19:50:53 +03:30

35 lines
748 B
Ruby

# encoding: UTF-8
# frozen_string_literal: true
module Matching
class OrderBookManager
attr :ask_orders, :bid_orders
def self.build_order(attrs)
attrs.symbolize_keys!
raise ArgumentError, "Missing ord_type: #{attrs.inspect}" unless attrs[:ord_type].present?
klass = ::Matching.const_get "#{attrs[:ord_type]}_order".camelize
klass.new attrs
end
def initialize(market, options={})
@market = market
@ask_orders = OrderBook.new(market, :ask, options)
@bid_orders = OrderBook.new(market, :bid, options)
end
def get_books(type)
case type
when :ask
[@ask_orders, @bid_orders]
when :bid
[@bid_orders, @ask_orders]
end
end
end
end