Skip to content

Commit

Permalink
Merge pull request #13 from kavehmz/kaveh/checking_digit_contracts
Browse files Browse the repository at this point in the history
checking digit contrcats
  • Loading branch information
tom-binary committed May 3, 2017
2 parents d8920b2 + 9ddd53e commit 5aab3f8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
5 changes: 5 additions & 0 deletions Changes
Expand Up @@ -2,6 +2,11 @@ Revision history for Finance-Contract

{{$NEXT}}

0.009 2017-05-03 01:54:55+00:00 UTC
Bug fixes:

* Support digit barriers correctly

0.008 2017-05-02 06:22:04+00:00 UTC
Bug fixes:

Expand Down
2 changes: 1 addition & 1 deletion Makefile.PL
Expand Up @@ -40,7 +40,7 @@ my %WriteMakefileArgs = (
"Test::CheckDeps" => "0.010",
"Test::More" => "0.94"
},
"VERSION" => "0.008",
"VERSION" => "0.009",
"test" => {
"TESTS" => "t/*.t"
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Finance/Contract.pm
Expand Up @@ -3,7 +3,7 @@ package Finance::Contract;
use strict;
use warnings;

our $VERSION = '0.008';
our $VERSION = '0.009';

=head1 NAME
Expand Down Expand Up @@ -775,7 +775,7 @@ sub _barrier_for_shortcode_string {
return 'S' . roundnear(1, $string / $self->pip_size) . 'P' if $self->supplied_barrier_type eq 'difference';

$string = $self->_pipsized_value($string);
if ($self->absolute_barrier_multiplier) {
if ($self->bet_type !~ /^DIGIT/ && $self->absolute_barrier_multiplier) {
$string *= _FOREX_BARRIER_MULTIPLIER;
} else {
$string = floor($string);
Expand Down
7 changes: 5 additions & 2 deletions t/for_shortcode_string.t
Expand Up @@ -23,6 +23,11 @@ $params->{absolute_barrier_multiplier} = 1;
$obj = new_ok( 'Finance::Contract', [$params] );
cmp_ok $obj->_barrier_for_shortcode_string('0.12'),'eq', '120000', 'A absolute barrier will be multiplied in 1e6 if absolute_barrier_multiplier=1';

$params->{bet_type} = 'DIGITMATCH';
$obj = new_ok( 'Finance::Contract', [$params] );
cmp_ok $obj->_barrier_for_shortcode_string('1'),'eq', '1', 'Even if absolute_barrier_multiplier is set there wont be any multiplication for ^DIGIT.*';

$params->{bet_type} = 'test';
$params->{supplied_barrier_type} = 'difference';
$obj = new_ok( 'Finance::Contract', [$params] );
cmp_ok $obj->_barrier_for_shortcode_string('+0.12'),'eq', 'S120P', 'A differnce barrier will manipulated to correct format depending on pipsize';
Expand All @@ -32,5 +37,3 @@ cmp_ok $obj->_barrier_for_shortcode_string('+0'),'eq', 'S0P', 'A differnce barri
cmp_ok $obj->_barrier_for_shortcode_string('0'),'eq', 'S0P', 'A differnce barrier that is 0 will be manipulated to correct format';

done_testing;


0 comments on commit 5aab3f8

Please sign in to comment.