Generate Stock Date CSV
How do I make an generate stock date csv?
What is a generate stock date csv? How do you make a generate stock date csv? This script and codes were developed by Adnene Manai on 15 October 2022, Saturday.
Generate Stock Date CSV - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Generate Stock Date CSV</title>
</head>
<body> <pre id="csv">
</pre> <script src="js/index.js"></script>
</body>
</html>
Generate Stock Date CSV - Script Codes JS Codes
var MONTHS = { Jan:'01 Jan', Feb:'02 Feb', Mar:'03 Mar', Apr:'04 Apr', May:'05 May', Jun:'06 Jun', Jul:'07 Jul', Aug:'08 Aug', Sep:'09 Sep', Oct:'10 Oct', Nov:'11 Nov', Dec:'12 Dec'
}
var DAYS = { Mon:'01 Mon', Tue:'02 Tue', Wed:'03 Wed', Thu:'04 Thu', Fri:'05 Fri', Sat:'06 Sat', Sun:'07 Sun'
}
var TICKER = [ 'FB', 'MSFT', 'AAPL', 'GOOGL'
]
var startDate = new Date('2011','0','01');
var endDate = new Date - 0;
Date.prototype.getWeek = function() { var onejan = new Date(this.getFullYear(), 0, 1); return Math.ceil((((this - onejan) / 86400000) + onejan.getDay() + 1) / 7);
}
// JSON to CSV Converter
function ConvertToCSV(objArray) { var array = typeof objArray != 'object' ? JSON.parse(objArray) : objArray; var str = ''; for (var i = 0; i < array.length; i++) { var line = ''; for (var index in array[i]) { if (line != '') line += ';' line += array[i][index]; } str += line + '\r\n'; } return str;
}
function getAllDays() { var s = new Date(startDate - 0); var e = new Date(endDate- 0); var a = []; a.push({ id:'id:PK', ticker: 'ticker', day_name:'day_name', month_name:'month_name', day_number:'day_number', year:'year', week_number:'week_number', value_1: 'value_1', value_2: 'value_2', value_3: 'value_3', value_4: 'value_4', value_per:'value_per' },{ id:'string', ticker: 'string', day_name:'string', month_name:'string', day_number:'string', year:'string', week_number:'string', value_1: 'double', value_2: 'double', value_3: 'double', value_4: 'double', value_per: 'double' } ); while(s < e) { var splitDate = s.toDateString().split(' '); TICKER.forEach(function(tiker, idx){ a.push({ id:s.toISOString(), ticker:tiker, day_name:DAYS[splitDate[0]], month_name:MONTHS[splitDate[1]], day_number:("0" + splitDate[2]).slice(-2), year:splitDate[3], week_number:("0" + s.getWeek()).slice(-2), value_1: Math.floor(Math.random() * 1) + 1, value_2: Math.floor(Math.random() * 50) + 1, value_3: Math.floor(Math.random() * 75) + 1, value_4: Math.floor(Math.random() * 2001) - 1000, value_per: Math.random() * idx < 1? 0.05 : 0.01 }); s = new Date(s.setDate(s.getDate() + 1)) }) } return a;
};
console.log(ConvertToCSV(JSON.stringify(getAllDays())));
document.getElementById('csv').innerHTML=ConvertToCSV(JSON.stringify(getAllDays()))
Developer | Adnene Manai |
Username | adnmanai |
Uploaded | October 15, 2022 |
Rating | 3 |
Size | 2,359 Kb |
Views | 14,168 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
A Pen by Adnene Manai | 1,641 Kb |
Etienne Cendrier | 4,564 Kb |
Quick starter with Angularjs | 1,662 Kb |
Gallery | 3,348 Kb |
Flexbox Gallery with Angularjs | 1,863 Kb |
Generate Date CSV | 2,204 Kb |
Svg ani | 14,097 Kb |
Angularjs - 8 cards carrousel | 3,571 Kb |
Gallery unsplash | 3,385 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Flex Table | Simeonoff | 4,059 Kb |
Obligatory CSS3 UI Nav | Romandiaz | 9,017 Kb |
Drifting Clouds | Benedikte | 2,247 Kb |
Css3 only dropdown menu | Riogrande | 2,519 Kb |
Caputre Cam with JS | KimmoCommit | 2,795 Kb |
Portfolio page | Bhavya_j | 2,804 Kb |
CSS Grid Test | Ajaykarwal | 2,377 Kb |
Shopping List | Markmurray | 6,015 Kb |
Simple personal profile | Miroot | 2,856 Kb |
FreeCodeCamp - Simon Game | Ivhed | 8,481 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!