overtime-live-trading-utils 0.0.26 → 0.0.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.ts +1 -0
- package/main.js +1 -1
- package/package.json +1 -1
- package/src/constants/common.ts +7 -0
- package/src/constants/constantsOpticodds.ts +152 -0
- package/src/constants/sports.ts +197 -29
- package/src/enums/sports.ts +8 -0
- package/src/enums/statuses.ts +19 -0
- package/src/utils/gameMatching.ts +4 -5
- package/src/utils/markets.ts +203 -0
- package/src/utils/odds.ts +501 -0
- package/src/utils/sports.ts +68 -14
package/index.ts
CHANGED
package/main.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(r,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.thalesUtils=e():r.thalesUtils=e()}(this,(()=>(()=>{"use strict";var r={d:(e,a)=>{for(var t in a)r.o(a,t)&&!r.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:a[t]})},o:(r,e)=>Object.prototype.hasOwnProperty.call(r,e),r:r=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})}},e={};r.r(e),r.d(e,{adjustSpreadOnOdds:()=>y,allowGameSportWithPeriodConstraint:()=>v,allowGameSportWithResultConstraint:()=>D,allowSoccerGame:()=>g,calculateImpliedOddsDifference:()=>I,checkGameContraints:()=>V,checkOddsFromBookmakers:()=>N,extractOddsForGamePerProvider:()=>G,gamesDatesMatching:()=>f,getBookmakersArray:()=>s,getLeagueSport:()=>b,getSpreadData:()=>B,teamNamesMatching:()=>R}),"function"!=typeof Object.assign&&(Object.assign=function(r,e){if(null==r)throw new TypeError("Cannot convert undefined or null to object");for(var a=Object(r),t=1;t<arguments.length;t++){var _=arguments[t];if(null!=_)for(var o in _)Object.prototype.hasOwnProperty.call(_,o)&&(a[o]=_[o])}return a});var a=function(r){return parseFloat(r.toPrecision(12))};function t(r,e,a){return void 0===a||0==+a?Math[r](e):(e=+e,a=+a,isNaN(e)||"number"!=typeof a||a%1!=0?NaN:e<0?-t(r,-e,a):(e=e.toString().split("e"),+((e=(e=Math[r](+(e[0]+"e"+(e[1]?+e[1]-a:-a)))).toString().split("e"))[0]+"e"+(e[1]?+e[1]+a:a))))}var _,o,i={decimal:{from:function(r){if((r=parseFloat(r))<=1)throw new Error("Outside valid range.");return r},to:function(){return this.decimalValue}},moneyline:{from:function(r){return(r=parseFloat(r))>=0?r/100+1:100/-r+1},to:function(){return this.decimalValue>=2?a(100*(this.decimalValue-1)):a(-100/(this.decimalValue-1))}},hongKong:{from:function(r){if((r=parseFloat(r))<0)throw new Error("Outside valid range.");return r+1},to:function(){return a(this.decimalValue-1)}},impliedProbability:{from:function(r){if((r="string"==typeof r&&"%"==r.slice(-1)?parseFloat(r)/100:parseFloat(r))<=0||r>=1)throw new Error("Outside valid range");return 1/r},to:function(r){if(r.percentage){var e=a(100/this.decimalValue);return null!==r.precision&&(e=t("round",e,-r.precision)),e.toString()+"%"}return a(1/this.decimalValue)}},fractional:{from:function(r){var e,a=r.toString().split("/");if(r=parseFloat(a[0]),2===a.length)e=parseFloat(a[1]);else{if(1!==a.length)throw new Error("Invalid fraction");e=1}if(0===r||0===e||r/e<=0)throw new Error("Outside valid range");return 1+r/e},to:function(r){return function(r,e){for(var a,t=[0,1],_=[1,0],o=function(r){var e=null,a=r.toString().indexOf("E");-1==a&&(a=r.toString().indexOf("e"));var t=null,_=(e=-1==a?r.toString():r.toString().substring(0,a)).toString().indexOf(".");-1==_?t=e:0===_?t=e.substring(1,e.length):_<e.length&&(t=e.substring(0,_)+e.substring(_+1,e.length));var o=t,i=o.toString().length,A=r,E=A.toString().length;0===A&&(E=0);var n,s=i-E;for(n=s;n>0&&o%2==0;n--)o/=2;for(n=s;n>0&&o%5==0;n--)o/=5;return o}(r),i=r,A=Math.pow(10,-e)/2,E=2;E<1e3;E++){var n=Math.floor(i);if(t[E]=n*t[E-1]+t[E-2],Math.abs(t[E])>o)return;if(_[E]=n*_[E-1]+_[E-2],a=t[E]/_[E],Math.abs(a-r)<A||NaN==a)return t[E].toString()+"/"+_[E].toString();i=1/(i-n)}}(this.decimalValue-1,r.precision||12)}},malay:{from:function(r){if((r=parseFloat(r))<=-1||r>1)throw new Error("Outside valid range.");return r<0&&(r=-1/r),r+1},to:function(){return this.decimalValue<=2?a(this.decimalValue-1):a(-1/(this.decimalValue-1))}},indonesian:{from:function(r){if(0===(r=parseFloat(r)))throw new Error("Outside valid range.");return r>=1?r+1:-1/r+1},to:function(){return this.decimalValue<2?a(-1/(this.decimalValue-1)):a(this.decimalValue-1)}}},A=((o=function(r){if("number"!=typeof r||isNaN(r))throw new Error("Invalid odds");this.decimalValue=a(r)}).prototype=(_=function(){throw new Error("This constructor is private, please use the from* functions")}).prototype,_.from=function(r,e){if(!i.hasOwnProperty(r))throw new Error("Unknown format "+r+".");var a=i[r].from(e);return new o(a)},_);A.prototype.to=function(r,e){if(!i.hasOwnProperty(r))throw new Error("Unknown format "+r+".");e=Object.assign({precision:null,percentage:!1},e);var a=i[r].to.call(this,e);return"number"==typeof a&&null!==e.precision&&(a=t("round",a,-e.precision)),a};var E,n=A.from,s=function(r,e,a){var t=r.find((function(r){return Number(r.sportId)===Number(e)}));if(t){if(""==t.primaryBookmaker)return a;var _=[];return t.primaryBookmaker&&_.push(t.primaryBookmaker),t.secondaryBookmaker&&_.push(t.secondaryBookmaker),t.tertiaryBookmaker&&_.push(t.tertiaryBookmaker),_}return a},N=function(r,e,a,t,_){var o=e.some((function(e){var t=r.get(e);return!!t&&(0===t.homeOdds||0===t.awayOdds||!a&&0===t.drawOdds||1===t.homeOdds||1===t.awayOdds||!a&&1===t.drawOdds)}));if(1==e.length){if(o)return[{homeOdds:0,awayOdds:0,drawOdds:0}];var i=e[0],A=r.get(i);return[{homeOdds:A.homeOdds,awayOdds:A.awayOdds,drawOdds:a?0:A.drawOdds}]}if(o)return[{homeOdds:0,awayOdds:0,drawOdds:0}];var E=r.get(e[0]),s=E.homeOdds,N=E.awayOdds,S=E.drawOdds;if(e.slice(1).some((function(e){var o=r[e];if(o){var i=o.homeOdds,A=o.awayOdds,E=o.drawOdds,l=n("decimal",s).to("impliedProbability"),L=n("decimal",N).to("impliedProbability"),d=a?0:n("decimal",S).to("impliedProbability"),M=n("decimal",i).to("impliedProbability"),u=n("decimal",A).to("impliedProbability"),O=a?0:n("decimal",E).to("impliedProbability"),P=I(l,M),c=I(L,u),w=a?0:I(d,O);if(P>t&&l>_&&M>_||c>t&&L>_&&u>_||!a&&w>t&&d>_&&O>_)return!0}return!1})))return console.log("Returning zero odds due to percentage difference"),[{homeOdds:0,awayOdds:0,drawOdds:0}];var l=[];return e.forEach((function(e){return l.push(r.get(e))})),null!=l[0]?l.map((function(r){return{homeOdds:r.homeOdds,awayOdds:r.awayOdds,drawOdds:a?0:r.drawOdds}})):(console.log("Returning zero odds cause no matching bookmakers have been found"),[{homeOdds:0,awayOdds:0,drawOdds:0}])},I=function(r,e){var a=Math.abs(r-e)/r*100;return console.log("% diff: "+a),a},S="Soccer",l="Football",L="Basketball",d="Baseball",M="Hockey",u="Fighting",O="Tennis",P="eSports",c="Volleyball",w="Cricket",T="Motosport",m="Golf",C={NCAAF:1,NFL:2,MLB:3,NBA:4,NCAAB:5,NHL:6,UFC:7,WNBA:8,MLS:10,EPL:11,LIGUE_ONE:12,BUNDESLIGA:13,LA_LIGA:14,SERIE_A:15,UEFA_CL:16,UEFA_EL:17,FIFA_WC:18,J1_LEAGUE:19,IPL:20,T20_BLAST:21,IIHF_WORLD_CHAMPIONSHIP:33,COPA_AMERICA:44,COPA_LIBERTADORES:45,UEFA_EURO:50,EREDIVISIE:57,PRIMEIRA_LIGA:61,SUMMER_OLYMPICS_SOCCER_WOMEN:65,SUMMER_OLYMPICS_SOCCER:66,FIFA_WC_WOMEN:76,ENGLAND_CUP:132,FRANCE_CUP:134,SPAIN_CUP:138,ITALY_CUP:141,TENNIS_GS:153,TENNIS_MASTERS:156,GERMANY_CUP:209,LIGA_MX:230,BRAZIL_1:268,UEFA_EURO_U21:288,FIFA_WORLD_CUP_U20:296,SUMMER_OLYMPICS_HANDBALL_WOMEN:380,SUMMER_OLYMPICS_HANDBALL:381,EUROLEAGUE:399,SUMMER_OLYMPICS_BASKETBALL:406,SUMMER_OLYMPICS_BASKETBALL_WOMEN:407,FIBA_WORLD_CUP:409,FORMULA1:445,MOTOGP:497,SAUDI_PROFESSIONAL_LEAGUE:536,SUMMER_OLYMPICS_WATERPOLO:8881,SUMMER_OLYMPICS_VOLEYBALL_WOMEN:8893,SUMMER_OLYMPICS_VOLEYBALL:8894,BOXING:9196,SUMMER_OLYMPICS_RUGBY:9578,SUMMER_OLYMPICS_RUGBY_WOMEN:9588,UEFA_NATIONS_LEAGUE:9806,CONCACAF_NATIONS_LEAGUE:9821,CSGO:9977,DOTA2:9983,SUMMER_OLYMPICS_BASKETBALL_3X3:10071,SUMMER_OLYMPICS_BASKETBALL_3X3_WOMEN:10072,SUMMER_OLYMPICS_QUALIFICATION:10502,LOL:10138,CONMEBOL_WC_QUALIFICATIONS:10199,UEFA_CONFERENCE_LEAGUE:10216,NON_TITLE_BOXING:10595,UEFA_CHAMPIONS_LEAGUE_QUALIFICATION:10611,UEFA_EUROPA_LEAGUE_QUALIFICATION:10613,UEFA_CONFERENCE_LEAGUE_QUALIFICATION:10615,GOLF_H2H:100021,GOLF_WINNER:100121,TENNIS_GRAND_SLAM_LIVE_MAPPING_V2_1:15312,TENNIS_GRAND_SLAM_LIVE_MAPPING_V2_2:15313,TENNIS_GRAND_SLAM_LIVE_MAPPING_V2_3:15314,TENNIS_GRAND_SLAM_LIVE_MAPPING_V2_4:15315,TENNIS_GRAND_SLAM_LIVE_MAPPING_V2_5:15316,TENNIS_GRAND_SLAM_LIVE_MAPPING_V2_6:15317,TENNIS_GRAND_SLAM_LIVE_MAPPING_V2_7:15318,TENNIS_MASTERS_LIVE_MAPPING_V2_1:15622,TENNIS_MASTERS_LIVE_MAPPING_V2_2:15623,TENNIS_MASTERS_LIVE_MAPPING_V2_3:15624,TENNIS_MASTERS_LIVE_MAPPING_V2_4:15625,TENNIS_MASTERS_LIVE_MAPPING_V2_5:15626,TENNIS_MASTERS_LIVE_MAPPING_V2_6:15627,TENNIS_MASTERS_LIVE_MAPPING_V2_7:15628,TENNIS_MASTERS_LIVE_MAPPING_V2_8:15632,TENNIS_MASTERS_LIVE_MAPPING_V2_9:15633,TENNIS_MASTERS_LIVE_MAPPING_V2_10:15634,TENNIS_MASTERS_LIVE_MAPPING_V2_11:15635,TENNIS_MASTERS_LIVE_MAPPING_V2_12:15636,TENNIS_MASTERS_LIVE_MAPPING_V2_13:15637,TENNIS_MASTERS_LIVE_MAPPING_V2_14:15638,TENNIS_MASTERS_LIVE_MAPPING_V2_15:15641,TENNIS_MASTERS_LIVE_MAPPING_V2_16:15642,TENNIS_MASTERS_LIVE_MAPPING_V2_17:15643,TENNIS_MASTERS_LIVE_MAPPING_V2_18:15644,TENNIS_MASTERS_LIVE_MAPPING_V2_19:15645,TENNIS_MASTERS_LIVE_MAPPING_V2_20:15646,TENNIS_MASTERS_LIVE_MAPPING_V2_21:15647,TENNIS_MASTERS_LIVE_MAPPING_V2_22:15648},p=[C.CSGO,C.DOTA2,C.LOL,C.TENNIS_GS,C.TENNIS_MASTERS,C.TENNIS_GRAND_SLAM_LIVE_MAPPING_V2_1,C.TENNIS_GRAND_SLAM_LIVE_MAPPING_V2_2,C.TENNIS_GRAND_SLAM_LIVE_MAPPING_V2_3,C.TENNIS_GRAND_SLAM_LIVE_MAPPING_V2_4,C.TENNIS_GRAND_SLAM_LIVE_MAPPING_V2_5,C.TENNIS_GRAND_SLAM_LIVE_MAPPING_V2_6,C.TENNIS_GRAND_SLAM_LIVE_MAPPING_V2_7,C.TENNIS_MASTERS_LIVE_MAPPING_V2_1,C.TENNIS_MASTERS_LIVE_MAPPING_V2_2,C.TENNIS_MASTERS_LIVE_MAPPING_V2_3,C.TENNIS_MASTERS_LIVE_MAPPING_V2_4,C.TENNIS_MASTERS_LIVE_MAPPING_V2_5,C.TENNIS_MASTERS_LIVE_MAPPING_V2_6,C.TENNIS_MASTERS_LIVE_MAPPING_V2_7,C.TENNIS_MASTERS_LIVE_MAPPING_V2_8,C.TENNIS_MASTERS_LIVE_MAPPING_V2_9,C.TENNIS_MASTERS_LIVE_MAPPING_V2_10,C.TENNIS_MASTERS_LIVE_MAPPING_V2_11,C.TENNIS_MASTERS_LIVE_MAPPING_V2_12,C.TENNIS_MASTERS_LIVE_MAPPING_V2_13,C.TENNIS_MASTERS_LIVE_MAPPING_V2_14,C.TENNIS_MASTERS_LIVE_MAPPING_V2_15,C.TENNIS_MASTERS_LIVE_MAPPING_V2_16,C.TENNIS_MASTERS_LIVE_MAPPING_V2_17,C.TENNIS_MASTERS_LIVE_MAPPING_V2_18,C.TENNIS_MASTERS_LIVE_MAPPING_V2_19,C.TENNIS_MASTERS_LIVE_MAPPING_V2_20,C.TENNIS_MASTERS_LIVE_MAPPING_V2_21,C.TENNIS_MASTERS_LIVE_MAPPING_V2_22],R=function(r,e,a,t,_,o){var i,A;if(p.includes(r)?(i=t.toLowerCase()==e.toLowerCase()||t.toLowerCase()==a.toLowerCase(),A=_.toLowerCase()==e.toLowerCase()||_.toLowerCase()==a.toLowerCase()):(i=t.toLowerCase()==e.toLowerCase(),A=_.toLowerCase()==a.toLowerCase()),!0!==i){var E=o.get(t.toLowerCase()),n=o.get(e.toLowerCase()),s=o.get(a.toLowerCase());if([E,n].some((function(r){return null==r})))return!1;i=p.includes(r)?E==n||E==s:E==n}if(!0!==A){var N=o.get(_.toLowerCase());if(n=o.get(e.toLowerCase()),[N,s=o.get(a.toLowerCase())].some((function(r){return null==r})))return!1;A=p.includes(r)&&N==n||N==s}return i&&A},f=function(r,e,a,t){var _;if(a.toString().startsWith(C.TENNIS_GS.toString())||a.toString().startsWith(C.TENNIS_MASTERS.toString())){var o=e.getTime(),i=r.getTime();_=Math.abs(i-o)<=Number(60*t*1e3)}else _=e.toUTCString()==r.toUTCString();return _},G=function(r,e,a,t,_){var o=new Map;return r.forEach((function(r){var i,A,E=e.odds.filter((function(e){return e.sports_book_name.toLowerCase()==r.toLowerCase()})),n=t.get(a.homeTeam.toLowerCase()),s=t.get(a.awayTeam.toLowerCase()),N=0;null!=(i=null==n?E.find((function(r){var e=t.get(r.name.toLowerCase());return null==e?r.name.toLowerCase()==a.homeTeam.toLowerCase():e==a.homeTeam.toLowerCase()})):E.find((function(r){var e=t.get(r.name.toLowerCase());return null==e?r.name.toLowerCase()==n:e==n})))&&(N=i.price);var I=0;null!=(A=null==s?E.find((function(r){var e=t.get(r.name.toLowerCase());return null==e?r.name.toLowerCase()==a.awayTeam.toLowerCase():e==a.awayTeam.toLowerCase()})):E.find((function(r){var e=t.get(r.name.toLowerCase());return null==e?r.name.toLowerCase()==s:e==s})))&&(I=A.price);var S=0;if(_){var l=E.find((function(r){return"draw"==r.name.toLowerCase()}));null!=l&&(S=l.price)}o.set(r.toLowerCase(),{homeOdds:N,awayOdds:I,drawOdds:S})})),o},U=((E={})[C.NCAAF]={sport:l,id:C.NCAAF,isDrawAvailable:!1},E[C.NFL]={sport:l,id:C.NFL,isDrawAvailable:!1},E[C.MLB]={sport:d,id:C.MLB,isDrawAvailable:!1},E[C.NBA]={sport:L,id:C.NBA,isDrawAvailable:!1},E[C.NCAAB]={sport:L,id:C.NCAAB,isDrawAvailable:!1},E[C.NHL]={sport:M,id:C.NHL,isDrawAvailable:!1},E[C.UFC]={sport:u,id:C.UFC,isDrawAvailable:!1},E[C.WNBA]={sport:L,id:C.WNBA,isDrawAvailable:!1},E[C.MLS]={sport:S,id:C.MLS,isDrawAvailable:!0},E[C.EPL]={sport:S,id:C.EPL,isDrawAvailable:!0},E[C.LIGUE_ONE]={sport:S,id:C.LIGUE_ONE,isDrawAvailable:!0},E[C.BUNDESLIGA]={sport:S,id:C.BUNDESLIGA,isDrawAvailable:!0},E[C.LA_LIGA]={sport:S,id:C.LA_LIGA,isDrawAvailable:!0},E[C.SERIE_A]={sport:S,id:C.SERIE_A,isDrawAvailable:!0},E[C.UEFA_CL]={sport:S,id:C.UEFA_CL,isDrawAvailable:!0},E[C.UEFA_EL]={sport:S,id:C.UEFA_EL,isDrawAvailable:!0},E[C.FIFA_WC]={sport:S,id:C.FIFA_WC,isDrawAvailable:!0},E[C.J1_LEAGUE]={sport:S,id:C.J1_LEAGUE,isDrawAvailable:!0},E[C.IPL]={sport:w,id:C.IPL,isDrawAvailable:!1},E[C.T20_BLAST]={sport:w,id:C.T20_BLAST,isDrawAvailable:!1},E[C.IIHF_WORLD_CHAMPIONSHIP]={sport:M,id:C.IIHF_WORLD_CHAMPIONSHIP,isDrawAvailable:!0},E[C.COPA_AMERICA]={sport:S,id:C.COPA_AMERICA,isDrawAvailable:!0},E[C.COPA_LIBERTADORES]={sport:S,id:C.COPA_LIBERTADORES,isDrawAvailable:!0},E[C.UEFA_EURO]={sport:S,id:C.UEFA_EURO,isDrawAvailable:!0},E[C.EREDIVISIE]={sport:S,id:C.EREDIVISIE,isDrawAvailable:!0},E[C.PRIMEIRA_LIGA]={sport:S,id:C.PRIMEIRA_LIGA,isDrawAvailable:!0},E[C.FIFA_WC_WOMEN]={sport:S,id:C.FIFA_WC_WOMEN,isDrawAvailable:!0},E[C.ENGLAND_CUP]={sport:S,id:C.ENGLAND_CUP,isDrawAvailable:!0},E[C.FRANCE_CUP]={sport:S,isDrawAvailable:!0},E[C.SPAIN_CUP]={sport:S,id:C.SPAIN_CUP,isDrawAvailable:!0},E[C.ITALY_CUP]={sport:S,isDrawAvailable:!0},E[C.TENNIS_GS]={sport:O,id:C.TENNIS_GS,isDrawAvailable:!1},E[C.TENNIS_MASTERS]={sport:O,id:C.TENNIS_MASTERS,isDrawAvailable:!1},E[C.GERMANY_CUP]={sport:S,id:C.GERMANY_CUP,isDrawAvailable:!0},E[C.BRAZIL_1]={sport:S,id:C.BRAZIL_1,isDrawAvailable:!0},E[C.UEFA_EURO_U21]={sport:S,id:C.UEFA_EURO_U21,isDrawAvailable:!0},E[C.FIFA_WORLD_CUP_U20]={sport:S,id:C.FIFA_WORLD_CUP_U20,isDrawAvailable:!0},E[C.EUROLEAGUE]={sport:L,id:C.EUROLEAGUE,isDrawAvailable:!1},E[C.FIBA_WORLD_CUP]={sport:L,id:C.FIBA_WORLD_CUP,isDrawAvailable:!1},E[C.FORMULA1]={sport:T,id:C.FORMULA1,isDrawAvailable:!1},E[C.MOTOGP]={sport:T,id:C.MOTOGP,isDrawAvailable:!1},E[C.SAUDI_PROFESSIONAL_LEAGUE]={sport:S,id:C.SAUDI_PROFESSIONAL_LEAGUE,isDrawAvailable:!0},E[C.BOXING]={sport:u,id:C.BOXING,isDrawAvailable:!1},E[C.UEFA_NATIONS_LEAGUE]={sport:S,id:C.UEFA_NATIONS_LEAGUE,isDrawAvailable:!0},E[C.CONCACAF_NATIONS_LEAGUE]={sport:S,id:C.CONCACAF_NATIONS_LEAGUE,isDrawAvailable:!0},E[C.CSGO]={sport:P,id:C.CSGO,isDrawAvailable:!1},E[C.DOTA2]={sport:P,id:C.DOTA2,isDrawAvailable:!1},E[C.SUMMER_OLYMPICS_QUALIFICATION]={sport:L,id:C.SUMMER_OLYMPICS_QUALIFICATION,isDrawAvailable:!1},E[C.LOL]={sport:P,id:C.LOL,isDrawAvailable:!1},E[C.CONMEBOL_WC_QUALIFICATIONS]={sport:S,id:C.CONMEBOL_WC_QUALIFICATIONS,isDrawAvailable:!0},E[C.UEFA_CONFERENCE_LEAGUE]={sport:S,id:C.UEFA_CONFERENCE_LEAGUE,isDrawAvailable:!0},E[C.NON_TITLE_BOXING]={sport:u,isDrawAvailable:!1},E[C.UEFA_CHAMPIONS_LEAGUE_QUALIFICATION]={sport:S,id:C.UEFA_CHAMPIONS_LEAGUE_QUALIFICATION,isDrawAvailable:!0},E[C.UEFA_EUROPA_LEAGUE_QUALIFICATION]={sport:S,id:C.UEFA_EUROPA_LEAGUE_QUALIFICATION,isDrawAvailable:!0},E[C.UEFA_CONFERENCE_LEAGUE_QUALIFICATION]={sport:S,isDrawAvailable:!0},E[C.GOLF_H2H]={sport:m,id:C.GOLF_H2H,isDrawAvailable:!1},E[C.GOLF_WINNER]={sport:m,id:C.GOLF_WINNER,isDrawAvailable:!1},E[C.LIGA_MX]={sport:S,id:C.LIGA_MX,isDrawAvailable:!0},E[C.SUMMER_OLYMPICS_SOCCER_WOMEN]={sport:S,id:C.SUMMER_OLYMPICS_SOCCER_WOMEN,isDrawAvailable:!0},E[C.SUMMER_OLYMPICS_SOCCER]={sport:S,id:C.SUMMER_OLYMPICS_SOCCER,isDrawAvailable:!0},E[C.SUMMER_OLYMPICS_BASKETBALL]={sport:L,id:C.SUMMER_OLYMPICS_BASKETBALL,isDrawAvailable:!1},E[C.SUMMER_OLYMPICS_BASKETBALL_WOMEN]={sport:L,id:C.SUMMER_OLYMPICS_BASKETBALL_WOMEN,isDrawAvailable:!1},E[C.SUMMER_OLYMPICS_VOLEYBALL_WOMEN]={sport:c,id:C.SUMMER_OLYMPICS_VOLEYBALL_WOMEN,isDrawAvailable:!1},E[C.SUMMER_OLYMPICS_VOLEYBALL]={sport:c,isDrawAvailable:!1},E),b=function(r){var e=U[r];return e?e.sport:""},V=function(r,e,a){var t,_=r.score_home_total,o=r.score_away_total,i=r.clock,A=r.period,E=r.status,n=r.home_team,s=r.away_team,N=b(e);return"completed"==E.toLowerCase()?(console.log("Blocking game ".concat(n," - ").concat(s," because it is no longer live.")),null):(N===L&&(t=v(n,s,A,a.get(L))),N===M&&(t=v(n,s,A,a.get(M))),N===d&&(t=v(n,s,A,a.get(d))),N===S&&(t=g(n,s,i,A,a.get(S))),N===O&&(t=D(r,n,s,A,_,o,e,N)),N===c&&(t=D(r,n,s,A,_,o,e,N)),t)},v=function(r,e,a,t){return Number(a)>=t?{allow:!1,message:"Blocking game ".concat(r," - ").concat(e," due to period: ").concat(a,". period")}:{allow:!0,message:""}},g=function(r,e,a,t,_){var o=Number(a);return!Number.isNaN(o)&&o>=_||Number.isNaN(o)&&"HALF"!=t?{allow:!1,message:"Blocking game ".concat(r," - ").concat(e," due to clock: ").concat(a,"min")}:{allow:!0,message:""}},D=function(r,e,a,t,_,o,i,A){var E=Number(t),n=F(E,r),s="atp"==r.league.toLowerCase(),N={home:_,away:o};return A==c?h(e,a,n,N,2,5==E?10:20):i.toString().startsWith(C.TENNIS_GS)&&s?h(e,a,n,N,2,5):i.toString().startsWith(C.TENNIS_GS)&&!s||i.toString().startsWith(C.TENNIS_MASTERS)?h(e,a,n,N,1,5):void 0},F=function(r,e){var a=0,t=0;switch(r){case 2:a=Number(e.score_home_period_2),t=Number(e.score_away_period_2);break;case 3:a=Number(e.score_home_period_3),t=Number(e.score_away_period_3);break;case 4:a=Number(e.score_home_period_4),t=Number(e.score_away_period_4);break;case 5:a=Number(e.score_home_period_5),t=Number(e.score_away_period_5)}return{home:a,away:t}},h=function(r,e,a,t,_,o){return Number(t.home)!=_&&Number(t.away)!=_||!(Number(t.home)==_&&a.home>=o||Number(t.away)==_&&a.away>=o)?{allow:!0,message:"",currentHomeGameScore:a.home,currentAwayGameScore:a.away}:{allow:!1,message:"Blocking game ".concat(r," - ").concat(e," due to current result: ").concat(t.home," - ").concat(t.away," (").concat(a.home," - ").concat(a.away,")")}},y=function(r,e,a){if(r.some((function(r){return 0===r})))return r;var t=r.reduce((function(r,e){return r+e}),0);if(t<=1)return Array(r.length).fill(0);if(0===a){if(!(e>100*(t-1)))return r;a=e}var _=1+a/100,o=_/t,i=r.map((function(r){return r*o}));if(i.some((function(r){return r>=1})))return Array(r.length).fill(0);var A=i.reduce((function(r,e){return r+e}),0);if(A<1)return Array(r.length).fill(0);var E=_/A;return i.map((function(r){return r*E}))},B=function(r,e,a,t){var _=r.find((function(r){return Number(r.typeId)===Number(a)&&Number(r.sportId)===Number(e)}));return _?{minSpread:_.minSpread?Number(_.minSpread):t,targetSpread:_.targetSpread?Number(_.targetSpread):0}:{minSpread:t,targetSpread:0}};return e})()));
|
|
1
|
+
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.thalesUtils=r():e.thalesUtils=r()}(this,(()=>(()=>{"use strict";var e={d:(r,a)=>{for(var t in a)e.o(a,t)&&!e.o(r,t)&&Object.defineProperty(r,t,{enumerable:!0,get:a[t]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},r={};e.r(r),e.d(r,{adjustSpreadOnOdds:()=>$,allowGameSportWithPeriodConstraint:()=>z,allowGameSportWithResultConstraint:()=>K,allowSoccerGame:()=>J,calculateImpliedOddsDifference:()=>p,checkGameContraints:()=>H,checkOddsFromBookmakers:()=>c,createTotalChildMarkets:()=>fe,cutOddsCloseToValue:()=>de,extractOddsForGamePerProvider:()=>re,filterOddsByMarketNameBookmaker:()=>ne,filterOddsByMarketNameTeamNameBookmaker:()=>oe,formatSpreadOdds:()=>se,gamesDatesMatching:()=>Y,getBookmakersArray:()=>u,getLeagueSport:()=>W,getLeagueSpreadType:()=>R,getLeagueTotalType:()=>U,getParentOdds:()=>ie,getSpreadData:()=>ee,groupAndFormatSpreadOdds:()=>le,groupOddsBySelectionAndPoints:()=>ce,processMarket:()=>pe,processTotalOdds:()=>ue,teamNamesMatching:()=>X}),"function"!=typeof Object.assign&&(Object.assign=function(e,r){if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var a=Object(e),t=1;t<arguments.length;t++){var o=arguments[t];if(null!=o)for(var i in o)Object.prototype.hasOwnProperty.call(o,i)&&(a[i]=o[i])}return a});var a=function(e){return parseFloat(e.toPrecision(12))};function t(e,r,a){return void 0===a||0==+a?Math[e](r):(r=+r,a=+a,isNaN(r)||"number"!=typeof a||a%1!=0?NaN:r<0?-t(e,-r,a):(r=r.toString().split("e"),+((r=(r=Math[e](+(r[0]+"e"+(r[1]?+r[1]-a:-a)))).toString().split("e"))[0]+"e"+(r[1]?+r[1]+a:a))))}var o,i,n={decimal:{from:function(e){if((e=parseFloat(e))<=1)throw new Error("Outside valid range.");return e},to:function(){return this.decimalValue}},moneyline:{from:function(e){return(e=parseFloat(e))>=0?e/100+1:100/-e+1},to:function(){return this.decimalValue>=2?a(100*(this.decimalValue-1)):a(-100/(this.decimalValue-1))}},hongKong:{from:function(e){if((e=parseFloat(e))<0)throw new Error("Outside valid range.");return e+1},to:function(){return a(this.decimalValue-1)}},impliedProbability:{from:function(e){if((e="string"==typeof e&&"%"==e.slice(-1)?parseFloat(e)/100:parseFloat(e))<=0||e>=1)throw new Error("Outside valid range");return 1/e},to:function(e){if(e.percentage){var r=a(100/this.decimalValue);return null!==e.precision&&(r=t("round",r,-e.precision)),r.toString()+"%"}return a(1/this.decimalValue)}},fractional:{from:function(e){var r,a=e.toString().split("/");if(e=parseFloat(a[0]),2===a.length)r=parseFloat(a[1]);else{if(1!==a.length)throw new Error("Invalid fraction");r=1}if(0===e||0===r||e/r<=0)throw new Error("Outside valid range");return 1+e/r},to:function(e){return function(e,r){for(var a,t=[0,1],o=[1,0],i=function(e){var r=null,a=e.toString().indexOf("E");-1==a&&(a=e.toString().indexOf("e"));var t=null,o=(r=-1==a?e.toString():e.toString().substring(0,a)).toString().indexOf(".");-1==o?t=r:0===o?t=r.substring(1,r.length):o<r.length&&(t=r.substring(0,o)+r.substring(o+1,r.length));var i=t,n=i.toString().length,s=e,l=s.toString().length;0===s&&(l=0);var d,u=n-l;for(d=u;d>0&&i%2==0;d--)i/=2;for(d=u;d>0&&i%5==0;d--)i/=5;return i}(e),n=e,s=Math.pow(10,-r)/2,l=2;l<1e3;l++){var d=Math.floor(n);if(t[l]=d*t[l-1]+t[l-2],Math.abs(t[l])>i)return;if(o[l]=d*o[l-1]+o[l-2],a=t[l]/o[l],Math.abs(a-e)<s||NaN==a)return t[l].toString()+"/"+o[l].toString();n=1/(n-d)}}(this.decimalValue-1,e.precision||12)}},malay:{from:function(e){if((e=parseFloat(e))<=-1||e>1)throw new Error("Outside valid range.");return e<0&&(e=-1/e),e+1},to:function(){return this.decimalValue<=2?a(this.decimalValue-1):a(-1/(this.decimalValue-1))}},indonesian:{from:function(e){if(0===(e=parseFloat(e)))throw new Error("Outside valid range.");return e>=1?e+1:-1/e+1},to:function(){return this.decimalValue<2?a(-1/(this.decimalValue-1)):a(this.decimalValue-1)}}},s=((i=function(e){if("number"!=typeof e||isNaN(e))throw new Error("Invalid odds");this.decimalValue=a(e)}).prototype=(o=function(){throw new Error("This constructor is private, please use the from* functions")}).prototype,o.from=function(e,r){if(!n.hasOwnProperty(e))throw new Error("Unknown format "+e+".");var a=n[e].from(r);return new i(a)},o);s.prototype.to=function(e,r){if(!n.hasOwnProperty(e))throw new Error("Unknown format "+e+".");r=Object.assign({precision:null,percentage:!1},r);var a=n[e].to.call(this,r);return"number"==typeof a&&null!==r.precision&&(a=t("round",a,-r.precision)),a};var l,d=s.from,u=function(e,r,a){var t=e.find((function(e){return Number(e.sportId)===Number(r)}));if(t){if(""==t.primaryBookmaker)return a;var o=[];return t.primaryBookmaker&&o.push(t.primaryBookmaker),t.secondaryBookmaker&&o.push(t.secondaryBookmaker),t.tertiaryBookmaker&&o.push(t.tertiaryBookmaker),o}return a},c=function(e,r,a,t,o){var i=r.some((function(r){var t=e.get(r);return!!t&&(0===t.homeOdds||0===t.awayOdds||!a&&0===t.drawOdds||1===t.homeOdds||1===t.awayOdds||!a&&1===t.drawOdds)}));if(1==r.length){if(i)return[{homeOdds:0,awayOdds:0,drawOdds:0}];var n=r[0],s=e.get(n);return[{homeOdds:s.homeOdds,awayOdds:s.awayOdds,drawOdds:a?0:s.drawOdds}]}if(i)return[{homeOdds:0,awayOdds:0,drawOdds:0}];var l=e.get(r[0]),u=l.homeOdds,c=l.awayOdds,m=l.drawOdds;if(r.slice(1).some((function(r){var i=e[r];if(i){var n=i.homeOdds,s=i.awayOdds,l=i.drawOdds,w=d("decimal",u).to("impliedProbability"),f=d("decimal",c).to("impliedProbability"),v=a?0:d("decimal",m).to("impliedProbability"),b=d("decimal",n).to("impliedProbability"),g=d("decimal",s).to("impliedProbability"),h=a?0:d("decimal",l).to("impliedProbability"),y=p(w,b),O=p(f,g),A=a?0:p(v,h);if(y>t&&w>o&&b>o||O>t&&f>o&&g>o||!a&&A>t&&v>o&&h>o)return!0}return!1})))return console.log("Returning zero odds due to percentage difference"),[{homeOdds:0,awayOdds:0,drawOdds:0}];var w=[];return r.forEach((function(r){return w.push(e.get(r))})),null!=w[0]?w.map((function(e){return{homeOdds:e.homeOdds,awayOdds:e.awayOdds,drawOdds:a?0:e.drawOdds}})):(console.log("Returning zero odds cause no matching bookmakers have been found"),[{homeOdds:0,awayOdds:0,drawOdds:0}])},p=function(e,r){var a=Math.abs(e-r)/e*100;return console.log("% diff: "+a),a},m="Soccer",w="Football",f="Basketball",v="Baseball",b="Hockey",g="Fighting",h="Tennis",y="eSports",O="Rugby",A="Volleyball",D="Handball",C="Cricket",L="Motosport",_="Golf",k=153,S=156,T=158,N=9977,I=9983,M=10138,P=100021,B=100121,F=[N,I,M,k,S,T,15312,15313,15314,15315,15316,15317,15318,15622,15623,15624,15625,15626,15627,15628,15632,15633,15634,15635,15636,15637,15638,15641,15642,15643,15644,15645,15646,15647,15648],j="Asian Handicap",E="Total Goals",V="Point Spread",G="Total Points",x=((l={})[1]={sport:w,id:1,isDrawAvailable:!1},l[2]={sport:w,id:2,isDrawAvailable:!1,spread:j,total:G},l[3]={sport:v,id:3,isDrawAvailable:!1,spread:"Run Line",total:"Total Runs"},l[4]={sport:f,id:4,isDrawAvailable:!1,spread:V,total:G},l[5]={sport:f,id:5,isDrawAvailable:!1,spread:V,total:G},l[6]={sport:b,id:6,isDrawAvailable:!1},l[7]={sport:g,id:7,isDrawAvailable:!1},l[8]={sport:f,id:8,isDrawAvailable:!1,spread:V,total:G},l[10]={sport:m,id:10,isDrawAvailable:!0,spread:j,total:E},l[11]={sport:m,id:11,isDrawAvailable:!0,spread:j,total:E},l[12]={sport:m,id:12,isDrawAvailable:!0,spread:j,total:E},l[13]={sport:m,id:13,isDrawAvailable:!0,spread:j,total:E},l[14]={sport:m,id:14,isDrawAvailable:!0,spread:j,total:E},l[15]={sport:m,id:15,isDrawAvailable:!0,spread:j,total:E},l[16]={sport:m,id:16,isDrawAvailable:!0,spread:j,total:E},l[17]={sport:m,id:17,isDrawAvailable:!0,spread:j,total:E},l[18]={sport:m,id:18,isDrawAvailable:!0,spread:j,total:E},l[19]={sport:m,id:19,isDrawAvailable:!0,spread:j,total:E},l[20]={sport:C,id:20,isDrawAvailable:!1},l[21]={sport:C,id:21,isDrawAvailable:!1},l[33]={sport:b,id:33,isDrawAvailable:!0},l[44]={sport:m,id:44,isDrawAvailable:!0,spread:j,total:E},l[45]={sport:m,id:45,isDrawAvailable:!0,spread:j,total:E},l[50]={sport:m,id:50,isDrawAvailable:!0,spread:j,total:E},l[57]={sport:m,id:57,isDrawAvailable:!0,spread:j,total:E},l[61]={sport:m,id:61,isDrawAvailable:!0,spread:j,total:E},l[65]={sport:m,id:65,isDrawAvailable:!0,spread:j,total:E},l[66]={sport:m,id:66,isDrawAvailable:!0,spread:j,total:E},l[76]={sport:m,id:76,isDrawAvailable:!0,spread:j,total:E},l[132]={sport:m,id:132,isDrawAvailable:!0,spread:j,total:E},l[134]={sport:m,id:134,isDrawAvailable:!0,spread:j,total:E},l[138]={sport:m,id:138,isDrawAvailable:!0,spread:j,total:E},l[141]={sport:m,id:141,isDrawAvailable:!0,spread:j,total:E},l[153]={sport:h,id:k,isDrawAvailable:!1},l[156]={sport:h,id:S,isDrawAvailable:!1},l[158]={sport:h,id:T,isDrawAvailable:!1},l[209]={sport:m,id:209,isDrawAvailable:!0,spread:j,total:E},l[268]={sport:m,id:268,isDrawAvailable:!0,spread:j,total:E},l[288]={sport:m,id:288,isDrawAvailable:!0,spread:j,total:E},l[296]={sport:m,id:296,isDrawAvailable:!0,spread:j,total:E},l[380]={sport:D,id:380,isDrawAvailable:!0},l[381]={sport:D,id:381,isDrawAvailable:!0},l[399]={sport:f,id:399,isDrawAvailable:!1,spread:V,total:G},l[406]={sport:f,id:406,isDrawAvailable:!1,spread:V,total:G},l[407]={sport:f,id:407,isDrawAvailable:!1,spread:V,total:G},l[409]={sport:f,id:409,isDrawAvailable:!1,spread:V,total:G},l[445]={sport:L,id:445,isDrawAvailable:!1},l[453]={sport:A,id:453,isDrawAvailable:!1},l[454]={sport:A,id:454,isDrawAvailable:!1},l[8910]={sport:"TableTennis",id:8910,isDrawAvailable:!1},l[497]={sport:L,id:497,isDrawAvailable:!1},l[536]={sport:m,id:536,isDrawAvailable:!0,spread:j,total:E},l[8881]={sport:"Waterpolo",id:8881,isDrawAvailable:!0},l[8893]={sport:A,id:8893,isDrawAvailable:!1},l[8894]={sport:A,id:8894,isDrawAvailable:!1},l[9196]={sport:g,id:9196,isDrawAvailable:!1},l[9578]={sport:O,id:9578,isDrawAvailable:!0},l[9588]={sport:O,id:9588,isDrawAvailable:!0},l[9698]={sport:b,id:9698,isDrawAvailable:!0},l[9699]={sport:b,id:9699,isDrawAvailable:!0},l[9806]={sport:m,id:9806,isDrawAvailable:!0,spread:j,total:E},l[9821]={sport:m,id:9821,isDrawAvailable:!0,spread:j,total:E},l[9977]={sport:y,id:N,isDrawAvailable:!1},l[9983]={sport:y,id:I,isDrawAvailable:!1},l[10071]={sport:f,id:10071,isDrawAvailable:!1},l[10072]={sport:f,id:10072,isDrawAvailable:!1},l[10502]={sport:f,id:10502,isDrawAvailable:!1,spread:V,total:G},l[10138]={sport:y,id:M,isDrawAvailable:!1},l[10199]={sport:m,id:10199,isDrawAvailable:!0,spread:j,total:E},l[10216]={sport:m,id:10216,isDrawAvailable:!0,spread:j,total:E},l[10595]={sport:g,id:10595,isDrawAvailable:!1},l[10611]={sport:m,id:10611,isDrawAvailable:!0,spread:j,total:E},l[10613]={sport:m,id:10613,isDrawAvailable:!0,spread:j,total:E},l[10615]={sport:m,id:10615,isDrawAvailable:!0,spread:j,total:E},l[100021]={sport:_,id:P,isDrawAvailable:!1},l[100121]={sport:_,id:B,isDrawAvailable:!1},l[230]={sport:m,id:230,isDrawAvailable:!0,spread:j,total:E},l),W=function(e){var r=x[e];return r?r.sport:""},R=function(e){var r=x[e];return r?r.spread:void 0},U=function(e){var r=x[e];return r?r.total:void 0},H=function(e,r,a){var t,o=e.score_home_total,i=e.score_away_total,n=e.clock,s=e.period,l=e.status,d=e.home_team,u=e.away_team,c=parseInt(s),p=W(r);return"completed"==l.toLowerCase()?{allow:!1,message:"Blocking game ".concat(d," - ").concat(u," because it is no longer live.")}:(p===f&&(t=z(d,u,c,a.get(f))),p===b&&(t=z(d,u,c,a.get(b))),p===v&&(t=z(d,u,c,a.get(v))),p===m&&(t=J(d,u,n,s,a.get(m))),p===h&&(t=K(e,d,u,s,o,i,r,p)),p===A&&(t=K(e,d,u,c,o,i,r,p)),t)},z=function(e,r,a,t){return!Number.isNaN(a)&&a>=t?{allow:!1,message:"Blocking game ".concat(e," - ").concat(r," due to period: ").concat(a,". period")}:{allow:!0,message:""}},J=function(e,r,a,t,o){var i=Number(a);return!Number.isNaN(i)&&i>=o||Number.isNaN(i)&&"HALF"!=t?{allow:!1,message:"Blocking game ".concat(e," - ").concat(r," due to clock: ").concat(a,"min")}:{allow:!0,message:""}},K=function(e,r,a,t,o,i,n,s){var l=Number(t),d=q(l,e),u="atp"==e.league.toLowerCase(),c={home:o,away:i};return s==A?Q(r,a,d,c,2,5==l?10:20):n.toString().startsWith(k)&&u?Q(r,a,d,c,2,5):n.toString().startsWith(k)&&!u||n.toString().startsWith(S)||n.toString().startsWith(T)?Q(r,a,d,c,1,5):{allow:!0,message:"The sport ".concat(n," does not have result constraint")}},q=function(e,r){var a=0,t=0;switch(e){case 2:a=Number(r.score_home_period_2),t=Number(r.score_away_period_2);break;case 3:a=Number(r.score_home_period_3),t=Number(r.score_away_period_3);break;case 4:a=Number(r.score_home_period_4),t=Number(r.score_away_period_4);break;case 5:a=Number(r.score_home_period_5),t=Number(r.score_away_period_5)}return{home:a,away:t}},Q=function(e,r,a,t,o,i){return Number(t.home)!=o&&Number(t.away)!=o||!(Number(t.home)==o&&a.home>=i||Number(t.away)==o&&a.away>=i)?{allow:!0,message:"",currentHomeGameScore:a.home,currentAwayGameScore:a.away}:{allow:!1,message:"Blocking game ".concat(e," - ").concat(r," due to current result: ").concat(t.home," - ").concat(t.away," (").concat(a.home," - ").concat(a.away,")")}},X=function(e,r,a,t,o,i){var n,s;if(F.includes(e)?(n=t.toLowerCase()==r.toLowerCase()||t.toLowerCase()==a.toLowerCase(),s=o.toLowerCase()==r.toLowerCase()||o.toLowerCase()==a.toLowerCase()):(n=t.toLowerCase()==r.toLowerCase(),s=o.toLowerCase()==a.toLowerCase()),!0!==n){var l=i.get(t.toLowerCase()),d=i.get(r.toLowerCase()),u=i.get(a.toLowerCase());if([l,d].some((function(e){return null==e})))return!1;n=F.includes(e)?l==d||l==u:l==d}if(!0!==s){var c=i.get(o.toLowerCase());if(d=i.get(r.toLowerCase()),[c,u=i.get(a.toLowerCase())].some((function(e){return null==e})))return!1;s=F.includes(e)&&c==d||c==u}return n&&s},Y=function(e,r,a,t){var o;if(W(a)==h){var i=r.getTime(),n=e.getTime();o=Math.abs(n-i)<=Number(60*t*1e3)}else o=r.toUTCString()==e.toUTCString();return o},Z="Draw",$=function(e,r,a){if(e.some((function(e){return 0===e})))return e;var t=e.reduce((function(e,r){return e+r}),0);if(t<=1)return Array(e.length).fill(0);if(0===a){if(!(r>100*(t-1)))return e;a=r}var o=1+a/100,i=o/t,n=e.map((function(e){return e*i}));if(n.some((function(e){return e>=1})))return Array(e.length).fill(0);var s=n.reduce((function(e,r){return e+r}),0);if(s<1)return Array(e.length).fill(0);var l=o/s;return n.map((function(e){return e*l}))},ee=function(e,r,a,t){var o=e.find((function(e){return Number(e.typeId)===Number(a)&&Number(e.sportId)===Number(r)}));return o?{minSpread:o.minSpread?Number(o.minSpread):t,targetSpread:o.targetSpread?Number(o.targetSpread):0}:{minSpread:t,targetSpread:0}},re=function(e,r,a,t,o){var i=new Map;return e.forEach((function(e){var n,s,l=r.odds.filter((function(r){return r.sports_book_name.toLowerCase()==e.toLowerCase()})),d=t.get(a.homeTeam.toLowerCase()),u=t.get(a.awayTeam.toLowerCase()),c=0;null!=(n=null==d?l.find((function(e){var r=t.get(e.name.toLowerCase());return null==r?e.name.toLowerCase()==a.homeTeam.toLowerCase():r==a.homeTeam.toLowerCase()})):l.find((function(e){var r=t.get(e.name.toLowerCase());return null==r?e.name.toLowerCase()==d:r==d})))&&(c=n.price);var p=0;null!=(s=null==u?l.find((function(e){var r=t.get(e.name.toLowerCase());return null==r?e.name.toLowerCase()==a.awayTeam.toLowerCase():r==a.awayTeam.toLowerCase()})):l.find((function(e){var r=t.get(e.name.toLowerCase());return null==r?e.name.toLowerCase()==u:r==u})))&&(p=s.price);var m=0;if(o){var w=l.find((function(e){return"draw"==e.name.toLowerCase()}));null!=w&&(m=w.price)}i.set(e.toLowerCase(),{homeOdds:c,awayOdds:p,drawOdds:m})})),i},ae=function(e){return 0===e?0:te("decimal","impliedProbability",e)},te=function(e,r,a){try{return d(e,a).to(r)}catch(e){return 0}},oe=function(e,r,a,t,o){var i=new Map;return console.log("Filtering odds by market name: "+r),a.forEach((function(a){var n=0,s=e.filter((function(e){return e.market_name.toLowerCase()===r.toLowerCase()&&e.sports_book_name.toLowerCase()==a.toLowerCase()&&e.selection.toLowerCase()==t.homeTeam.toLowerCase()}));null!=s&&(n=s.price);var l=0,d=e.filter((function(e){return e.market_name.toLowerCase()===r.toLowerCase()&&e.sports_book_name.toLowerCase()==a.toLowerCase()&&e.selection.toLowerCase()==t.awayTeam.toLowerCase()}));null!=d&&(l=d.price);var u=0;if(o){var c=e.filter((function(e){return e.market_name.toLowerCase()===r.toLowerCase()&&e.sports_book_name.toLowerCase()==a.toLowerCase()&&e.selection.toLowerCase()==Z.toLowerCase()}));null!=c&&(u=c.price)}i.set(a.toLowerCase(),{homeOdds:n,awayOdds:l,drawOdds:u})})),i},ie=function(e,r,a,t,o,i,n){console.log("Calculating parent odds");var s={homeTeam:t.home_team,awayTeam:t.away_team},l=oe(t.odds,"Moneyline",a,s,e),d=c(l,a,e,n,.2),u=d.some((function(e){return 1==e.homeOdds||1==e.awayOdds||1==e.drawOdds}));if([d[0].homeOdds,d[0].awayOdds,d[0].drawOdds].every((function(e){return 0==e}))||u)return console.log("No Moneyline odds found or there is 100% odd, returning zero odds."),e?[0,0]:[0,0,0];var p=function(e,r,a){var t,o,i,n,s;return a?[ae((null===(t=e.find((function(e){return e.selection===r.homeTeam})))||void 0===t?void 0:t.price)||0),ae((null===(o=e.find((function(e){return e.selection===r.awayTeam})))||void 0===o?void 0:o.price)||0)]:[ae((null===(i=e.find((function(e){return e.selection===r.homeTeam})))||void 0===i?void 0:i.price)||0),ae((null===(n=e.find((function(e){return e.selection===r.awayTeam})))||void 0===n?void 0:n.price)||0),ae((null===(s=e.find((function(e){return e.selection===Z})))||void 0===s?void 0:s.price)||0)]}([d[0].homeOdds,d[0].awayOdds,d[0].drawOdds],s,e),m=ee(r,o,1e5,i);return p=null!==m?$(p,m.minSpread,m.targetSpread):$(p,i,0),console.log("Parent odds calculated and adjusted for spread: "+JSON.stringify(p)),p},ne=function(e,r,a){return e.filter((function(e){return e.market_name.toLowerCase()===r.toLowerCase()&&e.sports_book_name.toLowerCase()==a.toLowerCase()}))},se=function(e,r,a,t,o,i){var n=e.filter((function(e){return.5===Math.abs(e.selection_points%1)}));return le(n,r).map((function(e){var r=e.line,n=e.odds,s=ae(n[0])||0,l=ae(n[1])||0,d=0===s||0===l;if(!d){var u,c=ee(t,a.leagueId,o,i);null!==c?(u=$([s,l],c.minSpread,c.targetSpread)).some((function(e){return 0===e}))?d=!0:(s=u[0],l=u[1]):(u=$([s,l],i,0)).some((function(e){return 0===e}))?d=!0:(s=u[0],l=u[1])}return{gameId:a.gameId,sportId:a.sportId,typeId:o,maturity:a.maturity,homeTeam:a.homeTeam,awayTeam:a.awayTeam,results:[],status:d?1:0,line:100*r,odds:[s,l]}})).filter((function(e){return null!==e}))},le=function(e,r){var a=e.reduce((function(e,a){var t=a.selection_points,o=a.price,i=a.selection===r.homeTeam,n=i?t:-t;return e[n]||(e[n]={home:null,away:null}),i?e[n].home=o:e[n].away=o,e}),{}),t=Object.entries(a).reduce((function(e,r){var a=r[0],t=r[1],o=parseFloat(a);return null!==t.home&&null!==t.away&&e.push({line:o,odds:[t.home,t.away]}),e}),[]);return t},de=function(e,r){return void 0===r&&(r=.952),e.map((function(e){return Math.abs(e)>r?0:e}))},ue=function(e,r,a,t,o,i){var n=[],s=e.filter((function(e){return.5===Math.abs(e.selection_points%1)})),l=ce(s);return Object.entries(l).forEach((function(e){var r=e[0],s=e[1],l=s.over,d=s.under,u=r.split("_"),c=(u[0],u[1]),p=ae(l)||0,m=ae(d)||0,w=0===p||0===m;if(!w){var f,v=ee(t,a.leagueId,o,i);null!==v?(f=$([p,m],v.minSpread,v.targetSpread)).some((function(e){return 0===e}))?w=!0:(p=f[0],m=f[1]):(f=$([p,m],i,0)).some((function(e){return 0===e}))?w=!0:(p=f[0],m=f[1])}var b={gameId:a.gameId,sportId:a.sportId,typeId:o,maturity:a.maturity,homeTeam:a.homeTeam,awayTeam:a.awayTeam,results:[],status:w?1:0,line:100*parseFloat(c),odds:[p,m]};n.push(b)})),n},ce=function(e){return e.reduce((function(e,r){var a="".concat(r.selection,"_").concat(r.selection_points);return e[a]||(e[a]={over:null,under:null}),"over"===r.selection_line?e[a].over=r.price:"under"===r.selection_line&&(e[a].under=r.price),e}),{})},pe=function(e,r,a,t,o,i,n){var s=t.filter((function(r){return r.sportId===String(e.leagueId)})),l=ie(!o,s,a,r,e.leagueId,i,n),u=0==l[0]||0==l[1]||o&&0==l[2];e.odds=e.odds.map((function(e,r){var a;switch(r){case 0:a=l[0];break;case 1:a=l[1];break;case 2:a=l[2]}return{american:d("impliedProbability",a).to("moneyline"),decimal:d("impliedProbability",a).to("decimal"),normalizedImplied:a}}));var c=u?[]:me(e,s,r,a,i);return console.log("Mapped event for game ID: "+e.gameId),e.childMarkets=c,e},me=function(e,r,a,t,o){var i=[];return i.concat(we(a,e,r,t,o))},we=function(e,r,a,t,o){var i=[],n=R(r.leagueId),s={homeTeam:e.home_team,awayTeam:e.away_team};if(n){var l=ne(e.odds,n,t[0]);if(l.length>0){var d=se(l,s,r,a,10001,o);i.push.apply(i,d)}}else console.warn("Spread type for sport ID ".concat(r.leagueId," not found."));return i},fe=function(e,r,a,t,o){var i=[],n=U(r.leagueId),s={homeTeam:e.home_team,awayTeam:e.away_team};if(n){var l=ne(e.odds,n,t[0]);l.length>0&&i.push.apply(i,ue(l,s,r,a,10002,o))}else console.warn("Configuration (totals) for sport ID ".concat(r.leagueId," not found."));return i};return r})()));
|
package/package.json
CHANGED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
export const FIRST_HALF_ASIAN_HANDICAP = '1st Half Asian Handicap';
|
|
2
|
+
export const FIRST_HALF_ASIAN_HANDICAP_CORNERS = '1st Half Asian Handicap Corners';
|
|
3
|
+
export const FIRST_HALF_BOTH_TEAMS_TO_SCORE = '1st Half Both Teams To Score';
|
|
4
|
+
export const FIRST_HALF_CORRECT_SCORE = '1st Half Correct Score';
|
|
5
|
+
export const FIRST_HALF_MONEYLINE = '1st Half Moneyline';
|
|
6
|
+
export const FIRST_HALF_TEAM_TOTAL = '1st Half Team Total';
|
|
7
|
+
export const FIRST_HALF_TEAM_TOTAL_EXACT = '1st Half Team Total Exact';
|
|
8
|
+
export const FIRST_HALF_TOTAL_CORNERS = '1st Half Total Corners';
|
|
9
|
+
export const FIRST_HALF_TOTAL_GOALS = '1st Half Total Goals';
|
|
10
|
+
export const FIRST_HALF_TOTAL_GOALS_ODD_EVEN = '1st Half Total Goals Odd/Even';
|
|
11
|
+
export const SECOND_HALF_ASIAN_HANDICAP_CORNERS = '2nd Half Asian Handicap Corners';
|
|
12
|
+
export const SECOND_HALF_BOTH_TEAMS_TO_SCORE = '2nd Half Both Teams To Score';
|
|
13
|
+
export const SECOND_HALF_MONEYLINE = '2nd Half Moneyline';
|
|
14
|
+
export const SECOND_HALF_TOTAL_CORNERS = '2nd Half Total Corners';
|
|
15
|
+
export const SECOND_HALF_TOTAL_GOALS = '2nd Half Total Goals';
|
|
16
|
+
export const SECOND_HALF_TOTAL_GOALS_ODD_EVEN = '2nd Half Total Goals Odd/Even';
|
|
17
|
+
export const ANYTIME_GOAL_SCORER = 'Anytime Goal Scorer';
|
|
18
|
+
export const ASIAN_HANDICAP = 'Asian Handicap';
|
|
19
|
+
export const ASIAN_HANDICAP_CARDS = 'Asian Handicap Cards';
|
|
20
|
+
export const ASIAN_HANDICAP_CORNERS = 'Asian Handicap Corners';
|
|
21
|
+
export const BOTH_TEAMS_TO_SCORE = 'Both Teams To Score';
|
|
22
|
+
export const CORRECT_SCORE = 'Correct Score';
|
|
23
|
+
export const DRAW_NO_BET = 'Draw No Bet';
|
|
24
|
+
export const FIRST_GOAL_SCORER = 'First Goal Scorer';
|
|
25
|
+
export const FIRST_TEAM_TO_SCORE_3_WAY = 'First Team To Score 3-Way';
|
|
26
|
+
export const LAST_GOAL_SCORER = 'Last Goal Scorer';
|
|
27
|
+
export const LAST_TEAM_TO_SCORE_3_WAY = 'Last Team To Score 3-Way';
|
|
28
|
+
export const MONEYLINE = 'Moneyline';
|
|
29
|
+
export const PLAYER_GOALS = 'Player Goals';
|
|
30
|
+
export const TEAM_CLEAN_SHEET = 'Team Clean Sheet';
|
|
31
|
+
export const TEAM_TOTAL = 'Team Total';
|
|
32
|
+
export const TEAM_TOTAL_CARD_POINTS = 'Team Total Card Points';
|
|
33
|
+
export const TEAM_TOTAL_CORNERS = 'Team Total Corners';
|
|
34
|
+
export const TEAM_TOTAL_ODD_EVEN = 'Team Total Odd/Even';
|
|
35
|
+
export const TOTAL_CARDS = 'Total Cards';
|
|
36
|
+
export const TOTAL_CORNERS = 'Total Corners';
|
|
37
|
+
export const TOTAL_CORNERS_ODD_EVEN = 'Total Corners Odd/Even';
|
|
38
|
+
export const TOTAL_GOALS = 'Total Goals';
|
|
39
|
+
export const TOTAL_GOALS_ODD_EVEN = 'Total Goals Odd/Even';
|
|
40
|
+
export const TO_QUALIFY = 'To Qualify';
|
|
41
|
+
export const HALFTIME_FULLTIME = 'Halftime / Fulltime';
|
|
42
|
+
|
|
43
|
+
export const FIRST_3_INNINGS_MONEYLINE = '1st 3 Innings Moneyline';
|
|
44
|
+
export const FIRST_3_INNINGS_RUN_LINE = '1st 3 Innings Run Line';
|
|
45
|
+
export const FIRST_3_INNINGS_TEAM_TOTAL = '1st 3 Innings Team Total';
|
|
46
|
+
export const FIRST_3_INNINGS_TOTAL_RUNS = '1st 3 Innings Total Runs';
|
|
47
|
+
export const FIRST_7_INNINGS_MONEYLINE = '1st 7 Innings Moneyline';
|
|
48
|
+
export const FIRST_7_INNINGS_RUN_LINE = '1st 7 Innings Run Line';
|
|
49
|
+
export const FIRST_7_INNINGS_TEAM_TOTAL = '1st 7 Innings Team Total';
|
|
50
|
+
export const FIRST_7_INNINGS_TOTAL_RUNS = '1st 7 Innings Total Runs';
|
|
51
|
+
export const FIRST_HALF_RUN_LINE = '1st Half Run Line';
|
|
52
|
+
export const FIRST_HALF_TOTAL_RUNS = '1st Half Total Runs';
|
|
53
|
+
export const FIRST_INNING_MONEYLINE_3_WAY = '1st Inning Moneyline 3-Way';
|
|
54
|
+
export const FIRST_INNING_RUN_LINE = '1st Inning Run Line';
|
|
55
|
+
export const FIRST_INNING_TOTAL_RUNS = '1st Inning Total Runs';
|
|
56
|
+
export const FIRST_INNING_TOTAL_RUNS_ODD_EVEN = '1st Inning Total Runs Odd/Even';
|
|
57
|
+
export const SECOND_INNING_MONEYLINE_3_WAY = '2nd Inning Moneyline 3-Way';
|
|
58
|
+
export const SECOND_INNING_RUN_LINE = '2nd Inning Run Line';
|
|
59
|
+
export const SECOND_INNING_TOTAL_RUNS = '2nd Inning Total Runs';
|
|
60
|
+
export const THIRD_INNING_MONEYLINE_3_WAY = '3rd Inning Moneyline 3-Way';
|
|
61
|
+
export const THIRD_INNING_RUN_LINE = '3rd Inning Run Line';
|
|
62
|
+
export const THIRD_INNING_TOTAL_RUNS = '3rd Inning Total Runs';
|
|
63
|
+
export const FOURTH_INNING_MONEYLINE_3_WAY = '4th Inning Moneyline 3-Way';
|
|
64
|
+
export const FOURTH_INNING_RUN_LINE = '4th Inning Run Line';
|
|
65
|
+
export const FOURTH_INNING_TOTAL_RUNS = '4th Inning Total Runs';
|
|
66
|
+
export const FIFTH_INNING_MONEYLINE_3_WAY = '5th Inning Moneyline 3-Way';
|
|
67
|
+
export const FIFTH_INNING_RUN_LINE = '5th Inning Run Line';
|
|
68
|
+
export const FIFTH_INNING_TOTAL_RUNS = '5th Inning Total Runs';
|
|
69
|
+
export const SIXTH_INNING_MONEYLINE_3_WAY = '6th Inning Moneyline 3-Way';
|
|
70
|
+
export const SIXTH_INNING_RUN_LINE = '6th Inning Run Line';
|
|
71
|
+
export const SIXTH_INNING_TOTAL_RUNS = '6th Inning Total Runs';
|
|
72
|
+
export const SEVENTH_INNING_MONEYLINE_3_WAY = '7th Inning Moneyline 3-Way';
|
|
73
|
+
export const SEVENTH_INNING_RUN_LINE = '7th Inning Run Line';
|
|
74
|
+
export const SEVENTH_INNING_TOTAL_RUNS = '7th Inning Total Runs';
|
|
75
|
+
export const EIGHTH_INNING_MONEYLINE_3_WAY = '8th Inning Moneyline 3-Way';
|
|
76
|
+
export const EIGHTH_INNING_RUN_LINE = '8th Inning Run Line';
|
|
77
|
+
export const EIGHTH_INNING_TOTAL_RUNS = '8th Inning Total Runs';
|
|
78
|
+
export const NINTH_INNING_MONEYLINE_3_WAY = '9th Inning Moneyline 3-Way';
|
|
79
|
+
export const NINTH_INNING_RUN_LINE = '9th Inning Run Line';
|
|
80
|
+
export const NINTH_INNING_TOTAL_RUNS = '9th Inning Total Runs';
|
|
81
|
+
export const FIRST_TEAM_TO_SCORE = 'First Team To Score';
|
|
82
|
+
export const NO_RUNS_FIRST_INNING = 'No Runs First Inning';
|
|
83
|
+
export const PLAYER_BASES = 'Player Bases';
|
|
84
|
+
export const PLAYER_BATTING_STRIKEOUTS = 'Player Batting Strikeouts';
|
|
85
|
+
export const PLAYER_BATTING_WALKS = 'Player Batting Walks';
|
|
86
|
+
export const PLAYER_DOUBLES = 'Player Doubles';
|
|
87
|
+
export const PLAYER_EARNED_RUNS = 'Player Earned Runs';
|
|
88
|
+
export const PLAYER_HITS = 'Player Hits';
|
|
89
|
+
export const PLAYER_HITS_RUNS_RBIS = 'Player Hits + Runs + RBIs';
|
|
90
|
+
export const PLAYER_HITS_ALLOWED = 'Player Hits Allowed';
|
|
91
|
+
export const PLAYER_HOME_RUNS = 'Player Home Runs';
|
|
92
|
+
export const PLAYER_HOME_RUNS_YES_NO = 'Player Home Runs Yes/No';
|
|
93
|
+
export const PLAYER_OUTS = 'Player Outs';
|
|
94
|
+
export const PLAYER_RBIS = 'Player RBIs';
|
|
95
|
+
export const PLAYER_RUNS = 'Player Runs';
|
|
96
|
+
export const PLAYER_SINGLES = 'Player Singles';
|
|
97
|
+
export const PLAYER_STOLEN_BASES = 'Player Stolen Bases';
|
|
98
|
+
export const PLAYER_STRIKEOUTS = 'Player Strikeouts';
|
|
99
|
+
export const PLAYER_TO_RECORD_WIN = 'Player To Record Win';
|
|
100
|
+
export const PLAYER_WALKS = 'Player Walks';
|
|
101
|
+
export const RUN_LINE = 'Run Line';
|
|
102
|
+
export const TOTAL_RUNS = 'Total Runs';
|
|
103
|
+
export const WILL_THERE_BE_OVERTIME = 'Will There Be Overtime';
|
|
104
|
+
|
|
105
|
+
export const FIRST_HALF_DOUBLE_CHANCE = '1st Half Double Chance';
|
|
106
|
+
export const FIRST_HALF_MONEYLINE_3_WAY = '1st Half Moneyline 3-Way';
|
|
107
|
+
export const FIRST_HALF_POINT_SPREAD = '1st Half Point Spread';
|
|
108
|
+
export const FIRST_HALF_RACE_TO_20_POINTS = '1st Half Race To 20 Points';
|
|
109
|
+
export const FIRST_HALF_RACE_TO_25_POINTS = '1st Half Race To 25 Points';
|
|
110
|
+
export const FIRST_HALF_RACE_TO_30_POINTS = '1st Half Race To 30 Points';
|
|
111
|
+
export const FIRST_HALF_RACE_TO_35_POINTS = '1st Half Race To 35 Points';
|
|
112
|
+
export const FIRST_HALF_RACE_TO_40_POINTS = '1st Half Race To 40 Points';
|
|
113
|
+
export const FIRST_HALF_RACE_TO_45_POINTS = '1st Half Race To 45 Points';
|
|
114
|
+
export const FIRST_HALF_RACE_TO_50_POINTS = '1st Half Race To 50 Points';
|
|
115
|
+
export const FIRST_HALF_RACE_TO_55_POINTS = '1st Half Race To 55 Points';
|
|
116
|
+
export const FIRST_HALF_RACE_TO_60_POINTS = '1st Half Race To 60 Points';
|
|
117
|
+
export const FIRST_HALF_TOTAL_POINTS = '1st Half Total Points';
|
|
118
|
+
export const FIRST_HALF_TOTAL_POINTS_ODD_EVEN = '1st Half Total Points Odd/Even';
|
|
119
|
+
export const FIRST_QUARTER_DOUBLE_CHANCE = '1st Quarter Double Chance';
|
|
120
|
+
export const FIRST_QUARTER_MONEYLINE = '1st Quarter Moneyline';
|
|
121
|
+
export const FIRST_QUARTER_MONEYLINE_3_WAY = '1st Quarter Moneyline 3-Way';
|
|
122
|
+
export const FIRST_QUARTER_POINT_SPREAD = '1st Quarter Point Spread';
|
|
123
|
+
export const FIRST_QUARTER_RACE_TO_10_POINTS = '1st Quarter Race To 10 Points';
|
|
124
|
+
export const FIRST_QUARTER_RACE_TO_15_POINTS = '1st Quarter Race To 15 Points';
|
|
125
|
+
export const FIRST_QUARTER_RACE_TO_20_POINTS = '1st Quarter Race To 20 Points';
|
|
126
|
+
export const FIRST_QUARTER_TEAM_TOTAL = '1st Quarter Team Total';
|
|
127
|
+
export const FIRST_QUARTER_TOTAL_POINTS = '1st Quarter Total Points';
|
|
128
|
+
export const FIRST_QUARTER_TOTAL_POINTS_ODD_EVEN = '1st Quarter Total Points Odd/Even';
|
|
129
|
+
export const FIRST_BASKET_INCLUDING_FT = 'First Basket Including FT';
|
|
130
|
+
export const PLAYER_ASSISTS = 'Player Assists';
|
|
131
|
+
export const PLAYER_DOUBLE_DOUBLE = 'Player Double Double';
|
|
132
|
+
export const PLAYER_MADE_THREES = 'Player Made Threes';
|
|
133
|
+
export const PLAYER_POINTS = 'Player Points';
|
|
134
|
+
export const PLAYER_POINTS_REBOUNDS_ASSISTS = 'Player Points + Rebounds + Assists';
|
|
135
|
+
export const PLAYER_REBOUNDS = 'Player Rebounds';
|
|
136
|
+
export const POINT_SPREAD = 'Point Spread';
|
|
137
|
+
export const RACE_TO_20_POINTS = 'Race To 20 Points';
|
|
138
|
+
export const TEAM_TOTAL_POINTS_ODD_EVEN = 'Team Total Points Odd/Even';
|
|
139
|
+
export const TOTAL_POINTS = 'Total Points';
|
|
140
|
+
export const TOTAL_POINTS_ODD_EVEN = 'Total Points Odd/Even';
|
|
141
|
+
|
|
142
|
+
export const GO_THE_DISTANCE = 'Go The Distance';
|
|
143
|
+
export const METHOD_OF_VICTORY = 'Method of Victory';
|
|
144
|
+
export const PLAYER_SIGNIFICANT_STRIKES = 'Player Significant Strikes';
|
|
145
|
+
export const PLAYER_TAKEDOWNS = 'Player Takedowns';
|
|
146
|
+
export const ROUND_BETTING = 'Round Betting';
|
|
147
|
+
export const TOTAL_ROUNDS = 'Total Rounds';
|
|
148
|
+
export const METHOD_OF_ENDING = 'Method Of Ending';
|
|
149
|
+
export const MONEYLINE_TOTAL_ROUNDS = 'Moneyline + Total Rounds';
|
|
150
|
+
export const WILL_A_POINT_BE_DEDUCTED = 'Will A Point Be Deducted';
|
|
151
|
+
export const WILL_FIGHT_END_IN_FIRST_MINUTE = 'Will Fight End In First Minute';
|
|
152
|
+
export const WINNING_ROUND = 'Winning Round';
|