Starting from QuoteLink 0.78.47 it is possible to use QuoteLink using a new interface based on the use of a Matlab MEX function This results is a very good system to get financial data into Matlab
pathtool
and add the folder:
Program Files (x86)\QuoteLink\bin (for a 32 bits setup) or Program Files\QuoteLink\bin (for a 64 bits setup)
inside that folder you can find 3 Matlab script examples:
last.m, eod.m, clean.m edit them for inspection
Issue the commands:
last('CSCO')
eod('CSCO')
These files are matlab script wrappers and are examples that use the general ql mex function.
The ql mex function is used as follows:
ql( <specification string constant or variable>, , arg1, arg2, ..., argn)
ql('KEY=VALUE KEY1=%1 KEY2=%2 ... KEYn=%n', VALUE1, VALUE2, ..., VALUEn)
the VALUE1 will replace %1 VALUE2 %2 and so on. If %n is present then VALUEn must appear on the right or an error is reported
Example:
ql ('TYPE=QUOTES FEED=IQ FIELD=LAST SYMBOL=%1', 'CSCO')
A key=value pair may also be given in the specification itself like as in FEED=IQ or TYPE=QUOTES
The accepted keys are documented in: key pairs and are the same already being used for Excel
There two new keys specific to Matlab which are MFROM and MTO. They allow the use of matlab time units directly (without conversions) (see eod.m for an example)
When using matlab there is an auxiliary application running named Winql.exe which holds the requests already issued. That way there is no need to reestablished the connections on every invocation. For a streaming feed WinQL maintains a streaming connection with the servers even after the mex file returns control to matlab.
All this results in a very fast answers for any subsequent requests.
The TYPE=CLEAN request (seen in clean.m) lets you empty all the quotes being hold on winql releasing resources. If you don't issue the CLEAN command when the feed limit is attained the older symbols are disconnected. The best way to keep track of what is going on is to keep the log open in verbose mode.The log application in verbose mode shows how many quotes are being monitored/rejected/waiting
If for any reason the ql command does not respond you may use *Ctrl and C* keys pressed simultaneously (like for M files)
*Excel and other apps* You can use use matlab, Excel and .NET applications simultaneously QuoteLink will optimize the connections to the server(s)
The ql MEX command answers synchronously. If you need hundreds of quotes or series it is not efficient to wait for an answer before sending the next as the servers handle much better more than a request at a time. The right way to do that first issue a request containing COMMIT=0 this sends the request but DOES NOT wait for the answer
...
ql ('SYMBOL=AMZN FEED=IQ TYPE=SERIES PERIOD=1 MFROM=%1 MTO=%2 *COMMIT=0*', now - 10, now)
ql ('SYMBOL=AA FEED=IQ TYPE=SERIES PERIOD=1 MFROM=%1 MTO=%2 COMMIT=0', now - 10, now)
ql ('SYMBOL=GOOG FEED=IQ TYPE=SERIES PERIOD=1 MFROM=%1 MTO=%2 COMMIT=0', now - 10, now)
... many more all at once...
with COMMIT=0 the answer is immediate but that doesn't mean the data is already in. I might be or not.
once all requets sent, issue again the same request but without COMMIT=0
ql ('SYMBOL=AMZN FEED=IQ TYPE=SERIES PERIOD=1 MFROM=%1 MTO=%2', now - 10, now)
...
If meanwhile the answer for AMZN came the answer will be instantaneous otherwise the function will wait for the server.
To see what is going on and when the different requests terminate it is useful to have the log application opened as some requests (like months of intra-day …) might take some time.
(please don't use if you are starting now as the MEX version is much better and this approach will be discontinued at some point)
It is possible to import data from QuoteLink into MatLab. Use QuoteLink version ql-0-77-106 or later.
for now use MatLab 32 bits edition
commands to use at the MatLab prompt:
Create a Link object instance. The Link object represents QuoteLink inside MatLab and you need only to do it once
link = actxserver('QLClient.Link')
Synchronous Request L1 quotes
spx = link.Request('SPX.XO', 'IQ') returns a QuoteLink Node object that contains all data for the symbol
spx.GetField('LAST').Value() returns last
spx = link.Series('SPX.XO', 60, 365, 'IQ', 60000) request 1Minute (=60s) bars, 365 days from IQ feed and use a timeout of 60000 milliseconds
cm = spx.Matrix() get a cell array with number of Bars x 6 Colums - where the 6 columns are Time, Open, High, Volume, Close, Volume - time is MatLab serial date
m = cell2mat(cm) cell2mat is a MatLab internal function to convert from cell array to a number matrix
The data is downloaded and cached locally for subsequent use.