From a7c09e14ae51eb631deff912dfbf49db1ee0e5ea Mon Sep 17 00:00:00 2001 From: NunoSempere Date: Fri, 4 Feb 2022 10:42:03 -0500 Subject: [PATCH] chore: Cleanup. - Deleted foretold community on astralcodexten questions - because now they are managed by Metaculus/Manifold - fixed small mistake for good judgment - recalculated scores for manifold markets - avoid low-quality markets. --- src/utils/mergeEverything.js | 62 +++-- src/utils/stars.js | 504 ++++++++++++++++++----------------- 2 files changed, 304 insertions(+), 262 deletions(-) diff --git a/src/utils/mergeEverything.js b/src/utils/mergeEverything.js index 512f778..c9b9368 100644 --- a/src/utils/mergeEverything.js +++ b/src/utils/mergeEverything.js @@ -1,23 +1,53 @@ -import { mongoRead, upsert } from "./mongo-wrapper.js" +import { mongoRead, upsert } from "./mongo-wrapper.js"; /* Merge everything */ -let sets = ["astralcodexten", "betfair", "coupcast", "csetforetell", "elicit", /* "estimize" ,*/ "fantasyscotus", "foretold", "givewellopenphil", "goodjudgment","goodjudmentopen", "hypermind", "kalshi", "ladbrokes", "manifoldmarkets", "metaculus", "omen", "polymarket", "predictit", "rootclaim", "smarkets", "wildeford", "williamhill", "xrisk"] -let suffix = "-questions" +// let sets = ["astralcodexten", "betfair", "coupcast", "csetforetell", "elicit", /* "estimize" ,*/ "fantasyscotus", "foretold", "givewellopenphil", "goodjudgment","goodjudmentopen", "hypermind", "kalshi", "ladbrokes", "manifoldmarkets", "metaculus", "omen", "polymarket", "predictit", "rootclaim", "smarkets", "wildeford", "williamhill", "xrisk"] +let sets = [ + "betfair", + "coupcast", + "csetforetell", + "elicit", + /* "estimize" ,*/ "fantasyscotus", + "foretold", + "givewellopenphil", + "goodjudgment", + "goodjudmentopen", + "hypermind", + "kalshi", + "ladbrokes", + "manifoldmarkets", + "metaculus", + "omen", + "polymarket", + "predictit", + "rootclaim", + "smarkets", + "wildeford", + "williamhill", + "xrisk", +]; -export async function mergeEverythingInner(){ - let merged = [] - for(let set of sets){ - let json = await mongoRead(set+suffix) - console.log(`${set} has ${json.length} questions\n`) - merged = merged.concat(json) +let suffix = "-questions"; + +export async function mergeEverythingInner() { + let merged = []; + for (let set of sets) { + let json = await mongoRead(set + suffix); + console.log(`${set} has ${json.length} questions\n`); + merged = merged.concat(json); } - let mergedprocessed = merged.map(element => ({...element, optionsstringforsearch: element.options.map(option => option.name).join(", ")})) - console.log(`In total, there are ${mergedprocessed.length} questions`) - return mergedprocessed + let mergedprocessed = merged.map((element) => ({ + ...element, + optionsstringforsearch: element.options + .map((option) => option.name) + .join(", "), + })); + console.log(`In total, there are ${mergedprocessed.length} questions`); + return mergedprocessed; } -export async function mergeEverything(){ - let merged = await mergeEverythingInner() - await upsert( merged,"metaforecasts") - console.log("Done") +export async function mergeEverything() { + let merged = await mergeEverythingInner(); + await upsert(merged, "metaforecasts"); + console.log("Done"); } diff --git a/src/utils/stars.js b/src/utils/stars.js index fd4cc71..91534c8 100644 --- a/src/utils/stars.js +++ b/src/utils/stars.js @@ -1,321 +1,333 @@ export function getStarSymbols(numstars) { - let stars = "★★☆☆☆" - switch (numstars) { - case 0: - stars = "☆☆☆☆☆" - break; - case 1: - stars = "★☆☆☆☆" - break; - case 2: - stars = "★★☆☆☆" - break; - case 3: - stars = "★★★☆☆" - break; - case 4: - stars = "★★★★☆" - break; - case 5: - stars = "★★★★★" - break; - default: - stars = "★★☆☆☆" - } - return (stars) + let stars = "★★☆☆☆"; + switch (numstars) { + case 0: + stars = "☆☆☆☆☆"; + break; + case 1: + stars = "★☆☆☆☆"; + break; + case 2: + stars = "★★☆☆☆"; + break; + case 3: + stars = "★★★☆☆"; + break; + case 4: + stars = "★★★★☆"; + break; + case 5: + stars = "★★★★★"; + break; + default: + stars = "★★☆☆☆"; + } + return stars; } -let average = array => array.reduce((a, b) => a + b, 0) / (array.length) +let average = (array) => array.reduce((a, b) => a + b, 0) / array.length; function calculateStarsAstralCodexTen(data) { - let nuno = data => 3 - let eli = (data) => null - let misha = (data) => null - let starsDecimal = average([nuno(data)]) //, eli(data), misha(data)]) - let starsInteger = Math.round(starsDecimal) - return starsInteger + let nuno = (data) => 3; + let eli = (data) => null; + let misha = (data) => null; + let starsDecimal = average([nuno(data)]); //, eli(data), misha(data)]) + let starsInteger = Math.round(starsDecimal); + return starsInteger; } function calculateStarsBetfair(data) { - let nuno = data => data.volume > 10000 ? 4 : (data.volume > 1000 ? 3 : 2) - let eli = (data) => data.volume > 10000 ? null : null - let misha = (data) => null - let starsDecimal = average([nuno(data)]) //, eli(data), misha(data)]) - // Substract 1 star if probability is above 90% or below 10% - if(data.option && - (data.option.probability < 0.1 || data.option.probability > 0.9) - ){ - starsDecimal = starsDecimal - 1 - } + let nuno = (data) => (data.volume > 10000 ? 4 : data.volume > 1000 ? 3 : 2); + let eli = (data) => (data.volume > 10000 ? null : null); + let misha = (data) => null; + let starsDecimal = average([nuno(data)]); //, eli(data), misha(data)]) + // Substract 1 star if probability is above 90% or below 10% + if ( + data.option && + (data.option.probability < 0.1 || data.option.probability > 0.9) + ) { + starsDecimal = starsDecimal - 1; + } - let starsInteger = Math.round(starsDecimal) - return starsInteger + let starsInteger = Math.round(starsDecimal); + return starsInteger; } function calculateStarsCoupCast(data) { - let nuno = (data) => 3 - let starsDecimal = average([nuno(data)]) //, eli(data), misha(data)]) - let starsInteger = Math.round(starsDecimal) - return starsInteger + let nuno = (data) => 3; + let starsDecimal = average([nuno(data)]); //, eli(data), misha(data)]) + let starsInteger = Math.round(starsDecimal); + return starsInteger; } function calculateStarsCSETForetell(data) { - let nuno = (data) => data.numforecasts > 100 ? 3 : 2 - let eli = (data) => 3 - let misha = (data) => 2 - let starsDecimal = average([nuno(data), eli(data), misha(data)]) - let starsInteger = Math.round(starsDecimal) - return starsInteger + let nuno = (data) => (data.numforecasts > 100 ? 3 : 2); + let eli = (data) => 3; + let misha = (data) => 2; + let starsDecimal = average([nuno(data), eli(data), misha(data)]); + let starsInteger = Math.round(starsDecimal); + return starsInteger; } function calculateStarsElicit(data) { - let nuno = data => 1 - let eli = (data) => null - let misha = (data) => null - let starsDecimal = average([nuno(data)]) //, eli(data), misha(data)]) - let starsInteger = Math.round(starsDecimal) - return starsInteger + let nuno = (data) => 1; + let eli = (data) => null; + let misha = (data) => null; + let starsDecimal = average([nuno(data)]); //, eli(data), misha(data)]) + let starsInteger = Math.round(starsDecimal); + return starsInteger; } function calculateStarsEstimize(data) { - let nuno = data => 2 - let eli = (data) => null - let misha = (data) => null - let starsDecimal = average([nuno(data)]) //, eli(data), misha(data)]) - let starsInteger = Math.round(starsDecimal) - return starsInteger + let nuno = (data) => 2; + let eli = (data) => null; + let misha = (data) => null; + let starsDecimal = average([nuno(data)]); //, eli(data), misha(data)]) + let starsInteger = Math.round(starsDecimal); + return starsInteger; } function calculateStarsForetold(data) { - let nuno = data => 2 - let eli = (data) => null - let misha = (data) => null - let starsDecimal = average([nuno(data)]) //, eli(data), misha(data)]) - let starsInteger = Math.round(starsDecimal) - return starsInteger + let nuno = (data) => 2; + let eli = (data) => null; + let misha = (data) => null; + let starsDecimal = average([nuno(data)]); //, eli(data), misha(data)]) + let starsInteger = Math.round(starsDecimal); + return starsInteger; } function calculateStarsGiveWellOpenPhil(data) { - let nuno = data => 2 - let eli = (data) => null - let misha = (data) => null - let starsDecimal = average([nuno(data)]) //, eli(data), misha(data)]) - let starsInteger = Math.round(starsDecimal) - return starsInteger + let nuno = (data) => 2; + let eli = (data) => null; + let misha = (data) => null; + let starsDecimal = average([nuno(data)]); //, eli(data), misha(data)]) + let starsInteger = Math.round(starsDecimal); + return starsInteger; } function calculateStarsGoodJudment(data) { - let nuno = data => 4 - let eli = (data) => 4 - let misha = (data) => 3.5 - let starsDecimal = average([nuno(data)]) //, eli(data), misha(data)]) - let starsInteger = Math.round(starsDecimal) - return starsInteger + let nuno = (data) => 4; + let eli = (data) => 4; + let misha = (data) => 3.5; + let starsDecimal = average([nuno(data)]); //, eli(data), misha(data)]) + let starsInteger = Math.round(starsDecimal); + return starsInteger; } function calculateStarsGoodJudmentOpen(data) { - let nuno = data => data.numforecasts > 100 ? 3 : 2 - let eli = (data) => 3 - let misha = (data) => (data.minProbability > 0.1 || data.maxProbability < 0.9) ? 3.1 : 2.5 - let starsDecimal = average([nuno(data), eli(data), misha(data)]) - let starsInteger = Math.round(starsDecimal) - return starsInteger + let nuno = (data) => (data.numforecasts > 100 ? 3 : 2); + let eli = (data) => 3; + let misha = (data) => + data.minProbability > 0.1 || data.maxProbability < 0.9 ? 3.1 : 2.5; + let starsDecimal = average([nuno(data), eli(data), misha(data)]); + let starsInteger = Math.round(starsDecimal); + return starsInteger; } function calculateStarsHypermind(data) { - let nuno = data => 3 - let eli = (data) => null - let misha = (data) => null - let starsDecimal = average([nuno(data)]) //, eli(data), misha(data)]) - let starsInteger = Math.round(starsDecimal) - return starsInteger + let nuno = (data) => 3; + let eli = (data) => null; + let misha = (data) => null; + let starsDecimal = average([nuno(data)]); //, eli(data), misha(data)]) + let starsInteger = Math.round(starsDecimal); + return starsInteger; } function calculateStarsKalshi(data) { - let nuno = data => data.interest > 500 && data.shares_volume > 10000 ? 4 : (data.shares_volume > 2000 ? 3 : 2) - // let eli = (data) => data.interest > 10000 ? 5 : 4 - // let misha = (data) => 4 - let starsDecimal = average([nuno(data)]) //, eli(data), misha(data)]) - // Substract 1 star if probability is above 90% or below 10% - if(data.option && - (data.option.probability < 0.1 || data.option.probability > 0.9) - ){ - starsDecimal = starsDecimal - 1 - } + let nuno = (data) => + data.interest > 500 && data.shares_volume > 10000 + ? 4 + : data.shares_volume > 2000 + ? 3 + : 2; + // let eli = (data) => data.interest > 10000 ? 5 : 4 + // let misha = (data) => 4 + let starsDecimal = average([nuno(data)]); //, eli(data), misha(data)]) + // Substract 1 star if probability is above 90% or below 10% + if ( + data.option && + (data.option.probability < 0.1 || data.option.probability > 0.9) + ) { + starsDecimal = starsDecimal - 1; + } - let starsInteger = Math.round(starsDecimal) - return starsInteger + let starsInteger = Math.round(starsDecimal); + return starsInteger; } function calculateStarsLadbrokes(data) { - let nuno = data => 2 - let eli = (data) => null - let misha = (data) => null - let starsDecimal = average([nuno(data)]) //, eli(data), misha(data)]) - let starsInteger = Math.round(starsDecimal) - return starsInteger + let nuno = (data) => 2; + let eli = (data) => null; + let misha = (data) => null; + let starsDecimal = average([nuno(data)]); //, eli(data), misha(data)]) + let starsInteger = Math.round(starsDecimal); + return starsInteger; } function calculateStarsManifoldMarkets(data) { - let nuno = data => 2 - let eli = (data) => null - let misha = (data) => null - let starsDecimal = average([nuno(data)]) //, eli(data), misha(data)]) - let starsInteger = Math.round(starsDecimal) - return starsInteger + let nuno = (data) => + data.volume7Days > 500 || (data.pool > 500 && data.volume7Days > 200) + ? 2 + : 1; + let eli = (data) => null; + let misha = (data) => null; + let starsDecimal = average([nuno(data)]); //, eli(data), misha(data)]) + let starsInteger = Math.round(starsDecimal); + return starsInteger; } function calculateStarsMetaculus(data) { - let nuno = data => data.numforecasts > 300 ? 4 : (data.numforecasts > 100 ? 3 : 2) - let eli = (data) => 3 - let misha = (data) => 3 - let starsDecimal = average([nuno(data), eli(data), misha(data)]) - let starsInteger = Math.round(starsDecimal) - return starsInteger + let nuno = (data) => + data.numforecasts > 300 ? 4 : data.numforecasts > 100 ? 3 : 2; + let eli = (data) => 3; + let misha = (data) => 3; + let starsDecimal = average([nuno(data), eli(data), misha(data)]); + let starsInteger = Math.round(starsDecimal); + return starsInteger; } function calculateStarsOmen(data) { - let nuno = data => 1 - let eli = (data) => null - let misha = (data) => null - let starsDecimal = average([nuno(data)]) //, eli(data), misha(data)]) - let starsInteger = Math.round(starsDecimal) - return starsInteger + let nuno = (data) => 1; + let eli = (data) => null; + let misha = (data) => null; + let starsDecimal = average([nuno(data)]); //, eli(data), misha(data)]) + let starsInteger = Math.round(starsDecimal); + return starsInteger; } function calculateStarsPolymarket(data) { - let nuno = data => data.volume > 10000 ? 4 : (data.volume > 1000 ? 3 : 2) - // let eli = (data) => data.liquidity > 10000 ? 5 : 4 - // let misha = (data) => 4 - let starsDecimal = average([nuno(data)]) //, eli(data), misha(data)]) - // Substract 1 star if probability is above 90% or below 10% - if(data.option && - (data.option.probability < 0.1 || data.option.probability > 0.9) - ){ - starsDecimal = starsDecimal - 1 - } + let nuno = (data) => (data.volume > 10000 ? 4 : data.volume > 1000 ? 3 : 2); + // let eli = (data) => data.liquidity > 10000 ? 5 : 4 + // let misha = (data) => 4 + let starsDecimal = average([nuno(data)]); //, eli(data), misha(data)]) + // Substract 1 star if probability is above 90% or below 10% + if ( + data.option && + (data.option.probability < 0.1 || data.option.probability > 0.9) + ) { + starsDecimal = starsDecimal - 1; + } - let starsInteger = Math.round(starsDecimal) - return starsInteger + let starsInteger = Math.round(starsDecimal); + return starsInteger; } function calculateStarsPredictIt(data) { - let nuno = data => 3 - let eli = (data) => 3.5 - let misha = (data) => 2.5 - let starsDecimal = average([nuno(data), eli(data), misha(data)]) - let starsInteger = Math.round(starsDecimal) - return starsInteger + let nuno = (data) => 3; + let eli = (data) => 3.5; + let misha = (data) => 2.5; + let starsDecimal = average([nuno(data), eli(data), misha(data)]); + let starsInteger = Math.round(starsDecimal); + return starsInteger; } function calculateStarsRootclaim(data) { - let nuno = data => 4 - let eli = (data) => null - let misha = (data) => null - let starsDecimal = average([nuno(data)/*, eli(data), misha(data)*/]) - let starsInteger = Math.round(starsDecimal) - return starsInteger + let nuno = (data) => 4; + let eli = (data) => null; + let misha = (data) => null; + let starsDecimal = average([nuno(data) /*, eli(data), misha(data)*/]); + let starsInteger = Math.round(starsDecimal); + return starsInteger; } function calculateStarsSmarkets(data) { - let nuno = data => 2 - let eli = (data) => null - let misha = (data) => null - let starsDecimal = average([nuno(data)]) //, eli(data), misha(data)]) - let starsInteger = Math.round(starsDecimal) - return starsInteger + let nuno = (data) => 2; + let eli = (data) => null; + let misha = (data) => null; + let starsDecimal = average([nuno(data)]); //, eli(data), misha(data)]) + let starsInteger = Math.round(starsDecimal); + return starsInteger; } - function calculateStarsWildeford(data) { - let nuno = data => 3 - let eli = (data) => null - let misha = (data) => null - let starsDecimal = average([nuno(data)]) //, eli(data), misha(data)]) - let starsInteger = Math.round(starsDecimal) - return starsInteger + let nuno = (data) => 3; + let eli = (data) => null; + let misha = (data) => null; + let starsDecimal = average([nuno(data)]); //, eli(data), misha(data)]) + let starsInteger = Math.round(starsDecimal); + return starsInteger; } function calculateStarsWilliamHill(data) { - let nuno = data => 2 - let eli = (data) => null - let misha = (data) => null - let starsDecimal = average([nuno(data)]) //, eli(data), misha(data)]) - let starsInteger = Math.round(starsDecimal) - return starsInteger + let nuno = (data) => 2; + let eli = (data) => null; + let misha = (data) => null; + let starsDecimal = average([nuno(data)]); //, eli(data), misha(data)]) + let starsInteger = Math.round(starsDecimal); + return starsInteger; } export function calculateStars(platform, data) { - let stars = 2; - switch (platform) { - case "AstralCodexTen": - stars = calculateStarsAstralCodexTen(data) - break; - case "Betfair": - stars = calculateStarsBetfair(data) - break; - case "CoupCast": - stars = calculateStarsCoupCast(data) - break; - case "CSET-foretell": - stars = calculateStarsCSETForetell(data) - break; - case "Elicit": - stars = calculateStarsElicit(data) - break; - case "Estimize": - stars = calculateStarsEstimize(data) - break; - case "Foretold": - stars = calculateStarsForetold(data) - break; - case "GiveWell/OpenPhilanthropy": - stars = calculateStarsGiveWellOpenPhil(data) - break; - case "Good Judgment": - stars = calculateStarsGoodJudment(data) - break; - case "Good Judgment Open": - stars = calculateStarsGoodJudmentOpen(data) - break; - case "Hypermind": - stars = calculateStarsHypermind(data) - break; - case "Kalshi": - stars = calculateStarsKalshi(data) - break; - case "Ladbrokes": - stars = calculateStarsLadbrokes(data) - break; - case "Manifold Markets": - stars = calculateStarsManifoldMarkets(data) - break; - case "Metaculus": - stars = calculateStarsMetaculus(data) - break; - case "Omen": - stars = calculateStarsOmen(data) - break; - case "Polymarket": - stars = calculateStarsPolymarket(data) - break; - case "PredictIt": - stars = calculateStarsPredictIt(data) - break; - case "Rootclaim": - stars = calculateStarsRootclaim(data) - break; - case "Smarkets": - stars = calculateStarsSmarkets(data) - break; - case "Peter Wildeford": - stars = calculateStarsWildeford(data) - break; - case "WilliamHill": - stars = calculateStarsWilliamHill(data) - break; - default: - stars = 2 - } - return stars + let stars = 2; + switch (platform) { + case "AstralCodexTen": + stars = calculateStarsAstralCodexTen(data); + break; + case "Betfair": + stars = calculateStarsBetfair(data); + break; + case "CoupCast": + stars = calculateStarsCoupCast(data); + break; + case "CSET-foretell": + stars = calculateStarsCSETForetell(data); + break; + case "Elicit": + stars = calculateStarsElicit(data); + break; + case "Estimize": + stars = calculateStarsEstimize(data); + break; + case "Foretold": + stars = calculateStarsForetold(data); + break; + case "GiveWell/OpenPhilanthropy": + stars = calculateStarsGiveWellOpenPhil(data); + break; + case "Good Judgment": + stars = calculateStarsGoodJudment(data); + break; + case "Good Judgment Open": + stars = calculateStarsGoodJudmentOpen(data); + break; + case "Hypermind": + stars = calculateStarsHypermind(data); + break; + case "Kalshi": + stars = calculateStarsKalshi(data); + break; + case "Ladbrokes": + stars = calculateStarsLadbrokes(data); + break; + case "Manifold Markets": + stars = calculateStarsManifoldMarkets(data); + break; + case "Metaculus": + stars = calculateStarsMetaculus(data); + break; + case "Omen": + stars = calculateStarsOmen(data); + break; + case "Polymarket": + stars = calculateStarsPolymarket(data); + break; + case "PredictIt": + stars = calculateStarsPredictIt(data); + break; + case "Rootclaim": + stars = calculateStarsRootclaim(data); + break; + case "Smarkets": + stars = calculateStarsSmarkets(data); + break; + case "Peter Wildeford": + stars = calculateStarsWildeford(data); + break; + case "WilliamHill": + stars = calculateStarsWilliamHill(data); + break; + default: + stars = 2; + } + return stars; }