vault backup: 2023-11-06 14:26:45
This commit is contained in:
parent
2651b40e45
commit
77c7162ecd
21
api.ts
21
api.ts
@ -37,10 +37,31 @@ function apply_guidance(doc: any) {
|
|||||||
for (let key of Object.keys(doc.hist)) {
|
for (let key of Object.keys(doc.hist)) {
|
||||||
// Update each item in the current key with the most recent price
|
// Update each item in the current key with the most recent price
|
||||||
updateWithMostRecentPrice(doc.hist[key]);
|
updateWithMostRecentPrice(doc.hist[key]);
|
||||||
|
console.log(doc.chan[0]);
|
||||||
|
assignRelevanceIndicator(doc.hist[key], doc.chan[0], doc.v1ds, doc.v0ds);
|
||||||
}
|
}
|
||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function assignRelevanceIndicator(items, channelFirstChar, v1ds, v0ds) {
|
||||||
|
for (let item of items) {
|
||||||
|
// Check if the first character of the item's channel matches the first character of the document's channel
|
||||||
|
let relevance = (item.chan === channelFirstChar) ? 'relevant' : 'not relevant';
|
||||||
|
|
||||||
|
// Further refine relevance based on v1ds and v0ds
|
||||||
|
if (v1ds === item.v1ds && relevance === 'relevant') {
|
||||||
|
relevance = 'most relevant'; // v1ds is more relevant than v0ds
|
||||||
|
} else if (v0ds === item.v0ds && relevance === 'relevant') {
|
||||||
|
relevance = 'relevant'; // v0ds is relevant but less so than v1ds
|
||||||
|
} else {
|
||||||
|
relevance = 'not relevant'; // Neither v1ds nor v0ds
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assign the calculated relevance to the item
|
||||||
|
item.relevance = relevance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Function to update each item with the most recent price
|
// Function to update each item with the most recent price
|
||||||
function updateWithMostRecentPrice(items) {
|
function updateWithMostRecentPrice(items) {
|
||||||
for (let item of items) {
|
for (let item of items) {
|
||||||
|
Loading…
Reference in New Issue
Block a user