Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getScore_V6( $real_cf, $rules_file, $stake, $isGROI = 'KROI', $_echo=true ) { // GROI, ROI, KROI
- static $RULES_BY_FILES;
- if(!isset($RULES_BY_FILES)){
- $RULES_BY_FILES = array();
- }
- if(!isset($RULES_BY_FILES[$rules_file])){
- $RULES_BY_FILES[$rules_file] = @json_decode(@file_get_contents(__("%s/json_overw_rules/%s.json", dirname(__FILE__), $rules_file)), true);
- if(!is_array($RULES_BY_FILES[$rules_file])){
- throw new Exception("ERROR: cant read rules from $rules_file");
- }
- }
- $score = 0; $n = 1;
- $roi = array();
- $min = -20; $max = 20;
- $roiIdx = 0;
- if ($isGROI === 'GROI') {
- $roiIdx = 1;
- }else if($isGROI === 'KROI') {
- $roiIdx = 2;
- }
- $bk_rules = $RULES_BY_FILES[$rules_file];
- foreach ($bk_rules as $bks => $local_rules) {
- if (!empty($stake[ $bks ])) {
- #$cf_diff = -((1 / $real_cf) - (1 / $stake[ $bks ])); #OVERW
- $fork_income = 1 - ((1 / $real_cf) + (1 / $stake[ $bks ])); #FORK_INCOME
- #$cf_diff = $stake[ $bks ];
- $inx = strval(ceil($fork_income / 0.0025)*0.0025);
- #if ($min > $local_rules['min']) $min = $local_rules['min'];
- #if ($max < $local_rules['max']) $max = $local_rules['max'];
- if (isset($local_rules[ $inx ])) {
- if (!is_array($local_rules[ $inx ]) && $isGROI === 'GROI') {
- throw new \Exception('Error: invalid rule format - GROI not found!');
- }
- if (!is_array($local_rules[ $inx ]) && $isGROI === 'ROI') {
- $roi[] = $local_rules[ $inx ];
- } else {
- if (is_array($local_rules[ $inx ])) {
- $roi[] = $local_rules[ $inx ][ $roiIdx ];
- }
- }
- if($_echo){
- echo __("\t%s%.2f\n", str_pad("$bks:", 15, " ", STR_PAD_RIGHT), $roi[count($roi)-1]);
- }
- $in1 = $inx;
- for ($i = 0; $i < $n; $i++) {
- $in1 = $in1 - 0.0025;
- if (!is_array($local_rules[ strval($in1) ]) && $isGROI === 'ROI') {
- $roi[] = $local_rules[ strval($in1) ];
- } else {
- if (is_array($local_rules[ strval($in1) ])) {
- $roi[] = $local_rules[ strval($in1) ][ $roiIdx ];
- }
- }
- }
- $in1 = $inx;
- for ($i = 0; $i < $n; $i++) {
- $in1 = $in1 + 0.0025;
- if (!is_array($local_rules[ strval($in1) ]) && $isGROI === 'ROI') {
- $roi[] = $local_rules[ strval($in1) ];
- } else {
- if (is_array($local_rules[ strval($in1) ])) {
- $roi[] = $local_rules[ strval($in1) ][ $roiIdx ];
- }
- }
- }
- }
- }
- }
- $avg_roi = 0.00;
- if (count($roi) > 0) {
- $avg_roi = array_sum($roi) / count($roi);
- $score = ($avg_roi - $min) / ($max - $min);
- }
- $_SERVER["API_SCORE"] = $score;
- echo __("\n[#] SCORE V6 by %s: %.2f / %.2f\n", $rules_file, $avg_roi, $score);
- return $score;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement