Amibroker Development Kit Question

mastermind007

Well-Known Member
#1
Hi

Many of you know about this development Kit and how it is used to develop a Plugin.

My first question revolves around GetQuotesEx and GetQuotes function. Does this function get called only for the ticker that is currently being viewed or is it called for all tickers in the Amibroker.

Second question revolves around supplying data in this function. In the like AmiQuote example shown in ADK, it uses different CSV (TXT) for each ticker. Whenever it gets called, it opens up the file, loads data and sends it.

Due to certain constraints, I want to only one file for all the tickers and naturally ticker name will be part of the line. What is the most efficient way to do it? What I mean is that ticks get stored in one file and data gets pushed into Ami ...

Currently I use COM interface which works very well using only two files for all symbols, so this question is to understand the ADK better.
 

josh1

Well-Known Member
#2
Hi,

The COM interface as its name is, only provides interface or exposes some of the functions of Amibroker. When you design a plug in you get access to the functionality of Amibroker. Thus single file will suffice if it contains scrip name in each line and you provide format of line in the format folder.
 

mastermind007

Well-Known Member
#3
Hi,

The COM interface as its name is, only provides interface or exposes some of the functions of Amibroker. When you design a plug in you get access to the functionality of Amibroker. Thus single file will suffice if it contains scrip name in each line and you provide format of line in the format folder.
Hello Josh

Thank you for replying.

I easily use Invoke function in COM

Invoke(fileName, formatFileName)

So, single CSV data file .format file works very well with Invoke functionality in COM, but the plugin has a function

int GetQuotes( LPCTSTR pszTicker, int nPeriodicity, int nLastValid, int nSize, struct QuotationFormat4 *pQuotes )

and plugin is supposed to fill in QuotationFormat4 structure. First parameter dictates the scrip for which data will be added and all examples
that I have uses pszTicker name to open a file or access a database record. So, if you have example that bypasses this, please show.
 
Last edited:

josh1

Well-Known Member
#4
Hello Josh

Thank you for replying.

I easily use Invoke function in COM

Invoke(fileName, formatFileName)

So, single CSV data file .format file works very well with Invoke functionality in COM, but the plugin has a function

int GetQuotes( LPCTSTR pszTicker, int nPeriodicity, int nLastValid, int nSize, struct QuotationFormat4 *pQuotes )

and plugin is supposed to fill in QuotationFormat4 structure. First parameter dictates the scrip for which data will be added and all examples
that I have uses pszTicker name to open a file or access a database record. So, if you have example that bypasses this, please show.
GetQuotes function is for old versions. You should be using GetQuotesEX(). I suppose you have read section 3.4 of the ADK.html file that comes with the ADK. If not, please do.

This function looks for the .aqi format file for parsing lines in ASCII file containing quotation data. After parsing, it fills quotation array with relevant info. This format does not contain scrip name.

Please note- I am basically not a C++ or C# programmer (...trying to help you). My logic is that you hard code pszTicker name for your data file. Include scrip name in your format file and pass that to the array while parsing. That should work.

My all utilities are using single data file to import quotes for multiple symbols using COM interface.
 

mastermind007

Well-Known Member
#5
GetQuotes function is for old versions. You should be using GetQuotesEX(). I suppose you have read section 3.4 of the ADK.html file that comes with the ADK. If not, please do.

This function looks for the .aqi format file for parsing lines in ASCII file containing quotation data. After parsing, it fills quotation array with relevant info. This format does not contain scrip name.
Thanks for reminding GetQuotesEx().

Now you understand the point I am trying to make. Quotation format used by plugin does not have tickername so logically whatever you send will get attached to name contained in string pszTicker.

josh1; said:
Please note- I am basically not a C++ or C# programmer (...trying to help you). My logic is that you hard code pszTicker name for your data file. Include scrip name in your format file and pass that to the array while parsing. That should work.
This I will certainly try but on a temp database :)

My all utilities are using single data file to import quotes for multiple symbols using COM interface.[/QUOTE]

Exactly same situation I also have .... COM Interface is simple but can only deal with subset of supported fields. You can find examples of it in many languages. I have written AFL plugins but this is stumbling block for writing data plugin.
 

mastermind007

Well-Known Member
#7
Did you get any success?
From a single file NO; It does not work as expected. Quotes gets all jumbled up.

You either need to separate file or place some kind of DBMS in between that will allow efficient query.

I use COM approach as it is little bit less code. Efficient or not, I do not know
 

josh1

Well-Known Member
#8
From a single file NO; It does not work as expected. Quotes gets all jumbled up.

You either need to separate file or place some kind of DBMS in between that will allow efficient query.

I use COM approach as it is little bit less code. Efficient or not, I do not know
Since you have already tried this, can you try import command with a single file from your plugin?

