[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: Remove blank symbols



PureBytes Links

Trading Reference Links

The java script program you are looking for is named cleanup.js. It 
is in c:\program files\amibroker\scripts on version 4.9. If it isn't 
there then it may not be shipped in 5.0. I may have found it on the 
AB site and added it to the scripts folder. I can't remember. I will 
include it below just in case it isn't there. I don't know if 5.0 is 
different enough that the one for 4.9 won't work, but I doubt it. 
Before you use it, it might be a good idea to back up your data base.

Barry

/*
** AmiBroker/Win32 scripting Example
**
** File:	Cleanup.js
** Created:	Tomasz Janeczko, December 2th, 2000
** Purpose:	Cleanup the database from not traded stocks
** Language: 	JScript (Windows Scripting Host)
*/

/* detection threshold (in days)  */
var Threshold = 30; // one month for example 
/* by default do not delete */
var DeleteByDefault = false;
/* ask the user for the decision */
var AskUser = true;
/* a timeout to wait until default route (no deletion) is taken */
var Timeout = 5;

var oAB = new ActiveXObject("Broker.Application");
var fso = new ActiveXObject("Scripting.FileSystemObject");
var Shell = new ActiveXObject("WScript.Shell");


var oStocks = oAB.Stocks;

var MiliSecInDay = 24 * 60 * 60 * 1000;

var Continue = true;

var StockQty = oStocks.Count;

var oStocksToDelete = new Array;
var oStocksNotTraded = new Array;

if( ! AskUser ) WScript.Echo("Cleanup script started" );

for( i = 0; i < StockQty && Continue; i++ )
{
	oStock = oStocks( i );

	var Qty = oStock.Quotations.Count; 

	var response = 0;

	if( Qty > 0 )
	{
		oQuote = oStock.Quotations( Qty - 1 );

		var oDate = new Date( oQuote.Date );

		var Today = new Date();

		DaysNotTraded = Math.floor( ( Today - 
oDate )/MiliSecInDay );

		if( DaysNotTraded > Threshold )
		{
			if( AskUser ) response = Shell.popup( 
oStock.Ticker + " is not traded since " + oDate.toLocaleString() + " 
(" + DaysNotTraded + " days).\nDo you wish to delete it?\n(Press 
Cancel to end the process)", Timeout, "Confirm delete", 3 + 256 );
			else          response = -1; /* default */
		}
	}
	else
	{
		if( AskUser ) response = Shell.popup( oStock.Ticker 
+ " has no quotes. Do you wish to delete it?",  Timeout, "Confirm 
delete", 3 + 256 );
		else          response = -1; /* default */
	}

	/* change default route if needed */
	if( response == -1 && DeleteByDefault ) response = 6;

	switch( response )
	{
		case -1:/* Timeout - fallback to no */
		case 7: /* No */
				oStocksNotTraded[ 
oStocksNotTraded.length ] = oStock.Ticker;
				break;
		case 6: /* Yes */
				oStocksToDelete[ 
oStocksToDelete.length ] = oStock.Ticker;
				break;
		case 2: /* Cancel */
				Continue = false;
				break;
		default: break;
	}
}

if( oStocksToDelete.length > 0 && Shell.popup( "You are now about to 
delete " + oStocksToDelete.length + " stock(s).\nDo you wish to 
proceed?" , 0, "Confirm delete", 4 + 256 ) == 6 )
{
	for( i = 0; i < oStocksToDelete.length; i++ )
	{
		oStocks.Remove( oStocksToDelete[ i ]  );
	}

	oAB.RefreshAll();
}

if( oStocksNotTraded.length > 0 && Shell.popup( "There are " + 
oStocksNotTraded.length + " not traded stock(s) detected but not 
deleted by your choice.\nDo you wish to save their tickers to 
\"nottraded.txt\" file?" , 0, "Confirm save", 4 + 256 ) == 6 )
{
	f = fso.OpenTextFile( "nottraded.txt", 2, true );	

	for( i = 0; i < oStocksNotTraded.length; i++ )
	{
		f.WriteLine( oStocksNotTraded[ i ]  );
	}

	f.Close();
}

WScript.Echo("Cleanup script finished" );
/* end of cleanup.js script */

--- In amibroker@xxxxxxxxxxxxxxx, "umrperumal" <umrperumal@xxx> wrote:
>
> Mr Barry,
> 
> You said there is a java.js script (shipped with AB) for cleaning 
up 
> blank symbols.But I see no such option under Tools menu.   Under 
> Tools, these are the options available : Datebase purify, Indicator 
> Maintenance, Bar Replay, Preferences, Save Preferences, Plug ins, 
> and Customize.
> 
> Can you say where exactly the clean up option is available.  I use 
> version 5.0.
> 
> Regards
> 
> Perumal
> 
> 
> 
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "Barry Scarborough" 
> <razzbarry@> wrote:
> >
> > But the question is why are the symbols blank? If the symbols are 
> > valid there should be data associated with them and you may want 
> to 
> > find a data source to download data for them. If not valid then 
> the 
> > Cleanup.js will solve the problem. 
> > 
> > Cleanup.js is a java script program shipped with AB that will 
blow 
> > away invalid or obsolete tickers. Look in Tools and scroll down 
to 
> > that program and run it. It will blow away any symbols that have 
> not 
> > been updated in 30 days. If there is no data it will blow the 
> symbol 
> > away.
> > 
> > 
> > Barry
> > 
> > --- In amibroker@xxxxxxxxxxxxxxx, "Graham Johnson" <grahamj@> 
> > wrote:
> > >
> > > I've recently had some data corruption, so reinstalled history 
> from 
> > > Premium Data.
> > > 
> > > Everything now looks fine except that under Symbols All there 
is 
> a 
> > huge 
> > > number of blank rows that have a Green marker.  After scrolling 
> > down 
> > > many times the rows with symbols are displayed and they have 
> Pink 
> > > markers.
> > > 
> > > Is there a means of bulk deleting the blank rows?  If I have to 
> > delete 
> > > them individually, it will take forever.
> > > 
> > > Graham
> > >
> >
>




Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html
 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/