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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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: Sat Dec 21 16:01:28 2024 UTC