Added Rootclaim to backend

This commit is contained in:
NunoSempere 2021-06-27 19:22:54 +02:00
parent d733804a72
commit 13481b8b0b
5 changed files with 86 additions and 5 deletions

View File

@ -14,9 +14,10 @@ import {goodjudgmentopen} from "./platforms/goodjudmentopen-fetch.js"
import {hypermind} from "./platforms/hypermind-fetch.js"
import {ladbrokes} from "./platforms/ladbrokes-fetch.js"
import {metaculus} from "./platforms/metaculus-fetch.js"
import {omen} from "./platforms/omen-fetch.js"
import {polymarket} from "./platforms/polymarket-fetch.js"
import {predictit} from "./platforms/predictit-fetch.js"
import {omen} from "./platforms/omen-fetch.js"
import {rootclaim} from "./platforms/rootclaim-fetch.js"
import {smarkets} from "./platforms/smarkets-fetch.js"
import {williamhill} from "./platforms/williamhill-fetch.js"
@ -26,7 +27,7 @@ import {rebuildNetlifySiteWithNewData} from "./utils/rebuildNetliftySiteWithNewD
import {doEverything, tryCatchTryAgain} from "./utils/doEverything.js"
/* Support functions */
let functions = [astralcodexten, coupcast, csetforetell, elicit, /* estimize, */ fantasyscotus, foretold, goodjudgment, goodjudgmentopen, hypermind, ladbrokes, metaculus, polymarket, predictit, omen, smarkets, williamhill, mergeEverything, addToHistory, rebuildNetlifySiteWithNewData, doEverything]
let functions = [astralcodexten, coupcast, csetforetell, elicit, /* estimize, */ fantasyscotus, foretold, goodjudgment, goodjudgmentopen, hypermind, ladbrokes, metaculus, omen, polymarket, predictit, rootclaim, smarkets, williamhill, mergeEverything, addToHistory, rebuildNetlifySiteWithNewData, doEverything]
let functionNames = functions.map(fun => fun.name)
let whattodoMessage = functionNames

View File

@ -0,0 +1,67 @@
/* Imports */
import fs from 'fs'
import axios from "axios"
import { calculateStars } from "../utils/stars.js"
import {upsert} from "../utils/mongo-wrapper.js"
/* Definitions */
let jsonEndpoint = "https://www.rootclaim.com/main_page_stories?number=100&offset=0"//"https://subgraph-matic.poly.market/subgraphs/name/TokenUnion/polymarket"//"https://subgraph-backup.poly.market/subgraphs/name/TokenUnion/polymarket"//'https://subgraph-matic.poly.market/subgraphs/name/TokenUnion/polymarket3'
/* Support functions
async function fetchAllContractInfo(){ // for info which the polymarket graphql API
let data = fs.readFileSync("./data/polymarket-contract-list.json")
let response = JSON.parse(data)
return response
}
*/
async function fetchAllRootclaims() { // for info which the polymarket graphql API
let response = await axios.get(jsonEndpoint)
.then(response => response.data)
if(response.length != (response[0]+1)){
console.log(response.length)
console.log(response[0])
//throw Error("Rootclaim's backend has changed.")
}
response.shift()
return response
}
async function fetchAndProcessData() {
let claims = await fetchAllRootclaims()
let results = []
for (let claim of claims) {
let options = []
for (let scenario in claim.scenarios) {
options.push({
"name": scenario.name,
"probability": scenario.net_prob / 100,
"type": "PROBABILITY"
})
}
let obj = ({
"title": claim.question,
"url": "https://www.rootclaim.com/analysis/"+claim.slug,
"platform": "Rootclaim",
"description": claim.background,
"options": options,
"timestamp": new Date().toISOString(),
"qualityindicators": {
"numforecasts": 1,
"stars": calculateStars("Rootclaim", ({}))
}
})
results.push(obj)
}
return results
}
/* Body */
export async function rootclaim() {
let results = await fetchAndProcessData()
// console.log(results)
// let string = JSON.stringify(results, null, 2)
// fs.writeFileSync('rootclaim-questions.json', string);
await upsert(results, "rootclaim-questions")
console.log("Done")
}
//rootclaim()

View File

@ -10,9 +10,10 @@ import {goodjudgmentopen} from "../platforms/goodjudmentopen-fetch.js"
import {hypermind} from "../platforms/hypermind-fetch.js"
import {ladbrokes} from "../platforms/ladbrokes-fetch.js"
import {metaculus} from "../platforms/metaculus-fetch.js"
import {omen} from "../platforms/omen-fetch.js"
import {polymarket} from "../platforms/polymarket-fetch.js"
import {predictit} from "../platforms/predictit-fetch.js"
import {omen} from "../platforms/omen-fetch.js"
import {rootclaim} from "../platforms/rootclaim-fetch.js"
import {smarkets} from "../platforms/smarkets-fetch.js"
import {williamhill} from "../platforms/williamhill-fetch.js"
import {mergeEverything} from "./mergeEverything.js"
@ -36,7 +37,7 @@ export async function tryCatchTryAgain (fun) {
}
}
export async function doEverything(){
let functions = [coupcast, csetforetell, elicit, /* estimize, */ fantasyscotus, foretold, /* goodjudgment, */ goodjudgmentopen, hypermind, ladbrokes, metaculus, polymarket, predictit, omen, smarkets, williamhill, mergeEverything, /*addToHistory,*/rebuildNetlifySiteWithNewData]
let functions = [coupcast, csetforetell, elicit, /* estimize, */ fantasyscotus, foretold, /* goodjudgment, */ goodjudgmentopen, hypermind, ladbrokes, metaculus, omen, polymarket, predictit, rootclaim, smarkets, williamhill, mergeEverything, /*addToHistory,*/rebuildNetlifySiteWithNewData]
// Removed Good Judgment from the fetcher, doing it using cron instead because cloudflare blocks the utility on heroku.
console.log("")

View File

@ -1,7 +1,7 @@
import { mongoRead, upsert } from "./mongo-wrapper.js"
/* Merge everything */
let sets = ["astralcodexten","coupcast", "csetforetell", "elicit", "estimize", "fantasyscotus", "foretold", "givewellopenphil", "goodjudgment","goodjudmentopen", "hypermind", "ladbrokes", "metaculus", "polymarket", "predictit", "omen", "smarkets", "williamhill", "xrisk"]
let sets = ["astralcodexten","coupcast", "csetforetell", "elicit", "estimize", "fantasyscotus", "foretold", "givewellopenphil", "goodjudgment","goodjudmentopen", "hypermind", "ladbrokes", "metaculus", "omen", "polymarket", "predictit", "rootclaim", "smarkets", "williamhill", "xrisk"]
let suffix = "-questions"
export async function mergeEverything(){

View File

@ -167,6 +167,15 @@ function calculateStarsPredictIt(data) {
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
}
function calculateStarsSmarkets(data) {
let nuno = data => 2
let eli = (data) => null
@ -233,6 +242,9 @@ export function calculateStars(platform, data) {
case "PredictIt":
stars = calculateStarsPredictIt(data)
break;
case "Rootclaim":
stars = calculateStarsRootclaim(data)
break;
case "Smarkets":
stars = calculateStarsSmarkets(data)
break;