What is FTShell3 FTShell version 7.0

last updated 01/19/2016

Note: This page best read with Microsoft Internet Explorer. Other browsers have problems with the indents and tabs.

FTShell3.DLL is a program file that is part of FastTrack's offerings. It is an ActiveX program  that provides computer program  a way to read to the FastTrack database, financial functions, and families interface. Your Windows computer MUST have a working, up-to-date copy of FT4Web and it's databases. It is NOT sufficient to copy databases from another computer.

FTShell3 replaces and combines the interfaces previously offered by FastTrack.DLL, FTDllShell.DLL, FTindica.DLL,  and FTFamRed.DLL.  Thus, FTSHell3  provides dividend-adjusted prices, AccuTrack, moving averages, Ulcer Index, and other statistical functions, as well as access to FastTrack families (lists of growth funds, technology stocks, Vanguard funds, etc.) to your computer programs.

FTSHell3 the latest version. It supersedes and replaces earlier FTShells. However, it is not binary compatible with earlier versions, therefore, all versions are still supplied for backward compatibility.  New development should be based on FTSHell3.

Changes from Prior FTShell2

  • Although FTSHELL2 had few problems and there were very few complaints, Error returns from FTShell2 were not in good shape. FTShell3 returns variants which may contain the desired result or be an error message. In most cases when the return is a negative long Integer (32-bit) then the return is an error. There are also LastERR and LastErrText properties that return helpful information to clarify errors. 
  • VB programmers deal with variable types with the VarType function

  • Many of the FTShell2 function calls now allow you to pass a variant parameter which may contain an array or prices or a ticker symbol.

FTShell requires programming skills. However, even if you are not a programmer, do not delete the files: FTShell.dll, FTShell2.dll FTSHell3  because they are used by various FastTrack and 3rd Party programs. The programs depend on the FTShell s being maintained by FastTrack.

There are also older interfaces (fasttrack.dll,  ftshell.dll, FTFamred.dll) continue to be available with limited support. We no longer suggest that programmers use these directly. Much thought has been put into the FTSHell3 "third-generation" interface to make the programmer's task easier. Specific enhancements include:

  • ActiveX functionality. Microsoft compilers will be able to access FTSHell3 functions using Microsoft's Intellisense features.
  • FTSHell3 is a Windows registered program. Therefore, you can access FTSHell3 from any program running in any folder.
  • FTSHell3 passes and returns Variants (objects in .NET). This makes the interface more uniform and easier to deal with when using VBScript, JavaScript, VB.NET. ASP, PowerBasic, C++.
  • Date and Market day functions have been incorporated. These will allow you to easily transform dates to market days, Julian dates, international dates,  and to recognizable written dates.
  • FastTrack families may be listed, read, and written by FTSHell3.
  • The statistic routines for Moving Average, SimpleMovingAverage, AccuTrack, UlcerIndex, Ulcer Performance Index, and  RSI have also been incorporated.

Steps in using FTShell on your 32-bit Windows computer.

  1. Be sure that you can use FT4Web and see charts. FTSHell3 won't work if FastTrack is not properly installed and updated.

  2. Ensure that fasttrack.dll and ftindica.dll are present in your C:\windows\System32\ folder. They do not have to be installed or registered. Just place them there.

  3. Run the program file. c:/ft/FT4WIN/FTDEVELOPER/FTSHELL/VB_6 Example/FTShell3Test.exe. Obviously if you installed FastTrack somewhere other than C:\ adjust the path shown here. This should produce a window full of numbers and comments as all FTShell3 features are exercised.

Steps in using FTShell on your 64-bit Windows computer.

  1. Be sure that you can use FT4Web and see charts. FTSHell3 won't work if FastTrack is not properly installed and updated.

  2. Ensure that fasttrack.dll and ftindica.dll are present in your C:\windows\SysWOW64\ folder.

  3. Run the program c:/ft/FT4WIN/FTDEVELOPER/FTSHELL/VB_6 Example/FTShell3Test.exe.  Obviously if you installed FastTrack somewhere other than C:\ adjust the path shown here. This should produce a window full of numbers and comments as all FTShell features are exercised.

Reference for FTShell3.DLL ActiveX Interface:

All arguments are passed as ActiveX variants. In .Net development environments use the type Object to receive and pass arguments. VB 5 and 6 aren't picky about variable types and will, generally, automatically convert (coerce) variable types. However, C++ and C# are less tolerant.

Data arrays are all 0 based. That is, they all must have a zeroth element. However, the 0th element is just a duplicate of element the 1st. A typical VB statement allocating space for an array of prices would use,

Dim FT as new FTShell3.clsFTShell  'reference to FTShell
Dim Prices() as Single            '32-bit floating point
Redim Prices(0 to ft.MaxNumDays)  'In .NET the 0 lower bound is implicit and unnecessary

