tweak: Consolidate the extra field as distinct from the quality indicators field. Replace tabs with spaces.
This commit is contained in:
parent
884cfb2463
commit
9159af7ece
|
@ -22,7 +22,7 @@ async function fetchAllCommunityQuestions(communityId) {
|
||||||
states: OPEN,
|
states: OPEN,
|
||||||
first: 500
|
first: 500
|
||||||
){
|
){
|
||||||
total
|
total
|
||||||
edges{
|
edges{
|
||||||
node{
|
node{
|
||||||
id
|
id
|
||||||
|
|
|
@ -22,7 +22,7 @@ async function fetchAllCommunityQuestions(communityId) {
|
||||||
states: OPEN,
|
states: OPEN,
|
||||||
first: 500
|
first: 500
|
||||||
){
|
){
|
||||||
total
|
total
|
||||||
edges{
|
edges{
|
||||||
node{
|
node{
|
||||||
id
|
id
|
||||||
|
|
|
@ -54,7 +54,9 @@ async function processPredictions(predictions) {
|
||||||
"volume7Days": prediction.volume7Days,
|
"volume7Days": prediction.volume7Days,
|
||||||
"volume24Hours": prediction.volume24Hours,
|
"volume24Hours": prediction.volume24Hours,
|
||||||
"pool": prediction.pool, // normally liquidity, but I don't actually want to show it.
|
"pool": prediction.pool, // normally liquidity, but I don't actually want to show it.
|
||||||
"isResolved": prediction.isResolved
|
},
|
||||||
|
"extra": {
|
||||||
|
"isResolved": prediction.isResolved
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -82,7 +82,7 @@ export async function metaculus() {
|
||||||
await sleep(5000)
|
await sleep(5000)
|
||||||
let questionPage = await fetchMetaculusQuestionDescription(result.page_url)
|
let questionPage = await fetchMetaculusQuestionDescription(result.page_url)
|
||||||
if(!questionPage.includes("A public prediction by")){
|
if(!questionPage.includes("A public prediction by")){
|
||||||
// console.log(questionPage)
|
// console.log(questionPage)
|
||||||
let descriptionraw = questionPage.split(`<div class="content" ng-bind-html-compile="qctrl.question.description_html">`)[1] //.split(`<div class="question__content">`)[1]
|
let descriptionraw = questionPage.split(`<div class="content" ng-bind-html-compile="qctrl.question.description_html">`)[1] //.split(`<div class="question__content">`)[1]
|
||||||
let descriptionprocessed1 = descriptionraw.split("</div>")[0]
|
let descriptionprocessed1 = descriptionraw.split("</div>")[0]
|
||||||
let descriptionprocessed2 = toMarkdown(descriptionprocessed1)
|
let descriptionprocessed2 = toMarkdown(descriptionprocessed1)
|
||||||
|
@ -114,13 +114,15 @@ export async function metaculus() {
|
||||||
"timestamp": new Date().toISOString(),
|
"timestamp": new Date().toISOString(),
|
||||||
"qualityindicators": {
|
"qualityindicators": {
|
||||||
"numforecasts": Number(result.number_of_predictions),
|
"numforecasts": Number(result.number_of_predictions),
|
||||||
|
"stars": calculateStars("Metaculus", ({ numforecasts: result.number_of_predictions }))
|
||||||
|
},
|
||||||
|
"extra": {
|
||||||
"resolution_data": {
|
"resolution_data": {
|
||||||
"publish_time": result.publish_time,
|
"publish_time": result.publish_time,
|
||||||
"resolution": result.resolution,
|
"resolution": result.resolution,
|
||||||
"close_time": result.close_time,
|
"close_time": result.close_time,
|
||||||
"resolve_time": result.resolve_time
|
"resolve_time": result.resolve_time
|
||||||
},
|
}
|
||||||
"stars": calculateStars("Metaculus", ({ numforecasts: result.number_of_predictions }))
|
|
||||||
}
|
}
|
||||||
//"status": result.status,
|
//"status": result.status,
|
||||||
//"publish_time": result.publish_time,
|
//"publish_time": result.publish_time,
|
||||||
|
|
|
@ -117,9 +117,11 @@ async function fetch_all() {
|
||||||
"liquidity": liquidity.toFixed(2),
|
"liquidity": liquidity.toFixed(2),
|
||||||
"tradevolume": tradevolume.toFixed(2),
|
"tradevolume": tradevolume.toFixed(2),
|
||||||
"stars": calculateStars("Polymarket", ({ liquidity, option: options[0], volume: tradevolume}))
|
"stars": calculateStars("Polymarket", ({ liquidity, option: options[0], volume: tradevolume}))
|
||||||
|
},
|
||||||
|
"extra": {
|
||||||
|
"address": info.address
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
address: info.address
|
|
||||||
*/
|
*/
|
||||||
})
|
})
|
||||||
if(info.category != "Sports"){
|
if(info.category != "Sports"){
|
||||||
|
|
|
@ -15,107 +15,107 @@ const endpoint = `https://docs.google.com/spreadsheets/d/${SHEET_ID}/edit#gid=0`
|
||||||
/* Support functions */
|
/* Support functions */
|
||||||
|
|
||||||
const formatRow = row => {
|
const formatRow = row => {
|
||||||
let colNames = ["Prediction Date", "Prediction", "Odds", "Actual", "Resolution Date", "Prediction Right?", "Brier Score", "Notes"]
|
let colNames = ["Prediction Date", "Prediction", "Odds", "Actual", "Resolution Date", "Prediction Right?", "Brier Score", "Notes"]
|
||||||
let result = ({})
|
let result = ({})
|
||||||
row.forEach((col,i) => {
|
row.forEach((col,i) => {
|
||||||
result[colNames[i]] = col
|
result[colNames[i]] = col
|
||||||
})
|
})
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchGoogleDoc(google_api_key){
|
async function fetchGoogleDoc(google_api_key){
|
||||||
// https://gist.github.com/micalevisk/9bc831bd4b3e5a3f62b9810330129c59
|
// https://gist.github.com/micalevisk/9bc831bd4b3e5a3f62b9810330129c59
|
||||||
let results = []
|
let results = []
|
||||||
const doc = new GoogleSpreadsheet(SHEET_ID)
|
const doc = new GoogleSpreadsheet(SHEET_ID)
|
||||||
doc.useApiKey(google_api_key)
|
doc.useApiKey(google_api_key)
|
||||||
|
|
||||||
await doc.loadInfo() // loads document properties and worksheets
|
await doc.loadInfo() // loads document properties and worksheets
|
||||||
console.log('>>', doc.title)
|
console.log('>>', doc.title)
|
||||||
|
|
||||||
const sheet = doc.sheetsByIndex[0]
|
const sheet = doc.sheetsByIndex[0]
|
||||||
const rows = await sheet.getRows({ offset:0, })
|
const rows = await sheet.getRows({ offset:0, })
|
||||||
|
|
||||||
console.log('# ' +
|
console.log('# ' +
|
||||||
rows[0]._sheet.headerValues.join(',')
|
rows[0]._sheet.headerValues.join(',')
|
||||||
)
|
)
|
||||||
let isEnd = false;
|
let isEnd = false;
|
||||||
for (let i in rows) {
|
for (let i in rows) {
|
||||||
let data = rows[i]._rawData
|
let data = rows[i]._rawData
|
||||||
if(data.length == 0) isEnd = true;
|
if(data.length == 0) isEnd = true;
|
||||||
if(!isEnd){
|
if(!isEnd){
|
||||||
let result = ({...formatRow(data), "url": endpoint + `&range=A${(Number(i) + 2)}`})
|
let result = ({...formatRow(data), "url": endpoint + `&range=A${(Number(i) + 2)}`})
|
||||||
// +2: +1 for the header row, +1 for starting at 1 and not at 0.
|
// +2: +1 for the header row, +1 for starting at 1 and not at 0.
|
||||||
// console.log(result)
|
// console.log(result)
|
||||||
results.push(result)
|
results.push(result)
|
||||||
|
|
||||||
// console.log(rows[i])
|
// console.log(rows[i])
|
||||||
// console.log(rows[i]._rawData)
|
// console.log(rows[i]._rawData)
|
||||||
// console.log(rows[i]["Prediction"])
|
// console.log(rows[i]["Prediction"])
|
||||||
}
|
}
|
||||||
// console.log(row._rawData.join(','))
|
// console.log(row._rawData.join(','))
|
||||||
// console.log(row._rawData.join(','))
|
// console.log(row._rawData.join(','))
|
||||||
}
|
}
|
||||||
// console.log(results)
|
// console.log(results)
|
||||||
return(results)
|
return(results)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function processPredictions(predictions){
|
async function processPredictions(predictions){
|
||||||
let currentPredictions = predictions.filter(prediction => prediction["Actual"] == "Unknown" )
|
let currentPredictions = predictions.filter(prediction => prediction["Actual"] == "Unknown" )
|
||||||
let results = currentPredictions.map(prediction => {
|
let results = currentPredictions.map(prediction => {
|
||||||
let probability = Number(prediction["Odds"].replace("%", ""))/100
|
let probability = Number(prediction["Odds"].replace("%", ""))/100
|
||||||
let options = [
|
let options = [
|
||||||
{
|
{
|
||||||
"name": "Yes",
|
"name": "Yes",
|
||||||
"probability": probability,
|
"probability": probability,
|
||||||
"type": "PROBABILITY"
|
"type": "PROBABILITY"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "No",
|
"name": "No",
|
||||||
"probability": 1 - probability,
|
"probability": 1 - probability,
|
||||||
"type": "PROBABILITY"
|
"type": "PROBABILITY"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
let result = ({
|
let result = ({
|
||||||
"title": prediction["Prediction"],
|
"title": prediction["Prediction"],
|
||||||
"url": prediction["url"],
|
"url": prediction["url"],
|
||||||
"platform": "Peter Wildeford",
|
"platform": "Peter Wildeford",
|
||||||
"description": prediction["Notes"] || "",
|
"description": prediction["Notes"] || "",
|
||||||
"options": options,
|
"options": options,
|
||||||
"timestamp": new Date(Date.parse(prediction["Prediction Date"] + "Z")).toISOString(),
|
"timestamp": new Date(Date.parse(prediction["Prediction Date"] + "Z")).toISOString(),
|
||||||
"qualityindicators": {
|
"qualityindicators": {
|
||||||
"stars": calculateStars("Peter Wildeford"),
|
"stars": calculateStars("Peter Wildeford"),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return result
|
return result
|
||||||
})
|
})
|
||||||
results = results.map(result => ({...result, title: result.title.replace(" [update]", "")})).reverse()
|
results = results.map(result => ({...result, title: result.title.replace(" [update]", "")})).reverse()
|
||||||
|
|
||||||
let uniqueTitles = []
|
let uniqueTitles = []
|
||||||
let uniqueResults = []
|
let uniqueResults = []
|
||||||
results.forEach(result => {
|
results.forEach(result => {
|
||||||
if(!uniqueTitles.includes(result.title)) uniqueResults.push(result)
|
if(!uniqueTitles.includes(result.title)) uniqueResults.push(result)
|
||||||
uniqueTitles.push(result.title)
|
uniqueTitles.push(result.title)
|
||||||
})
|
})
|
||||||
return(uniqueResults)
|
return(uniqueResults)
|
||||||
// console.log(results)
|
// console.log(results)
|
||||||
// console.log(results.map(result => result.options))
|
// console.log(results.map(result => result.options))
|
||||||
}
|
}
|
||||||
// processPredictions()
|
// processPredictions()
|
||||||
|
|
||||||
/* Body */
|
/* Body */
|
||||||
export async function wildeford_inner(google_api_key) {
|
export async function wildeford_inner(google_api_key) {
|
||||||
let predictions = await fetchGoogleDoc(google_api_key)
|
let predictions = await fetchGoogleDoc(google_api_key)
|
||||||
let results = await processPredictions(predictions) // somehow needed
|
let results = await processPredictions(predictions) // somehow needed
|
||||||
// console.log(results)
|
// console.log(results)
|
||||||
// let string = JSON.stringify(results, null, 2)
|
// let string = JSON.stringify(results, null, 2)
|
||||||
// fs.writeFileSync('polyprediction-questions.json', string);
|
// fs.writeFileSync('polyprediction-questions.json', string);
|
||||||
await upsert(results, "wildeford-questions")
|
await upsert(results, "wildeford-questions")
|
||||||
console.log("Done")
|
console.log("Done")
|
||||||
}
|
}
|
||||||
//example()
|
//example()
|
||||||
|
|
||||||
export async function wildeford(){
|
export async function wildeford(){
|
||||||
const GOOGLE_API_KEY = process.env.GOOGLE_API_KEY || getCookie("google-api") // See: https://developers.google.com/sheets/api/guides/authorizing#APIKey
|
const GOOGLE_API_KEY = process.env.GOOGLE_API_KEY || getCookie("google-api") // See: https://developers.google.com/sheets/api/guides/authorizing#APIKey
|
||||||
await applyIfCookieExists(GOOGLE_API_KEY, wildeford_inner)
|
await applyIfCookieExists(GOOGLE_API_KEY, wildeford_inner)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user