Scheduled autoupdate with amiquote

Hi!
I want to schedule EOD update with amiquote, using windows task scheduler. I have come up with a simple bat file that seems to work. Just want to hear your comments and also if there is a better way, using better technics, safer, more stable etc.

The ping is used for 5s delay.

Here's the bat file:

@echo OFF
call :sub >>log.txt 2>&1
exit /b


:sub
echo ---------- this is UPDATE.BAT %DATE%  %TIME% ----------

echo %TIME% kill AmiBroker
start "taskkill" taskkill /IM "broker.exe"

echo %TIME% kill AmiQuote
start "taskkill" taskkill /IM "quote.exe"
ping localhost -n 6 >nul


echo %TIME% start AmiBroker
cd C:\Program Files (x86)\Amibroker
start "amibroker" "broker.exe"
ping localhost -n 6 >nul

cd C:\Program Files (x86)\Amibroker\AmiQuote
echo %TIME% start AmiQuote /autoupdate /close
quote.exe /autoupdate /close
ping localhost -n 6 >nul


echo %TIME% kill AmiQuote
start "taskkill" taskkill /IM "quote.exe"

echo %TIME% kill AmiBroker
start "taskkill" taskkill /IM "broker.exe"

echo %TIME% end 
rem end of :sub
2 Likes

if you can automatically download, it will be very easy :+1:

@wmrazek - using taskkill is bad idea, may lead to data corruption.

Instead, you should just keep AmIBroker running and use AmiBroker's Batch and scheduler
to run AmiQuote with auto-update http://www.amibroker.com/guide/h_batch.html

1 Like

Oh this is great, the Batch and scheduler. Just what we need. It will save me many hours... ;0)

An update. Same thing but now with a jscript. Also added that more days will be updated. I have seen that Yahoo sometimes has incorrect values for the latest days and it is corrected a few days later. So this script now updates the last 10 days.

var d = new Date();
WScript.echo("--- Amiquote downloadAndImport.js ", d, " ---");

var AQ = new ActiveXObject("AmiQuote.Document");

// Set FromDate to current time minus 10 days
var FromDate = new Date();
FromDate.setDate(FromDate.getDate() - 10);

// Set ToDate to current time
var ToDate = new Date;

WScript.echo("FromDate = ", FromDate.getDate(), ", ToDate = ", ToDate.getDate());

/* getVarDate is required to convert from JScript Date to OLE-automation date */
AQ.From = FromDate.getVarDate();
AQ.To = ToDate.getVarDate();

AQ.AutoImport = true; // import automatically


// set up AmiQuote for Yahoo, download and import
AQ.Open("yahoo.tls");
AQ.Source = 0; // Yahoo
AQ.Download(); // starts download

// wait until download and import is finished
while( AQ.DownloadInProgress || AQ.ImportInProgress )
{
    WScript.sleep(5000); // wait 5 seconds before querying status again
}
WScript.echo("Yahoo complete");


// set up AmiQuote for Stooq, download and import
AQ.Open("stooq.tls");
AQ.Source = 5; // Stooq
AQ.Download(); // starts download

// wait until download and import is finished
while( AQ.DownloadInProgress || AQ.ImportInProgress )
{
    WScript.sleep(5000); // wait 5 seconds before querying status again
}
WScript.echo("Stooq complete ");


WScript.echo("--- script finished ---");
WScript.echo(" ");


The Amibroker batch and scheduler is used, very convinient. 
![scheduler|690x325](upload://fx4uAOFT08xxx0sLM8X4dTa8k9e.jpeg) 

The scheduler calls a .bat file that calls the jscript. I didn't manage to call the jscript from scheduler so this is a temporary solution and it works. It's also an easy way to get a simple log file, log.txt. The .bat-file: 
@echo OFF
call :sub >> log.txt 2>&1
exit /b

:sub
cd C:\Program Files (x86)\AmiBroker\AmiQuote
cscript //Nologo downloadAndImport.js >> log.txt
rem end of :sub
2 Likes

Sorry, what's the difference with Amiquote auto update? Thanksamiquate

Batupermata: The difference is that it's automatic. Also it gets quotes for 10 days back. Amiquote auto update makes almost the same thing but manually. In my case I have a server for the quote database and all it does is updating the database from different data sources (right now yahoo and stooq).

1 Like