This Is A File
This Is A File
<head>
<title>Main Stock Market Analysis</title>
<link href="index.css" type="text/css" rel="stylesheet">
</head>
<SCRIPT language=JavaScript>
var message = "function disabled";
<div id ="stock-info">
<div id="stock-chart">
<div class="chart-container">
<canvas id="chartCanvas" width="800" height="400"></canvas>
<div class="chart-tooltip" id="tooltip"></div>
<div class="x-axis-label" id="xAxisLabel"></div>
</div>
<div id="button">
<button id="btn1d">1 Month</button>
<button id="btn1mo">3 Month</button>
<button id="btn1y">1 Year</button>
<button id="btn5y">5 Years</button>
</div>
</div>
<div id ="summary">
<div><span id="name"></span> <span
id="profit"> </span> <span id ="bookValue"></span></div>
<p></p>
</div>
</div>
<div id="stock-list"></div>
</div>
<script src="index.js" type="module"></script>
<!-- <script>
document.addEventListener("keydown", function(e) {
if (
(e.ctrlKey && e.shiftKey && e.keyCode === 67) || // Ctrl + Shift + C
(Copy)
(e.ctrlKey && e.shiftKey && e.keyCode === 73) || // Ctrl + Shift + I
(Inspect)
e.keyCode === 123 || // F12 (Developer Tools)
(e.metaKey && e.shiftKey && e.keyCode === 67) || // Command + Shift + C
(Copy)
(e.metaKey && e.shiftKey && e.keyCode === 73) // Command + Shift + I
(Inspect)
) {
e.preventDefault();
console.log("This key combination is disabled.");
}
}); -->
<!-- </script> -->
</body>
</html>
#################################
body {
font-family: Arial, sans-serif;
padding: 20px;
background-color: rgb(1, 1, 41);
color: white;
}
#header{
height: 10%;
width: 100%;
justify-content: center;
text-align: center;
margin-bottom: 20px;
canvas {
/* border: 1px solid #ccc; */
}
.chart-container {
position: relative;
}
.chart-tooltip {
position: absolute;
display: none;
padding: 5px;
/* background-color: rgba(0, 0, 0, 0.7); */
background-color: rgb(1, 1, 69);
color: #fff;
font-size: 12px;
border-radius: 5px;
pointer-events: none;
}
.x-axis-label {
position: absolute;
bottom: -20px;
font-size: 10px;
color: #888;
}
#stock-chart{
/* background-color: rgb(34, 34, 34); */
background-color: rgb(1, 1, 69);
border-radius: 10px;
width: 60%;
margin-top: 10px;
padding-top: 20px;
/* border: 2px solid transparent;
border-image: linear-gradient(to right, #f00, #0f0, #00f);
border-image-slice: 1;
animation: fade 5s infinite; */
}
#stock-chart button{
background-color: rgb(2, 2, 116);
/* opacity: .7; */
font-size: 18px;
color: white;
border-radius: 20px;
border: none;
margin-right: 40px;
margin-bottom: 10px;
}
#chart-canvas{
margin-top: 10px;
padding-top: 10px;
}
#stock-chart button:hover{
opacity: 1;
background-color: rgb(3, 3, 131);
color: white;
border-radius: 20px;
cursor: pointer;
/* margin-right: 20px ; */
}
#summary{
margin-top: 20px;
width: 60%;
}
#summary p{
font-size: 12px;
display: flex;
justify-content: center;
}
#name{
/* font-weight: 100; */
font-size: 20px;
font-weight: bolder;
}
#profit{
/* font-weight: 100; */
font-size: 20px;
font-weight: bolder;
}
#bookValue{
/* font-weight: 100; */
font-size: 20px;
font-weight: bolder;
}
#container{
display: flex;
}
#stock-list{
position: absolute;
right: 80px;
}
.list{
position: relative;
right: 0px;
height: 30px;
width: 60px;
/* padding: 10px; */
color: white;
justify-content: center;
align-items: center ;
margin: 5px;
border-radius: 5px;
/* padding-left: 30px; */
background-color: rgb(1, 1, 102);
}
.list:hover{
background-color: rgb(1, 1, 41);
cursor: pointer;
}
.list span{
margin-right: 10px ;
}
#button{
margin-top:30px ;
display: flex;
justify-content: center;
padding-left: 10px;
}
.list_i span{
margin: 10px;
}
######################################
import fetchAndCreateChart from "./charts.js";
// import {st} from "./charts"
let st = "AAPL";
fetchAndCreateChart('5y',st);
try {
const response = await fetch(url);
const result = await response.json();
const bookValue = result.stocksStatsData[0][symbol].bookValue;
const profit = result.stocksStatsData[0][symbol].profit;
const stocksummary = document.querySelector('#summary');
stocksummary.querySelector('#name').textContent = symbol;
const Profit = document.getElementById("profit")
Profit.textContent = `${profit}%`;
if (profit > 0) {
Profit.setAttribute('style', 'color: green');
} else {
Profit.setAttribute('style', 'color: red');
}
document.getElementById("bookValue").textContent = `$${bookValue}`;
} catch (error) {
console.error(error);
}
}
#######################################
// export let st = "AAPL"
import {getStocks,getStats} from "./index.js"
let st;
export default async function fetchAndCreateChart(range = "5y",symbol ="AMRN") {
st = symbol;
try {
const response = await fetch(url);
const result = await response.json();
console.log(result);
// consoele.log("hello");
// console.log(result.stocksData[0].AAPL)
let chartData = result.stocksData[0][st][range].value;
let labels = result.stocksData[0][st][range].timeStamp;
onedaybtn.addEventListener('click',()=>{
fetchAndCreateChart("1mo",st);
})
onemonbtn.addEventListener('click',()=>{
fetchAndCreateChart("3mo",st);
})
oneyrbtn.addEventListener('click',()=>{
fetchAndCreateChart("1y",st);
})
fiveyrbtn.addEventListener('click',()=>{
fetchAndCreateChart("5y",st);
})
tooltip.style.display = 'block';
tooltip.style.left = `${x + 10}px`;
tooltip.style.top = `${y - 20}px`;
tooltip.textContent = `${stockName}: $${stockValue}`;
xAxisLabel.style.display = 'block';
xAxisLabel.style.fontSize = '14px';
xAxisLabel.style.fontWeight = 'bolder';
xAxisLabel.style.left = `${x}px`;
xAxisLabel.textContent = xAxisValue;
// Clear the canvas except for the vertical line and data point
ctx.clearRect(0, 0, canvas.width, chartHeight);
ctx.clearRect(0, chartHeight + 20, canvas.width, canvas.height - chartHeight
- 20);
// Draw a vertical line at the current x position when hovering over the
chart
ctx.beginPath();
ctx.moveTo(x, 0);
ctx.lineTo(x, chartHeight);
ctx.strokeStyle = '#ccc';
ctx.stroke();
canvas.addEventListener('mouseout', () => {
tooltip.style.display = 'none';
xAxisLabel.style.display = 'none';
ctx.clearRect(0, 0, canvas.width, canvas.height);
drawChart(data, labels, stockName);
});
##################################################