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

Re: [amibroker] STOCK TICKERS GO TO THE P's, THEN STOP??



PureBytes Links

Trading Reference Links

Hi Patrick,
 
How do I get back to "Auto-update quote (US && Canada)"? When I try to update auto update quote. It gives my fatal error: can not find Sharenet Downloader program.
 
regards,
Alex
 
NW Trader <47nwtrader@xxxxxxxxxx> wrote:
Hi Jim,
 
You could use the database purify tool [ Tools-->Database Purify ] with only a check for missing quotes for the last X days where X is the number of days your database has had corrupt data (I use the NASDAQ Comp [COMPQX]  as the reference symbol).  
 
Or you could use the attached EZ cleanup script which I modified from the one installed under tools as clean up database.  The difference is that with my EZ script it runs without you having to intervene at every bad symbol.  I have copied it below as well as attached it to this email.  To install it, copy and save it to the scripts directory with an extension of .js  (I have a paternalistic ISP that blocks .js or other possibly dangerous files, so must name the attachment with .txt).  Then go Tools --> customize add a new menu item EZ Cleanup and in the command line put C:\Program Files\AmiBroker\Scripts\EZ_Cleanup.js (or whatever the path to the scripts subfolder is on your computer).  Now just click and go -- depending on your machine, it may take a while -- my 3.2 GHz, 3MB DDR2, 160 GB SATA XP Pro box takes 2 or 3 minutes to process the entire TC2005 database.  When it finishes, you will get a popup box asking for confirmation to delete the bad tickers.  Database Purify is quicker, but I don't find it as easy.  I routinely run the EZCleanup script after updating my TC2005 and QP databases to delete symbols that have no trading history for the past 20 days. 
 
Let me know if you have a problem. 
 
Peace and Justice   ---   Patrick
===========================================================================================================
/*
** EZ Cleanup Script
**
** File:  Cleanup.js --> EZCleanup.js
** Created:  Tomasz Janeczko, December 2th, 2000 
** Modified:  Patrick Hargus, Oct 22, 2003
** Purpose:  Cleanup the database to remove non-trading stocks
** Language:   JScript (Windows Scripting Host)
*/

/* detection threshold (in days)  */
var Threshold = 20; // one month for example
/* by default do not delete = FALSE , EDITED TO TRUE*/
var DeleteByDefault = true;
/* ask the user for the decision - default is true */
var AskUser = false                       
/* 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" );

 
 
 
----- Original Message -----
Sent: Sunday, May 22, 2005 5:37 PM
Subject: Re: [amibroker] STOCK TICKERS GO TO THE P's, THEN STOP??

NW Trader:

     Thanks for your help.  I got back the remainder
of my tickers with the maneuver you described.  I
appreciate your answer, but now I have another
question.  In the folder 'WORKPLACE--->
SYMBOLS--->ALL' I have a long parade of green boxes,
with no names next to them.  I can erase them, but its
time consuming because they disasppear only one ticker
at a time!  Not only that, a similar list of green
diamond boxes appears in a couple other lists under
the description 'Undefined.'  Should I just ignore
these things? Are they some kind of blank placeholders
that get filled eventually with ticker names?  Is
there a way to identify a big bunch of these 'empty
ticker symbols' and erase a group of them?  Was I
creating these things inadvertantly?  Did they--do
they-- migrate over from TC2005?  Am I doing something
wrong?
     Any help would be appreciated.

Jim Brady


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 other support material please check also:
http://www.amibroker.com/support.html



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

/* detection threshold (in days) */
var Threshold = 20; // one month for example
/* by default do not delete = FALSE , EDITED TO TRUE so automaticly deletes*/
var DeleteByDefault = true;
/* ask the user for the decision - default is true EDITED TO FALSE so no intervention required*/
var AskUser = false
/* 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" );


Do you Yahoo!?
Make Yahoo! your home page

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 other support material please check also:
http://www.amibroker.com/support.html





Yahoo! Groups Links