What is FTShell
|
|||||||||||||||||||||
|
FTShell2.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. FTShell2 replaces and combines the interfaces previously offered by FastTrack.DLL, FTDllShell.DLL, FTindica.DLL, and FTFamRed.DLL. Thus, FTShell2 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. FTShell2 version 6.6 is the latest version. It supersedes and replaces FTShell 6.5. However, it is not binary compatible with 6.5, therefore, both versions are still supplied for backward compatibility. FTShell2 is not dependent on a library known as Stamin32.DLL. This dependency has caused problems with Windows Vista and 7 operating systems especially the 64-bit versions. All documentation using the term, "FTShell", applies equally to the newer FTShell2. As of 3/2011 there is no difference in functionality of FTShell and FTShell2. However, This may change in the future. New development should be based on FTShell2. FTShell requires programming skills. However, even if you are not a programmer, do not delete the files: FTShell.dll, FTShell2 because they are used by various FastTrack and 3rd Party programs. The programs depend on FTShell being maintained by FastTrack. While the 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 FTShell2 "second-generation" interface to make the programmer's task easier. Specific enhancements include:
Steps in using FTShell on your 32-bit Windows computer.
Steps in using FTShell on your 64-bit Windows computer.
Reference for FTShell.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 pickly 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 #1. A typical VB statement allocating space for an array of prices would use,
Dates and Date Functions
Dividend-Adjusted Data
|
|||||||||||||||||||||
| Call Type Name and parameters | |||||||||||||||||||||
| Property | ArrayBase(ABase as variant) as Variant
|
||||||||||||||||||||
| Function | Date2Julian(ByVal
vDay as
variant )
as Variant
Returns Julian Dates
|
||||||||||||||||||||
| Function |
Date2Str(vDay as variant,
optional vFMT as variant) as Variant
|
||||||||||||||||||||
| Function |
Date2MarketDay (vDay as Variant) as Variant
|
||||||||||||||||||||
| Function | DateMath( interval As String,
number As Double, vDay As Variant) as Variant
Above, Date Math returns 28-Feb-95, not 31-Feb-95.
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 "business days". Applications that would require skipping weekend days (like Saturday and/or Sunday) would have to be custom coded. |
||||||||||||||||||||
| Function |
DivAdjPrices(ByVal symbol As String, optional StrFlag as Boolean
=False, optional Reserved as string) as Variant
Returns all dividend-adjusted prices as a variant containing
Examples of usage Power Basic should include this statement in code.
String of Data If StrFlag is true (=-1) then, the variant returned is a string separated by pipe | characters. There are up to seven significant digits in each number. The first element is the string is the count of subsequent pipe | separated prices. |
||||||||||||||||||||
| 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. |
||||||||||||||||||||
| Function | Family(ByVal FamName As String)
as Variant
String parts:
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. |
||||||||||||||||||||
| 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
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
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: |
||||||||||||||||||||
| Function | FamNameValid(Nam$) as Variant
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. |
||||||||||||||||||||
| Function |
FamWrite(ByVal Fam$) as Variant Writes a four part formatted string to a FTDIR\USERDEF\. The parts are separated by pipe | characters
Note: FTDir is a FTShell functions specifying the path to the installation of FT4Web's databases Error Returns: 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, "|") | ||||||||||||||||||||
| Property | FTAccount as variant
| ||||||||||||||||||||
| Property | FTDBOpen as Variant
| ||||||||||||||||||||
| Property | FTDir as Variant
| ||||||||||||||||||||
| Function | HeadTail(ByVal
Source As String, Optional ByRef Tail as string, ByVal N as Long ) as
Variant 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:
| ||||||||||||||||||||
| Function | isIssue(ByVal symbol As String) as
Variant Returns true when
| ||||||||||||||||||||
| Property | LastErrNum() as Variant
| ||||||||||||||||||||
| Property | LastErrText (Optional
ErrorNumber as Variant)
as Variant
| ||||||||||||||||||||
| Function | MarketDay2Date(ByVal
vDay As Long) as Variant
| ||||||||||||||||||||
| Function | MarketDay2Julian(ByVal
vDay As Variant) as Variant
| ||||||||||||||||||||
| Function | MaxNumDays as Variant
| ||||||||||||||||||||
| Function | RelIndex(ByVal sym As String) as Variant
| ||||||||||||||||||||
| Function | Shell_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:
| ||||||||||||||||||||
| Function | StartMarketDay (ByVal symbol As String) as Variant
| ||||||||||||||||||||
| Function | StartMarketDay (ByVal symbol As String) as Variant
|
||||||||||||||||||||
| Function | UpdateStatus(ByRef
Status as string) as Variant
(FTShell2 only)
Use this call to determine if the databases are all updated to the same date.
| ||||||||||||||||||||
Mathematical Functions | |
| Function | AccuTrack(ByVal vDay as variant, ByVal ShortParam as Single, ByVal LongParam as Single, ByRef RedvPrices As Variant, ByRef GreenvPrices As Variant) As Variant
|
| Function | AnnReturn(ByRef vPrices As Variant, ByVal StartDate As Variant, ByVal EndDate As Variant) As Variant
|
| Function | Correlation(ByRef vPrices As Variant, ByRef vBasis As Variant, CorLength As Variant, ByVal StartDate As Variant, ByVal EndDate As Variant) As Variant
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 ( change per day).
|
| Function | MovingAvg(ByRef vPrices As Variant, SmoothDays As Variant, ByVal StartDate As Variant, ByVal EndDate As Variant) As Variant
|
| Function | RSI(ByRef vPrices As Variant, NDays As Variant, ByVal StartDate As Variant, ByVal EndDate As Variant) As
Variant
|
| Function | SD(ByRef vPrices As Variant, ByVal StartDate As Variant, ByVal EndDate As Variant) As Variant
Returns a variant containing a single floating point value which is the Standard Deviation of the returns of the vPrices dividend-adjusted price series. This value should match the value in FT4Web for the period. SD measures the volatility of returns,
There is an example of use in C:\FT\FT4WIN\ftdeveloper\FTShell\Excel\ |
| Function | SimpleMovingAvg(ByRef vPrices As Variant,
Byval NDays As Variant, ByVal StartDate As Variant, ByVal EndDate As Variant) As Variant
|
| Function | UlcerIndex(ByRef vPrices As Variant, ByVal StartDate As Variant, ByVal EndDate As Variant) As Variant
|
| Function | UPIndex ( ByRef vPrices As Variant, ByRef vBasis As Variant, ByVal StartDate As Variant, ByVal EndDate As Variant) As Variant
|
| Function | Yield1Y ( ByRef Symbol as string, ByVal vEnddate as variant) As Variant (FTShell2 only)
|
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
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 FTShell2.clsFTshell2 '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
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 FTshell2 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 FTShell2.clsFTShell2
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
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;
FTShell2.clsFTshell2 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.
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 FTShell2.clsFTshell2
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 levelEnd 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 SubNotes: 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
Reference the object:
FTD=GetObject("C:\FT\FT4WIN\ftshell2.dll","FTShell2.clsFtShell2")
*All variables should be passed by reference using an "@" before the variable.