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

[amibroker] Anyone, please debug this script.



PureBytes Links

Trading Reference Links

Hi, this script is to import data from a csv file. Its format is
strange though. It contains data in the following format for a single
ticker on a particular date.

Time(in hhmmss),Last Price,Volume

(e.g
105557,101.05,131.00
         105600,101.10,100.00
         105604,101.05,50.00
   )

I need to import the above data to an intraday database.

The ticker name and date are needed to be manually added to the script.

I have modified the script from http://www.amibroker.com/docs/ab302.html and made this.

It gives the error at 
quote = stock.Quotations.Add(time.getVarTime() );

I am a newbie to this script programming. Any help would be greatly appreciated.





This is the script.


ImportCSV( "c:\\testfile.csv" );

function ImportCSV( filename )
{
    var fso, f, r;
    var ForReading = 1;
    var AmiBroker;
    var ticker = "TST";      /* Manually enter Ticker Name */
    var date = "08/14/2008"; /* Manually enter Date */
    var quote;
    var fields;
    var stock;
    var time;

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

        /* ... and file system object */
   fso = new ActiveXObject( "Scripting.FileSystemObject" );

        /* add a ticker - this is safe operation, in case that      */
        /* ticker already exists, AmiBroker returns existing one  */
       /* we are doing this outside loop since the file contains */
       /* quotes of single stock only */


    stock = AmiBroker.Stocks.Add( ticker );

        /* open ASCII file */

    f = fso.OpenTextFile( filename, ForReading);

 
       /* read the file line by line */

    
    while ( !f.AtEndOfStream )
    {  
                                   
                           r =  f.ReadLine();

          
                          /* split the lines using comma as a separator */
                          fields = r.split(",");

                          /* parse the time from the text file */
                          time = new Time( fields[ 0 ] );
          
                          /* add a new quotation */
                         quote = stock.Quotations.Add( time.getVarTime() );
           
                         /* put data into it */
                         quote.Close = parseFloat( fields[ 1 ] );
                         quote.Volume = parseInt( fields[ 2 ] );
                                   
       }


    /* refresh ticker list and windows */
    AmiBroker.RefreshAll();

    /* notify the user */
    WScript.Echo( "Finished" );

}




__._,_.___

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




Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___