Loads data from external text files and attaches it to a specific instruments.

 

This Function has been depreciated because the LoadIPVFromFile & LoadBPVFromFile functions were added to Trading Blox Builder.  Those functions work better than this function and would be a better choice for new projects.

 

Note:

Option-1 is functional, but Option-2 has been removed.

 

Syntax:

instrument.LoadExternalData( externalFileName, "date", "beta", "eps" )

 

Parameter"

Description:

externalFileName

File name of the file you want to load.

date-optional

When this is used, it will add information using the dates.

Optional-Parameters

"date", "beta", "eps" are the additional column names.  These are optional parameters that can be left out.  When the optional column names for the new property data are used, the Auto-Index IPV property names must must match the names of the columns used in calling the function.

 

IF NOT instrument.LoadExternalData( externalFileName, "date", "beta", "eps" ) THEN

 

Note:

When using the instrument object it must have default context such as in the After Instrument Day script.  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 must be loaded with an instrument by using LoadSymbol before using the LoadExternalData function call.

 

See also LoadIPVFromFile function.

 


Option 1:

Declare columns to be added as Instrument Permanent Variables  (IPV)  Auto Index Series so they can then be accessed using the normal instrument.property-name usage and plotted.

 

File Format:

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

 

This code loads external data files which use the symbol in the name and adds two new instrument properties:

beta

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

 

A header is required, but ignored.  To load a  data file with this name, "CL_ExternalData.csv", using the above LoadExternalData the script 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

 


If this function is placed in the Before Test script, it will load (refresh the data by reloading it again) before each parameter test run.

 

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.LoadExternalData( externalFileName,
          "date", "beta", "eps" ) THEN

 
      PRINT "Could not Load External Data for ", externalFileName
  ENDIF
NEXT ' index value

Returns:

Returns a TRUE value when successful.

 

Links:

LoadIPVFromFile

See Also:

Instrument Loading

 


Edit Time: 9/21/2020 2:38:10 PM


Topic ID#: 405

 

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