Branch Coverage

blib/lib/Finance/Nadex.pm
Criterion Covered Total %
branch 166 278 59.7


line true false branch
38 0 0 unless $self->logged_in
53 0 0 unless $self->logged_in
57 0 0 unless scalar @orders
70 0 0 unless $self->logged_in
74 0 0 unless exists $args{'id'}
76 0 0 unless $args{'id'}
92 0 0 unless $cancelled_response
104 6 12 unless $self->logged_in
109 2 10 unless exists $args{'price'}
112 1 9 unless exists $args{'direction'}
115 1 8 unless exists $args{'epic'}
118 1 7 unless exists $args{'size'}
123 0 7 unless $args{'epic'}
129 1 6 unless $self->_is_valid_price($args{'price'}, $contract->type)
132 1 5 unless $self->_is_valid_direction($args{'direction'})
133 0 5 unless $contract
138 1 4 unless $self->_is_valid_size($args{'size'})
141 2 2 if $args{'direction'} eq 'buy'
142 1 3 if $args{'direction'} eq 'sell'
147 3 1 if $contract->type eq 'binary'
167 4 0 if defined $order
177 0 7 unless $self->logged_in
182 0 7 unless exists $args{'epic'}
185 0 7 unless $args{'epic'}
190 0 7 unless $epic_ref
194 0 7 unless exists $epic_ref->{'instrument'} and exists $epic_ref->{'marketSnapshot'}
198 0 7 unless $epic_ref->{'instrument'}{'instrumentType'} and $epic_ref->{'instrument'}{'marketName'} and $epic_ref->{'instrument'}{'displayPrompt'}
221 0 6 unless $self->logged_in
226 2 4 unless exists $args{'market'}
229 1 3 unless exists $args{'instrument'}
232 1 2 unless exists $args{'series'}
235 0 2 unless $args{'market'}
237 0 2 unless $args{'instrument'}
239 0 2 unless $args{'series'}
242 0 2 if exists $index_name{$args{'instrument'}}
246 0 2 unless $market_list_ref
255 0 2 unless $market_id
260 0 2 unless $instruments_list_ref
267 2 0 if $instrument->{'name'} eq $args{'instrument'}
270 0 2 unless $instrument_id
275 0 2 unless $instrument_list_ref
281 2 0 if $series->{'name'} eq $args{'series'}
284 0 2 unless $time_series_id
290 0 2 unless $series_list_ref
309 0 6 unless $self->logged_in
314 2 4 unless exists $args{'period'}
317 0 4 unless exists $args{'market'}
322 1 1 unless exists $args{'time'} or exists $args{'period'} and $args{'period'} =~ /^event$/i
325 1 2 unless exists $args{'instrument'}
328 0 2 unless exists $args{'strike'}
331 0 2 unless $args{'period'}
333 0 2 unless $args{'market'}
337 0 1 unless $args{'time'} or exists $args{'period'} and $args{'period'} =~ /^event$/i
339 0 2 unless $args{'instrument'}
341 0 2 unless $args{'strike'}
343 2 0 if exists $args{'period'}
345 1 1 if exists $args{'time'}
349 0 2 unless $market_list_ref
358 0 2 unless $market_id
362 0 2 unless $market_list_ref
371 0 2 unless $market_id
375 0 2 unless $market_list_ref
382 1 1 if $args{'period'} eq 'Daily'
383 0 2 if $args{'period'} eq 'Intraday'
384 0 2 if $args{'period'} eq 'Weekly'
385 1 1 if $args{'period'} eq 'Event'
387 0 2 unless $target_period_time
397 0 2 unless $market_id
401 0 2 unless $market_list_ref
407 1 1 if exists $args{'time'}
408 1 1 unless exists $args{'time'}
409 2 0 if ($market->{'instrumentName'} =~ /$args{'strike'}( \($args{'time'}\))?$/)
425 0 3 unless $self->logged_in
430 1 2 unless exists $args{'name'}
433 0 2 unless $args{'name'}
437 0 2 unless $market_list_ref
446 0 2 unless $market_id
450 0 2 unless $market_list_ref
465 0 2 unless $self->logged_in
470 0 2 unless $market_list_ref
487 0 2 unless $self->logged_in
492 1 1 unless exists $args{'instrument'}
494 0 1 unless $args{'instrument'}
497 0 1 if exists $index_name{$args{'instrument'}}
503 1 0 if ($instrument eq $args{'instrument'})
516 0 1 unless $epic_ref
518 0 1 unless $epic_ref
533 0 5 unless $self->logged_in
537 0 5 if exists $args{'instrument'} and $index_name{$args{'instrument'}}
541 2 3 unless exists $args{'market'}
544 1 2 unless exists $args{'instrument'}
548 0 2 unless $market_list_ref
557 0 2 unless $market_id
562 0 2 unless $market_list_ref
569 2 0 if $instrument->{'name'} eq $args{'instrument'}
572 0 2 if $instrument->{'name'} eq 'Forex' and $args{'market'} eq '5 Minute Binaries'
575 0 2 if $instrument->{'name'} eq 'Indices' and $args{'market'} eq '20 Minute Binaries'
578 0 2 unless $instrument_id
583 0 2 unless $market_list_ref
587 0 2 if ($args{'market'} eq '5 Minute Binaries' or $args{'market'} eq '20 Minute Binaries')
593 0 0 if $instrument->{'name'} eq $args{'instrument'}
596 0 0 unless $instrument_id
601 0 0 unless $market_list_ref
626 11 61 unless $self->{'security_token'}
628 0 61 unless $self->{'session_id'}
641 0 0 unless exists $args{'username'} or exists $self->{'username'}
644 0 0 unless exists $args{'password'} or exists $self->{'password'}
646 13 0 if exists $args{'username'}
647 13 0 if exists $args{'password'}
675 0 25 if (exists $args{'platform'} and $args{'platform'} eq 'demo') { }
700 1 2 unless $self->logged_in
704 1 1 unless exists $args{'id'}
705 0 1 unless $args{'id'}
713 0 1 unless $order_ref
723 1 1 unless $self->logged_in
730 0 1 unless $order_list_ref
747 1 2 unless $self->logged_in
752 1 1 unless exists $args{'id'}
754 0 1 unless $args{'id'}
762 0 1 unless $position_ref
772 1 1 unless $self->logged_in
779 0 1 unless $position_list_ref
813 0 0 if $response->header('X-SECURITY-TOKEN')
843 40 0 if $response->header('X-SECURITY-TOKEN')
881 16 1 if $response->header('X-SECURITY-TOKEN')
899 12 2 if (not exists $args{'accept_match'} or $args{'accept_match'} == 0) { }
900 10 2 if ($market->{'name'} eq $args{'name'})
905 2 0 if ($market->{'name'} =~ /$args{'name'}/ or $market->{'name'} eq $args{'name'})
921 12 0 if $key =~ /JSESSIONID/
931 1 6 if $price =~ /-|\+/
933 5 1 if ($type eq 'binary')
934 0 5 unless $price =~ /^(\d+\.\d{1,2}|\.\d{1,2}|\d+)$/
936 5 0 if ($price =~ /\.(\d+)/)
937 0 0 if $1 != 0 and $1 != 25 and $1 != 50 and $1 != 75
941 1 5 if ($type eq 'spread')
942 0 1 unless $price =~ /^(\d+|\d+\.\d{1,4})$/
955 5 1 exists $valid{$direction} ? :
963 1 4 unless $size =~ /^\d+$/
965 0 4 if $size == 0