Support Articles

Support Articles Financial Modelling and Analysis Futuregrowth Asset Management I-NET Bridge DDE Interface Component for MATLAB

Futuregrowth Asset Management I-NET Bridge DDE Interface Component for MATLAB

Dr Tim Gebbie from Futuregrowth Asset Management describes, and makes available, a set of MATLAB functions which Futuregrowth Asset Management developed to access I-Net Bridge transactional and historic data from within the MATLAB environment. The functions interface to the ILINK.EXE interface component using MATLAB's DDE functionality to create and manipulate a custom MATLAB INET object.

To use the MATLAB INET object and methods follow the following steps:

  • Download the matlab_inet zip file.
  • Extract the contents of the zip file retaining the directory structure. You can extract the zip file to any directory you wish. The directory to which you unzipped the files should now contain a directory called "inet". The "inet" directory should contain the files "cell2commandlist.m", "commandlist2cell.m" and "Contents.m" as well at the directory "@inet". The "@inet" directory should contain 8 m-files including "inet.m".
  • Start MATLAB.
  • Use PATHTOOL to add a path to the "inet" directory. For example, if you extracted the zip file to "C:\MATLAB701\work", you need to add a path to "C:\MATLAB701\work\inet".
  • Have a look at the examples (put a link to the html) or use HELP @inet\inet to see the documentation and examples of how to use the MATLAB INET object to access the I-Net Bridge data feed.

 

Note that this program is free software; you can use, redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. See the license terms for more details. (Put a link to the licensing in the html)

Contents

Futuregrowth Asset Management

The Quantitative Equity Division of Futuregrowth Asset Management believes in the ability of a disciplined, dynamic quantitative approach to extract value for clients, from market inefficiencies & behavioural irregularities, while ensuring that fundamental experience is systematically integrated into the process.

Background to the INET Component

In the Quantitative Equity Division we had the business requirement of direct data access from the MATLAB development environment to INET-Bridge. Both real-time data, transactional data and historic data. We have analysts who use Windows XP installations of MATLAB R14sp1 hence the obvious choice was to use the DDE channel management capabilities of MATLAB to fulfill these requirements. This allowed us to use the ILINK.EXE interface component provided by I-NET Bridge. We had the further requirement of data encapsulation and the integration of the encapsulated date-time stamp financial data with the MATLAB financial time-series toolbox objects, the FINTS objects. The INET object forms one small component in the entire suite of financial data management and modeling tools we have constructed to met our business requirements. The active management of domestic risk controlled equity portfolio's.

The INET object is simply a data container that uses three DDE functions to interface with I-NET Bridge via ILINK. It uses DDEINIT to open a channel to one of data services, DDEREQ to use the channel to get the required data and DDETERM to close the channel.

The key problems encountered were that of correctly associating date-time stamps of data from I-NET Bridge with the working day convention we use in-house. Our in-house systems require, for modeling purposes, no phase leads or lags in the data. Data must be recorded on the measurement days, for example, not on the sample period calendar days. This was corrected during the type conversion to the FINTS objects. It also allow the I-NET Bridge data to be easily reconcilled with data from other data sources.

Historic data retrieval

% single stock, single item, monthly sampled
I1 = inet('hist','AGL','CLOSE','01-06-03','01-01-04','M')
% single stock, multiple items, monthly sampled
I2 = inet('hist','AGL','CLOSE,DIV,EARN','01-06-03','01-01-04','M')
% multiple stocks, single item, monthly sampled
I3 = inet('hist','AGL','CLOSE','01-01-94','01-01-04','M')
% multiple stock names, and multiple items last 10 days of data
I4 = inet('hist','AGL,RCH,IMP','CLOSE,EARN','-10','01-01-04','D')

@INET - ILINK hist
-

Topic : hist:AGL:01-06-03:01-01-04:M
Items : CLOSE
Format : string

-
-

@INET - ILINK hist
-

Topic : hist:AGL:01-06-03:01-01-04:M
Items : CLOSE,DIV,EARN
Format : string

-
-

@INET - ILINK hist
-

Topic : hist:AGL:01-01-94:01-01-04:M
Items : CLOSE
Format : string

-
-

@INET - ILINK hist
-

Topic : hist:AGL:-10:01-01-04:D
    hist:RCH:-10:01-01-04:D
    hist:IMP:-10:01-01-04:D
Items : CLOSE,EARN
Format : string