Dates and Date Functions

  • FT databases Dates begin at calendar date 9/1/1988. This is MarketDay #1 and Julian date 32387. Julian dates are computed using Microsoft's standard. That is, Julian dates are sequential numbers starting at December 31, 1899 (Julian date=1).
  • Market Days are a sequential count of days in the database. Generally there are 21 or 22 Market Days in a month. Only US NYSE stock market days are counted. The FT database does not contain data for markets that are open on NYSE holidays.
  • Date functions are not picky about the way you specify a particular day. In the descriptive sections below the vDay variant variable may contain be any String Date format according to your Windows Regional settings, or may be a Julian date, or Market Day. The vDay variant  may contain string variable, numeric variable, or date variable. This offers tremendous flexibility. See http://msdn.microsoft.com/en-us/library/az4se3k1.aspx for an extensive discussion or an alternate link.
    •  For example,
      • Date2Julian(5127)              'a Market Day
      • Date2Julian("12/31/2008")      'a String Date
      • Date2Julian("January 1, 2009") 'a String Date(not a Market Day)
      • Date2Julian(39813)             'a Julian Date
    • All return a Julian Date =  39813 
  • VDay which does not fall on a Market Day will return the date of the previous Market Day.
  • vDay which cannot be resolved to a day will be interpreted as 09/01/1988.
  • vDay that is before 09/01/1988 is interpreted as 09/01/1988.
  • vDay that is after the end of the most recently updated FT database is interpreted as the date of the last day of data in the FT Databases.

Dividend-Adjusted Data

