How to use actRun method in stryker-parent

Best JavaScript code snippet using stryker-parent

app.js

Source:app.js Github

copy

Full Screen

1app = angular.module("Equisym", ["ngMaterial", "ngMessages", "ngSanitize", "ngCsv", "nvd3", "pascalprecht.translate", "ngStorage", "printThis", "appConfig", "MainCtrl"]), angular.module("appConfig", []).config(["$mdThemingProvider", "$mdIconProvider", "$mdThemingProvider", "$translateProvider", function (a, e, a, t) {2 iconp = e.defaultFontSet("fas"), angular.forEach({3 "md-plus": '<svg fill="#000000" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/><path d="M0 0h24v24H0z" fill="none"/></svg>',4 "md-close": '<svg fill="#000000" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>',5 "md-arrow-back": '<svg fill="#000000" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M0 0h24v24H0z" fill="none"/><path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"/></svg>',6 "md-apps": '<svg fill="#000000" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><g transform="translate(3, 3)"><circle cx="2" cy="2" r="2"></circle><circle cx="2" cy="9" r="2"></circle><circle cx="2" cy="16" r="2"></circle><circle cx="9" cy="2" r="2"></circle><circle cx="9" cy="9" r="2"></circle><circle cx="16" cy="2" r="2"></circle><circle cx="16" cy="9" r="2"></circle><circle cx="16" cy="16" r="2"></circle><circle cx="9" cy="16" r="2"></circle></g></svg>',7 "md-enter": '<svg fill="#000000" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M0 0h24v24H0z" fill="none"/><path d="M11 5v5.59H7.5l4.5 4.5 4.5-4.5H13V5h-2zm-5 9c0 3.31 2.69 6 6 6s6-2.69 6-6h-2c0 2.21-1.79 4-4 4s-4-1.79-4-4H6z"/></svg>',8 "md-save": '<svg fill="#000000" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M0 0h24v24H0z" fill="none"/><path d="M17 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V7l-4-4zm-5 16c-1.66 0-3-1.34-3-3s1.34-3 3-3 3 1.34 3 3-1.34 3-3 3zm3-10H5V5h10v4z"/></svg>',9 "md-delete": '<svg fill="#000000" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"/><path d="M0 0h24v24H0z" fill="none"/></svg>',10 "md-bars": '<svg fill="#000000" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M0 0h24v24H0z" fill="none"/><path d="M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z"/></svg>',11 "md-more-v": '<svg fill="#000000" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M0 0h24v24H0z" fill="none"/><path d="M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"/></svg>',12 "md-search": '<svg fill="#000000" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/><path d="M0 0h24v24H0z" fill="none"/></svg>',13 "md-chevron-down": '<svg fill="#000000" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"/><path d="M0 0h24v24H0z" fill="none"/></svg>',14 "md-check": '<svg fill="#000000" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M0 0h24v24H0z" fill="none"/><path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"/></svg>',15 "md-edit": '<svg fill="#000000" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"/><path d="M0 0h24v24H0z" fill="none"/></svg>',16 "md-settings": '<svg fill="#000000" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M0 0h24v24H0z" fill="none"/><path d="M19.43 12.98c.04-.32.07-.64.07-.98s-.03-.66-.07-.98l2.11-1.65c.19-.15.24-.42.12-.64l-2-3.46c-.12-.22-.39-.3-.61-.22l-2.49 1c-.52-.4-1.08-.73-1.69-.98l-.38-2.65C14.46 2.18 14.25 2 14 2h-4c-.25 0-.46.18-.49.42l-.38 2.65c-.61.25-1.17.59-1.69.98l-2.49-1c-.23-.09-.49 0-.61.22l-2 3.46c-.13.22-.07.49.12.64l2.11 1.65c-.04.32-.07.65-.07.98s.03.66.07.98l-2.11 1.65c-.19.15-.24.42-.12.64l2 3.46c.12.22.39.3.61.22l2.49-1c.52.4 1.08.73 1.69.98l.38 2.65c.03.24.24.42.49.42h4c.25 0 .46-.18.49-.42l.38-2.65c.61-.25 1.17-.59 1.69-.98l2.49 1c.23.09.49 0 .61-.22l2-3.46c.12-.22.07-.49-.12-.64l-2.11-1.65zM12 15.5c-1.93 0-3.5-1.57-3.5-3.5s1.57-3.5 3.5-3.5 3.5 1.57 3.5 3.5-1.57 3.5-3.5 3.5z"/></svg>'17 }, function (a, e) {18 iconp.icon(e, "data:image/svg+xml, " + a, 24)19 }), a.definePalette("tstarPallete", {20 50: "f5f5f5",21 100: "e8e8e8",22 200: "dcdcdc",23 300: "cfcfcf",24 400: "bababa",25 500: "b0b0b0",26 600: "9d9d9d",27 700: "898989",28 800: "767676",29 900: "626262",30 A100: "444444",31 A200: "313131",32 A400: "1d1d1d",33 A700: "0a0a0a",34 contrastDefaultColor: "light",35 contrastDarkColors: ["50", "100", "200", "300", "400", "500", "600", "700", "800", "A100", "A200", "A400", "A700"],36 contrastLightColors: ["900"]37 }), a.theme("default").primaryPalette("tstarPallete");38 var r = {39 en: {40 APP_NAME: "Equity Curve Simulator",41 PARAMETERS: "Parameters",42 STARTING_EQ: "Starting Equity",43 RISK_PER_TRADE: "Risk Per Trade",44 WIN_PROB: "Win Probability",45 WIN_LOSS_REL: "Win:Loss Ratio",46 TRADES_PER_RUN: "Trades Per Run",47 RUNS_LINES: "Scenarios (Lines)",48 GRAPH_SCALE: "Graph Scale",49 RUN_SIMULATION: "Run Simulation",50 GRAPH: "Graph",51 TRADE: "Trade",52 EQ: "Equity",53 MAX: "Maximum",54 MIN: "Minimum",55 AVG: "Average",56 RESULTS: "Results",57 AVG_PERFORMANCE: "Avg. Performance",58 MAX_DRAWDOWN: "Max. Drawdown",59 AVG_MAX_DRAWDOWN: "Avg. Max. Drawdown",60 RETURN_MAX_DRAWDOWN: "Return Over Max Drawdown",61 MAX_EQ: "Max. Equity",62 MIN_EQ: "Min. Equity",63 MAX_CONSEC_WINS: "Max. Consecutive Wins",64 MAX_CONSEC_LOSES: "Max. Consecutive Losses",65 EXPECTATION: "Expectation",66 KELLY: "Kelly Criterion",67 DOWNLOAD_DATA: "Download Data",68 PRINT: "Print",69 GOT_IT: "Got It",70 H_AVG_PERFORMANCE: "Measures the average of the returns on the investments done over a specific period. It can be positive, representing a gain in value, or negative, representing a loss",71 H_MAX_DRAWDOWN: "Maximum DrawDown (MDD) is an indicator of downside risk over a specified time period. MDD = (Trough Value – Peak Value) ÷ Peak Value",72 H_AVG_MAX_DRAWDOWN: "The maximum drawdown value of each possible scenario (each line) is summed and then divided by the number of scenarios",73 H_RETURN_MAX_DRAWDOWN: "Return over maximum drawdown (RoMaD) is a risk-adjusted return metric. RoMaD = Portfolio Return / Max. Drawdown",74 H_MAX_EQ: "Is the highest equity value obtained in all the possible scenarios",75 H_MIN_EQ: "Is the lowest equity value obtained in all the possible scenarios",76 H_MAX_CONSEC_WINS: "Is the maximum number of consecutive wins on the trades",77 H_MAX_CONSEC_LOSES: "Is the maximum number of consecutive losses on the trades",78 H_EXPECTATION: "The mathematical expectation of any bet is defined as follows: the sum of all possible gains and losses multiplied by their relative probabilities. Written as a formula: e= (w × p) + (-v × 1). e = mathematical expectation, w = gain on the winning bet, p = probability of the win, v = value of the loss, l = probability of the loss",79 H_KELLY: "In probability theory and intertemporal portfolio choice, the Kelly criterion, Kelly strategy, Kelly formula, or Kelly bet is a formula used to determine the optimal size of a series of bets in order to maximize the logarithm of wealth"80 },81 fr: {82 APP_NAME: "Simulateur de courbe de profit",83 PARAMETERS: "Paramètres",84 STARTING_EQ: "Capital initial",85 RISK_PER_TRADE: "Risque par transaction",86 WIN_PROB: "Probabilité de gains",87 WIN_LOSS_REL: "Ratio Gains:Pertes",88 TRADES_PER_RUN: "Transactions par scénario",89 RUNS_LINES: "Nombre de simulations (Lignes)",90 GRAPH_SCALE: "Échelle du graphique",91 RUN_SIMULATION: "Lancer la simulation",92 GRAPH: "Graphique",93 TRADE: "Transaction",94 EQ: "Capital",95 MAX: "Maximum",96 MIN: "Minimum",97 AVG: "Moyenne",98 RESULTS: "Résultats",99 AVG_PERFORMANCE: "Performance moyenne",100 MAX_DRAWDOWN: "Baisse maximale",101 AVG_MAX_DRAWDOWN: "Moyenne des baisses maximales",102 RETURN_MAX_DRAWDOWN: "Rendement par rapport à la baisse maximale",103 MAX_EQ: "Capital maximum",104 MIN_EQ: "Capital minimum",105 MAX_CONSEC_WINS: "Nombre maximum de gains consécutifs",106 MAX_CONSEC_LOSES: "Nombre maximum de pertes consécutives",107 EXPECTATION: "Espérance",108 KELLY: "Critère de Kelly",109 DOWNLOAD_DATA: "Téléchargement",110 PRINT: "Imprimer",111 GOT_IT: "Compris",112 H_AVG_PERFORMANCE: "Mesure la moyenne des rendements des investissements réalisés sur une période donnée. Elle peut être positive, représentant un gain de valeur, ou négative, représentant une perte",113 H_MAX_DRAWDOWN: "Le Maximum Drawdown (MDD) est un indicateur du risque de baisse sur une période de temps spécifiée. MDD = (Trough Value - Peak Value) ÷ Peak Value",114 H_AVG_MAX_DRAWDOWN: "La valeur de tirage maximum de chaque scénario possible (chaque ligne) est additionnée puis divisée par le nombre de scénarios",115 H_RETURN_MAX_DRAWDOWN: "Le rendement par rapport au tirage maximal (RoMaD) est une mesure de rendement ajustée au risque. RoMaD = rendement du portefeuille / tirage max.",116 H_MAX_EQ: "Mesure la valeur nette la plus élevée obtenue dans tous les scénarios possibles",117 H_MIN_EQ: "Mesure la valeur nette la plus basse obtenue dans tous les scénarios possibles",118 H_MAX_CONSEC_WINS: "Mesure le nombre maximum de victoires consécutives sur les trades",119 H_MAX_CONSEC_LOSES: "Mesure le nombre maximum de pertes consécutives sur les trades",120 H_EXPECTATION: "L'espérance mathématique de tout pari est définie comme suit: la somme de tous les gains et pertes possibles multipliées par leurs probabilités relatives. Écrit comme une formule: e = (w × p) + (-v × 1). E = espérance mathématique, w = gain sur le pari gagnant, p = probabilité de gain, v = valeur de la perte, l = probabilité de la perte ",121 H_KELLY: "En théorie des probabilités et choix de portefeuille intertemporel, le critère de Kelly est une formule utilisée pour déterminer la taille optimale d'une série de paris afin de maximiser le logarithme de la richesse"122 } 123 };124 t.useSanitizeValueStrategy("escape").translations("en", r.en).translations("fr", r.fr).preferredLanguage("en")125}]), angular.module("MainCtrl", []).controller("MainCtrl", ["$scope", "$rootScope", "$timeout", "$translate", "$mdDialog", "$localStorage", "$window", function (a, e, t, r, n, o, i) {126 Rs = a;127 var s = {},128 l = r.instant;129 Rs.Inputs = {130 currencySymbol: "$",131 startingEq: 100,132 winProb: 50,133 winRatio: 2,134 trades: 100,135 runs: 10,136 risk: 1,137 riskType: "Percent",138 scale: "Normal",139 calculating: !1,140 calcDone: !1141 }, s.Control = {}, s.gamble = (() => {142 return Math.floor(100 * Math.random()) < Rs.Inputs.winProb143 }), s.getRiskedVal = (a => {144 if (a <= 0) return 0;145 var e = "Percent" == Rs.Inputs.riskType ? a * Rs.Inputs.risk / 100 : Math.min(Rs.Inputs.risk, a);146 return e = Math.min(e, a)147 }), s.calcEq = ((a, e, t) => {148 if (a <= 0) return 0;149 var r = e * Rs.Inputs.winRatio,150 n = t ? a + r : a - e;151 return n = Math.max(n, 0), s.actRun.eq = n152 }), s.trade = (() => {153 1 == s.Control.currentTrade && (s.actRun = {154 run: s.Control.currentRun,155 eq: angular.copy(Rs.Inputs.startingEq),156 maxEq: 0,157 maxDD: 0,158 maxDDAbs: 0,159 trades: []160 }, s.Control.CW = 0, s.Control.CL = 0);161 var a = s.gamble(),162 e = s.getRiskedVal(s.actRun.eq),163 t = {164 run: s.Control.currentRun,165 trade: s.Control.currentTrade,166 tradeGlob: s.Control.currentTradeGlob,167 risked: e,168 win: a,169 eq: s.calcEq(s.actRun.eq, e, a),170 cw: s.Control.CW,171 cl: s.Control.CL172 };173 s.actRun.maxEq = Math.max(s.actRun.maxEq, t.eq), t.dd = (s.actRun.maxEq - t.eq) / s.actRun.maxEq, t.dd > s.actRun.maxDD && (s.actRun.maxDD = t.dd, s.actRun.maxDDAbs = t.dd * s.actRun.maxEq), s.actRun.trades.push(t), s.Control.currentTradeGlob++, a ? (s.Control.CW++, s.Control.CL = 0) : (s.Control.CL++, s.Control.CW = 0), s.Control.currentTrade >= Rs.Inputs.trades ? (s.Results.push(s.actRun), s.Control.currentTrade = 1, s.Control.currentRun++) : s.Control.currentTrade++, s.Control.currentTradeGlob <= s.Control.totalTrades || (console.log("Termine"), s.finishCalc())174 }), Rs.run = (() => {175 Rs.Inputs.calculating || (Rs.reset(), Rs.Inputs.calculating = !0, Rs.Inputs.calcDone = !1, Rs.chartData = [], console.log("Starting"), t(() => {176 for (var a = 1; a <= s.Control.totalTrades; a++) s.trade()177 }, 1500))178 }), Rs.reset = (() => {179 s.Results = [], s.Control = {}, s.Control.currentRun = 1, s.Control.currentTrade = 1, s.Control.currentTradeGlob = 1, s.Control.totalTrades = Rs.Inputs.runs * Rs.Inputs.trades, s.Control.CW = 0, s.Control.CL = 0, s.Control.chartFixed = !1180 }), s.finishCalc = (() => {181 var a = [];182 s.TData = [], s.Results.forEach(e => {183 var t = {184 key: "Run #" + e.run,185 strokeWidth: .5,186 values: [{187 x: 0,188 y: Rs.Inputs.startingEq189 }]190 };191 e.trades.forEach(a => {192 t.values.push({193 x: a.trade,194 y: a.eq195 }), 1 == e.run && s.TData.push({196 sum: 0,197 min: a.eq,198 max: a.eq199 }), TD = s.TData[a.trade - 1], TD.sum += a.eq, TD.min = Math.min(TD.min, a.eq), TD.max = Math.max(TD.max, a.eq), 1 == a.tradeGlob ? (s.Control.minEq = a.eq, s.Control.maxEq = a.eq, s.Control.maxCW = 0, s.Control.maxCL = 0) : (s.Control.minEq = Math.min(s.Control.minEq, a.eq), s.Control.maxEq = Math.max(s.Control.maxEq, a.eq), s.Control.maxCW = Math.max(s.Control.maxCW, a.cw), s.Control.maxCL = Math.max(s.Control.maxCL, a.cl))200 }), a.push(t)201 });202 var e = [{203 x: 0,204 y: Rs.Inputs.startingEq,205 size: 5206 }],207 t = [];208 s.Control.maxTAvg = 0, s.TData.forEach((a, r) => {209 a.avg = a.sum / Rs.Inputs.runs, e.push({210 x: r + 1,211 y: a.avg,212 size: 70213 }), t.push({214 x: r + 1,215 y: Rs.Inputs.startingEq216 }), s.Control.lastTAvg = a.avg, s.Control.maxTAvg = Math.max(s.Control.maxTAvg, a.avg)217 }), a.push({218 key: "Average",219 strokeWidth: 3,220 color: "black",221 values: e222 }), s.calcVars();223 var r = Math.ceil(s.Control.maxEq).toString().length;224 r = Math.max(r, 2), Rs.chartOps.chart.margin.left = 10 * r + 20, Rs.chartOps.chart.yAxis.axisLabelDistance = 10 * r - 50, Rs.chartData = a, Rs.Inputs.calculating = !1, Rs.Inputs.calcDone = !0225 }), s.calcVars = (() => {226 Rs.Vars = v = {}, g = Rs.Inputs, c = s.Control, v.Accuracy = g.winProb / 100, v.PayOff = g.winRatio, v.Kelly = d3.format(",.2f")(v.Accuracy - (1 - v.Accuracy) / v.PayOff), v.Expectation = d3.format(",.2f")(v.Accuracy * v.PayOff - (1 - v.Accuracy)), v.minEq = d3.format(",.2f")(c.minEq), v.maxEq = d3.format(",.2f")(c.maxEq), v.maxCW = d3.format(",.0f")(c.maxCW), v.maxCL = d3.format(",.0f")(c.maxCL), v.avgMaxDD = 0, v.maxDD = 0, v.maxDDAbs = 0, s.Results.forEach(a => {227 v.avgMaxDD += a.maxDD, v.maxDD = Math.max(v.maxDD, a.maxDD), v.maxDDAbs = Math.max(v.maxDDAbs, a.maxDDAbs)228 }), v.maxDD = d3.format(",.2%")(v.maxDD), v.maxDDAbs = d3.format(",.2f")(v.maxDDAbs), v.avgMaxDDRaw = v.avgMaxDD / g.runs, v.avgMaxDD = d3.format(",.2%")(v.avgMaxDDRaw), v.avgPerfAbs = d3.format(",.2f")(c.lastTAvg - g.startingEq), v.avgPerf = d3.format(",.2%")((c.lastTAvg - g.startingEq) / g.startingEq), v.retMaxDD = d3.format(",.0f")((v.avgPerfAbs) / (Math.abs(v.avgMaxDDRaw)))*0.01, Rs.Vars = v229 }), Rs.chartOps = {230 chart: {231 type: "lineChart",232 height: 500,233 margin: {234 top: 10,235 right: 20,236 bottom: 40,237 left: 50238 },239 pointSize: a => a.size || 4,240 pointShape: a => a.shape || "circle",241 x: function (a) {242 return a.x243 },244 y: function (a) {245 if (a) return a.y246 },247 noData: "No Data",248 useInteractiveGuideline: !0,249 showLegend: !1,250 xAxis: {251 axisLabel: ""252 },253 yAxis: {254 axisLabel: "",255 tickFormat: function (a) {256 return d3.format(",.0f")(a)257 },258 axisLabelDistance: -20259 },260 color: ["#f5f5f5", "#e8e8e8", "#dcdcdc", "#cfcfcf", "#bababa", "#b0b0b0", "#9d9d9d", "#898989", "#767676", "#626262", "#444444", "#313131", "#1d1d1d", "#0a0a0a", "#0a0a0a"],261 interpolate: "monotone",262 interactiveLayer: {263 showGuideLine: !0,264 tooltip: {265 contentGenerator: a => {266 if (null === a || 0 == a.value) return "";267 TD = s.TData[a.value - 1];268 var e = "<table><thead><tr><td class=x-value colspan=2><span class='tooltip text-bold text-green'>" + l("TRADE") + " #" + a.value + "</span></td></tr></thead><tbody>";269 return e += "<tr><td class=key>" + l("AVG") + ":</td><td class=value>" + d3.format(",.2f")(TD.avg) + "<td><tr>", e += "<tr><td class=key>" + l("MAX") + ":</td><td class=value>" + d3.format(",.2f")(TD.max) + "<td><tr>", e += "<tr><td class=key>" + l("MIN") + ":</td><td class=value>" + d3.format(",.2f")(TD.min) + "<td><tr>", e += "</tbody></table>"270 }271 }272 },273 dispatch: {274 renderEnd: function (a) {275 s.fixChart()276 }277 }278 }279 }, s.fixChart = (() => {280 s.Control.chartFixed || (window.dispatchEvent(new Event("resize")), s.Control.chartFixed = !0)281 });282 var d = window.innerHeight - 110;283 d = Math.min(d, 500), Rs.chartOps.chart.height = d, Rs.chartConfig = {284 deepWatchData: !1,285 deepWatchDataDepth: 0286 }, Rs.CSVHeaders = ["Run", "Trade", "Win", "Equity"], Rs.getCSV = (() => {287 var a = [];288 return s.Results.forEach(e => {289 e.trades.forEach(t => {290 a.push([e.run, t.trade, t.win, d3.format(".2f")(t.eq)])291 })292 }), a293 }), Rs.IndHelp = ((a, e) => {294 n.show(n.alert().clickOutsideToClose(!0).targetEvent(a).fullscreen(!1).title(l(e)).textContent(l("H_" + e)).ok(l("GOT_IT")))295 }), Rs.Languages = [{296 id: "en",297 name: "English"298 }, {299 id: "fr",300 name: "Francais"301 }];302 var m = i.navigator.language || i.navigator.userLanguage;303 m ? (m = m.substring(0, 2), -1 == ["en", "fr"].indexOf(m) && (m = "en")) : m = "en", Rs.Storage = o.$default({304 Lang: m305 }), Rs.changeLang = (() => {306 r.use(Rs.Storage.Lang), Rs.chartOps.chart.xAxis.axisLabel = l("TRADE") + " #", Rs.chartOps.chart.yAxis.axisLabel = l("EQ") + " (" + Rs.Inputs.currencySymbol + ")"307 }), Rs.changeLang(), Rs.run();308 for (var u = i.location.href.split("/"), h = u[0] + "/", g = 2; g < u.length - 1; g++) h = h + "/" + u[g];309 Rs.baseURL = h + "/", Rs.Version = 202009220921...

Full Screen

Full Screen

MainCtrl.js

Source:MainCtrl.js Github

copy

Full Screen

1angular.module('MainCtrl', [])2.controller('MainCtrl', ['$scope', '$rootScope', '$timeout', '$translate', '$mdDialog', '$localStorage', '$window', 3 function ($scope, $rootScope, $timeout, $translate, $mdDialog, $localStorage, $window) {4 5 Rs = $scope;6 var Ctrl = {};7 var t = $translate.instant;8 Rs.Inputs = {9 currencySymbol: '$',10 startingEq: 100,11 winProb: 50,12 winRatio: 2,13 trades: 100,14 runs: 10,15 risk: 1,16 riskType: 'Percent',17 scale: 'Normal',18 calculating: false,19 calcDone: false20 };21 Ctrl.Control = {};22 Ctrl.gamble = () => {23 var randomNum = Math.floor(Math.random()*100);24 return (randomNum < Rs.Inputs.winProb);25 };26 Ctrl.getRiskedVal = (eq) => {27 if(eq <= 0) return 0;28 var riskedVal = (Rs.Inputs.riskType == 'Percent') ? (eq * Rs.Inputs.risk / 100) : Math.min(Rs.Inputs.risk, eq);29 return riskedVal = Math.min(riskedVal, eq);30 };31 Ctrl.calcEq = (eq, risked, win) => {32 if(eq <= 0) return 0;33 var winnings = risked * Rs.Inputs.winRatio;34 var newEq = ( win ? (eq + winnings) : (eq - risked) );35 newEq = Math.max(newEq, 0);36 //console.log(eq, win, risked, winnings, newEq);37 return Ctrl.actRun.eq = newEq;38 };39 Ctrl.trade = () => {40 if(Ctrl.Control.currentTrade == 1){41 Ctrl.actRun = {42 run: Ctrl.Control.currentRun,43 eq: angular.copy(Rs.Inputs.startingEq),44 maxEq: 0,45 maxDD: 0,46 maxDDAbs: 0,47 trades: []48 };49 Ctrl.Control.CW = 0;50 Ctrl.Control.CL = 0;51 };52 var win = Ctrl.gamble();53 var risked = Ctrl.getRiskedVal(Ctrl.actRun.eq);54 var trade = {55 run: Ctrl.Control.currentRun,56 trade: Ctrl.Control.currentTrade,57 tradeGlob: Ctrl.Control.currentTradeGlob, 58 risked: risked,59 win: win,60 eq: Ctrl.calcEq(Ctrl.actRun.eq, risked, win),61 cw: Ctrl.Control.CW,62 cl: Ctrl.Control.CL,63 };64 //DD65 Ctrl.actRun.maxEq = Math.max(Ctrl.actRun.maxEq, trade.eq);66 trade.dd = (Ctrl.actRun.maxEq - trade.eq) / Ctrl.actRun.maxEq;67 if(trade.dd > Ctrl.actRun.maxDD){68 Ctrl.actRun.maxDD = trade.dd;69 Ctrl.actRun.maxDDAbs = trade.dd * Ctrl.actRun.maxEq;70 };71 //console.log(trade);72 Ctrl.actRun.trades.push(trade);73 Ctrl.Control.currentTradeGlob++;74 //Consecutive Win Loses (Global)75 if(win){76 Ctrl.Control.CW++; Ctrl.Control.CL = 0;77 }else{78 Ctrl.Control.CL++; Ctrl.Control.CW = 0;79 };80 if(Ctrl.Control.currentTrade >= Rs.Inputs.trades){81 Ctrl.Results.push(Ctrl.actRun);82 Ctrl.Control.currentTrade = 1;83 Ctrl.Control.currentRun++;84 }else{85 Ctrl.Control.currentTrade++;86 };87 if(Ctrl.Control.currentTradeGlob <= Ctrl.Control.totalTrades){88 //Rs.progress = Math.ceil(Ctrl.Control.currentTradeGlob / Ctrl.Control.totalTrades * 100);89 //console.log(Ctrl.Control.progress);90 }else{91 //Finish92 console.log('Termine');93 Ctrl.finishCalc();94 };95 };96 Rs.run = () => {97 if(Rs.Inputs.calculating) return;98 Rs.reset();99 Rs.Inputs.calculating = true;100 Rs.Inputs.calcDone = false;101 Rs.chartData = [];102 console.log('Starting');103 $timeout(() => {104 for(var i = 1; i <= Ctrl.Control.totalTrades; i++){105 Ctrl.trade();106 };107 }, 1500);108 };109 Rs.reset = () => {110 Ctrl.Results = [];111 Ctrl.Control = {};112 Ctrl.Control.currentRun = 1;113 Ctrl.Control.currentTrade = 1;114 Ctrl.Control.currentTradeGlob = 1;115 Ctrl.Control.totalTrades = Rs.Inputs.runs * Rs.Inputs.trades;116 Ctrl.Control.CW = 0;117 Ctrl.Control.CL = 0;118 Ctrl.Control.chartFixed = false;119 };120 Ctrl.finishCalc = () => {121 var Data = [];122 Ctrl.TData = [];123 Ctrl.Results.forEach((Run) => {124 var Serie = {125 key: 'Run #' + Run.run,126 strokeWidth: 0.5,127 values: [{ x: 0, y: Rs.Inputs.startingEq }]128 };129 Run.trades.forEach((Trade) => {130 Serie.values.push({ x: Trade.trade, y: Trade.eq });131 if(Run.run == 1){132 Ctrl.TData.push({133 sum: 0,134 min: Trade.eq,135 max: Trade.eq,136 });137 };138 TD = Ctrl.TData[(Trade.trade - 1)];139 TD.sum += Trade.eq;140 TD.min = Math.min(TD.min, Trade.eq);141 TD.max = Math.max(TD.max, Trade.eq);142 //Vars143 if(Trade.tradeGlob == 1){144 Ctrl.Control.minEq = Trade.eq;145 Ctrl.Control.maxEq = Trade.eq;146 Ctrl.Control.maxCW = 0;147 Ctrl.Control.maxCL = 0;148 }else{149 Ctrl.Control.minEq = Math.min(Ctrl.Control.minEq, Trade.eq);150 Ctrl.Control.maxEq = Math.max(Ctrl.Control.maxEq, Trade.eq);151 Ctrl.Control.maxCW = Math.max(Ctrl.Control.maxCW, Trade.cw);152 Ctrl.Control.maxCL = Math.max(Ctrl.Control.maxCL, Trade.cl);153 };154 155 });156 Data.push(Serie);157 });158 var TAvgs = [{ x: 0, y: Rs.Inputs.startingEq, size: 5 }];159 var TIniEq = [];160 Ctrl.Control.maxTAvg = 0;161 Ctrl.TData.forEach((TD, i) => {162 TD.avg = (TD.sum / Rs.Inputs.runs);163 TAvgs.push({ x: (i+1), y: TD.avg, size: 70 });164 TIniEq.push({ x: (i+1), y: Rs.Inputs.startingEq });165 Ctrl.Control.lastTAvg = TD.avg;166 Ctrl.Control.maxTAvg = Math.max(Ctrl.Control.maxTAvg, TD.avg);167 });168 Data.push({169 key: 'Average',170 strokeWidth: 3,171 color: 'black',172 values: TAvgs173 });174 /*Data.push({175 key: 'Initial',176 strokeWidth: 1,177 color: '#ccc',178 classed: 'dashed',179 values: TIniEq180 });*/181 //console.log(Ctrl.TData);182 Ctrl.calcVars();183 //Ajustar eje Y184 185 var maxEqLen = Math.ceil(Ctrl.Control.maxEq).toString().length;186 maxEqLen = Math.max(maxEqLen, 2);187 Rs.chartOps.chart.margin.left = (maxEqLen * 10) + 20;188 Rs.chartOps.chart.yAxis.axisLabelDistance = (maxEqLen * 10) - 50;189 //console.log(Math.ceil(Ctrl.Control.maxEq).toString());190 Rs.chartData = Data;191 192 Rs.Inputs.calculating = false;193 Rs.Inputs.calcDone = true;194 /*$timeout(() => {195 window.dispatchEvent(new Event('resize'));196 }, 600);*/197 198 //Rs.chartApi.update();199 //delete Ctrl.Results;200 //delete Data;201 };202 Ctrl.calcVars = () => {203 Rs.Vars = v = {};204 i = Rs.Inputs;205 c = Ctrl.Control;206 v.Accuracy = (i.winProb / 100);207 v.PayOff = i.winRatio;208 v.Kelly = d3.format(',.2f')(v.Accuracy - ((1-v.Accuracy) / v.PayOff ));209 v.Expectation = d3.format(',.2f')((v.Accuracy * v.PayOff) - (1 - v.Accuracy));210 v.minEq = d3.format(',.2f')(c.minEq);211 v.maxEq = d3.format(',.2f')(c.maxEq);212 v.maxCW = d3.format(',.0f')(c.maxCW);213 v.maxCL = d3.format(',.0f')(c.maxCL);214 //DD215 v.avgMaxDD = 0;216 v.maxDD = 0;217 v.maxDDAbs = 0;218 Ctrl.Results.forEach((Run) => {219 v.avgMaxDD += Run.maxDD;220 v.maxDD = Math.max(v.maxDD, Run.maxDD);221 v.maxDDAbs = Math.max(v.maxDDAbs, Run.maxDDAbs);222 });223 v.maxDD = d3.format(',.2%')(v.maxDD);224 v.maxDDAbs = d3.format(',.2f')(v.maxDDAbs);225 v.avgMaxDDRaw = v.avgMaxDD / i.runs;226 v.avgMaxDD = d3.format(',.2%')(v.avgMaxDDRaw);227 //Perf228 v.avgPerfAbs = d3.format(',.2f')(c.lastTAvg - i.startingEq);229 v.avgPerf = d3.format(',.2%')((c.lastTAvg - i.startingEq) / i.startingEq);230 v.retMaxDD = d3.format(',.2%')((c.lastTAvg - (c.maxTAvg - v.avgMaxDDRaw)) / (c.maxTAvg - v.avgMaxDDRaw));231 //console.log(v);232 Rs.Vars = v;233 };234 Rs.chartOps = {235 chart: {236 type: 'lineChart',237 height: 500,238 margin : {239 top: 10,240 right: 20,241 bottom: 40,242 left: 50243 },244 pointSize: (d) => {245 return d.size || 4;246 },247 pointShape: (d) => {248 return d.shape || 'circle';249 },250 x: function(d){ return d.x; },251 y: function(d){ if(d) return d.y; },252 noData: 'No Data',253 useInteractiveGuideline: true,254 showLegend: false,255 xAxis: {256 axisLabel: ''257 },258 yAxis: {259 axisLabel: '',260 tickFormat: function(d){261 return d3.format(',.0f')(d);262 },263 axisLabelDistance: -20264 },265 color: ['#88A80B','#BCDA45','#A7CB1B','#6F8B00','#526700','#579E0A','#8ACD41','#70BF19','#448300','#326100','#AFAA0B','#E3DE48','#D4CE1C','#918C00','#6B6800'],266 interpolate: 'monotone',267 interactiveLayer: {268 showGuideLine: true,269 tooltip: {270 contentGenerator: (d) => {271 if (d === null || d.value == 0) { return ''; }272 //console.log(d,a);273 TD = Ctrl.TData[(d.value - 1)];274 var table = "<table><thead><tr><td class=x-value colspan=2><span class='tooltip text-bold text-green'>" +t('TRADE')+ " #" + d.value + "</span></td></tr></thead><tbody>";275 table += "<tr><td class=key>" +t('AVG')+ ":</td><td class=value>" + d3.format(',.2f')(TD.avg) + "<td><tr>";276 table += "<tr><td class=key>" +t('MAX')+ ":</td><td class=value>" + d3.format(',.2f')(TD.max) + "<td><tr>";277 table += "<tr><td class=key>" +t('MIN')+ ":</td><td class=value>" + d3.format(',.2f')(TD.min) + "<td><tr>";278 table += "</tbody></table>";279 return table;280 281 }282 }283 },284 dispatch: {285 renderEnd: function(e){ Ctrl.fixChart(); }286 }287 //forceY: [0,100],288 },289 };290 Ctrl.fixChart = () => {291 if(Ctrl.Control.chartFixed) return;292 window.dispatchEvent(new Event('resize'));293 Ctrl.Control.chartFixed = true;294 };295 var wih = (window.innerHeight - 110);296 wih = Math.min(wih, 500);297 Rs.chartOps.chart.height = wih;298 299 Rs.chartConfig = {300 //refreshDataOnly: true,301 deepWatchData: false,302 deepWatchDataDepth: 0303 };304 305 Rs.CSVHeaders = [ 'Run', 'Trade', 'Win', 'Equity' ];306 Rs.getCSV = () => {307 var CSV = [];308 Ctrl.Results.forEach((Run) => {309 Run.trades.forEach((Trade) => {310 CSV.push([ Run.run, Trade.trade, Trade.win, d3.format('.2f')(Trade.eq) ]);311 });312 });313 return CSV;314 };315 //Indicators Help316 Rs.IndHelp = (ev, k) => {317 $mdDialog.show(318 $mdDialog.alert()319 .clickOutsideToClose(true).targetEvent(ev).fullscreen(false)320 .title(t(k))321 .textContent(t('H_'+k))322 .ok(t('GOT_IT'))323 );324 };325 //Cambio de Lenguaje326 Rs.Languages = [327 { id: 'en', name: 'English' },328 { id: 'es', name: 'Español' },329 ];330 var navLan = $window.navigator.language || $window.navigator.userLanguage;331 if(navLan){332 navLan = navLan.substring(0,2);333 if( (['en','es']).indexOf(navLan) == -1 ) navLan = 'en';334 }else{335 navLan = 'en';336 };337 Rs.Storage = $localStorage.$default({338 Lang: navLan339 });340 Rs.changeLang = () => {341 $translate.use(Rs.Storage.Lang);342 Rs.chartOps.chart.xAxis.axisLabel = t('TRADE') + ' #';343 Rs.chartOps.chart.yAxis.axisLabel = t('EQ') + ' (' + Rs.Inputs.currencySymbol + ')';344 };345 Rs.changeLang();346 347 Rs.run();348 //Calcular base URL349 var winloc = $window.location.href.split('/');350 var winstr = winloc[0] + '/';351 for (var i = 2; i < (winloc.length-1); i++) {352 winstr = winstr + '/' + winloc[i];353 };354 Rs.baseURL = winstr + '/';355 Rs.Version = 201810160921;356 357 }...

Full Screen

Full Screen

test-context.js

Source:test-context.js Github

copy

Full Screen

1'use strict';2var assert = require('assert');3var StringReader = require('../lib/string-reader');4var Lexer = require('../lib/lexer');5var Parser = require('../lib/parser');6var Context = require('../lib/context');7var ctx = new Context(null);8function test(contents, expStr, expRun) {9 var reader = new StringReader(contents.toString(), 'fileName');10 var lexer = new Lexer(reader);11 var parser = new Parser(lexer);12 var syntax;13 var actStr = [];14 var actRun = [];15 while (syntax = parser.parseStatement()) {16 try {17 actStr.push(syntax.toString().trim());18 } catch (e) {19 actStr.push(new Error);20 }21 try {22 actRun.push((syntax.run(ctx) + '').trim());23 } catch (e) {24 actRun.push(new Error);25 }26 }27 assert.deepEqual(actStr, expStr);28 assert.deepEqual(actRun, expRun);29}30var testCases = [31 ['a=1;', ['a=1;'], [new Error]],32 ['b=a+1;', ['b=a+1;'], [new Error]],33 ['c=a+b*3;', ['c=a+b*3;'], [new Error]],34 ['var a=1; a;', ['var a = 1;', 'a;'], ['undefined', '1']],35 ['var b=a+1; b;', ['var b = a+1;', 'b;'], ['undefined', '2']],36 ['var c=a+b*3; c;', ['var c = a+b*3;', 'c;'], ['undefined', '7']],37 ['var d=a*((b+3)); d;', ['var d = a*(b+3);', 'd;'], ['undefined', '5']],38 ['4+x;', ['4+x;'], [new Error]],39 ['y=4+x;', ['y=4+x;'], [new Error]],40];41describe('Context test', function () {42 testCases.forEach(function (elem) {43 var name = (elem[0].trim() + ' → ' + elem[1].join(' ') + ' → ' + elem[2].join(' ')).replace(/\n/g, '');44 it(name, function () {45 test(elem[0], elem[1], elem[2]);46 });47 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var actRun = require('stryker-parent').actRun;2actRun({ port: 3000 });3module.exports = function (config) {4 config.set({5 });6};7 at Object.actRun (/Users/niels/Projects/stryker-js/packages/stryker-parent/stryker-parent.js:4:16)8 at Object.<anonymous> (/Users/niels/Projects/stryker-js/packages/stryker-parent/test.js:2:9)9 at Module._compile (module.js:653:30)10 at Object.Module._extensions..js (module.js:664:10)11 at Module.load (module.js:566:32)12 at tryModuleLoad (module.js:506:12)13 at Function.Module._load (module.js:498:3)14 at Module.require (module.js:597:17)15 at require (internal/module.js:11:18)16 at Object.<anonymous> (/Users/niels/Projects/stryker-js/packages/stryker-parent/node_modules/jasmine/lib/jasmine.js:1:1)17 at Module._compile (module.js:653:30)18 at Object.Module._extensions..js (module.js:664:10)19 at Module.load (module.js:566:32)20 at tryModuleLoad (module.js:506:12)21 at Function.Module._load (module.js:498:3)22 at Module.require (module.js:597:17)23 at require (internal/module.js:11:18)24 at Object.<anonymous> (/Users/niels/Projects/stryker-js/packages/stryker-parent/node_modules/jasmine/lib/jasmine-core/jasmine.js:

Full Screen

Using AI Code Generation

copy

Full Screen

1var stryker = require('stryker-parent');2var options = {3};4stryker.actRun(options, function (error, result) {5 console.log('Done!');6});7var stryker = require('stryker-parent');8var options = {9};10stryker.actRun(options, function (error, result) {11 console.log('Done!');12});13var stryker = require('stryker-parent');14var options = {15};16stryker.actRun(options, function (error, result) {17 console.log('Done!');18});19var stryker = require('stryker-parent');20var options = {21};22stryker.actRun(options, function (error, result) {23 console.log('Done!');24});25var stryker = require('stryker-parent');26var options = {27};28stryker.actRun(options, function (error, result) {29 console.log('Done!');30});31var stryker = require('stryker-parent');32var options = {33};34stryker.actRun(options, function (error, result) {35 console.log('Done!');36});37var stryker = require('stryker-parent');38var options = {39};40stryker.actRun(options, function (error, result) {41 console.log('Done!');42});43var stryker = require('stryker

Full Screen

Using AI Code Generation

copy

Full Screen

1var stryker = require('stryker-parent');2stryker.actRun();3module.exports = {4 actRun: function () {5 console.log('I am in actRun method');6 }7}8var stryker = require('stryker-parent');9stryker.actRun();10var strykerChild = require('stryker-child');11module.exports = {12 actRun: function () {13 strykerChild.actRun();14 }15}16module.exports = {17 actRun: function () {18 console.log('I am in actRun method');19 }20}21I'm trying to create a module that uses other modules. I'm not sure how to do it. I tried to use require() but it doesn't work. Here is my code:22var module = require('./module.js');23module.doSomething();24var otherModule = require('./otherModule.js');25exports.doSomething = function() {26 otherModule.doSomethingElse();27}28exports.doSomethingElse = function() {29 console.log('Do something else');30}31I'm trying to create a module that uses other modules. I'm not sure how to do it. I tried to use require() but it doesn't work. Here is my code:32var module = require('./module.js');33module.doSomething();34var otherModule = require('./otherModule.js');35exports.doSomething = function() {36 otherModule.doSomethingElse();37}

Full Screen

Using AI Code Generation

copy

Full Screen

1var stryker = require('stryker-parent');2stryker.actRun({3});4module.exports = function(config) {5 config.set({6 preprocessors: {7 },8 });9};

Full Screen

Using AI Code Generation

copy

Full Screen

1var stryker = require('stryker-parent');2var options = {3}4stryker.actRun(options);5module.exports = function (config) {6 config.set({7 });8};9{10 "scripts": {11 },12 "dependencies": {13 }14}15var gulp = require('gulp');16var stryker = require('gulp-stryker-parent');17gulp.task('stryker', function () {18 return gulp.src('stryker.conf.js')19 .pipe(stryker());20});21module.exports = function (config) {22 config.set({23 });24};25module.exports = function (grunt) {26 grunt.initConfig({27 stryker: {28 options: {29 }30 }31 });32 grunt.loadNpmTasks('grunt-stryker-parent');33 grunt.registerTask('default', ['stryker']);34};

Full Screen

Using AI Code Generation

copy

Full Screen

1var stryker = require('stryker');2var strykerParent = require('stryker-parent');3var path = require('path');4var fs = require('fs');5var strykerConfig = {6};7var strykerConfigPath = path.join(__dirname, 'stryker.conf.js');8if (fs.existsSync(strykerConfigPath)) {9 strykerConfig = require(strykerConfigPath);10}11strykerParent.actRun(stryker, strykerConfig);12module.exports = function (config) {13 config.set({14 });15};16module.exports = {

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run stryker-parent automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful