TDF_LIB Programmer's Guide



Table of contents.

Library overview.
Library operation.
Sample programs.
Compiler support.
Installation notes.
Software License Agreement.
Technical Support Agreement.

Library overview.


The Tierra del Fuego Ltd library you have purchased (hereafter called TDF_LIB) consists of the same code that we use to build our products. It is what we like to humbly consider the ultimate market analysis programmers' toolkit. It contains a standardized data access subsystem, hundreds of indicator routines, a fast & tiny graphics subsystem, routines to handle every kind of date conversion and hundreds of other type utility routines. Also included are 6 sample programs to get you started with the library. And these are not toy programs, I use all of them myself, one I distribute as a free utility, and one I sell as a product. No matter what you want to do in market software, starting from the TDF_Lib you are already more than half way done.

The doc set consists of 5 library reference files - TDF_LIB.DOC (this file), TDFLIBR1.DOC, TDFLIBR2.DOC, TDFLIBR3.DOC (reference manual volumes 1, 2 & 3) and FUNCTIDX.DOC (both reference manuals table of contents and a complete function index). There are also doc files for 2 of the sample programs - CSTM_RPT.DOC and DUMP_CDT.DOC. The complete doc set is available on-line via the program LIB_HELP (or TDF_HELP if running from the \tdf_ltd directory). TDF_LIB.DOC gives a general overview of the library, for specifics on the modules in the library and their routines there are the reference manuals. TDFLIBR1.DOC documents the indicator functions (both the stand-alones and the CSTM_RPTs), TDFLIBR2.DOC covers the rest of the library's utility modules and finally TDFLIBR3.DOC covers the demo programs.

Library operation.


The library consists of 95 % C and 5 % assembler. There are ready to go versions already built for both Microsoft and Borland. This document and the library have been written for programmers. The best documentation is down where you need it, in the source. All of the functions have been documented in the reference manual volumes 1, 2 & 3 and cross-referenced and indexed in functidx.doc. Using the F1 search in OLM you are always just a couple of keystrokes away from your answer. All that is needed here are a few comments on a few of subsystems.

Standardized database access


One of the strongest advantages of the TDF library is a standardized database access subsystem. This allows you the programmer to code and not have to worry about differing binary storage formats between data vendors. The most common formats are supported (CSI, Computrac, & Metastock and well as ASCII). The programmer always has a standard 7 field data record to work with (date,high,low,close,vol,open,oint).
The data access subsystem only needs 2 pieces of data defined before you can use it. You must define the database type and the database directory path. Look for the set path stuff in stdbpath.c. Once the database has been defined the basic access routines are in dtfl_acc.c. From this module there are just 4 calls you need to use to lookup a ticker's data file, open it and load all its data. There are also 2 files of advanced database functions layered on top of dtfl_acc.c. These files are memcptdt.c for memory master file caching, lazy man's 1 function file lookup and load, and forward date searching functions and wrt_dt_r.c for Computrac/Metastock data file writing.

Indicators

Almost all the common indicators are coded up somewhere (at-least that is all public-domain non-proprietary indicators). Everything is supported in CSTM_RPT and what isn't can be programmed in CSTM_RPT with its primitives. Most indicators are also supported in callable module format also. The stand-alone module versions allow you to call them and pass them the data and the CSTM_RPT versions support secondary data sourcing and forward projecting. See the CSTM_RPT docs and the module banner for the file cstm_ind.c for more information about secondary data sources and forward projecting.

GRX subsystem

The graphics subsystem is a nice, fast, & tiny EGA level 1 driver and the level 2 and 3 routines to build a very versatile little package. I use this package myself in my real-time data collection program. I know its not 1024 X 1024 VGA but I really must challenge you as to why you need that to plot 50 or 100 data points. Don't be concerned if you have a VGA system, the VGA supports the EGA modes. I would rather get it on the screen fast then have incredible resolution. So I know the code is old and ugly, but true beauty lies deeper. In this tiny package you get 7 pre-defined screen layouts, bar, candlestick, equivolume or indicator charting, indicator histograms and chart overlays.

Command line switch processing

In getargs.c you will find complete support for parsing, converting and storing of user command line switches into your programs variables. The command line switches can be of the following types: INTEGER , BOOLEAN , CHARACTER , STRING , FLT.

Run-time configuration processing

In prc_cnfg.c there is complete support for processing and storing variable data in free-form ASCII configuration files. The individual configuration entries may also have their own validation routines.

Date support and conversion

All the common date formats that one normally finds in market data are supported with conversions routines. The supported formats are YYMMDD floats, YYMMDD strings, MM/DD/YY strings , European DD/MM/YY strings and UINT julian dates. Also supported is holiday tracking. See modules j_date_r.c, c_date_r.c, dos_time.c and mrk_dayr.c.

No Menu

The argument can be made that missing from the library are menuing routines. But I must say that this space is intentionally blank. No seriously, there are many types of menu and GUI libraries out there, in many levels of complexity so I feel that the market doesn't need another. If you need one I could give you a couple of recommendations as to the 2 packages I use. One is the interface you see in the help subsystem front-ends TDF_HELP & LIB_HELP and the other is the interface used in the Trading Room.

Sample programs.


Ok there is a lot of code here (over 28000 lines). Even if I wrote vast dialog on every line, you would still have to dig in to the code and read it to understand how things work. For me the best way to learn something is with examples. So included in the package are 3 sample programs, 1 ultimate sample program (an entire actual product) and a pair of convenient tools. The programs that use a run-time configuration file to define the database info are shipped with a executable, but the ones that use the other way (defined constants) will need to be rebuilt on your box. So let's dig in.

DUMP_CDT

Let's start with a pretty clear subsystem example. The program dump_cdt.c started out as the testbed that I used to develop the standardized data base access routines in dtfl_acc.c. The program also has some easy rules about the database directories so it doesn't bother with any of the stdbpath.c or prc_cnfg.c code. This program also doesn't use any of the fancy database stuff in memcptdt.c or wrt_dt_r.c. This program is now something I give away as a free utility so I have even wrote a manual for it (dump_cdt.doc). The manual also has some good info on the difference between database types. It is ready to run.

ANAL_CYC

The anal_cyc.c is a good example of a narrow subject question being answered in software fast using the library. The basic problem was that I wanted a simple way to track a few cycles against a couple of markets. I also wanted to watch for Bower Power shifts. Since I only use this program for only a couple of markets, the database path code uses default constant strings for database dir path and database type that are defined in stdbpath.h. You will also need to update the file cycle.dat which is currently setup for the Dow industrials. You will need update the ticker string to whatever ticker you use (if you don't have Dow data, just use any stock market index). The cycle record definitions should be self-explanatory. You may also have to update the compressed print printer escape sequences if your printer isn't a IBM / Epson compatible. You will need to rebuild this program for your environment.

SNAPSHOT

Snapshot is a useful tool I use to check things during the day. Since it is tiny program it runs in little memory with my real-time collection package also loaded and running. The program is crude (Metastock its not) but Metastock doesn't run in 100000 bytes of memory. It is good example of the GRX subsystem. This program supports run-time configuration files so once you have update the default RTCF "TDF_DATA.CNF" for your machine's environment this one will be ready to go.

CSTM_RPT

Cstm_rpt is the real bonus of the package. Full source for a real product. More than 8000 lines of C. Since this is also a product, I have also wrote a manual for it. This program provides a user a way of writing their own custom market reports in English. This program does support run-time configuration files so it is shipped ready to run (once the RTCF has been updated of course). To build a local copy you will need to build a medium TDF library to link against. See the makefile for examples.

NICESHEL

I am the world's laziest typist. So I always clone code rather than type. Hence the program niceshel.c. Niceshel.c is just what the name implies, a nice shell to start with. The program as shipped will compile and run (it just won't do much). But no what what market question you have,if you start cloning from here you are all ready half way done. You have the full TDF library at your beck and call. For example define 1 variable, add 3 lines of code and you could have a program that given a ticker on the command line it would load the ticker's data and graph it.

PPRINT

The C++ program pprint.cpp was something I got a year ago from a mag. What it is is a nice Pretty Printer program for C source. It runs a IBM/Epson type printer in near letter quality mode to produce very nice hardcopy listings. It also runs the printer in compressed mode so you get 96 characters per line. That is why I am shipping a copy, some of my recent source lines are longer than 80 characters. The program does have
some nice technology in it though. I hacked another object into the printer object that handles the pretty printing. The new object talks to the print symbiont to support queuing from a program (among other things). Unfortunately to do this it needs to have a directory to work with. The default directory it uses is c:\spooler. Just update the constant in spooler.hpp to change it. Without using the spooler object the printer object will talk to the printer itself and dump the whole file (and you lose your box till its done). With the spooler object active (and the print command loaded) the printer will build a file in the spooler directory with a name of the style DDHHMMSS.PRT (DD-day, HH-hour, etc.) and then queue it to the print queue. This does mean though you will have to cleanup this directory but a simple "del c:\spooler\*.prt" in your autoexec.bat will work just fine. The program as shipped requires that you use the command line switch /s to tell the printer to use the spooler. Once you have updated the spooler.hpp also update pprint.cpp to define AUTO_SPOOLER and you won't have to use the command line
switch. I'm sorry, I only have Borland C++ so I don't know how Microsoft C++ will handle this.


Compiler support.


I use both Microsoft and Borland Turbo C so the code runs clean on both of them. There are a couple of run-time library differences between the 2 compilers, but the TDF_LIB source code has conditional compiles built in to handle them. The machine.h include file defines constants for each compiler. The library make file makefile.mak also defines constants for each compiler. So you don't need to worry about it. Between Microsoft and Borland, they account for over 90% of the C compiler market but if you use another brand, as long is it is ANSI C, the TDF library code will run fine. You will need to update the compiler identification section in machine.h though.

The library as shipped comes with pre-built small memory model libraries. The Microsoft version is called ms_tdf.lib and the Turbo C version is called tc_tdf.lib. There are no restrictions on running other models, I just didn't want to ship 12 libraries. There is a defined make file for the library and the sample programs. Small model builds for both the Microsoft & Borland compilers are defined for the TDF library and all the C sample programs (the CPP sample program is only defined for Borland). There are also examples defined to show how to build other memory models. The primary build targets are tc_tdf, tc_anal_cyc, tc_dump_cdt, tc_cstm_rpt, tc_snapshot, tc_pprint and tc_niceshel for Borland and ms_tdf, ms_anal_cyc, ms_dump_cdt, ms_cstm_rpt, ms_snapshot, ms_pprint and ms_niceshel for Microsoft.

OK, slight problem. I discovered while testing everything after rebuilding my hard disk after a crash that NMAKE complains that the targets are too long (one more reason Borland has won me away from Microsoft). So rather then change the targets (which would make them less readable), I have included an old copy of Borland's MAKE (don't tell Philippe).


Installation notes.


You will need to update the database type and database path strings to reflect your environment in these 2 files - tdf_data.cnf (the default run-time configuration file for programs that use a RTCF) and stdbpath.h for programs that you just want to compile in a constant database type and location. The stdbpath.h must be updated before you build either anal_cyc.c or snapshot.c. The tdf_data.cnf must be updated before you run cstm_rpt.exe.

The \TDF_LIB directory contains 2 ready to go small model libraries. The Microsoft version is called ms_tdf.lib and the Turbo C version is called tc_tdf.lib. You may wish to copy a library to your compiler's library directory and rename it there to just tdf.lib.

Turbo C Users - since Borland doesn't use environment variables for its path information like Microsoft does you will probably have to update the makefile and the project files. In the makefile file you will have to update the DRIVE macro if your compiler is not on the C: drive. The makefile also has support for Turbo C V1.0 program names (!%&%#$ software manufacturers who rename their stuff). Each of the individual program project file will probably also need their compiler include directory path and library directory paths updated. This is easily done via the IDE menu command selections - Options | Directories.

Turbo C Users - You may want to install the help system front-end programs ( TDF_HELP or LIB_HELP ) into the IDE to have the docs available with a hot key while working in the editor. This is easily done via the IDE menu command selections - Options | Transfer. The project file for anal_cyc shows how it is done. It will not work on your box of-course until you update the program path on the Modify/New Transfer Item dialog box. I must confess, you can probably also install the help system into the Microsoft programmer's workbench, it is just that Borland has won the battle for my favorite development environment, so I haven't used Microsoft much in the last 2 years so I don't know how to do it.

Software License Agreement.


The terms of this license shall commence from the date the software package is opened, or thirty days after purchase, whichever occurs first, and shall remain in force in perpetuity. This agreement constitutes the entire agreement unless agreed to in writing in advance by Tierra del Fuego Ltd.. In order to preserve and protect its
rights under applicable laws, Tierra del Fuego Ltd. does not sell any rights in Tierra del Fuego Ltd. software. Rather, Tierra del Fuego Ltd. grants the right to use Tierra del Fuego Ltd. software by means of a software license. Tierra del Fuego Ltd. specifically retains title to all Tierra del Fuego Ltd. software.

Tierra del Fuego Ltd. grants to you the non-exclusive, non-assignable right to use the accompanying source code, royalty-free, on a single computer. Except as provided herein, Tierra del Fuego Ltd. does not grant any express or implied right to you to or under Tierra del Fuego Ltd. patents, copyrights, trademarks, or trade secret information. You may not rent or lease the TDF_LIB source code or otherwise transfer the TDF_LIB source code and accompanying materials.


CONFIDENTIALITY: The library and its manual are protected by copyright, trade secret and trademark law. By accepting this license you acknowledge that the library and manual are proprietary in nature, and that the library and manual contain valuable confidential information developed at great expense, including data processing algorithms, innovations, and concepts. You will not disclose to others or utilize such trade secrets or proprietary information except as provided herein. Under no conditions may this software ever be released to any software competitor of Tierra del Fuego Ltd. If you utilize hired programmer(s) who work at a different site than the address of the original purchaser you must contact me for and have your programmer(s) sign a non-disclosure agreement. These obligations shall survive the termination of this agreement.

You may write and compile programs using the Tierra del Fuego Ltd. source code contained in this package. If you are the licensed, registered owner of this package, you may use, reproduce, give away or sell any program you write in executable form only without additional license or fees subject to the following conditions :

All copies of the program must bear your copyright notice and you will include a single credit line to Tierra del Fuego Ltd. somewhere in your on-line documentation. Also, you agree not to remove any Tierra del Fuego Ltd. copyright or other proprietary rights notice from any portion of the Tierra del Fuego library source code that bears such a notice. Tierra del Fuego Ltd retains title and ownership of all TDF_Lib source code. You must also agree to notify me if you choose to use the library in the general-market distribution program (either as freeware, bannerware, shareware or for-profitware) and provide me with a demo of your finished product. I do not wish to have any editoral input into your work, I, like a proud father just want to see how you used mine and by your feedback I can improve my products for you. If you wish, you may use the TDF BBS for distribution of your software if you develop freeware, bannerware or shareware.

You will remain solely responsible to anyone receiving the program for any support, service, upgrades or technical or other assistance, and such recipients will have no right to contact Tierra del Fuego Ltd. for such services or assistance.

You will indemnify and hold Tierra del Fuego Ltd. and its suppliers harmless from and against any claims or liabilities arising out of the use, reproduction or distribution of the program.

You do not distribute any Tierra del Fuego Ltd. source code in any form (including but not limited to compiled object, ASCII text or hardcopy) regardless of any modifications that you make to the source code.

You may not use any of the source code or sample programs to produce products that are generally competitive with or a substitute for the TDF_LIB library or any of its sample programs.

NO WARRANTIES, The accompanying source code is distributed "as is", without warranty of any kind. To the maximum extent permitted by law, Tierra del Fuego Ltd and all its agents and representatives, disclaims all warranties, either expressed or implied, including but not limited to implied warranties of merchantability and fitness for a particular purpose. The entire risk arising out of the use or performance of the source code and any accompanying materials remains with you.

NO LIABILITY FOR CONSEQUENTIAL DAMAGES, In no event shall Tierra del Fuego Ltd. be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption,
loss of business information, or other pecuniary loss) arising out of the use of or inability to use the source code, even if Tierra del Fuego Ltd. has been advised of the possibility of such damages.

This license statement shall be construed, interpreted and governed by the laws of the State of Michigan. If any provision of this statement is found void or unenforceable, it will not affect the validity of the balance of this statement, which shall remain valid and enforceable according to its terms. All rights not specifically granted in this   statement are reserved by Tierra del Fuego Ltd.

Technical Support Agreement.

With the purchase of this software library you will also receive a credit of $100.00 towards technical support and consulting services.

Rates per hour - By telephone during market hours ( M - F, from CBT T-Bond opening to CME S & P closing) $100.00, All other times $50.00, E-Mail on the Tierra del Fuego Ltd. BBS $25.00 (not for connect time, just billed for my typing time). The basic custom development rate is $50.00 per hour, other rates and billing structures are possible depending on factors like type of project and its size and the completeness of the preliminary design doc. Time will be tracked increments of 6 minutes or 10 message units per hour. Phone callbacks will also carry a surcharge of $1.00 per message unit or $10.00 per hour billed to your tech support account balance.

OK I must say, I'm not in the business of shaking people down for tech support moneys. Bug calls and installation problems will always be free. And of course the meter never runs while talking about possible new business. It is just that my time is valuable so by tracking it, it forces you to value it too. Please try to optimize your calls, write down a question list before calling, have a listing handy and have your box booted up. Also I will not bother to bill your account for a quickie call or two (less than 5 minutes) but please wait till the S & Ps close or call during lunch. The $100.00 account should be more than enough to get most people up to speed with the library so you may also use this credit for custom coding. So if you need a routine or 2 or something in the library doesn't quite meet your needs, let's talk.

Now some more legalese - I can not look over your shoulder and read your screen, so no matter what you say to me and no matter what your problem is, my suggestions will be just that - suggestions only, you must bare all responsibilities for your actions and any consequences. By calling you signify that you do agree to this condition and further agree to indemnify Tierra del Fuego Ltd. against any such claims.