Loads data from an external text files and attaches it to particular instruments.

 

Note:

To use this method the instrument object must have Instrument Context that is available in a typical instrument script section like the After Instrument Day script section and other instrument script section.

 

Normally this function is used in the Before Simulation or Before Test script, so you need to create a BPV Instrument variable to use it.  It also must be loaded with an instrument by using the LoadSymbol function before executing this function.

 

See also LoadExternalData function.

 

This function requires that all IPV's are created and defined.  When this function is used in the Before Simulation script, the data is only loaded once for the entire simulation.   When placed in the Before Test script, it is loaded (refreshed) before each parameter test-step execution.

 

Note:

When used in the Before Simulation script, to avoid overwriting the data with the default value, the IPV should be set as Simulation Scope.

 

Any header column names in the file itself are ignored.

 

Example

 

This code loads external data files which use the symbol in the name and adds two new instrument properties: beta and eps. These new properties can be accessed in other scripts like:

IF instrument.beta > 1.2 THEN

OR

IF instrument.eps > instrument.eps[90] THEN

 

File Format

The LoadExternalData call requires comma delimited text files with the first column being a date in the format YYYYMMDD.

A header is required, but ignored.

 

A data file, "CL_ExternalData.csv", which corresponds to the above LoadExternalData call might use quarterly data:

Date,     beta, eps
20050115, 1.201, 5.8
20050415, 1.345, 6.2
20050715, 1.112, 5.3
20051015, 1.535, 6.9
20060115, 1.231, 8.4

 

This function will load data into the dates supplied, and the remainder of the IPV will be at the default value.

 

Indexing works like a normal IPV depending on whether this IPV was setup for auto indexing or not. Auto indexing is recommended for this function. For example, using the above data on 20050715:

value = instrument.beta   ' returns 1.112
value = instrument.beta[1] ' returns default value
value = instrument.beta[2] ' returns default value

 

Note:

This function will load date and time data into an IPV as well. The file format would then be Date, Time, column1, column2. This format will  work correctly if the instrument data is also intraday data.  All date time combinations in the file must also be present in the instrument data file.

 

Syntax:

'  No "Date" parameter is used in this function.
loaded = LoadIPVFromFile( fileName, [, columnOne][,columnTwo] [,etc.] )

 

Parameter:

Description:

fileName

The name of the file to open. If no path name is given, it defaults to the location of the instrument data file.

[, columnOne]

Adding More Columns is Optional: The name for the first column of data after the date and optional time.

[,columnTwo]

Adding More Columns is Optional: The name for the second column of data after the date and optional time.

[,etc.]

Adding More Columns is Optional: The name of an additional column of data.

 

Example:

Note:

The variable "portfolioInstrument" is a BPV instrument variable, and is loaded with LoadSymbol prior to the use of this function. The default location for these files is the location of the data for the instrument.  To use a full path, include the "C:\" and any location can be used.

 


VARIABLES: instrumentCount TYPE: Integer
VARIABLES: externalFileName TYPE: String
 
'  Get the instrument count.
instrumentCount = system.totalInstruments
 
'  Loop initializing each instrument.
FOR index = 1 TO instrumentCount STEP 1
 
  '  Set the portfolio instrument. "portfolioInstrument" is defined as a BPV Instrument variable.
  portfolioInstrument.LoadSymbol( index )
   
  '  Get the symbol for the instrument.
  externalFileName = portfolioInstrument.symbol +
          "_ExternalData.csv"
   
  '  Print out the file name.
  PRINT "Loading External File: ", externalFileName
   
  '  Load the external data.
  IF NOT portfolioInstrument.LoadIPVFromFile( externalFileName,
          "beta", "eps" ) THEN
      PRINT "Could not Load External Data for ", externalFileName
  ENDIF
NEXT ' index value

Returns:

TRUE  when the symbol is able to load successfully.

 

Links:

 

See Also:

 

 


Edit Time: 9/25/2017 09:09:54 AM


Topic ID#: 406

 

Created with Help & Manual 7 and styled with Premium Pack Version 2.80 © by EC Software