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

[amibroker] Need help debugging Java Script



PureBytes Links

Trading Reference Links

Hi I'm a new Amibroker user.  What I'm trying to do is automate the
synchronization of a native database that is not updated by amiquote.
 In my case I'm using a utility called Qcollector which downloads
e-signal data to my hard drive.  I want to do this so that 1) my data
is local instead of on the e-signal server and the programs that use
my data will run faster 2) maintain the historical data I have
accumulated to date 3)maintain my current database structure which
consists of two directories on a drive reserved for data, one
directory is for intraday data the other is for end of day.  Below
these directories are sub directories for different instrument
groupings. 4)This structure supports other trading programs that I'm
not prepared to abandon yet. 5) avoid multiple databases that could
a)get out of sync b) would be time consuming to maintain separately.

So my first step was to look at the manual process of importing ascii
data into amibroker.   After much trial and error I realized that
Amibroker wants a single database in the Amibroker directory. 
Following  creation of the latter database I did the File -> Open
step, then did File -> Database Options -> Intraday Settings -> Allow
mixed intraday/EOD data;  followed by File -> Ascii Import Wizard to
point Amibroker to my existing data files and to define the format of
the files.

I tried updating the data and found that I need to perform the File ->
Ascii Import Wizard step for each of my data directories in order for
Amibroker to recognize the update.  It is this last step that I'm
looking to automate since I think everything I described above only
has to be done once.

So I came up with a java script to do this automation but I can't get
it to run.  Windows script host gives me the following msg:
 
Line: 1
character: 2
error: invalid character
code: 800A03F6
source: Microsoft jscript compilation error

I've tried a version of the script with all the comments stripped
out...the same error occured.  I tried running Microsoft Script
Debugger and it won't even run the script; all of the debugging
buttons are greyed out after I open the file.  My code is shown below.
Can anyone help me?

Regards,
Ray
=====================================================================
/* File:	 Sync_AmiBroker_DB
   Created:	 Raymond Connolly 2008 08 09
   Purpose:	 Update Amibroker Database
   Language: 	 JavaScript (Windows Scripting Host)

   Note: that for each of the subdirectories where files are stored
   when downloaded from e-Signal, a .format file must be created and 
   saved in "C:\\Program Files\AmiBroker\Formats".  The naming 
   convention for the .format files is "INT + subdirectory name(as
defined 
   in D:\\01 Intraday Data) + .format"  for intraday files and 
   "EOD + subdirectory name" (as defined in D:\\02 EOD Data) + .format" 
   for end of day files.*/

/*************************************************/
/*Constants                                      */              
/*************************************************/

/* The directory where intraday files are stored when downloaded from
e-Signal*/
intradaydir = "D:\\01 Intraday Data"; 

/* The directory where end of day files are stored when downloaded
from e-Signal*/
eoddir = "D:\\02 EOD Data"; 

/* directory is a control variable to allow processing of intraday
files followed by end of day files*/
directory = intradaydir;

/* The path to the .format definition files in Amibroker path =
"C:\\Program Files\AmiBroker\Formats\";*/

/* Create AmiBroker object */
AmiBroker = new ActiveXObject("Broker.Application"); 

/* Create FileSystemObject */
var fso = new ActiveXObject("Scripting.FileSystemObject"); 

/***********************************************/
/* Main Synchronize Amibroker Database         */       
/***********************************************/

function Main()
{
     /* Iterate through subdirectories in intradaydir then eoddir*/
     if(directory == intradaydir)
     {
          Interogatelocaldatadirectories(directory)
          directory = eoddir
     }
     else
     {
          Interogatelocaldatadirectories(directory)
     }
     			
     /* refresh ticker list and windows */
     AmiBroker.RefreshAll();
}
Main();


 function Interogatelocaldatadirectories(directoryspec)
     {
         /* Variables for interogating intradaydir or eoddir*/ 
         var f, fc, d;

          f = fso.GetFolder(directoryspec);
          fc = new Enumerator(f.SubFolders);
          d = ""; /* assign empty string to make sure that d is a
string object*/
          for (; !fc.atEnd(); fc.moveNext())
          {
               d += fc.item();
               SyncAmibrokerDB(d);
          }
     }

     function SyncAmibrokerDB(folderspec)
     {
        /* Variables for manipulating files within intradaydir or   
eoddir*/ 
        var g, gc, filename;

        /* The .format definition file in Amibroker*/ 
        var format;  
     
        /* Iterate through files in each  subdirectory in directory*/
        g = fso.GetFolder(folderspec);
        gc = new Enumerator(g.files);
        filename = ""; /* assign empty string to make sure that      
filename is a string object*/
        for (; !gc.atEnd(); gc.moveNext())
        {
           filename += gc.item();
           if(directory == intradaydir)
           {
               /* specify intraday format definition file */
	       format = "INT " + filename + ".format";                
           }
           else
           {
                /*  specify end of day format definition file */
                format = "EOD " + filename + .format";                
           }

           /* import the data using appropriate format definition*/ file 
           AmiBroker.Import( 0, filename, format);
        }
     }



------------------------------------

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/