lib/cotcube-level/helpers.rb
# :swaps is an array of swaps
# :zero  is the current interval (ohlc)
# :stencil is the according current stencil (eod or intraday)
:swaps is an array of swaps
:zero  is the current interval (ohlc)
:stencil is the according current stencil (eod or intraday)
: swaps is an array of swaps : zero is the current interval ( ohlc ) : stencil is the according current stencil ( eod or intraday )
def check_exceedance(swaps:, zero:, stencil:, contract:, sym:, debug: false)
      swaps.map do |swap|
        next if  swap[:datetime] >= zero[:datetime] or swap[:empty]
        update = stencil.use with: swap, sym: sym, zero: zero
        if update[:exceeded]
          to_save = {
            datetime: zero[:datetime],
            ref:      swap[:digest],
            side:     swap[:side],
            exceeded: update[:exceeded]
          }
          save_swaps to_save, interval: swap[:interval], swap_type: swap[:swap_type], contract: contract, sym: sym, quiet: (not debug)
          swap[:exceeded] = update[:exceeded]
        end
        %i[ current_change current_value current_diff current_dist alert].map{|key| swap[key] = update[key] }
        swap
      end.compact
    end
def check_exceedance ( swaps : , zero : , stencil : , contract : , sym : , debug : false ) swaps . map do | swap | next if swap [ :datetime ] >= zero [ :datetime ] or swap [ :empty ] update = stencil . use with : swap , sym : sym , zero : zero if update [ :exceeded ] to_save = { datetime : zero [ :datetime ] , ref : swap [ :digest ] , side : swap [ :side ] , exceeded : update [ :exceeded ] } save_swaps to_save , interval : swap [ :interval ] , swap_type : swap [ :swap_type ] , contract : contract , sym : sym , quiet : ( not debug ) swap [ :exceeded ] = update [ :exceeded ] end %i[ current_change current_value current_diff current_dist alert ] . map { | key | swap [ key ] = update [ key ] } swap end . compact end
:swaps is an array of swaps
:zero  is the current interval (ohlc)
:stencil is the according current stencil (eod or intraday)
: swaps is an array of swaps : zero is the current interval ( ohlc ) : stencil is the according current stencil ( eod or intraday )
# swaps cannot exceed the day they are found (or if they are found in the future)
swaps
<not_specific>
zero
<not_specific>
stencil
<not_specific>
contract
<not_specific>
sym
<not_specific>
debug
<not_specific>