Advertisement
viamvadens

Untitled

Dec 2nd, 2018
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.38 KB | None | 0 0
  1.  
  2. function getScore_V6( $real_cf, $rules_file, $stake, $isGROI = 'KROI', $_echo=true ) { // GROI, ROI, KROI
  3. static $RULES_BY_FILES;
  4. if(!isset($RULES_BY_FILES)){
  5. $RULES_BY_FILES = array();
  6. }
  7. if(!isset($RULES_BY_FILES[$rules_file])){
  8. $RULES_BY_FILES[$rules_file] = @json_decode(@file_get_contents(__("%s/json_overw_rules/%s.json", dirname(__FILE__), $rules_file)), true);
  9. if(!is_array($RULES_BY_FILES[$rules_file])){
  10. throw new Exception("ERROR: cant read rules from $rules_file");
  11. }
  12. }
  13. $score = 0; $n = 1;
  14. $roi = array();
  15. $min = -20; $max = 20;
  16.  
  17. $roiIdx = 0;
  18.  
  19. if ($isGROI === 'GROI') {
  20. $roiIdx = 1;
  21. }else if($isGROI === 'KROI') {
  22. $roiIdx = 2;
  23. }
  24.  
  25. $bk_rules = $RULES_BY_FILES[$rules_file];
  26.  
  27. foreach ($bk_rules as $bks => $local_rules) {
  28. if (!empty($stake[ $bks ])) {
  29. #$cf_diff = -((1 / $real_cf) - (1 / $stake[ $bks ])); #OVERW
  30. $fork_income = 1 - ((1 / $real_cf) + (1 / $stake[ $bks ])); #FORK_INCOME
  31.  
  32. #$cf_diff = $stake[ $bks ];
  33. $inx = strval(ceil($fork_income / 0.0025)*0.0025);
  34.  
  35. #if ($min > $local_rules['min']) $min = $local_rules['min'];
  36. #if ($max < $local_rules['max']) $max = $local_rules['max'];
  37.  
  38. if (isset($local_rules[ $inx ])) {
  39.  
  40. if (!is_array($local_rules[ $inx ]) && $isGROI === 'GROI') {
  41. throw new \Exception('Error: invalid rule format - GROI not found!');
  42. }
  43.  
  44. if (!is_array($local_rules[ $inx ]) && $isGROI === 'ROI') {
  45. $roi[] = $local_rules[ $inx ];
  46. } else {
  47. if (is_array($local_rules[ $inx ])) {
  48. $roi[] = $local_rules[ $inx ][ $roiIdx ];
  49. }
  50. }
  51.  
  52. if($_echo){
  53. echo __("\t%s%.2f\n", str_pad("$bks:", 15, " ", STR_PAD_RIGHT), $roi[count($roi)-1]);
  54. }
  55.  
  56. $in1 = $inx;
  57. for ($i = 0; $i < $n; $i++) {
  58. $in1 = $in1 - 0.0025;
  59.  
  60. if (!is_array($local_rules[ strval($in1) ]) && $isGROI === 'ROI') {
  61. $roi[] = $local_rules[ strval($in1) ];
  62. } else {
  63. if (is_array($local_rules[ strval($in1) ])) {
  64. $roi[] = $local_rules[ strval($in1) ][ $roiIdx ];
  65. }
  66. }
  67. }
  68.  
  69. $in1 = $inx;
  70. for ($i = 0; $i < $n; $i++) {
  71. $in1 = $in1 + 0.0025;
  72.  
  73. if (!is_array($local_rules[ strval($in1) ]) && $isGROI === 'ROI') {
  74. $roi[] = $local_rules[ strval($in1) ];
  75. } else {
  76. if (is_array($local_rules[ strval($in1) ])) {
  77. $roi[] = $local_rules[ strval($in1) ][ $roiIdx ];
  78. }
  79. }
  80.  
  81. }
  82.  
  83.  
  84. }
  85. }
  86. }
  87.  
  88. $avg_roi = 0.00;
  89. if (count($roi) > 0) {
  90. $avg_roi = array_sum($roi) / count($roi);
  91. $score = ($avg_roi - $min) / ($max - $min);
  92. }
  93.  
  94. $_SERVER["API_SCORE"] = $score;
  95.  
  96. echo __("\n[#] SCORE V6 by %s: %.2f / %.2f\n", $rules_file, $avg_roi, $score);
  97.  
  98. return $score;
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement