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

Re: [amibroker] Automatic download ? (until it works)



PureBytes Links

Trading Reference Links


Dear Johan,
 
First you should click on Yahoo.js.
 
Clicking on URLGet without giving URL gives you 
the errors. 
This little utility is described in the newsletter 
(6/2001)
 
If you receive <FONT 
face="Courier New" size=2>"The server name or adress could not be resolved" 
it means that URLGet can get the
address of DNS server. Please check 
your
TCP/IP settings. 
 
URLGet program uses default TCP/IP 
connection
as defined in Internet Explorer 
Settings/Connections.
 
You can check manually if the URLGet itself 
works correctly
on your machine by issuing the following 
command:
 
URLGet <A 
href="">http://www.yahoo.com<FONT 
size=2> index.html
 
This should get the home page of yahoo and 
store it to local
index.html page. If it works also the script 
should work.
 
Best regards,Tomasz Janeczko===============AmiBroker - the 
comprehensive share manager.<A 
href="">http://www.amibroker.com
<BLOCKQUOTE 
>
----- Original Message ----- 
<DIV 
>From: 
<A title=GEERTS.JOHAN@xxxx 
href="">GEERTS.JOHAN@xxxx 
To: <A title=amibroker@xxxxxxxxxxxxx 
href="">amibroker@xxxxxxxxxxxxxxx 
Sent: Thursday, June 14, 2001 9:53 
PM
Subject: [amibroker] Automatic 
download ? (until it works)
Hello group,I hope I find someone in the groupwho 
can help!I'm trying to automate daily updates from Yahoo, but still 
having problems.  I'm trying it for a week now, but don't 
succeed.  I created a folder C:\Yahoo and copied the URL Get.exe 
program and the file Yahoo.js there.  But when I doubleclick on the 
URL Get.exe to run the program, I retrieve the following message : "You 
have to define URL and local file name in program arguments" ! So, where 
do I have to do that?  And when I doubleclick on Yahoo.js, I retrieve 
the following message : URLGET : "The server name or adress could notbe 
resolved" !I'm not that good in English (my native language is 
Dutch) so maybe I misunderstood the instructions (and yes, I read all 
newsletters). It's to difficult for me, so, is there anyone who can 
explane it, step by step, using simple terms?I included the script 
of the Yahoo.js file so you can check it.PLEASE, HELP ME 
!!!Best regards,Johan/*** AmiBroker/Win32 
scripting Example**** File:  Yahoo.js** Created:  Tomasz 
Janeczko, March 4rd, 2001** Purpose:  Download and import DAILY 
updates from Yahoo** Language:   _javascript_ (Windows Scripting 
Host)*****//**************************************************************//* 
Constants                                                  
*//**************************************************************//* 
The ticker to check *//* Set it to empty string "" if you don't want to 
check */ChkTicker = "A";/* 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 = true;/* URL from 
where data are downloaded *//* quote.yahoo.com supports US and Canada 
markets only */URLPrefix = "<A 
href="">http://quote.yahoo.com/d/quotes.csv?s=";URLPostfix 
= "&f=snl1d1t1c1ohgv&e=.csv";/* extension of file name, 
YYYYMMDD will be prepended */FileExt = ".aqd";/* Max. number of 
tickers to download in one run *//* Should be no more than 30 becauseof 
the limitations of command line string length */ChunkSize = 
30;/**************************************************************//* 
Main 
part                                                  
*//**************************************************************//* 
Create AmiBroker app object */AmiBroker = new ActiveXObject( 
"Broker.Application" );/* ... and file system object */FileSys = new 
ActiveXObject( "Scripting.FileSystemObject" );WshShell = new 
ActiveXObject( "WScript.Shell" );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, 
"aqd.format" );}catch( e ){  return false;}/* 
refresh ticker list and windows */AmiBroker.RefreshAll();return 
true;}function CheckFolder(){if( ! FileSys.FolderExists( 
DestDir ) ){  FileSys.CreateFolder( DestDir 
);}}function IsValidDatabase(){if( ChkTicker !="" 
&& 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;var Today = new Date();if( ! 
IsValidDatabase() ) return;CheckFolder();var Qty = 
AmiBroker.Stocks.Count;var TickerList = ""; var j = 0; /* this 
variable is used for marking different files from one day */for( i 
= 0; i < Qty; i++ ){  TickerList += AmiBroker.Stocks(i 
).Ticker;  if( ( i % ChunkSize ) == (ChunkSize-1) || i == ( Qty - 
1) )  {         y = 
Today.getFullYear();   m = Today.getMonth() + 1;   
d = Today.getDate();   bOK = true;   
filename = y + ( m < 10 ? "0" : "" ) + m + ( d < 10 ? "0" : "" ) + d 
+ "_" + j + FileExt;   URL = "" + TickerList + 
URLPostfix;   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;   }   j++;   
TickerList = "";  }  else  {   
TickerList += "+";   }}    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();Your 
use of Yahoo! Groups is subject to the <A 
href="">Yahoo! Terms of Service.