FTShell3 (and all prior api's) provides dividend-adjusted data. This topic is amply covered in FastTrack help documentation. FT4Web displays both adjusted and unadjusted prices, a feature not available through FTShell3.

Programmers: Specially note that dividend-adjustment causes historical data to change. If you stuff FT data into another form of database, then you will be sorry. Your charted data will appear to have big stair-steps when dividends are paid.

Historical data is adjusted so that the return across a dividend will be correct. Prices more recent than a the last dividend will match what is printed in The WSJ . . . but will change when a dividend is paid.

Pick up the data directly from the FT database through FTSHell3 whenever your application requires data. FTShell3 is fast and small . . . far faster and smaller than SQL and other database formats.

More detailed Help

Links within the help point to the help and charts of the FastTrack for the Web product. FT4WEB uses the same data and methods as does FTShell, and may be valuable to you in understanding some of the more technical functions.

Error Handling

Most functions return a Variant ( same as a .Net Object ). If the return is a negative Long Integer (32-bit signed), then it is an error code. You must test the type of returned Variant to determine that the call was successful. Because the FTShell functions return variants, you should always have a variant on the left side of your equations.

General errors which may be returned by any Function call. These include

  • -1: Unable to open/find database file"
  • -2: One or more of the FastTrack database have a corrupted header. Use FTComm to do an On Line Integrity Check
  • -3: The FT4Win INI file is corrupted or registry entries are corrupted. Reinstall FTComm from www.fasttrack.net
  • -4: The symbols.ix file is corrupted and and cannot be rebuilt. This may be a Windows permission problem. Ensure that C:\FT\FT4WIN\SYMBOLS.IX is not write protected, hidden, or in use by some other process.
  • -5: No such issue. The ticker is not found in the FT databases or FNU files.
  • -6: The issue was found, but it's data is corrupted. Run FTComm OLIC.
  • -7: This is an internal error. Call FT Tech support. The Symbols.IX file and the symbols in the database files mismatch.  Execute FTrebuildSymbols.
  • -8: Array Index out of bounds. All Arrays must have a 0th element.
  • -99 and -999: General errors which are fatal. The may have some explanation in the LTerrText propert.

Specific Errors which are returned by Functions

Some functions have errors that are unique to that function.

-100: "DateAdd error#" & Str$(Err) & ": " & Err.Description

-101: "Family GetFamInSeq: No families were found."
-102: "Family GetFamInSeq: No more families. Sequence number beyond the last"
-103: "Family GetType: The Path parameter -does not specify a valid FT folder name."

-104: "Family Read: No families matching FamType"
-105: "Family Read: Rebuilding the Symbols.ix. Do an FTComm Uodate and OLIC."
-106: "Family Read: Read Error No such family."
-107: "Family Read: General Read Error "
-108: "Family Read: The family has no members that are in the current FT Databases."
-109: "Family Read: Unknown Error number"

-110: "Family Write: Existing Family overwritten.S ome family members are not in the FT Database and have been removed."
-111: "Family Write: FastTrack-defined family already exists named . . . No family written."
-112: "Family Write: Number of Family members must the greater than 0. No Family written"
-113: "Family Write: Family name is an invalid filename, use the NameValid function before writing."
-114: "Family Write: Family file is cannot be deleted or overwritten. It may be set to read-only or in use."

-116: "DateMath: The Interval parameter is invalid."
-117: "DateMath: Calculated date is before 1/1/0001 or later than 12/31/9999."

-118: "Fam Delete"
-119: "Family Delete"

-120: "Rateof Return Error. The rate must be a number >-99 and <999 followed by a % sign"
-121: "General: Mathematical error. Division by zero, number to large, etc. "

-131: "Invalid format parameter passed to Date2Str function."

-140: "Invalid Smoothing Parameter passed to MovingAvg function"
-142: "Error within Simple MovingAvg"
-145: "Error within SD"
-147: "Error within RSI"
-150: "Error within Correlation"
-152: "Error within UlcerIndex"
-154: "Error within UPIndex"

Call Type      Name and parameters
Function Date2Julian(ByVal vDay as variant )  as Variant

Returns:  A Julian Date

For most users these are the major date types which can be passed. Click for more detail :

Error returns: All string and numeric values are handled according to vDay rules.

Function Date2Str(vDay as variant, optional vFMT as variant) as Variant

Returns: Returns a String Date inside a Variant.

The vDay parameter is processed using vDay rules before conversion to string. The string is formatted, using Microsoft rules, according to the string in FMT$. Click for format details. For most users these following formats should be sufficient:
 
Example:
The Fourth of July 1996 with Windows Regional USA settings will appear as
  • vFMT= "MM/DD/YYYY"
    07/03/1996    'the 4th was not a Market Day. See Vday rules
  • vFMT optional vFMT parameter is not specified
     7/3/96
  • vFMT= "DD-MMM-YY"
      04-Jul-96
  • vFMT = "#####" '3249 (the Julian  date as a string)

Error returns:

Function Date2MarketDay (vDay as Variant) as Variant

Returns: Converts any date format to a FastTrack Market Day.  

Examples:

For the period 09/01/1988 - 08/31/1989 comprises 364 calendar days, or 252 FastTrack Market days numbered 1 - 252 . . . only US NYSE market days are counted. Data originating in nonUS markets on US holidays markets is not contained in the database.

As a reference;

Market Day       1  =  09/01/1998
Market Day  5027 = 08/08/2008

If DT is does not fall on a Market Day (for example a Saturday), then then last prior market date is returned.

 Error returns: None
Function DateMath ( interval As String, number As variant, StartDate as Date) as Variant
Performs mathematics on a date. Returns the result as a Microsoft date variable within a variant.
 
'The DateAdd function syntax has these named arguments:
 
interval  String expression that is the interval of time you want to add. >
yyyy Year
q Quarter
m Month
d Day

Note: Intervals y and w exist, but are identical to d in function.

ww Week
h Hour
s  Seconds
number Numeric expression that is the number of intervals you want to add. It can be positive (to get  dates in the future) or negative (to get dates in the past).
date  Variant (Date) or literal representing date to which the interval is added.

 

You can use the DateMath function to add or subtract a specified time interval from a date. Note that StartDate is NOT subject to vDay rules. You must enter a valid String Date or Date variable which  WILL NOT be changed to a market date. However, note that the calculated return date will always be adjuted to fall on a market date.
 
For example, you can use Date Math to calculate a date one month from StartDate=#01/31/2001#

DateMath ("m", 1, StartDate)

  • Above, DateMath returns 28-Feb-2001  '
  • If StartDate  is 31-Jan-2000, the same statement above returns 29-Feb-2000 because 2000 is a leap year.
  • If StartDate  is 31-Jan-1999, the same statement above returns 26-Feb-1999 because the 28th was not a Market Day.

If the calculated date would precede the year 100 (that is, you subtract more years than are in date), an error occurs. If number isn't an integer, it is rounded to the nearest whole number before being evaluated.

Note: To add days to date, you can use either "d", "y", or "w". Be advised that the term "weekday" ("w") has nothing to do with skipping weekend days; i.e., it is NOT equivalent to "Market Days". The example below always returns a date which is a Market Day.

 

Error returns:

  • -124 long integer:
    The Interval parameter is invalid.

  • -125 long integer:
    Calculated date is before 1/1/0001 or later than 12/31/9999

Function DivAdjPrices ( ByVal symbol As String, optional  Delimit as String ="", optional Reserved as string)  as Variant

Returns all dividend-adjusted prices as a variant containing either

  • When Delimit is empty (""), an array of Single numbers (32-bit floating point) for the symbol. The array is sized from 0 through the most recent market day. All prices preceding the inception date of the Symbol's data are returned as the same value as the inception day's price. The array(0) price  is always a duplicate of array(1) price. The data for 9/1/88 is in array(1).
  • When Delimit is not empty, a string of delimited data. See below.

Examples of usage

Power Basic should include this statement in code.

dim PA as variant, P!(0 to 1)
Object call FT.DivAdjPrices(Sym) to PA
'check variable type for error - code not shown
Let P!()= PA    'P!() array will be resized as needed in he LET

The Microsoft Visual Basic code looks like this

Dim P!( ), v As Variant, FT as New FTShell3.clsFTShell3
v = FT.DivadjustedPrices(Sym)
If VarType(v)=vbLong then
    debug.print "This is error #" & CStr$(v)  Stop
End If
p!=v

Delimit

If Delimit is empty ( "" ) then, the variant returns an array as discussed above.

If Delimit is not empty, the function returns a string of prices separated  by the characters in Delimit. The first element is the string is the count of prices that follow.

Error returns: Only General Errors

Function FamDelete(ByVal Family$)  as Variant

Deletes family files within the FTPath\USERDEF\ folder. Will not delete any families in other folders. FamDelete will delete write-protected files. Files are NOT moved to the trash can. Delete them and they are gone.

Error Returns:

  • -114: A Family file is cannot be deleted or overwritten. It may be set to read-only or in use.
  • -120: Attempted to delete an FTDEF family. You can only delete families in the \USERDEF folder.
Function Family(ByVal FamName As String) as Variant

Reads an existing family returning a three part string, each part separated by a Pipe character |

String parts:

  1. Family Description text.
  2. A count of number of family members that follow in the string.
  3. The ticker symbols for each family member.

If the returned string is empty, then the family was not found. Check the family name carefully. The name must be a valid Windows file name. Names can be verified with the NameValid function.

Error Returns:

  • -105: Family Read: Rebuild the Symbols.ix. Do an FTComm Update and OLIC.
  • -106: Family Read: Read Error No such family.
  • -107: Family Read: General Read Error
  • -108:Family Read: The family has no members that are in the current FT Databases.
Event FamilyChange (ChangedFamily as Variant)

This event fires in your application when a family has been changed/deleted/added by another call in FTShell. The name of the affected family is passed in ChangeFamily.

Most programmers will simply ignore this event which, unhandled, will cause no problems for most simple programs.

Error Returns: N/A

Function Families (ByVal FamType As String) as Variant

Returns a two part string separated by | pipe characters. The families will be of the type specified by the FamType string

  • a count of families returned in text
  • family names separated by a | pipe character |

If the returned string is empty, then no matching families were found. Check the family type carefully.

FamType:

Families are physical disk files within physical disk folders. Family folders must be contained in the FTPath  folder. The name of the folder is the FamType. Standard predefined FamTypes are

  • USERDEF - User defined families. This folder is directly in the FTPath
  • FTDEF - Fund FastTrack Defined Families. This folder is directly in the FTPath.
  • SFTDEF - Stock FastTrack Defined Families. This folder is within FTPath\FT4WIN\

Other folders containing families may be within FTPath  However, this is an extension of the historical standard operating usage of families and these folders may not be used by legacy applications that do not use FastTrack's DLL's for family access. any folder located anywhere within FTPath will be searched for .FAM files. files which are found to be invalid will not be listed. However, the test is not rigorous. Therefore. it is possible to read a family full of trash. 

Error Returns: General errors

  • -104: Family Read: No families matching FamType
  • -105: Family Read: Rebuild the Symbols.ix. Do an FTComm Uodate and OLIC.
  • -107: Family Read: General Read Error
Function FamNameValid(Nam$)  as Variant
Background: FastTrack maintains predefined families. This DLL will not delete or modify the FT predefined families. The user must pick valid names for the families he creates. Valid names must also follow Windows file name conventions, and cannot be the same as FastTrack-defined family names.

This routine DOES NOT verify the existence of a family. If a user-defined family of the same name exists, then the Name  considered valid.

Returns: 32-bit long signed integers

  • 115: Family Name is a valid name and there is no FastTrack-Defined family of the same name.
  • 116: Family Name is not valid name or there is a FastTrack-Defined family of the same name.

Error Returns: None

Function FamWrite(ByVal Fam$) as Variant

Writes a file containing a four part formatted string to a FT\USERDEF\. The parts are separated by pipe | characters

  • Family name. Should be validated with NameValid before using
  • Family Description text
  • A count of number of family members in text.
  • The ticker symbols for each family member separated by pipe | characters .

Note: FTDir is a FTShell functions specifying the path to the installation of FT4Web's databases

Error Returns:

  • -110: Existing Family overwritten, However, some family members were not in the FT Database and have been removed from the family.
  • -111: FastTrack-defined family already exists. No family written.
  • -112: Number of Family members must the greater than 0. No Family written. None of the family's ticker symbols are in the FT Database
  • -113: Family name is an invalid filename, use the NameValid function before writing.
  • -114: Family file is cannot be deleted or overwritten. May be in use or read-only.

VB 6 Example:

Assuming that you have built a string array of ticker symbols in the variant v, the code to make a family is as follows: 

NX& = ft.FamWrite ("MyStocks|Stocks|" & CStr(UBound(V)) & "|" & Join$(v, "|")

PropertyFTAccount as variant

Returns the FastTrack account number licensed to the current user. this property is read only

Error returns: None

PropertyFTDBOpen as Variant
Returns the status of the initial database open. Because the open occurs at class initialization, there can be no error return.  FTDBOpen=0 means the open was successful. This property is read only. 
Error returns: General Errors
PropertyFTDir as Variant
Returns the installation folder for FastTrack. When FTShell initializes, it locates the FastTrack folder, and saves the root of the FastTrack installation. This is usually C:\FT\
 
Error returns: General Errors
FunctionHeadTail(ByVal Source As String, Optional ByRef Tail as string, ByVal N as Long )  as Variant

Returns:

  • Each time this functions is called the Text string is parsed for a pipe character | Tab Character, or comma character  (separators). If no separator exists then the function returns the source. 
  • The function returns the head (Source characters preceding the separator ). Tail becomes the remaining Source. If the source is empty, then the function returns a null string.  Returned strings are stripped of leading/trailing blanks.
  • When N is >1 then, the head precedes the Nth separator. Tail returns then string after the Nth Separator. 
  • Use HeadTail to separate out elements of the separator delimited string returned by various calls. This makes for easy usage with scripts that are not capable of dealing with arrays.

Programming hint:

Do 'retrieve successive fields from a delimited string
   Head$=HeadTail( Source$, Source$ ) 
Loop until Source$="" 'Source$ becomes smaller with each HeadTail call

Error returns: None

FunctionisIssue(ByVal symbol As String)  as Variant

Returns: True when

  1. The issue is in one of the FT Databases
  2. The issue is an FNU file
  3. The issue is a rate of return (symbol ending in %)

Error returns: General Errors

PropertyLastErr() as Variant

Returns: The Last Error number. Read Only. A Zero return indicates no error. Other error numbers are clarified by the LastErrText.

Note: There is no problem using a single FTShell instance used by a single task. However, the LastErr is a global value that has limited use in multi-threaded environments such as when FTShell3 is used at the web server Windows IIS Application level. Specifically, by the time your program retrieves the LastErr, the err number may reflect a function call made by a different user.
 
If you use LastErr, then we suggest that you instantiate FTShell at the Session level during debugging to avoid this problem.
Error returns: None
PropertyLastErrText ( ErrorNumber as Variant) as Variant

Returns: error text. Read Only. However, the LastErr is a global value that has limited use in multi-threaded environments such as when FTShell3 is used at the web server Windows IIS Application level.

Error returns: None

FunctionMarketDay2Date(ByVal vDay As Long) as Variant

Returns:  Microsoft date type variable. 

Error returns: None
FunctionMarketDay2Julian(ByVal vDay  As Variant) as Variant

Returns: A Julian date.

Error returns: None

FunctionMaxNumDays as Variant

Returns: The number of market days in the most recently updated database. Not all databases may have the same date.

Error returns: None

FunctionRelIndex(ByVal sym As String) as Variant

Returns: the symbol of a market index or index mutual fund. This is the index which is most closely highly correlated to the Sym (correlation of day to day price change).

Since there are only about 100 relevant indexes, this mechanism enables you to group tickers by similarity. Simplistically, a diversified portfolio would not hold multiple issues whose RelIndex is the same.

Error returns: General errors

FunctionShell_Close()

Returns: None

Performs and orderly shutdown of FTShell.  Generally, not calling close will cause no problems. However, in a programming environment where the DLL is instantiated again and again, memory leaks may develop which can be avoided by doing the Shell_Close.

Subsequent calls made to the FTShell object will generate errors. Your program should destroy the FTShell object (set it to nothing) immediately after Close.

NEVER CALL SHELL_CLOSE FROM A WEB APPLICATION. When multiple users are using the FTShell via IIS, this call would only be made in the Global.ASA website shut down event handler.

VB 6 Example:

Dim FT As New FTShell.clsFTshell 'create the object
FT.Shell_Close                   'shut down the object

Error returns: None

FunctionStartMarketDay (ByVal symbol As String) as Variant

The starting FastTrack Market Day for the symbol's data in the FastTrack Database. This is the day before the first change in price in the data series. This often differs from the official inception date.

Error returns: General errors

FunctionStartMarketDay (ByVal symbol As String) as Variant

The starting FastTrack Market Day for the symbol's data in the FastTrack Database. This is the day before the first change in price in the data series. This may differs from the official inception date as funds commonly are flat in their early history.

Error returns: General errorsl

FunctionUpdateStatus(ByRef Status as string)  as Variant (FTSHell3 only)

Use this function to determine if the databases are all updated to the same date.

Returns:

  • Status: a string containing pipe delimited FT database path | Last Date for each database. The string is defined in the calling program, modified by UpdateStatus, and returned to the calling program.
  • Returns True (-1) if all FT Databases are up to date for the same date.
  • Returns false (0): The solutions are to (1) do another FTComm update to resolve the problem, or to (2) delete the databases to which you do not subscribe.

 

Mathematical Functions

Note: any price arrays passed to these functions must have a 0th element i.e Redim X(0,  to last day). On return X(0) and (1) will have the same value. Actual prices begin at the 1st element i.e. X(1). This is for compatibility for languages that require all arrays to start at the 0th element.

Function AccuTrack(ByVal ShortParam as Single, ByVal LongParam as Single, ByRef RedvPrices As Variant, ByRef GreenvPrices As Variant) As Variant

The RedvPrices and GreenvPrices may be 

  •  variants that contain 32-bit floating single arrays of prices.

  • Ticker symbol strings. The prices are read before use.

Returns: 

  • a variant containing a 32-bit floating-point array which contains the same AccuTrack values that FT4Web displays. 

  • All the values are are computed from Inception Date of the RedvPrices to the last day of data.

  • The AT values prior to the Inception Date  backfilled with the AT value on the Inception Date.

To match FT4Web AccuTrack values, you must display a chart which starts on the Inception Date and end of the last date of data in the FTDatabase. The RedvPrices data must match the red line's data in FT4Web. The GreenvPrices data must match the green line's data in FT4Web.  

There is an example of use in C:\FT\FT4WIN\ftdeveloper\FTShell\Excel\

Error returns: General errors

  • Any negative long integer returned is an mathematical error.
Function AnnReturn(ByRef vPrices As Variant, ByVal vStartDate As Variant, ByVal vEndDate As Variant) As Variant

vPrices may be 

  •  A variant that contains a 32-bit floating single array of prices.

  • A ticker symbol string. The prices are read before use.

Returns: A 32-bit floating-point as a variant that contains the same Ann= annualized return that FT4Web displays for the period.

  • vPrices is a 32-bit floating-point array of  prices.
  • vStartDate and vEndDate follow vDay rules.

Error Returns: General errors

  • Any long integer returned is a mathematical error.
Function Correlation (ByRef vPrices As Variant, ByRef vBasis As Variant, CorLength As Variant, ByVal vStartDate As Variant, ByVal vEndDate As Variant) As Variant

vPrices and vBasis may be 

  • A variant that contains a 32-bit floating single array of prices.

  • A ticker symbol string. The prices are read before use.

Returns: A variant containing a single floating point value which is the Correlation of the returns of the vPrice price series compared to the vBasis series. This value should match the Cor= value in FT4Web for the period. Correlation measure the degree to which two different price series exhibit similar movement (daily change).

  • StartDate and EndDate follow vDay rules.
  • Correlation length makes relatively little difference.  The longer the length, generally, the slightly higher the correlation. Common length values are in the range of 1-5.
  • The calculation needs at least 6 samples. For example, the correlation of a 12-market day period should have a correlation length of no more than 2 (and 1 would be better).

Error Returns: General errors

  • Any long integer return is an mathematical error.
  • -150: "Error within Correlation"
Function MovingAvg(ByRef vPrices As Variant, SmoothDays As Variant, ByVal StartDate As Variant, ByVal EndDate As Variant) As Variant

vPrices may be 

  •  A variant that contains a 32-bit floating single array of prices.

  • A ticker symbol string. The prices are read before use.

Returns: A variant containing a 32-bit floating-point

 array of  prices that are the exponential moving average of dividend adjusted prices. Exponential moving averages are usually favored over simple averages for use in stock market analysis.

  • vPrices is a 32-bit floating-point array of  prices.
  • StartDate and EndDate follow vDay rules.
  • SmoothDays must contain a numeric value for the  number of days to be averaged. 50 is a common value. However, the value may contain fractional values, for example 7.5 days. A value of 0 or a negative value will cause an error.

Error Returns:General errors

  • Any long integer return is an mathematical error.
  • -140: "Invalid Smoothing Parameter passed to MovingAvg function"
Function RSI(ByRef vPrices As Variant, NDays As Variant, ByVal vStartDate As Variant, ByVal vEndDate As Variant) As Variant

vPrices may be 

  • A variant that contains a 32-bit floating single array of prices.

  • A ticker symbol string. The prices are read before use.

Returns: A variant containing a 32-bit floating-point array of  RSI values. These should be identical to the RSI values produced by FT4Web.

  • vPrices is a 32-bit floating-point array of  prices.
  • vStartDate and vEndDate follow vDay rules.
  • NDays must contain a numeric value for the  number of days to be averaged. 14 is a common value. Value of <=0 will return an error.

Error Returns: General errors

  • Any long integer return is an mathematical error.
FunctionSD(ByRef vPrices As Variant, ByVal vStartDate As Variant, ByVal vEndDate As Variant) As Variant

vPrices may be 

  • A variant that contains a 32-bit floating single array of prices.

  • A ticker symbol string. The prices are read before use.

Returns: A variant containing a 32-bit floating point value which is the Standard Deviation of the returns of the vPrices  price series. This value should match the SD=value in FT4Web for the period. SD measures the volatility of returns. The calculation is performed on daily prices and adjusted to a monthly-basis.

  • vPrices is a 32-bit floating-point array of  prices.
  • vStartDate and vEndDate follow vDay rules.

There is an example of use in C:\FT\FT4WIN\ftdeveloper\FTShell\Excel\

Error Returns: General errors

  • Any long integer return is an mathematical error.
Function SimpleMovingAvg(ByRef vPrices As Variant, Byval NDays As Variant, ByVal StartDate As Variant, ByVal EndDate As Variant) As Variant

vPrices may be 

  •  A variant that contains a 32-bit floating single array of prices.

  • A ticker symbol string. The prices are read before use.

Returns: A variant containing a 32-bit floating-point array of  prices that are the simple moving average of dividend adjusted prices. Exponential (see above) moving averages are usually favored for use in stock market analysis.

  • vPrices is a 32-bit floating-point array of  prices.
  • vStartDate and vEndDate follow vDay rules.
  • NDays must contain a numeric value for the  number of days to be averaged. 50 is a common value.

Error Returns: General errors

  • Any long integer return is an mathematical error.
  • -142: "Error within Simple MovingAvg"
Function UlcerIndex(ByRef vPrices As Variant, ByVal vStartDate As Variant, ByVal vEndDate As Variant) As Variant

vPrices may be 

  •  A variant that contains a 32-bit floating single array of prices.

  • A ticker symbol string. The prices are read before use.

Returns: The Ulcer Index. Should provide the same value for the period as shown in the FT4Web spreadsheet. The Ulcer Index is a good statistic for comparing the risk of diversified assets.

  • vPrices is a 32-bit floating-point array of  prices.
  • StartDate and EndDate follow vDay rules.

Error Returns: General errors

  • Any long integer return is an mathematical error.
  • -152: "Error within UlcerIndex"
Function

UPIndex ( ByRef vPrices As Variant, ByRef vBasis As Variant, ByVal vStartDate As Variant, ByVal vEndDate As Variant) As Variant

vPrices and vBasis may be 

  • A variant that contains a 32-bit floating single array of prices.

  • A ticker symbol string. The prices are read before use.

Returns: The 32-bit floating-point Ulcer performance Index as a variant. Should provide the same value for the period as shown in the FT4Web spreadsheet. Ulcer Performance Index provides a good statistic for comparing the risk and return of diversified assets.

The vBasis data will always have a UPI value of 0.00 beaucse its drawdown and return will be the basis upon which all the vPrices UPI will be calculated.

  • vPrices and vBasis are a 32-bit floating-point arrays of  prices.
  • StartDate and EndDate follow vDay rules.

Error Returns: General errors

  • Any long integer return is an mathematical error.
  • -154: "Error within UPIndex"
Function

Yield1Y ( ByRef Symbol as string, ByVal vEndDate as variant) As Variant

Returns: The Yield1Y value (a percentage) for the year period ending on  vEndDate. The implicit Start date and End dates follow vDay rules. 

The Symbol parameter may not be an array of prices since such an array would not contain distributions qualitying as income for the Yield calculation.

Error Return: General errors

-118: Yield1Y: The evaluated period must be at least one-year long.

Brief Programmers Guide to using FTShell

There is a program on your computer in C:\FT\FT4WIN\ftdeveloper\FTShell\VB 6 EXAMPLE\FTShellTest.exe which tests much of the functionality of FTShell (not all or it). This program should run on any machine that has a working FT4Web. The VB6 source file is available in c:\FT\FT4WIN\FTDEVELOPER\FTShell\VB 6 Example\FTShellTest_Source_vb6.frm

Visual Basic 6.0 (and VBA)  Practical Example

Using VBA is the most popular way people use FTShell as VBA is included free in every copy of Microsoft Excel. See the c:\ft\ftdeveloper\ftshell\excel\ folder for several examples. The example below runs with VB6 or within VBA. It doesn't contain any Excel cell/column/row references, but rather just outputs text files.

This program prints every bit of dividend-adjusted data in FT Databases to individual text files. Cut and paste into a new VB6 or VBA form or module
Runs about 2,000 text files per minute on an XP Pro 2006 AMD Dual CPU laptop with 2-GB. 

'----Private Sub Form_Load()---VB6 generates this top line

Dim I&, N&, P!(), Symbols$, Sym$
Dim FT As New FTSHell3.clsFTSHell3                     'be sure to set a reference to the FTShell.DLL
Symbols$ = FT.Family("ALL")                          'get a '|' delimited list of families
For I& = 1 To Val(FT.HeadTail(Symbols$, Symbols$, 3))'start parsing the list at the third element (the count of elements)
  Sym$ = FT.HeadTail(Symbols$, Symbols$)             'each subsequent element is a ticker symbol
  P! = FT.DivAdjPrices(Sym$)                         'read the prices
  Open "C:\temp\" & Sym$ & ".TXT" For Output As #1   'the temp folder must exist
  For N& = 1 To FT.MaxNumDays
    Print #1, FT.Date2Str(N&, "MM/DD/YY") & ","; P!(NX&)
  Next N&
  Close #1:  DoEvents                                'allow interrupts and windows events to happen
Next I&
Set FT=Nothing : DoEvents                            'shutdown the class. Allow Windows to deallocate resources before form exits.

'------End Sub-------VBA generates this bottom line

Visual Basic.Net 2005 (and later) Windows Form

All arguments are passed as ActiveX variants. In Net development environments variants are type Object. In most cases VB will coerce (transform) the parameters and returned values to the types needed.

Start VB.NET for Windows Forms with a new project. Right-click on WindowsApplication under the Solution explorer. Select add reference. Select the Browse window. Find FTSHell3 reference to the most recent (highest version). Now you are ready to code

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim ftd As New FTSHell3.clsFTSHell3
Dim prices!() 'empty 32-bit floating point array
Prices! = ftd.DivAdjPrices("FMAGX")' gets a floating point price array for Fidelity Magellan
form1.Text = CStr(prices(10)) 'the 10th price (from September 1988)appears in the form caption
End Sub

C#.NET 2010 Console Application Example

This is an example written in C# using the C#.NET 2010 to call FTShell Features. You must add a reference to FTShell.DLL, a COM object. There is a small executable that runs the example named:

C:\FT\FT4WIN\ftdeveloper\FTShell\CS_Net_Example\CS_NET_EXAMPLE.EXE

This program requires Microsoft FrameWork 4.O, If the program fails due to Framework error, then you can download the Framework 4 Client from microsoft.com. This may involve a lengthy download. Do not bother doing this unless you are a .NET programmer.

For C#.NET programmers, below is the heart of the example.

We have not included executable or source files. It is not practical to attempt to load a .Net 2010 Solution into an older version of .NET. Just make your own console application by cutting and pasting the code below.

C# code .Net 2010
-----------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
object sym = "FMAGX";
Single[] P;
FTSHell3.clsFTSHell3 shell = new FTShell.clsFTshell();

Console.WriteLine("Hit any key to display all FMAGX data");
Console.ReadKey();
P = shell.DivAdjPrices(sym);
for (int i = 1; i <= shell.MaxNumDays; i++)
{
Console.WriteLine( shell.MarketDay2Date(i).ToString("MM/dd/yy ") + P[i].ToString("C"));
}

Console.WriteLine("Hit any key to print FMAGX name");
Console.ReadKey();
Console.WriteLine(shell.SymName(sym));
Console.ReadKey();
}
}
}

End of C# Code
------------------

Programmer Note from FastTracker Roger Hunter:

Be sure to Compile for x86. DO NOT set to "Any CPU" in the Build options. With console programs, Any CPU is the default, while it's x86 for Windows Forms programs. the build option is always set to x86.

Visual Basic.Net 2005 (and later) for access by Windows IIS web pages

This routine should be part out your GLOBAL.ASA file. You do not want to create multiple FTSHELL objects as this may cause conflicts between processes. Putting the reference in the GLOBAL.ASA means that there is one copy of the DLL and that all web page references flow through this DLL in a single threaded manner. No single call to the DLL is lengthy so users should not notice delays. 

Note: Windows Network services MUST have security access to the \FT folder and/or other folders and files that FTShell will use.

Dim FTDll As New FTSHell3.clsFTSHell3
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when IIS start the website
Application.Add("FTDll", FTDll)
Application("FTDLL").ArrayBase(1) 'ESTABLISH FOR ALL SESSIONS. Do not call at Session level

End Sub

Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when IIS shutdowns the website 
Application("FTDLL").shell_close. 'Do not call at Session level
Application.Remove("FTDll")
end Sub

Notes:  Reference in your code in modules (not in global ASA) as follows

Dim FTD as FTDll = Application("FTDLL")
Dim prices() As Single
prices = ftd.DivAdjPrices("FMAGX")

