-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoracleFactors.js
More file actions
85 lines (75 loc) · 3.61 KB
/
oracleFactors.js
File metadata and controls
85 lines (75 loc) · 3.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
const fs = require('fs');
const path = require('path');
const oracleFactorsUSD = new Map([
["Nonfarm Payrolls", ["Initial Jobless Claims", "Continuing Jobless Claims", "ADP Nonfarm Employment Change", "Challenger Job Cuts", "Employment Component (ISM Manufacturing/Services)"]],
["Unemployment Rate", ["Labor Force Participation Rate", "U6 Unemployment Rate", "Job Openings (JOLTS)"]],
["Average Hourly Earnings", ["Employment Cost Index", "Unit Labor Costs", "Wage Growth (Atlanta Fed)"]],
["ISM Manufacturing PMI", ["Factory Orders", "Durable Goods Orders", "Manufacturing Production", "New Orders Index"]],
["ISM Services PMI", ["Services Revenue Surveys", "Business Activity Index", "New Orders Index (Services)"]],
["Retail Sales", ["Consumer Confidence", "Redbook Index", "Vehicle Sales", "Chain Store Sales"]],
["Core Retail Sales", ["Retail Inventories", "Core PCE", "Wholesale Inventories"]],
["CPI", ["PPI", "Import Prices", "Energy Prices", "Rents Index"]],
["Core CPI", ["Owners’ Equivalent Rent", "Used Car Prices", "Medical Care Services Index"]],
["PPI", [
"ISM Manufacturing Prices",
"ISM Non-Manufacturing Prices",
"Crude Oil Inventories",
"CFTC Aluminium speculative net positions",
"CFTC Copper speculative net positions",
"CFTC Corn speculative net positions",
"CFTC Crude Oil speculative net positions",
"CFTC Gold speculative net positions",
"CFTC Natural Gas speculative net positions",
"CFTC Silver speculative net positions",
"CFTC Soybeans speculative net positions",
"CFTC Wheat speculative net positions"
]],
["Core PPI", ["Core Input Prices", "Intermediate Goods Prices"]],
["Initial Jobless Claims", ["State-Level Jobless Reports", "Holiday Effects"]],
["Continuing Jobless Claims", ["Duration of Unemployment", "Rolling Average of Initial Claims"]],
["Fed Interest Rate Decision", ["Core PCE", "CPI", "FOMC Minutes", "Fed Funds Futures"]],
["GDP", ["Atlanta Fed GDPNow", "Inventories", "Trade Balance", "Personal Consumption Expenditures"]],
["Durable Goods Orders", ["Capital Goods Orders", "Business Equipment Orders", "Factory Orders"]],
]);
// 2. Génération automatique du Set des oracles secondaires
const allOracleNames = new Set();
for (const factors of oracleFactorsUSD.values()) {
for (const oracleName of factors) {
allOracleNames.add(oracleName);
}
}
/** Check if a news is an oracle factor (O(1) using Set) */
function isOracleFactor(eventName) {
const normalized = eventName.toLowerCase();
for (const oracle of allOracleNames) {
if (normalized.includes(oracle.toLowerCase())) {
return true;
}
}
return false;
}
function getMainNews(oracleName) {
const normalized = oracleName.toLowerCase();
for (const [main, factors] of oracleFactorsUSD.entries()) {
for (const factor of factors) {
if (normalized.includes(factor.toLowerCase())) {
return main;
}
}
}
return "Unknown";
}
/** Save oracle value to a text file (non-blocking) */
function saveOracle(mode, eventName, actualValue, previousValue) {
const logPath = (mode === "monthly") ? path.join(__dirname, 'oracle_Monthly_data.txt') : path.join(__dirname, 'Daily_data.txt');
const line = `${getMainNews(eventName)} ; ${eventName} ; ${actualValue} ; ${previousValue}\n`;
fs.appendFile(logPath, line, (err) => {
if (err) console.error("Erreur d'écriture oracle:", err);
});
}
module.exports = {
allOracleNames,
oracleFactorsUSD,
isOracleFactor,
saveOracle
};