if bar.nil? loop do # Dequeue from event queue break if event.nil? case event.type when :market # Strategy analyzes market data # Portfolio updates holdings when :signal # Portfolio places order when :order # Broker executes order when :fill # Portfolio updates holdings end end