Hello Sir,
This is my first post in this forum thanks to everyone helping to each other’s.
I’m using mixed EOD/intraday database in that I want to Delete Only Intraday database starting From to between the date Range, also I tried in AB Edit> Delete Range option, but it’s Deleting including EOD Database, finally I used Below JavaScript code download from internet its working fine but its time-consuming process to Delete 1 symbol of 20 days (1m) data it will take approximately 7 to 8 minutes to delete intraday Data, so I have more than 250 symbols it’s very time consuming process, anyone help me to speech up the Below JavaScript code or do you have any others suggestions to complete my work.
Thank you
Regards
Veeresh wali
Date.prototype.yyyymmddhhmmss = function()
{
//Modified the code from
var mm = this.getMonth() + 1; // getMonth() is zero-based
var dd = this.getDate();
var hh = this.getHours();
var mi = this.getMinutes();
var ss = this.getSeconds();
var yyyymmdd = [ this.getFullYear(), ( mm > 9 ? '' : '0' ) + mm, (dd > 9 ? '' : '0') + dd ].join('');
var hhmmss = [ ( hh > 9 ? '' : '0' ) + hh, ( mi > 9 ? '' : '0' ) + mi, ( ss > 9 ? '' : '0' ) + ss, ].join('');
return yyyymmdd + '' + hhmmss;
};
filespec = "C:/AmiData1m/WatchLists/Delete Test.tls";
DataDir = "C:\\AmiData1m";
var fso, watchlist, s, ForReading;
ForReading = 1, ForWriting = 2, s = "";
fso = new ActiveXObject( "Scripting.FileSystemObject" );
watchlist = fso.OpenTextFile( filespec, ForReading, false );
var oAB = new ActiveXObject( "Broker.Application" );
oAB.LoadDatabase( DataDir );
var oStocks = oAB.Stocks;
var Qty = oStocks.Count;
var DeleteFrom = new Date( "September 01, 2021 09:15:00" ).yyyymmddhhmmss();
var DeleteTo = new Date( "September 30, 2021 15:29:00" ).yyyymmddhhmmss();
file = fso.OpenTextFile( "_remowe_xdays.log", ForWriting, true );
file.WriteLine( "Starting delete quotes from date:" + DeleteFrom );
file.WriteLine( "" );
while( !watchlist.AtEndOfStream )
{
s = watchlist.ReadLine();
for( i = 0; i < Qty; i++ )
{
oStock = oStocks( i );
if( s == oStock.Ticker )
{
file.Write( i + ". " + oStock.Ticker + "=" );
for ( j = oStock.Quotations.Count - 1; j >= 0; j-- )
{
var tmpDateNum = new Date( oStock.Quotations( j ).Date ).yyyymmddhhmmss();
if( ( tmpDateNum % 1000000 != 0 ) && ( tmpDateNum >= DeleteFrom ) && ( tmpDateNum <= DeleteTo ) ) // Intraday Only
{
oStock.Quotations.Remove( j );
}
}
file.WriteLine( "OK" );
}
}
}
watchlist.Close();
oAB.RefreshAll();
oAB.SaveDatabase();
WScript.Echo( "Done!" );