-
-

Type-casting historic data to financial time-series data

% type-casting single stock, single items, to FINTS object
fints(I1)
% type-casting single stock, multiple items, to FINTS object
fints(I2)
% type-casting multiple stocks, single items, to annual FINTS object
fints(I3,'A')
% type-casting multiple stocks, multiple items, to weekly FINTS object
fI4w=fints(I4,'W')
% example of the first object
fI4w{1}
% example of the second object
fI4w{2}


ans =

desc : AGL
freq : Monthly (3)

 

'dates:
(8)'
  'CLOSE:
(8)'
'31-May-2003'   [
12550]
'30-Jun-2003'   [
11589]
'31-Jul-2003'   [
12900]
'31-Aug-2003'   [
13755]
'30-Sep-2003'   [
12452]
'31-Oct-2003'   [
14035]
'30-Nov-2003'   [
13625]
'31-Dec-2003'   [
14300]

 

ans =

desc : AGL
freq : Monthly (3)

 

Columns 1 through 2

'dates:
(8)'
  'CLOSE:
(8)'
'31-May-2003'   [ 12550]
'30-Jun-2003'   [ 11589]
'31-Jul-2003'   [ 12900]
'31-Aug-2003'   [ 13755]
'30-Sep-2003'   [ 12452]
'31-Oct-2003'   [ 14035]
'30-Nov-2003'   [ 13625]
'31-Dec-2003'   [ 14300]

 

Columns 3 through 4

'DIV:
(8)'
  'EARN:
(8)'
[
3.6000]
  [
10.2700]
[
3.9000]
  [
11.1200]
[
3.5000]
  [
9.9900]
[
2.9400]
  [
8.0800]
[
3.2400]
  [
8.9200]
[
2.8800]
  [
7.9200]
[
2.9600]
  [
8.1600]
[
2.8200]
  [
7.7700]

 

ans =

desc : TOANNUAL: AGL
freq : Annual (6)

 

'dates:
(11)'
  'CLOSE:
(11)'
'31-Dec-1993'   [
5488]
'30-Dec-1994'   [
5900]
'29-Dec-1995'   [
5500]
'31-Dec-1996'   [
6438]
'31-Dec-1997'   [
4910]
'31-Dec-1998'   [
4145]
'29-Dec-1999'   [
9925]
'29-Dec-2000'   [
10225]
'31-Dec-2001'   [
18320]
'31-Dec-2002'   [ 12650]
'31-Dec-2003'   [ 14300]

 

fI4w =

[2x3 fints] [2x3 fints]


ans =

desc : TOWEEKLY: CLOSE
freq : Weekly (2)

 

Columns 1 through 2

'dates: (2)'   'AGL:
(2)'
'24-Dec-2003'   [
14539]
'02-Jan-2004'   [
14300]

 

Columns 3 through 4

'RCH:
(2)'
  'IMP:
(2)'
[
1562]
  [
57000]
[
1551]
  [
58000]

 

ans =

desc: TOWEEKLY: EARN
freq: Weekly (2)

Columns 1 through 2

'dates: (2)'   'AGL:
(2)'
'24-Dec-2003'   [
7.6400]
'02-Jan-2004'   [
7.7700]

 

Columns 3 through 4

'RCH:
(2)'
  'IMP:
(2)'
[
5.2800]
  [
9]
[
5.3200]
  [
8.8400]

Historic data retreival following an object based approach

% set the required codes
I1 = set(inet,'codes','AGL')
% set the required items
I1 = set(I1,'items','CLOSE')
% set the required start dates
I1 = set(I1,'start_date','-10')
% set the required end dates
I1 = set(I1,'end_date','')
% get the data
I1 = ilinkdde(I1)
% type convert to a FINT object
fints(I1)

@INET - ILINK hist
-

Topic :  
Items : CLOSE
Format : string

-
-

@INET - ILINK hist
-

Topic :  
Items : CLOSE
Format : string

-
-

@INET - ILINK hist
-

Topic :  
Items : CLOSE
Format : string

-
-

@INET - ILINK hist
-

Topic :  
Items : CLOSE
Format : string

-
-

@INET - ILINK hist
-

Topic : hist:AGL:-10::D
Items : CLOSE
Format : string

-
-


ans =


desc: AGL
freq: Daily (1)

