UNPKG

shubhadownloader

Version:

There is large amount of information available in market place. The markets are always in sync. In today's world investors find it very difficult to make effective use of information available to them. Shubha Downloader is great tool which resolves this problem and helps investor to increase his productivity and stay focused on decision making. Shubha Downloader enable end user to download market data from available sources and organize it. Shubha Downloader is Open source & FREE utility for end users. Shubha Downloader have main features as follows End of the day market data from web to your favorite charting application . Fundamental market data from web to your favorite charting application. Market reports from web to your favorite charting application.

212 lines (193 loc) 7.66 kB
/***************************** * *Author:JAYANT PATIL *COMPANY NAME XNet Inc,Pune. *last modified date:02-jan-2013 * * * *Description: *this function will create folder hierarchies if not found and * *variables : path contains the name of root folder like C:/data * * *copyright 2013 ******************************/ /******************************** <Shubha Downloader, It downloads end of day pricing data from publicly available sites and converts it different formats....> Copyright (C) 2013 Shubhalabha.in This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ***********************************/ function mkdir(path) { var fs=require('fs'); fs.exists(path, function (exists) { if(exists){ //document.getElementById("om").innerHTML+='<br>dir already exist'; } else { fs.mkdir(path, 0777, function(err){ if(err) { document.getElementById("om").innerHTML+='<br><font color=red>Error: Connot create directory Please Check Path '+path+'</font>'; } else document.getElementById("om").innerHTML+='<br>'+path+' dir created succesfully....'; }); } }); } function makedir(root,baseurl,fromd,tod){ var step=require('step'); step( function firstFunction(){ mkdir(root); //creating root if its not available Ext.getCmp('pbar3').updateText('Creating directory'+root); Ext.getCmp('pbar3').updateProgress(1.0); return this; }, function secondFunction(err, text){ if(err){document.getElementById("om").innerHTML+="<br/>"+err;} mkdir(root+'/downloads'); //path of file downloading folder Ext.getCmp('pbar3').updateText('Creating directory'+root+'/downloads'); Ext.getCmp('pbar3').updateProgress(1.0); return this; }, function thirdFunction(err, text){ if(err){document.getElementById("om").innerHTML+="<br/>"+err;} mkdir(root+'/reports');//path of file logs folder Ext.getCmp('pbar3').updateText('Creating directory'+root+'/reports'); Ext.getCmp('pbar3').updateProgress(1.0); return this; }, function fourthFunction(err, text){ if(err){document.getElementById("om").innerHTML+="<br/>"+err;} mkdir(root+'/logs');//path of file logs folder Ext.getCmp('pbar3').updateText('Creating directory'+root+'/logs'); Ext.getCmp('pbar3').updateProgress(1.0); return this; }, function fifveFunction(err, text){ if(err){document.getElementById("om").innerHTML+="<br/>"+err;} mkdir(root+'/std_csv');//path of outpout folder Ext.getCmp('pbar3').updateText('Creating directory'+root+'/std_csv'); Ext.getCmp('pbar3').updateProgress(1.0); return this; }, function sixFunction(err, text){ if(err){document.getElementById("om").innerHTML+="<br/>"+err;} setTimeout(function(){mkdir(root+'/downloads/unzip');//path of file unzippin folder Ext.getCmp('pbar3').updateText('Creating directory'+root+'/downloads/unzip'); Ext.getCmp('pbar3').updateProgress(1.0); },1000); return this; }, function sevenFunction(err, text){ if(err){document.getElementById("om").innerHTML+="<br/>"+err;} setTimeout(function(){mkdir(root+'/downloads/temp');//path of file unzippin folder Ext.getCmp('pbar3').updateText('Creating directory'+root+'/downloads/temp'); Ext.getCmp('pbar3').updateProgress(1.0); },1000); return this; }, function eightFunction(err, text){ if(err){document.getElementById("om").innerHTML+="<br/>"+err;} setTimeout(function(){mkdir(root+'/downloads/mcxindia');//path of file unzippin folder Ext.getCmp('pbar3').updateText('Creating directory'+root+'/downloads/mcxindia'); Ext.getCmp('pbar3').updateProgress(1.0); },1000); return this; }, function nineFunction(err, text){ if(err){document.getElementById("om").innerHTML+="<br/>"+err;} setTimeout(function(){mkdir(root+'/downloads/temp_yahoo');//path of file unzippin folder Ext.getCmp('pbar3').updateText('Creating directory'+root+'/downloads/temp_yahoo'); Ext.getCmp('pbar3').updateProgress(1.0); },1000); return this; }, function tenthFunction(err, text){ if(err){document.getElementById("om").innerHTML+="<br/>"+err;} setTimeout(function(){mkdir(root+'/downloads/unzip/unzip1');//path of file unzippin folder Ext.getCmp('pbar3').updateText('Creating directory'+root+'/downloads/unzip/unzip1'); Ext.getCmp('pbar3').updateProgress(1.0); },2000); return this; }, function mkEventDir(err, text){ if(err){document.getElementById("om").innerHTML+="<br/>"+err;} mkdir(root+'/events'); //path of file downloading folder Ext.getCmp('pbar3').updateText('Creating directory'+root+'/events'); Ext.getCmp('pbar3').updateProgress(1.0); return this; }, function elventhFunction(err, text) { //console.log('\n Amibroker 1'); var csv = require('ya-csv'); var reader = csv.createCsvFileReader('settings.csv',{'separator': ','}); reader.addListener('data', function(data) { if(data[0]=='format') { //console.log('\n Amibroker 2'); if(data[1].search('AmiBroker')>=0) { //console.log('\n Amibroker 3'); mkdir(root+'/amibroker');//for bse output files Ext.getCmp('pbar3').updateText('Creating directory'+root+'/amibroker'); Ext.getCmp('pbar3').updateProgress(1.0); } if(data[1].search('FChart')>=0) { mkdir(root+'/fchart');//for bse output files Ext.getCmp('pbar3').updateText('Creating directory'+root+'/fchart'); Ext.getCmp('pbar3').updateProgress(1.0); } if(data[1].search('MetaStock')>=0) { mkdir(root+'/metastock');//for bse output files Ext.getCmp('pbar3').updateText('Creating directory'+root+'/metastock'); Ext.getCmp('pbar3').updateProgress(1.0); } if(data[1].search('Ninja')>=0) { mkdir(root+'/ninja');//for bse output files Ext.getCmp('pbar3').updateText('Creating directory'+root+'/ninja'); Ext.getCmp('pbar3').updateProgress(1.0); } if(data[1].search('Advanced_Get')>=0) { mkdir(root+'/advanceget');//for bse output files Ext.getCmp('pbar3').updateText('Creating directory'+root+'/advanceget'); Ext.getCmp('pbar3').updateProgress(1.0); } } }); return this; }, function newfunction() { // first timme create log.txt here for timstamp var downloadpath=root+'/downloads/'; //path of file downloading folder var unzippath=root+'/downloads/unzip/';//path of file unzippin folder // var temppath=root+'/temp/';//path of file unzippin folder var logpath=root+'/logs/';//path of file unzippin folder var outputpath=root+'/std_csv/'; /***********************/ setTimeout(performtask,2000,baseurl,downloadpath,unzippath,outputpath,logpath,fromd, tod); //call to function for perform task of downloading and processing.. return this; } ); }