AmiQuote Automation

I did read many forum topics now and can not find out how to do what I want.

I would like to run make a batch in this way: Load Database - update symbols by amiquote - making some scans.

Now the point with "update symbols by amiquote" makes me problems.

First attempt was to use: ecuteAndWait amiquote\quote.exe /autoupdate /close. Looks good in the first try but has a big drawback. It uses the source which was used last manually. I did not find any possibility to specyfy this in the command line. I do make experiments with Amiquote from time to time so I can not trust this method. Maybe I am wrong and there is a possibility to set the source at command line.

Second attempt: I start a external script file to make this by OLE automation.

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

FromDate = new Date(1995, 5, 1, 0, 0, 0);
/* year, month-1, day, hour, min, sec (required by JScript date constructor) */

 ToDate = new Date; // current time

 /* 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
 AQ.Source = 0; // Yahoo Historical

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
 }

This is looking good in the first place but has also a big drawback. OLE does not support autoupdate (AmiQuote's OLE Automation Object Model). If I do not have autoupdate,I do not have the Information what date was updated last. So I have to import the whole time frame. This is not good as Yahoo data has Issues and some of them I removed by removing quotes from the database not to make troubles in my calculation. Overwriting the whole time back overwrites also this effort. So also not usable.

Maybe there is a possibility to call autoupdate in OLE or set source in command line. Or this functionality can be added with little effort. Please!!!!!!

1 Like

hello @firstmichal

i run this combination of AFL and javascript to auto-update the EOD symbols that exist in the .tls file(s).

This is an AFL and downloads **the last bar of your chart until today ** from 2 different Source yahoo and finam.

I hope it helps.
Maybe there is other way to Auto-update from the last bar but i dont know.
At this moment this works fine for my needs

//////////////////////////////////////////////////////////////////////////////////
_SECTION_BEGIN("AmiQuote_FromDate_allInOne");
// https://forum.amibroker.com/t/how-to-specify-the-download-site-for-amiquote-in-batch-processor/1877/2
//  Panos 19-10-2019 
// 1) Opens AQ,
// 2) find the date of the last bar, of the current chart
// 3) set up AQ.Source of your choice


path64= "C:\\Program Files\\AmiBroker\\AmiQuote\\";  // place your path here for AmiQuote
 
dt_From = DateTimeToStr( LastValue( DateTime() ),4 ); printf("dtstr " + dt_From);
//---(2) Update Data Up to Today, Split it to String YYYY-MM-DD  -----------
dt_ToDayNow= DateTimeFormat( "%Y-%m-%d", Now(5) ) ; printf( "\n  DateTimeFormat Now(1) =\t" +dt_ToDayNow +"\n");


 // Press Gui that works like ParamTrigger in the chart or ctrl+ r parameters
 GuiToggle( "AmiQuote GlobalIndex-Crypto-Forex", 3, Status( "pxchartleft" ) + 10  , 156, 230, 24, 1 );
 
if( ParamTrigger( "Download From Yahoo", "GlobalIndex-Crypto" ) OR  GuiGetCheck( 3 ))
{  
    AQ = CreateObject( "AmiQuote.Document" );
    AQ.Open(path64+"Yahoo_GlobalIndex.tls");  // place your .tls file here
    AQ.Source = 0; 								// change as needed
    AQ.From = dt_From; 							// date of Last bar of your active chart 
    AQ.To = Now();
    AQ.AutoImport = 1; //False; //True;
    AQ.Download();
// By Tomasz  busy waiting is PROHIBITED Instead of busy waiting in AFL (which is not good thing to do), you could just use ShellExecute to call external JScript.
    while( AQ.DownloadInProgress() OR AQ.ImportInProgress() )
    {
        ThreadSleep( 10 );  //ThreadSleep( milliseconds ) 
    }
	
////////////////////////////////////////////////
// part 2: Now download the second symbol list    
    AQ.Open(path64+"Yahoo_Crypto_GBP.tls");			// place your second .tls file here
    
    AQ.AutoImport = 1; //False; //True;  
    AQ.Download();
    
        while( AQ.DownloadInProgress() OR AQ.ImportInProgress() )
    {
        ThreadSleep( 10 );  // ( milliseconds ) 
    }
	
///////////////////////////////////////////////////////// 
// part 3: open a javascript file.  location on your hard
Shellexecute("C:\\Program Files\\AmiBroker\\AmiQuote\\automata_rossos.js","",""); 

GuiSetCheck( 3, 0 );  // reset 
}

_SECTION_END();

And below here is the Java script that AFL calls in the step part 3

/*
** AmiBroker/Win32 scripting Example
**
** File:		automata_rossos.js
** Created:		Panos, Aug 8th, 2019
** Purpose:		Open Amiquote and download EOD Data , tested with AmiQuote Version 4.02
** Language: 	JScript (Windows Scripting Host)
*/

path64= "C:\\Program Files\\AmiBroker\\AmiQuote\\";

AQ = new ActiveXObject("AmiQuote.Document");
//AQ.GetSymbolsFromAmiBroker();
AQ.Open( path64+"Forex-Finam.tls");			// place your .tls file here
AQ.Source = 4; // Finam Current

//AQ.AutoImport = false; // no automatic import

AQ.Download(); // starts download

while( AQ.DownloadInProgress || AQ.ImportInProgress )
{
WScript.sleep(50000); // wait 5 seconds while AmiQuote is downloading
}

//WScript.echo("Download and import complete");
5 Likes

Hallo PanoS
Thanks for your Reply. Although your Answer was not exactly what I was searching for. But it brought me to an idea. As AmiQuote uses the last set Source, I could open Start/setSource/Quit by OLE. This would set the source for the next start. And than start the download by executeAndWait amiquote\quote.exe /autoupdate /close.
I will try out tomorrow and tell if it worked. But nevertheless a command line attribute /source=0 would be the most elegant solution. (Hopefully somebody from Amibroker team is reading this....)

Well it is working!
AmiQouoteSetSource.js

AQ = new ActiveXObject("AmiQuote.Document");
AQ.Source = 0; // Yahoo Historical
WScript.sleep(1000); //Wait 1 secound.
AQ.Quit;

Batch1

This sets the Source and performs a update....
But anyway a command line attribute /source=0 would be the most elegant solution. (Hopefully somebody from Amibroker team is reading this....)

1 Like

Hello, would you mind explaining what you want, how you do it and what have you got?
Thank you

-) What I want:
The Idea was to create a Amibroker Batch which will first start AmiQuote to autoupdate the database and when the data is actual perform calculations.
-) What problems did I face:
See original entry
-) How did I do it:
As already described first start the AmiQouoteSetSource.js than execute "amiquote\quote.exe /autoupdate /close" to update the quotes.
-) What have I got?
An updated database for calculations

I hope this helps you somehow. If not please describe which part is not understandable for you.

3 Likes

thanks for your explanation. Sorry for so many question but I try to learn. A batch for scanning is just having a batch of actions in a list and when I pass the explorer only that batch is made with updated data, as well?
Because to run the data update you have to keep running the update by opening a friend, right? Or is there a way to automatically run amiquote at a specific time without having to do it manually?
Regards

Sorry for answering so late, but I overlooked your question.
Yes, starting a batch at a specific time is possible, just use the scheduler. (see screen shot)
grafik

2 Likes

In my search for this I also found another thread with a solution by Tomasz. Maybe this helps others in the future: