TDF_lib for WIN32 Programmer's Guide

Warning -
This file has not been fully updated yet. Lots of DOS stuff can still be found :-)
See the release notes file also for more Window32 info.

Table of contents.

Library overview.
Library operation.
Sample programs.                                            updated
Perl Scripts.                                                      updated
Utility programs.                                                updated
Compiler support.
Installation notes.
Technical Support Agreement.                          updated

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 100 % ANSI C. 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

Graphics windows - including HLC & OHLC bars, candlesticks and equivolume charts with overlays. And standalone indicator and histograms. With automatic or user-controlled scaling. All drawing elements are controllable - 16+ million colors and use any TrueType font on your system. Can also be saved to disk as a BMP file.

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. The subsystem is Y2K compliant.

Sample programs.

Ok there is a lot of code here (over 41300 lines of C source plus 2000 lines of perl source and almost 1000 lines of indicator engine code). 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 9 sample programs and a pair of convenient tools and 3 perl scripts. So let's dig in.

TDF_TTY

This program is a real-time data collection client for a Signal data stream. It will read a signal data feed off the serial port, parse, convert and store the data. It will also split the data stream in multiple channels of data which it will broadcast to other applications via UDP (as many as you want). These data channels are news, time stamps and raw quote data. The program will also set your computer's clock to the timestamp broadcast by Signal. This program as shipping only supports output of end-of-day data. If you want a complete collection engine framework with support for real-time data display as both quotes & graphics screens - you will want to look at my currently unnamed product (look_here). Or write it yourself :-)

Warning - this is only a client app, you still need software to drive the receiver and handle passwords. Plus a cable to do a Y-split on the data stream coming out of the receiver.

SNAPSHOT

SnapShot is  Q & D program to load 1 to 4 charts (and possible indicators) and possibly dump the chart out to disk as a bitmap file (which can be converted to a JPG by cjpeg). You can also call SnapShot from a batch file to quickly throw up a series of your favorite charts and indicators for a given ticker (see \tdf\exes\mrk_view.bat). This is also a fine example of the G_WIN subsystem. It can display charts as OHLC bars, candlesticks or equivolume styles with indicator overlays, standalone indicator screens and histograms.

SS2

SS2 is a version of SnapShot compiled with a DOS style main. This yields a program that when called from a batch file in a console session will automatically pause until the window is fully displayed before dumping a bitmap file. It will then return control to the batch file to allow cjpeg to convert the disk dumped BMP file into a JPG suitable web posting. Using a batch file you can build a custom web page / chartbook for yourself daily automatically.

APP_MON

A simple program to monitor heartbeat signals from multiple programs. The heartbeat messages are LAN broadcast UDP packets. The monitored programs can either be local to the machine or remote on the LAN. You can also use this to detect operating system crashes.

BLKBOARD

A nice display program featuring a udp addressable display screen suitable for black-board message display from another app. This is also example of the QS_WIN (Quote Screen Windows) routines.

DUMP_CDT

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.

QSW_DEMO


This is simple demo app for the QS_WIN (Quote Screen Windows) routines.

WLOGGER

A very useful little utility. It will listen to a udp port and log everything seen to a scrolling TTY window. This is also a nice example of  the TTY window routines.

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. You will  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.

CSTM_RPT

Cstm_rpt is the real bonus of the package. Full source for a real product. 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 uses the Indicator Engine of the TDF_lib. You can also process the output report into colored web pages via the crpt2web.pl perl script.

NICE SHELLS - CONS_APP & WIN_APP

I am the world's laziest typist. So I always clone code rather than type. Hence the programs cons_app.c & win_app.c. The shells are just what the header says, a nice shell to start with. Cons_app.c is a shell for building windows console applications and win_app.c is a starting point for building a Windows app. The programs as shipped will compile and run (they 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 (but of course - snapshot already does that).

Perl Scripts.

QUOTESCR.PL

This is a simple client application to monitor a UDP data feed output from TDY_TTY.  This program also shows the power of perl. The complete program including UDP support, vt100 screen display support and realtime parsing and display of the data feed in about 360 lines.

This script can be run from either a MSDOS window or from a Unix telnet session. As a matter of fact that why I wrote it. When I'm out on a contracting job or traveling, I telnet back to my Unix LAN Gateway machine and use this to monitor the markets remotely.

ERR_PAGE.PL & HTMLROUT.PL

A real-time perl client for monitoring a UDP port for debug messages and automatically generating web pages of LAN wide error logs

CRPT2WEB.PL

This is a script to take a output report from CSTM_RPT and generate a HTML web page file with colored indicator signals out of it.


Utility programs.

SENDER

This is a QND to dump a data file out a UDP port.

CJPEG

This is a program to convert BMP files dumped from SnapShot to JPG's suitable for web posting. This program is part of the freeware release from the Indenpendant JPEG Group.


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.

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.

Consulting rates per hour - By telephone during market hours ( M - F, from CBT T-Bond opening to CME S & P closing) $500.00, All other times $100.00, E-Mail consulting $50.00 (not billed for thinking time, just billed for my typing time). The basic custom development rate is $100.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.


Revised on 30 September 1998
-->