|
|
@@ -1,29 +1,8 @@
|
|
|
const crypto = require('crypto');
|
|
|
-const Logs = require('../libs/logs');
|
|
|
const IOR_KEYS_MAP = require('./iorKeys');
|
|
|
const { getSetting } = require('./settings');
|
|
|
const { eventSolutions } = require('./eventSolutions');
|
|
|
|
|
|
-const HG_REBATE_RATIO_LOWER = 0.75;
|
|
|
-
|
|
|
-/**
|
|
|
- * 筛选最优赔率
|
|
|
- */
|
|
|
-// const oddRebateValue = (odds, platform, key) => {
|
|
|
-// const setting = getSetting();
|
|
|
-// let rebateRatio = setting[`${platform}RebateRatio`] ?? 0;
|
|
|
-// let rebateType = setting[`${platform}RebateType`] ?? 0;
|
|
|
-
|
|
|
-// if (platform == 'hg' && key.startsWith('ior_m')) {
|
|
|
-// rebateRatio -= HG_REBATE_RATIO_LOWER;
|
|
|
-// }
|
|
|
-
|
|
|
-// if (rebateType == 0) {
|
|
|
-// return odds * (1 + rebateRatio / 100);
|
|
|
-// }
|
|
|
-// return odds + rebateRatio / 100;
|
|
|
-// }
|
|
|
-
|
|
|
const cartesianOdds = (selection) => {
|
|
|
const [a, b, c] = selection;
|
|
|
return a.flatMap(itemA => b.flatMap(itemB => c.map(itemC => [itemA, itemB, itemC])));
|
|
|
@@ -65,28 +44,11 @@ const getOptimalSelections = (odds, rules) => {
|
|
|
}
|
|
|
else {
|
|
|
const { ps, ...itemRest } = item;
|
|
|
- // const candidates = ['ob', 'hg', 'no'].filter((k) => k in item);
|
|
|
const candidates = Object.keys(itemRest);
|
|
|
if (candidates.length === 0) {
|
|
|
isValid = false;
|
|
|
break;
|
|
|
}
|
|
|
- // Logs.out('candidates', candidates)
|
|
|
- // const best = candidates.reduce((a, b) => {
|
|
|
- // const aValue = oddRebateValue(item[a].v-1, a, key);
|
|
|
- // const bValue = oddRebateValue(item[b].v-1, b, key);
|
|
|
- // const seletcted = aValue > bValue ? a : b;
|
|
|
- // return seletcted;
|
|
|
- // });
|
|
|
- // Logs.out('best', item, best)
|
|
|
- // selection.push({
|
|
|
- // k: key,
|
|
|
- // p: best,
|
|
|
- // v: item[best].v,
|
|
|
- // r: item[best].r,
|
|
|
- // s: item[best].s,
|
|
|
- // o: item
|
|
|
- // });
|
|
|
selection.push(candidates.map(k => ({
|
|
|
k: key,
|
|
|
p: k,
|
|
|
@@ -96,7 +58,6 @@ const getOptimalSelections = (odds, rules) => {
|
|
|
q: item[k].q,
|
|
|
o: item
|
|
|
})));
|
|
|
- // .filter(item => item.q !== 0)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -111,20 +72,8 @@ const getOptimalSelections = (odds, rules) => {
|
|
|
validOptions.forEach(iors => {
|
|
|
results.push({ rule, iors, ruleIndex });
|
|
|
});
|
|
|
-
|
|
|
- // if (validOptions.length > 0) {
|
|
|
- // const iors = validOptions.reduce((a, b) => {
|
|
|
- // const sumA = a.reduce((sum, x) => sum + x.v, 0);
|
|
|
- // const sumB = b.reduce((sum, x) => sum + x.v, 0);
|
|
|
- // return sumA > sumB ? a : b;
|
|
|
- // });
|
|
|
- // results.push({ rule, iors, ruleIndex });
|
|
|
- // }
|
|
|
});
|
|
|
- // if (results.length) {
|
|
|
- // Logs.outDev('results', results);
|
|
|
- // }
|
|
|
- // return [];
|
|
|
+
|
|
|
return results;
|
|
|
}
|
|
|
|
|
|
@@ -160,7 +109,7 @@ const getPlatformKey = (cpr) => {
|
|
|
* 添加返佣
|
|
|
*/
|
|
|
const attachRebate = (ior) => {
|
|
|
- const { obRebateRatio, obRebateType, hgRebateRatio, hgRebateType, pcRebateRatio, pcRebateType } = getSetting();
|
|
|
+ const { obRebateRatio, obRebateType, hgRebateRatio, hgRebateLower, hgRebateType, pcRebateRatio, pcRebateType } = getSetting();
|
|
|
const { p, k } = ior;
|
|
|
let rebate = 0, rebateType = 0;
|
|
|
if (p == 'ps') {
|
|
|
@@ -179,7 +128,7 @@ const attachRebate = (ior) => {
|
|
|
rebate = hgRebateRatio;
|
|
|
rebateType = hgRebateType;
|
|
|
if (k.startsWith('ior_m')) {
|
|
|
- rebate -= HG_REBATE_RATIO_LOWER;
|
|
|
+ rebate = hgRebateLower;
|
|
|
}
|
|
|
}
|
|
|
return { ...ior, b: rebate, t: rebateType };
|
|
|
@@ -276,7 +225,6 @@ const getPassableEvents = (relations, eventsLogsMap) => {
|
|
|
* 盘口组合计算
|
|
|
*/
|
|
|
const eventsCombination = (passableEvents, innerBase, innerRebate) => {
|
|
|
- // Logs.outDev('passableEvents', passableEvents);
|
|
|
const { innerDefaultAmount, innerRebateRatio } = getSetting();
|
|
|
const solutions = [];
|
|
|
passableEvents.forEach(events => {
|
|
|
@@ -316,15 +264,11 @@ const eventsCombination = (passableEvents, innerBase, innerRebate) => {
|
|
|
}
|
|
|
if (!isNaN(sol?.win_average)) {
|
|
|
const id = info.id;
|
|
|
- // const sortedCpr = sortCpr(cpr);
|
|
|
const keys = cpr.map(item => `${item.k}-${item.p}`).join('##');
|
|
|
- // Logs.outDev('keys', `${id}##${keys}`)
|
|
|
const sid = crypto.createHash('sha1').update(`${id}-${keys}`).digest('hex');
|
|
|
const crpGroup = `${id}_${cpr.find(item => item.p == 'ps').k}`;
|
|
|
const hasLower = cpr.some(item => item.q === 0);
|
|
|
- // Logs.outDev('crpGroup', crpGroup)
|
|
|
const platformKey = getPlatformKey(cpr);
|
|
|
- // Logs.outDev('platformKey', platformKey, cpr)
|
|
|
const timestamp = Date.now();
|
|
|
solutions.push({sid, sol, cpr, cross: platformKey, info, group: crpGroup, lower: hasLower, rule: `${iorGroup}:${ruleIndex}`, timestamp});
|
|
|
}
|