Please note that AmiBroker caches response received from GetQuotesEx() and will not ask for quotes again for the symbol until: (a) user chooses "Refresh" from View menu, (b) plugin notifies AmiBroker that new data arrived using WM_USER_STREAMING_UPDATE message, (c) old data were removed from the cache.


So, somewhere in the GetquotesEx() function, we write the import call to Amibroker and tell it to import our single file quotes for multiple stickers.
Say ---- Import(0, FileName, "My.format")

The My.format file could look like this if you are creating bars--
# Format definition file generated automatically
# by AmiBroker's ASCII Import Wizard
$FORMAT Ticker, Date_DMY, Time, Open, High, Low, Close, Volume
$SKIPLINES 0
$SEPARATOR ,
$CONT 1
$GROUP 255
$AUTOADD 1
$DEBUG 1

Or like this if you are passing just single quote for each ticker --
# Format definition file generated automatically
# by AmiBroker's ASCII Import Wizard
$FORMAT Date_DMY, Ticker, Time, Close, Volume, OpenInt, Skip
$SKIPLINES 0
$SEPARATOR ,
$CONT 1
$GROUP 255
$AUTOADD 1
$DEBUG 1

Alternately, can we do away with the remaining code in GetquoteEx() function and just execute import within it?
 

mastermind007

Well-Known Member
#9
Please note that AmiBroker caches response received from GetQuotesEx() and will not ask for quotes again for the symbol until: (a) user chooses "Refresh" from View menu, (b) plugin notifies AmiBroker that new data arrived using WM_USER_STREAMING_UPDATE message, (c) old data were removed from the cache.
This I've read before and I've interpreted it that plugin has to keep notifying Ami to have GetQuoteEx called. Ami will not automatically go looking for data.


So, somewhere in the GetquotesEx() function, we write the import call to Amibroker and tell it to import our single file quotes for multiple stickers.
Say ---- Import(0, FileName, "My.format")

The My.format file could look like this if you are creating bars--
# Format definition file generated automatically
# by AmiBroker's ASCII Import Wizard
$FORMAT Ticker, Date_DMY, Time, Open, High, Low, Close, Volume
$SKIPLINES 0
$SEPARATOR ,
$CONT 1
$GROUP 255
$AUTOADD 1
$DEBUG 1

Or like this if you are passing just single quote for each ticker --
# Format definition file generated automatically
# by AmiBroker's ASCII Import Wizard
$FORMAT Date_DMY, Ticker, Time, Close, Volume, OpenInt, Skip
$SKIPLINES 0
$SEPARATOR ,
$CONT 1
$GROUP 255
$AUTOADD 1
$DEBUG 1

Alternately, can we do away with the remaining code in GetquoteEx() function and just execute import within it?
Josh

Import is a COM oriented feature and GetQuoteEx is a C++ legacy. I've not attempted to merge the two. Here goes my best attempt to explain you Why.

To help understand the difference, visualize Amibroker as a house that has a rear and a front door. Plugin is the front door and COM is the rear door. For sake of simplicity, Front door allows one tick at a time as long as it can provide its name before entering. Ami uses ticker's name to determine where exactly the tick should be seated once indoors. Rear door allows many ticks at once without having to provide the name before entry.

Every time a price tick wants to enter the house, he rings front doorbell (send WM_USER_STREAMING_UPDATE) causing Ami to opens the door (invoke callback GetQuoteEx). At this point, Ami opens door expecting a ticker with a proper name.

If we merge the COM with plugin, we'd be ringing front door, but every time Ami opens the front door, we'd be sending bunch of ticks in thru the rear door. Of course each tick entering thru rear door must know where they should go and seat themselves and cannot rely on guidance from Ami .
 
Last edited:

josh1

Well-Known Member
#10
Every time a price tick wants to enter the house, he rings front doorbell (send WM_USER_STREAMING_UPDATE) causing Ami to opens the door (invoke callback GetQuoteEx). At this point, Ami opens door expecting a ticker with a proper name.
WM_USER_STREAMING_UPDATE is used by Quote Tracker Plugin. I did not find it in anywhere ASCII plugin (Samples). Hence we need not use that message. We need not tell it to open front door.

If we merge the COM with plugin, we'd be ringing front door, but every time Ami opens the front door, we'd be sending bunch of ticks in thru the rear door. Of course each tick entering thru rear door must know where they should go and seat themselves and cannot rely on guidance from Ami .
"OLE automation interface is provided to control AmiBroker from the OUTSIDE process (such as windows scripting host)."
IMHO Plugin is an outside process getting access to inside objects of AMI.
Hence we may try to push data thru rear door. If Ami accepts the command, it will know where to seat the each tick by looking at the format file. (Which it does when I push data from Excel using OLE automation.) User Guide says - it is possible to access Broker.Application and underlying objects from AFL formulas.
In that case, Plugin should be able to do the same.
PS. Import Command will have to be somewhere else since Ami calls back GetQuotes(Ex).
 
Last edited:

Similar threads