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.

366 lines (329 loc) 19.5 kB
Ext.Loader.setConfig({enabled: true}); Ext.Loader.setPath('Ext.ux', 'ux/'); Ext.require([ 'Ext.grid.*', 'Ext.data.*', 'Ext.util.*', 'Ext.tip.QuickTipManager', 'Ext.ux.LiveSearchGridPanel','Ext.form.field.ComboBox' ]); Ext.onReady(function() { Ext.QuickTips.init(); // sample static data for the store Ext.grid.dummyData = []; /** * Custom function used for column renderer * @param {Object} val */ function change(val){ if(val > 0){ return '<span style="color:green;">' + val + '</span>'; }else if(val < 0){ return '<span style="color:red;">' + val + '</span>'; } return val; } /** * Custom function used for column renderer * @param {Object} val */ function pctChange(val){ if(val > 0){ return '<span style="color:green;">' + val + '%</span>'; }else if(val < 0){ return '<span style="color:red;">' + val + '%</span>'; } return val; } Ext.define('Company', { extend: 'Ext.data.Model', fields: [ {name: 'date'}, {name: 'symbol'}, {name: 'securityname'}, {name: 'clientname'}, {name: 'buysale'}, {name: 'quantitytraded'}, {name: 'tradeprice'}, {name: 'remarks', type: 'text'} ] }); var mystore = Ext.create('Ext.data.ArrayStore', { model: 'Company', data: Ext.grid.dummyData }); // create the Grid, see Ext. var sgrid = Ext.create('Ext.ux.LiveSearchGridPanel', { store: mystore, columnLines: true, columns: [ Ext.create('Ext.grid.RowNumberer'), { text : 'Date', flex : 1, sortable : false, dataIndex: 'date', renderer: function renderTip(val, meta, rec, rowIndex, colIndex, store) { meta.tdAttr = 'data-qtip='+val; return val; } }, { text : 'Symbol', width : 75, sortable : true, dataIndex: 'symbol', renderer: function renderTip(val, meta, rec, rowIndex, colIndex, store) { meta.tdAttr = 'data-qtip='+val; return val; } }, { text : 'Security Name', width : 75, sortable : true, dataIndex: 'securityname', renderer: function renderTip(val, meta, rec, rowIndex, colIndex, store) { meta.tdAttr = 'data-qtip='+val; return val; } }, { text : 'Client Name', width : 75, sortable : true, dataIndex: 'clientname', renderer: function renderTip(val, meta, rec, rowIndex, colIndex, store) { meta.tdAttr = 'data-qtip='+val; return val; } }, { text : 'Buy / Sale', width : 75, sortable : true, dataIndex: 'buysale', renderer: function renderTip(val, meta, rec, rowIndex, colIndex, store) { meta.tdAttr = 'data-qtip='+val; return val; } }, { text : 'Quantity Traded', width : 85, sortable : true, dataIndex: 'quantitytraded', renderer: function renderTip(val, meta, rec, rowIndex, colIndex, store) { meta.tdAttr = 'data-qtip='+val; return val; } }, { text : 'Trade Price / Wght. Avg. Price', width : 85, sortable : true, dataIndex: 'tradeprice', renderer: function renderTip(val, meta, rec, rowIndex, colIndex, store) { meta.tdAttr = 'data-qtip='+val; return val; } }, { text : 'Remarks', width : 85, sortable : true, dataIndex: 'remarks', renderer: function renderTip(val, meta, rec, rowIndex, colIndex, store) { meta.tdAttr = 'data-qtip='+val; return val; } } ], dockedItems: [{ dock: 'top', xtype: 'toolbar', items: [{ xtype: 'combobox', id: 'file', fieldLabel: 'Select file', labelWidth: 60, store: ['Block Deals','Bulk Deals'], editable: false, forceSelection: true, listeners: { 'select': function(combo, row, index) { var fname = Ext.getCmp('file').getValue(); if(fname == "Block Deals") { var async = require('async'); var fs = require('fs'); var csv=require('ya-csv'); var reader = csv.createCsvFileReader('settings.csv',{'separator': ','}); reader.addListener('data', function(data) { if(data[0]=="datafolder") { var csv = require('ya-csv'); if(fs.existsSync(data[1]+'/reports/NSE_block_deals.csv')) { async.parallel({ data1 : function(callback){ if (fs.existsSync(data[1]+'/reports/NSE_block_deals.csv')) { fs.readFile(data[1]+'/reports/NSE_block_deals.csv','utf-8', function(err, data){ if(err) { document.getElementById("om").innerHTML+="<br/>An error occured while reading "; } callback(err, data); }); }else { // Here readdir's functionaliity has no use. It is written for only to send // '0' data in its callback function because we cannot call "callback(err, data);" // function out side a callback function fs.readdir('./', function(err, files){ if(err) { document.getElementById("om").innerHTML+="<br/>An error occured while reading "; } callback(err,'0'); }); } } }, function(err, result) { if(result['data1'].search('Not Found')>=0 ||result['data1'].search('html')>=0) { // console.log('data-'+result['data1']); Ext.Msg.alert('Message','<font color=red>NSE_block_deals.csv file not present</font>'); } else { sgrid.body.mask('Loading...'); var store = sgrid.getStore(); //code for the nse bulk deal //************************** var reader = csv.createCsvFileReader(data[1]+'/reports/NSE_block_deals.csv', { columnsFromHeader: true }); var arrData = new Array(); reader.addListener('data', function(data) { var arrTempData = new Array(); arrTempData.push(data["Date"]); arrTempData.push(data["Symbol"]); arrTempData.push(data["Security Name"]); arrTempData.push(data["Client Name"]); arrTempData.push(data["Buy / Sell"]); arrTempData.push(data["Quantity Traded "]); arrTempData.push(data["Trade Price / Wght. Avg. Price"]); arrTempData.push(data["Remarks"]); arrData.push(arrTempData); if(data[0] == null || data[0] == "") { mystore.loadData(arrData,false); sgrid.body.unmask(); } }); } }); }else { Ext.Msg.alert('Message','<font color=red>NSE_block_deals.csv file not present</font>'); } } }); } if(fname == "Bulk Deals") { var async = require('async'); var fs = require('fs'); var csv=require('ya-csv'); var reader = csv.createCsvFileReader('settings.csv',{'separator': ','}); reader.addListener('data', function(data) { if(data[0]=="datafolder") { var csv = require('ya-csv'); if(fs.existsSync(data[1]+'/reports/NSE_bulk_deals.csv')) { async.parallel({ data1 : function(callback){ if (fs.existsSync(data[1]+'/reports/NSE_bulk_deals.csv')) { fs.readFile(data[1]+'/reports/NSE_bulk_deals.csv','utf-8', function(err, data){ if(err) { document.getElementById("om").innerHTML+="<br/>An error occured while reading "; } callback(err, data); }); }else { // Here readdir's functionaliity has no use. It is written for only to send // '0' data in its callback function because we cannot call "callback(err, data);" // function out side a callback function fs.readdir('./', function(err, files){ if(err) { document.getElementById("om").innerHTML+="<br/>An error occured while reading "; } callback(err,'0'); }); } } }, function(err, result) { if(result['data1'].search('Not Found')>=0 ||result['data1'].search('html')>=0) { // console.log('data-'+result['data1']); Ext.Msg.alert('Message','<font color=red>NSE_bulk_deals.csv file not present</font>'); } else { sgrid.body.mask('Loading...'); var store = sgrid.getStore(); //code for the nse bulk deal //************************** var reader = csv.createCsvFileReader(data[1]+'/reports/NSE_bulk_deals.csv', { columnsFromHeader: true }); var arrData = new Array(); reader.addListener('data', function(data) { var arrTempData = new Array(); arrTempData.push(data["Date"]); arrTempData.push(data["Symbol"]); arrTempData.push(data["Security Name"]); arrTempData.push(data["Client Name"]); arrTempData.push(data["Buy / Sell"]); arrTempData.push(data["Quantity Traded "]); arrTempData.push(data["Trade Price / Wght. Avg. Price"]); arrTempData.push(data["Remarks"]); arrData.push(arrTempData); if(data[0] == null || data[0] == "") { mystore.loadData(arrData,false); sgrid.body.unmask(); } }); } }); }else { Ext.Msg.alert('Message','<font color=red>NSE_bulk_deals.csv file not present</font>'); } } }); } } } }] }], height: 380, width: 690, title: 'Market Analysis', renderTo: 'grid-example', listeners : { render : function(grid){ }, load: function(){ }, delay: 200 }, viewConfig: { stripeRows: true } }); });