Alternately, use the Application reference. However, you won't get any Intellisense prompting of the available calls

    NX&=Application("FTDLL").DivAdjPrices("FMAGX", prices())

If your web project has a class, be sure the inherits the Application interface. 

Public Class Model
Inherits System.Web.UI.Page   'IMPORTANT: Allows you to access the Application variables
Dim FTD as FTDLL=Application("FTDLL")

. . .
end Class

Visual FoxPro Example

Practical  VIsual FoxPro Example by FastTracker Paul Montgomery:

FP is not a strong typed language. It is possible to declare variables as a particular type but not customary. I was trying to pass 2 arrays (using FTShell2) created by the FTShell2.divAdjPrices() call. I passed them by reference using the VFP syntax of @pricearray1 and @pricearray2. The error I received is well documented on the MS VFP pages but my application of the Service Pack for VFP version 8 did not solve the problem as the site suggested it might. I imagine that VFP 9.0, the last and most stable version, is likely not to have the problem, but the new FTShell3 solved my issue by allowing me to pass tickers instead of price arrays.

Below is a short clip I used to run monthly correlations for the Fidelity Select Family against all the ETF's in the FT database. It could be used to create extensive matrices and studies if the results were stored and sorted in tables and not just displayed to the desktop. It runs very quickly on my XP machine.


******************************************************************************
FTD=GetObject("D:\FT\FT4WIN\ftshell3.dll","FTShell3.clsFtShell3")
lcselectstr = FTD.family("SELECT")
lcetfstr = FTD.family("ETF-ALL")
i = 3
lcselectsym = "*"
DO WHILE !EMPTY(lcselectsym)
lcselectsym = STREXTRACT(lcselectstr,"|","|",i,3)
IF EMPTY(lcselectsym)
EXIT
ENDIF
e = 3
lcetfsym = "*"
DO WHILE !EMPTY(lcetfsym)
lcetfsym = STREXTRACT(lcetfstr,"|","|",e,3)
lcstartdate = FTD.Date2Str(FTD.StartMarketDay(lcetfsym))
lncorrelation = FTD.correlation(lcselectsym,lcetfsym,21,lcstartdate,DTOC(DATE()))
?lcselectsym + " / " + lcetfsym + " " + lcstartdate + " - " + DTOC(DATE())
??lncorrelation
e = e + 1
ENDDO
i = i + 1
ENDDO
ftd.Shell_Close()
***************************************************************************