From d9b654d19e089b1883fd9e4644ca2552e3487346 Mon Sep 17 00:00:00 2001 From: NunoSempere Date: Fri, 3 Sep 2021 23:00:07 +0200 Subject: [PATCH] fix: Changed units of Kalshi volume to shares traded - Previously was in dollars - Also some tweaks to stars - Also some tweaks too Good Judgment fetching1 --- src/platforms/goodjudgment-fetch.js | 15 ++++++++++----- src/platforms/kalshi-fetch.js | 6 +++--- src/utils/stars.js | 4 ++-- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/platforms/goodjudgment-fetch.js b/src/platforms/goodjudgment-fetch.js index d347c29..6e6e606 100644 --- a/src/platforms/goodjudgment-fetch.js +++ b/src/platforms/goodjudgment-fetch.js @@ -21,9 +21,10 @@ export async function goodjudgment() { let jsonTable = Tabletojson.convert(content, { stripHtmlFromCells: false }) jsonTable.shift() // deletes first element jsonTable.pop() // deletes last element - if (endpoint == endpoints[1]) jsonTable.pop() // pop again - //console.log(jsonTable) + if (endpoint == endpoints[1]) jsonTable.pop() // pop again\ + // console.log(jsonTable) for (let table of jsonTable) { + // console.log(table) let title = table[0]['0'] .split("\t\t\t") .splice(3)[0] @@ -50,7 +51,11 @@ export async function goodjudgment() { probability: Number(row['3'].split("%")[0]) / 100, type: "PROBABILITY" })) - let analysis = table.filter(row => row[0].includes("Examples of Superforecaster commentary"))[0][0] + let analysis = table.filter(row => row[0]? row[0].toLowerCase().includes("commentary") : false) + // "Examples of Superforecaster Commentary" / Analysis + // The following is necessary twite, because we want to check if there is an empty list, and then get the first element of the first element of the list. + analysis = analysis ? analysis[0] : "" + analysis = analysis ? analysis[0] : "" // console.log(analysis) let standardObj = ({ "title": title, @@ -63,7 +68,7 @@ export async function goodjudgment() { "stars": calculateStars("Good Judgment", ({})), }, "extra": { - "superforecastercommentary": analysis + "superforecastercommentary": analysis || "" } }) results.push(standardObj) @@ -73,7 +78,7 @@ export async function goodjudgment() { let string = JSON.stringify(results, null, 2) // fs.writeFileSync('./data/goodjudgment-questions.json', string); // fs.writeFileSync('./goodjudgment-questions-test.json', string); - // console.log(results) + console.log(results) await upsert(results, "goodjudgment-questions") console.log("Done") } diff --git a/src/platforms/kalshi-fetch.js b/src/platforms/kalshi-fetch.js index 3784234..a7ba28a 100644 --- a/src/platforms/kalshi-fetch.js +++ b/src/platforms/kalshi-fetch.js @@ -47,12 +47,12 @@ async function processMarkets(markets) { "options": options, "timestamp": new Date().toISOString(), "qualityindicators": { - "stars": calculateStars("Kalshi", ({volume: market.volume, interest: market.open_interest})), + "stars": calculateStars("Kalshi", ({shares_volume: market.volume, interest: market.open_interest})), "yes_bid": market.yes_bid, "yes_ask": market.yes_ask, "spread": Math.abs(market.yes_bid-market.yes_ask), - "volume": market.volume, - "open_interest": market.open_interest + "shares_volume": market.volume, // Assuming that half of all buys are for yes and half for no, which is a big if. + // "open_interest": market.open_interest, also in shares } }) return result diff --git a/src/utils/stars.js b/src/utils/stars.js index bb6a0ed..447d08f 100644 --- a/src/utils/stars.js +++ b/src/utils/stars.js @@ -132,8 +132,8 @@ function calculateStarsHypermind(data) { } function calculateStarsKalshi(data) { - let nuno = data => data.interest > 500 && data.volume > 10000 ? 4 : (data.volume > 1000 ? 3 : 2) - let eli = (data) => data.interest > 10000 ? 5 : 4 + 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%