'dates: (10)'   'CLOSE:
(10)'
'01-Nov-2004'   [
13575]
'02-Nov-2004'   [
13721]
'03-Nov-2004'   [
13601]
'04-Nov-2004'   [
13585]
'05-Nov-2004'   [
14000]
'06-Nov-2004'   [
NaN]
'07-Nov-2004'   [
NaN]
'08-Nov-2004'   [
13751]
'09-Nov-2004'   [
14100]
'10-Nov-2004'   [
14327]

Real-time data retrieval

% real time data for multiple shares and items
I9=inet('real','AGL,RCH,IMP','CLOSE,BID,OFFER');

List the objects data

list(I9)

@INET - ILINK real
-

Topic : AGL,RCH,IMP
Items : CLOSE,BID,OFFER
Format : string

-

05:09:09 14327 #N/A #N/A
05:09:23 1750 #N/A #N/A
05:09:14 53400 #N/A #N/A

-

Type casting real time-data to a FINTS object

% type casting to a set of fints objects
fI9=fints(I9)
% example of the first of the set
fI9{1}

fI9 =

Columns 1 through 2

[1x3 fints] [1x3 fints]

Column 3

[1x3 fints]


ans =


desc: AGL
freq: Unknown (0)

Columns 1 through 2

'dates: (1)'   'times: (1)'
'11-Nov-2004'   '05:09'  

 

Columns 3 through 4

'CLOSE: (1)'   'BID: (1)'
[ 14327]   [ NaN]

 

Column 5

'OFFER:
(1)'
[
NaN]

Type convert INET object to a data matrix representation

inet2mat(I9)

ans =

1.0e+005 *

Columns 1 through 3

7.3226 0.1433 NaN
7.3226 0.0175 NaN
7.3226 0.5340 NaN

 

Column 4

NaN
NaN
NaN

Contents file

help inet
help inet/fints

Futuregrowth INET ILINK Toolbox
Version 0.999b (R14) 01-Aug-2004

--------------------------------
Copyright(C)2004 Futuregrowth Asset Management

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA

--------------------------------

Futuregrowth Asset Management
The Quantitative Equity Division of Futuregrowth Asset Management
believes in the ability of a disciplined, dynamic quantitative
approach to extract value for clients, from market inefficiencies
& behavioural irregularities, while ensuring that fundamental
experience is systematically integrated into the process.

General information.
The toolbox provides an interface to INET BRIDGE Historic, Real-time,
Transaction and Ticker data using a DDE channel to the ILINK interface.
It provides an mechanism for the conversion of INET data to FINTS and
FDS objects.

Table 1 : Real-Time DDE Codes

--------------------------------

1ST BOOKS CLOSE DATE BCLSDT1
1ST INTEREST DATE e.g. 30.06 INT_DT1
2ND INTEREST DATE INT_DT2
2ND BOOKS CLOSE DATE BCLSDT2
ANNUAL VOLUME TRADED AVOLUME
MAGIC NUMBER FOR INDICES AVOLUME
ANNUAL VALUE TRADED AVALUE
ANNUAL DIVIDEND DIV
BID BID
BID TIME B_TIME
BIDDER BIDDER
CLOSE CLOSE
CODE CODE
COUPON COUPON - BONDS
CURRENT PRICE
(Using higher/buyer,lower/seller rule)
SPOT
CURRENT PRICE
(As above, excluding foreign trades)
CSHSPOT
DATE PAID LAST DIV. PMT_DT1
DATE OF HIGHEST VALUE IN LAST 12 MONTHS HI12DT
DATE OF LOWEST VALUE IN LAST 12 MONTHS LO12DT
DATE DECLARED LAST DIVIDEND DCL_DT1
DATE OF LOWEST VALUE ALLLODT
DATE PAID 2ND LAST DIV. PMT_DT2
DATE DECLARED 2ND LAST DIV. DCL_DT2
DATE OF HIGHEST VALUE ALLHIDT
DEAL TYPE e.g. CASH, FP, etc. DEALTYP
DIV. STATUS I OR F 2ND LAST DIV. DSTAT2
DIV. STATUS INTERIM OR FINAL LAST DIV. DSTAT1
DIVIDEND YIELD DYLD
EARNINGS YIELD EYLD
FINANCIAL YEAR-END FYE
HIGH FOR THE DAY HI
HIGHEST VALUE IN LAST 12 MONTHS HI12VAL
HIGHEST VALUE ALL_HI
INDEX CODE e.g. IX14,CI27 ICODES
INDEX MEMBER IMEMB
ISSUE DATE BONDS ISS_DT
ISSUER - BONDS ISSUER
LAST TRADE DATE LTDATE
LAST MONTH'S CLOSE M_CLOSE
LAST TRADE LTRADE
LDR 2ND LAST DIV REG_DT2
LDR LAST DIV. REG_DT1
LOW FOR THE DAY LO
LOWEST VALUE ALL_LO
LOWEST VALUE IN LAST 12 MONTHS LO12VAL
MARKET CAPITAL MKT_CAP
MATURITY DATE BONDS MAT_DT
NO. OF DEALS NUM_TRD
NO. OF LAST MONTH e.g 3 = MARCH LSTMNTH
OFFER OFFER
OFFER TIME O_TIME
OFFERER OFFERER
OPEN INTEREST OPN_INT
OPENING TRADE OPN_TRD
PERCENTAGE CHANGE FROM CLOSE PERC
POINTS CHANGE FROM CLOSE POINTS
PREVIOUS TRADE PTRADE
PRICE EARNINGS PEARN_Y
EPS LATEST 12 MONTHS EARN
SECTOR CODE e.g. MGO = MINING GOLD SCODE
SHARE STATUS suspended or not SSTAT
SHARES IN ISSUE SISS
SHORT NAMES SNAME
TIME LAST BID,OFFER OR TRADE UPDATED TIME
TRADE TRADE
VALUE TRADED VAL_TRD
VALUE OF LAST DIVIDEND DVAL1
VALUE OF 2ND LAST DIV. DVAL2
VOLATILITY VTY
VOLUME TRADED VOL_TRD

 

