Skip to content

Commit

Permalink
feat: save Insight Prediction progress
Browse files Browse the repository at this point in the history
Note that the fetcher is subject to this bug:
<#94>

which means that it'll hit insight pretty hard.
  • Loading branch information
NunoSempere committed Jul 28, 2022
1 parent 69ab8f9 commit 3892db1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 20 deletions.
33 changes: 14 additions & 19 deletions src/backend/platforms/insight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ async function fetchData(bearer: string) {

console.log(`Page = #${pageNum}`);
// console.log(newPageData)
console.dir(finalObject, {depth: null});
// console.dir(finalObject, {depth: null});
results.push(... finalObject);

let newPagination = newPage.meta.pagination;
Expand All @@ -79,35 +79,30 @@ async function fetchData(bearer: string) {
}

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}-${
prediction.id
}`;
const probability = prediction.probability;
const options: FetchedQuestion["options"] = [
{
name: "Yes",
probability: probability,
type: "PROBABILITY"
}, {
name: "No",
probability: 1 - probability,
type: "PROBABILITY"
},
];
const options: FetchedQuestion["options"] = prediction.options
const result: FetchedQuestion = {
id,
title: prediction.title,
url: "https://example.com",
description: prediction.description,
url: `https:${
prediction.url
}`,
description: prediction.rules,
options,
qualityindicators: {
volume: prediction.volume,
createdTime: prediction.created_at
// other: prediction.otherx,
// indicators: prediction.indicatorx,
}
};
return result;
});
// Filter results
return results; // resultsProcessed
}

Expand All @@ -117,12 +112,12 @@ export const insight: Platform = {
name: platformName,
label: "Insight Prediction",
color: "#ff0000",
version: "v0",
version: "v1",
async fetcher() {
let bearer = process.env.INSIGHT_BEARER;
let data = await fetchData(bearer);
// console.log(data);
let results = []; // await processPredictions(data); // somehow needed
let results = await processPredictions(data);
console.log(results);
return results;
},
calculateStars(data) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const getCurrencySymbolIfNeeded = ({
"openInterest",
"liquidity",
];
let dollarPlatforms = ["predictit", "kalshi", "polymarket"];
let dollarPlatforms = ["predictit", "kalshi", "polymarket", "insight"];
if (indicatorsWhichNeedCurrencySymbol.includes(indicator)) {
if (dollarPlatforms.includes(platform)) {
return "$";
Expand Down

0 comments on commit 3892db1

Please sign in to comment.