php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #71253 No option to specify the resulting precision
Submitted: 2015-12-30 23:44 UTC Modified: 2016-01-08 17:52 UTC
From: cdtreeks at gmail dot com Assigned:
Status: Not a bug Package: Trader (PECL)
PHP Version: 7.0.1 OS: CentOS 7 (N/A)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: cdtreeks at gmail dot com
New email:
PHP Version: OS:

 

 [2015-12-30 23:44 UTC] cdtreeks at gmail dot com
Description:
------------
It appears all of the EMA functions within the Trader PECL package return their responses to a fixed 2 decimal places.

When trading, having 5 decimal places of precision is required and as such, these functions in their current form are somewhat useless.

I'd like to suggest implementing a third, optional parameter for $precision:
array trader_ema ( array $real, integer $timePeriod [, integer $precision = 2] )

For backwards compatibility reasons, I'd suggest the default value remains set to 2 to mimic current behavior so the change is non-breaking.

This change request applies to the following functions (although many more of the Trader functions might also benefit from this too):
 - trader_dema
 - trader_ema
 - trader_tema

Test script:
---------------
$real = [
    1.00215,
    1.00217,
    1.00209,
    1.00205,
    1.00211,
    1.00211,
    1.00215,
    1.00217,
    1.00209,
    1.00205,
    1.00211,
    1.00211,
    1.00215,
    1.00217,
    1.00209,
    1.00205,
    1.00211,
    1.00211
    1.00215,
    1.00217,
    1.00209,
    1.00205,
    1.00211,
    1.00215
];

$emas = trader_ema($real, 10);

print_r($emas); // All resulting values have been fixed to 2DP

Expected result:
----------------
Either the resulting values from the EMA functions should mimic the maximum number of decimal places supplied in the $real array. Or, better yet, we should be able to specify an additional, optional argument for the precision as mentioned above.

Actual result:
--------------
All resulting values are fixed to 2DP.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-01-08 17:52 UTC] ab@php.net
-Status: Open +Status: Not a bug
 [2016-01-08 17:52 UTC] ab@php.net
Thanks on the interest on the trader ext. Please see the run time configuration http://php.net/manual/en/trader.configuration.php that can be used to affect the precision of the outcome.

Thanks.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 04:01:27 2024 UTC