Table 2 : Historic Codes

--------------------------------

ARBITRAGE VOLUME A_VOL
CLEAN PRICE CLEAN
CLOSE PRICE/CLOSE VALUE/CLOSE YIELD CLOSE
DIVIDEND YIELD DIV
EARNINGS YIELD EARN
HIGH PRICE/HIGH VALUE/HIGH YIELD HIGH
LAST TRADE LAST
LOW PRICE/LOW VALUE/LOW YIELD LOW
MARKET CAPITAL M_CAP
MEAN PRICE MEAN
OPEN TRADE OPEN
OPEN INTEREST O_INT
SETTLEMENT PRICE SETTLE
SHARES IN ISSUE SISS
TOTAL PRICE TOTAL
VALUE TRADED VALUE
VOLUME TRADED VOLUME

 

Table 3 : Allowed INET Periodicities

--------------------------------

D - Daily data series (Contiguous)
X - Working Days excluding weekends
W - Weekly data series
M - Monthly data series
Q - Quarterly data series
A - Annual data series



Table 4 : Live Transaction fields
--------------------------------

BID
OFFER
BIDDER
OFFERER
TRADE
DEALTYP
REC_NO

Managing the INET data.
@INET data object - interface to matlab database toolbox
public:
<a href="matlab:help inet">inet</a> - object constructor
<a href="matlab:help fints">fints</a> - type convert to a FINTS time-series object
<a href="matlab:help set">set</a> - set attributes
<a href="matlab:help get">get</a> - get attributes
<a href="matlab:help display">display</a> - display the object
<a href="matlab:help ilinkdde">ilinkdde</a> - parse, connected and execute DDE requests
<a href="matlab:help inet2mat">inet2mat</a> - convert INET object to numeric matrix

Test Code
No test code is provided. Ensure that the holidays function provides
the holidays appropriate for the country this is being used in if
FINTS is used to change to and from business days.

Obsolete functions.
None at this time.

GUI Utilities.
None at this time.

Known bugs.
The numeric format is problematic due to INET data formating.

 

inet is both a directory and a function.

@INET INET data object using ILINK.EXE via DDE channel

I = INET Empty INET object. All properties can be accessed
using SET and GET directly. That is the recommended route.

I = INET(I) Takes itself as an argument. Useful to check
object structure.

I = INET(CODES) CODES can be a cell string array or a comma
separated list of codes.

I = INET(TOP,CODES) TOP gives the required application topic
to be used: 'trans', 'hist', 'real', 'ticker'. CODES is as before.

I = INET(TOP,CODES,ITEMS) ITEMS can be a cell string array or a
comma separated list of codes. ITEMS for 'trans' should be of the
form 'NN:ITEM1,ITEM2,...' where NN is number of rows required.

