function getTeslaPrice() {
// Eikon API의 올바른 엔드포인트 URL을 확인하세요.
const url = "https://api.refinitiv.com/marketdata/price"; // 예시 URL, 실제 URL로 교체 필요
const options = {
method: "GET",
headers: {
"Authorization": "Bearer 22a107f781ba4bffa71d80362e8e5c188f1f1d49", // API 키를 Authorization 헤더에 포함
"Content-Type": "application/json"
}
// payload: JSON.stringify({ "rics": ["TSLA.O"] }) // 필요 시 요청 본문 추가
};
try {
const response = UrlFetchApp.fetch(url, options);
const data = JSON.parse(response.getContentText());
// Eikon API의 데이터 구조에 맞게 수정하세요
const teslaPrice = data.price; // 실제 데이터 구조에 맞게 조정 필요
return teslaPrice;
} catch (e) {
Logger.log("Error fetching data: " + e.message);
return "Error";
}
}
function updateTeslaPriceInSheet() {
const price = getTeslaPrice();
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("고유계정 시트");
if (sheet) {
sheet.getRange("C141").setValue(price);
} else {
Logger.log("Sheet named '고유계정 시트' not found.");
}
}
I received an Error 404 when I used the code with Google Apps Script in Google Sheets. Could you please tell me what might be wrong with the code? I want to retrieve the current Tesla stock price. If the endpoint code is incorrect, could you provide the correct endpoint? Additionally, please provide the Python library for this task as well. Your help is urgently needed. Thank you.