PureBytes Links
Trading Reference Links
|
You have copied/edited it wrong, should be:
FileSys = new ActiveXObject( "Scripting.FileSystemObject" );
(as in the original)
instead of:
FileSys = new ActiveXObject( "Scripting.NOFileSystemObject" );
Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message -----
From: "fgornati" <francogornati@xxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Wednesday, December 14, 2005 2:24 PM
Subject: [amibroker] Script for downloading from different servers
> Hi all,
>
> I'm having problems with Yahoo 'current' data for the Italian market since US Yahoo servers are now storing Turnover figures
> instead of Volume figures and the series have become inconsistent.
>
> A solution would be to download the quotes from Italian Yahoo 'current' servers that for the while are still storing the right
> figures.
>
> Marcin has kindly suggested me to try to adapt a script from TJ's newsletter of 2001
> (http://www.amibroker.com/newsletter/02-2001.html) but that seems to be well beyond my abilities.
>
> I've changed the constants and tried the script. I'm getting an error at line 43 (should be FileSys = new ActiveXObject(
> "Scripting.NOFileSystemObject" )): "automation server cannot create the object". Beside that, I'm not sure that this script will
> download 'current' quotes since it's been thought to download historical quotes.
>
> Does anyone has any hint about that or better a script to adapt?
>
> Thanks,
>
> Franco
>
>
> The script:
>
> --------------------------------------------------------------------------------
> /*
> ** AmiBroker/Win32 scripting Example
> **
> ** Language: JavaScript (Windows Scripting Host)
> **
> **
> */
>
> /**************************************************************/
> /* Constants */
> /**************************************************************/
>
> /* The ticker to check */
> ChkTicker = "^MIBTEL";
>
> /* The folder where the files will be downloaded */
> DestDir = "C:\\YAHOO\\";
>
> /* The name and the path to downloader program */
> DownloaderPrg = "URLGet.exe";
>
> /* Force download - if true causes downloading data file */
> /* even if it exists on the local drive */
> ForceDownloadFlag = false;
>
> /* URL from where data are downloaded */
> /* Note that australian-stockmarket site changed directory for 2001 quotes */
> URLPrefix = "http://it.old.finance.yahoo.com/d/";
>
> /* extension of file name, YYYYMMDD will be prepended */
> FileExt = ".prn";
>
> /* max number of days to download when history is empty */
> nMaxHistoryLen = 365;
>
> /**************************************************************/
> /* Main part */
> /**************************************************************/
>
> /* Create AmiBroker app object */
> AmiBroker = new ActiveXObject( "Broker.Application" );
> /* ... and file system object */
> FileSys = new ActiveXObject( "Scripting.NOFileSystemObject" );
> WshShell = new ActiveXObject( "WScript.Shell" );
>
> var MiliSecInDay = 24 * 60 * 60 * 1000;
>
> function Download( URL, filename )
> {
> if( ! ForceDownloadFlag && FileSys.FileExists( filename ) ) return true;
>
> if( WshShell.Run( DownloaderPrg + " " + URL + " " + filename, 0, true ) == 0 ) return true;
>
> WScript.echo("Download of " + URL + " failed." );
>
> return false;
> }
>
> function Import( filename )
> {
> try
> {
> AmiBroker.Import( 0, filename, "prnn.format" );
> }
> catch( e )
> {
> return false;
> }
>
> /* refresh ticker list and windows */
> AmiBroker.RefreshAll();
> return true;
> }
>
> function CheckFolder()
> {
> if( ! FileSys.FolderExists( DestDir ) )
> {
> FileSys.CreateFolder( DestDir );
> }
> }
>
> function GetNumberOfDaysToLoad()
> {
> var Today = new Date();
> var LastDate = new Date();
>
> LastDate.setDate( LastDate.getDate() - nMaxHistoryLen ); // one year
>
> if( AmiBroker.Stocks.Count > 0 )
> {
> nQty = AmiBroker.Stocks( ChkTicker ).Quotations.Count;
> if( nQty > 0 )
> {
> LastDate = new Date( AmiBroker.Stocks( ChkTicker ).Quotations( nQty - 1 ).Date );
> }
> }
>
>
> // the difference is in milliseconds
> return ( Math.floor( (Today - LastDate)/MiliSecInDay ) );
>
> }
>
> function IsValidDatabase()
> {
> if( AmiBroker.Stocks.Count > 0 )
> {
> try
> {
> return AmiBroker.Stocks( ChkTicker ).Ticker == ChkTicker;
> }
> catch( e )
> {
> WScript.echo("The database currently loaded into AmiBroker does not have " + ChkTicker + "\nSo I guess this is not correct
> database.\nUpdate failed.");
> }
> }
>
> return false;
> }
>
> function Main()
> {
> bOK = true;
>
> if( ! IsValidDatabase() ) return;
>
> var CurDate = new Date();
> var NumDays = GetNumberOfDaysToLoad();
>
> WScript.echo("Your database is " + NumDays + " day(s) old.\n" + (NumDays > 0 ? "Downloading missing quotes" : "No update is
> needed" ) );
>
> CheckFolder();
>
> for( i = 0; i < NumDays; i++ )
> {
> if( CurDate.getDay() > 0 && CurDate.getDay() < 6 )
> {
> // bussiness day
> y = CurDate.getFullYear();
> m = CurDate.getMonth() + 1;
> d = CurDate.getDate();
>
> bOK = true;
>
> filename = y + ( m < 10 ? "0" : "" ) + m + ( d < 10 ? "0" : "" ) + d + FileExt;
>
> URL = URLPrefix + filename;
>
> if( y == 2001 && URLPrefix2001 != "" )
> {
> URL = URLPrefix2001 + filename;
> }
>
> if( Download( URL, DestDir + filename ) )
> {
> if( ! Import( DestDir + filename ) ) bOK = false;
> }
> else
> {
> bOK = false;
> }
>
> if( ! bOK && WshShell.popup( "The download and/or import of the " + filename + " has failed.\nThis can be because the data are not
> available or network connection problem.\nDo you want to abort?" , 0, "Abort updating", 4 + 256 ) == 6 )
> {
> break;
> }
>
> }
>
> CurDate.setDate( CurDate.getDate() - 1 );
> }
>
> if( bOK ) WScript.echo("Update script finished. Your database is now up-to-date" );
> else WScript.echo("Update script finished. There were, however, some errors during download/import");
>
> }
>
> Main();
>
>
>
>
>
>
> 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
>
>
>
>
>
>
>
------------------------ Yahoo! Groups Sponsor --------------------~-->
Try Online Currency Trading with GFT. Free 50K Demo. Trade
24 Hours. Commission-Free.
http://us.click.yahoo.com/RvFikB/9M2KAA/U1CZAA/GHeqlB/TM
--------------------------------------------------------------------~->
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
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> 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/
|