Delete EOD and Intraday data (mixed db) for a specific symbol and date

I have the following JS, modified from some codes I found online. The code works, I can successfully delete the mixed data for a specified symbol on a specified date but it is taking quite a long time, around 4-5 minutes for 1 symbol for 1 day data.

Just wondering is anyone can comment on the code to improve or has a totally different way of doing this (programmatically).

name = "AMZN"
var oAB = new ActiveXObject("Broker.Application");
var fso = new ActiveXObject("Scripting.FileSystemObject");
file    = fso.OpenTextFile( "_remove_Single_Quote.log", 2, true );

SecInDay = 24 * 60 * 60;

var DeleteFrom = new Date("october 22, 2020 00:00:00");
var DeleteTo = new Date("october 22, 2020 23:59:59");

//add a day to the date
DeleteTo.setDate(DeleteTo.getDate() + 1);

// make date with time 00:00:00        
var DayDeleteFrom = new Date((Math.floor(DeleteFrom / SecInDay)) * SecInDay);
var DayDeleteFromNum = (Math.floor(DeleteFrom / SecInDay)) * SecInDay;

var DayDeleteTo = new Date((Math.floor(DeleteTo / SecInDay)) * SecInDay);
var DayDeleteToNum = (Math.floor(DeleteTo / SecInDay)) * SecInDay;

st = oAB.Stocks(name)

for (j=st.Quotations.Count-1;j>=0;j--)
{
		tmpDate = new Date( st.Quotations( j ).Date );
		tmpDateNum = st.Quotations( j ).Date ;
		if (tmpDateNum >= DayDeleteFromNum) 
		{
			if (tmpDateNum <= DayDeleteToNum) 
			{
				st.Quotations.Remove(j);
			}
		}
		else 
		{
			break;
		} 
}

oAB.SaveDatabase( );
oAB.RefreshAll();
1 Like

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.