anchor.diff:          {MD, N+1}
       end, 1, Input),
     Events = run_filter(fun candle/2, State0, MDList, []),
  +  ?assertNot(lists:member(undefined, Events)),
     [{Bid,Ask} || #md{bid = [{Bid,_}], ask = [{Ask,_}]} <- Events].
   
   test_trade_candle(Input) ->
  
positive.code:         {#trade{timestamp = N, price = Price, volume = 1}, N+1}
      end, 1, Input),
    Events = run_filter(fun candle/2, [{type, trade}], TradeList, []),
    [Price || #trade{price = Price} <- Events].
  
  
  run_filter(Fun, List) ->
    run_filter(Fun, undefined, List, []).
  
  run_filter(Fun, State, [Event|List], Acc) ->
    {Events, State1} = Fun(Event, State),
  
negative.code:   ok.
  
  candle_no_undefined_test() ->
    % Test candle does not return anything on empty data
    ?assertEqual([], test_candle([])),
    % Test candle on poor periods
    ?assertEqual([{1,5}, {1,5}, {1,5}, {1,5}], test_candle([{1,5}])),
    ?assertEqual([{1,5}, {1,5}, {1,5}, {2,4}], test_candle([{1,5}, {2,4}])), % Second event does not compare more or less than first
  