feat: save Insight Prediction progress

Note that the fetcher is subject to this bug:
<https://github.com/quantified-uncertainty/metaforecast/issues/94>

which means that it'll hit insight pretty hard.
This commit is contained in:
NunoSempere 2022-07-28 14:04:14 -04:00
parent 69ab8f905c
commit 3892db1157
2 changed files with 15 additions and 20 deletions

View File

@ -65,7 +65,7 @@ async function fetchData(bearer: string) {
console.log(`Page = #${pageNum}`); console.log(`Page = #${pageNum}`);
// console.log(newPageData) // console.log(newPageData)
console.dir(finalObject, {depth: null}); // console.dir(finalObject, {depth: null});
results.push(... finalObject); results.push(... finalObject);
let newPagination = newPage.meta.pagination; let newPagination = newPage.meta.pagination;
@ -79,35 +79,30 @@ async function fetchData(bearer: string) {
} }
async function processPredictions(predictions: any[]) { async function processPredictions(predictions: any[]) {
let results = await predictions.map((prediction) => { let filteredPredictions = predictions.filter(prediction => !prediction.is_resolved && prediction.category != "Sports")
let results = filteredPredictions.map((prediction) => {
const id = `${platformName}-${ const id = `${platformName}-${
prediction.id prediction.id
}`; }`;
const probability = prediction.probability; const options: FetchedQuestion["options"] = prediction.options
const options: FetchedQuestion["options"] = [
{
name: "Yes",
probability: probability,
type: "PROBABILITY"
}, {
name: "No",
probability: 1 - probability,
type: "PROBABILITY"
},
];
const result: FetchedQuestion = { const result: FetchedQuestion = {
id, id,
title: prediction.title, title: prediction.title,
url: "https://example.com", url: `https:${
description: prediction.description, prediction.url
}`,
description: prediction.rules,
options, options,
qualityindicators: { qualityindicators: {
volume: prediction.volume,
createdTime: prediction.created_at
// other: prediction.otherx, // other: prediction.otherx,
// indicators: prediction.indicatorx, // indicators: prediction.indicatorx,
} }
}; };
return result; return result;
}); });
// Filter results
return results; // resultsProcessed return results; // resultsProcessed
} }
@ -117,12 +112,12 @@ export const insight: Platform = {
name: platformName, name: platformName,
label: "Insight Prediction", label: "Insight Prediction",
color: "#ff0000", color: "#ff0000",
version: "v0", version: "v1",
async fetcher() { async fetcher() {
let bearer = process.env.INSIGHT_BEARER; let bearer = process.env.INSIGHT_BEARER;
let data = await fetchData(bearer); let data = await fetchData(bearer);
// console.log(data); let results = await processPredictions(data);
let results = []; // await processPredictions(data); // somehow needed console.log(results);
return results; return results;
}, },
calculateStars(data) { calculateStars(data) {

View File

@ -74,7 +74,7 @@ const getCurrencySymbolIfNeeded = ({
"openInterest", "openInterest",
"liquidity", "liquidity",
]; ];
let dollarPlatforms = ["predictit", "kalshi", "polymarket"]; let dollarPlatforms = ["predictit", "kalshi", "polymarket", "insight"];
if (indicatorsWhichNeedCurrencySymbol.includes(indicator)) { if (indicatorsWhichNeedCurrencySymbol.includes(indicator)) {
if (dollarPlatforms.includes(platform)) { if (dollarPlatforms.includes(platform)) {
return "$"; return "$";