I = INET(TOP,CODES,ITEMS,STARTDATE) The start date STARTDATE for the
data series can be a.) blank to indicate that the earliest date is
to be used b.) start data specified in the format 'dd-mm-yy' c.) specified
in the form -xx for which STARTDATE = ENDDATE-XX periods and ENDDATE
is the last date for which data is avaliable.

I = INET(TOP,CODES,ITEMS,STARTDATE,ENDDATE) The end date ENDDATE for the
data series can be a.) left blank in which case ENDATE = TODAY -1 b.)
end date may be specified in the format 'dd-mm-yy', or c.) specified as +xx
where ENDDATE = STARTDATE + XX periods.

I = INET(TOP,CODES,ITEMS,STARTDATE,ENDDATE,PERIODICITY) The periodicity
of the data series can be one of the following : 'D','X','W','M','Q','A'.

Example 1: Historic data for more than one entity for the last 10 days
I = inet('hist','AGL,RCH','CLOSE','-10','','D');

Example 2: Historic data for a single entity but many items
I = inet('hist','AGL','CLOSE,EARN,DIV,VALUE','-10','','D');

Example 3: Historic data between two different data ranges
I = inet('hist','AGL','CLOSE','01-10-03','01-12-03','D');

Example 4: Historic data days beyond a given start date
I = inet('hist','AGL','CLOSE','01-10-03','+10','D');

See Also : SET, FINTS, FDS, CONTENTS

 

@INET/FINTS(INET) Typecast INET object to a FINTS object

FTS = FINTS(INET) Convert INET Bridge ILINKDDE object INET
into a time-series object FTS. The type conversion attempts
to find the required information from the object provided.
If there are more than one data item in the FDS object a
cell-array is returned which contains each item as a FINTS object.
Here the date convention of INET is preserved.

FTS = FINTS(INET,FREQ) FREQ can take on any of the allowed frequency
formats:

UNKNOWN, Unknown, unknown, U, u, 0
DAILY, Daily, daily, D, d, 1
WEEKLY, Weekly, weekly, W, w, 2
MONTHLY, Monthly, monthly, M, m, 3
QUARTERLY, Quarterly, quarterly, Q, q, 4
SEMIANNUAL, Semiannual, semiannual, S, s, 5
ANNUAL, Annual, annual, A, a, 6


Here the date convention of INET is convert to the date convention of
MATLAB which uses the last business day when the frequency is changed.
The last business day information is obtained from the holidays files.
Ensure that the holidays file is the modified one that uses the
appropriate country holiday set by default.

Example 1:

>> fints(inet('hist','AGL','CLOSE,DIV,EARN,BID','-10','','D'))

ans =

desc: AGL
freq: Daily (1)

'dates: (10)'   'CLOSE:
(10)'
  'DIV:
(10)'
  'EARN:
(10)'
  'BID:
(10)'
'17-Oct-2004'   [
NaN]
  [
NaN]
  [
NaN]
  [
NaN]
'18-Oct-2004'   [
14465]
  [
2.6300]
  [
6.7900]
  [
14455]
'19-Oct-2004'   [
14094]
  [
2.7000]
  [
6.9600]
  [
14080]

...

Example 2:

>> fints(inet('hist','AGL,RCH,IMP','CLOSE','-10','','D'))

ans =

desc: CLOSE
freq: Daily (1)

'dates: (10)'   'AGL:
(10)'
  'RCH:
(10)'
  'IMP:
(10)'
'17-Oct-2004'   [
NaN]
  [
NaN]
  [
NaN]
'18-Oct-2004'   [
14465]
  [
1797]
  [
51000]
'19-Oct-2004'   [
14094]
  [
1808]
  [
50400]

...

Example 3:

>> f=fints(inet('hist','AGL,RCH,IMP','CLOSE,EARN','-10','','D'))

f = [10x3 fints] [10x3 fints]

The first FINTS object is associated with the first ITEM and the
Second ITEM. The columns of the FINTS object are the entities.

See Also: FINTS, FDS

Contributor details

Author

Dr Tim Gebbie
Head of Research
Quantitative Equity Division
Futuregrowth Asset Management
3rd Floor, Great Westerford
Main Rd, Rondebosch
7700
South Africa

INET Contact

Melanie Forde
Sales and Product Consultant
I-Net Bridge (Pty) Ltd
www.inet.co.za