DTFL_ACC module routines - WIN32

Company Information Software Products TDF Market Reports Download Area take me Home

DTFL_ACC.C - DaTa FiLe ACCess routines

Standardized data file access routines to support Computrac/Metastock, CSI and ASCII data files. For use by the commercial TDF product line. At a abstract level this module is driven by ticker_strs and returns standard records of type DATA_REC (date,high,low,close,vol,open,open_int). It expects that the GLOBAL vars data_path & database_type have already been setup. Random and sequential access is supported for all database types.

standard call flow -
1. - int lookup_data_file_num()
2. - FILE *open_data_file()
3. - int get_data_record_n() and then multiple
int get_next_data_record() Or this alternate method
1. - int lookup_data_file_num()
2. - FILE *open_data_file()
3. - int load_one_intraday_day()

There is also a lazy-mans do everything routine in MEMCPTDT.C that is layered on this module -
1. - DATA_REC *load_last_n_data_records()

Function dspy_dtfl_acc_prc_globals
Include file DTFL_ACC.H
Prototype void dspy_dtfl_acc_prc_globals( void )
Remarks Display the process global vars for module - dtfl_acc.

Function lookup_data_file_num
Include file DTFL_ACC.H
Prototype int lookup_data_file_num( char *requested_ticker )
Remarks Main first entry for this module. We need to look up the user's ticker str in the master file, fetch the data file number and build the data file names. This is the master dispatch routine. After lookup the GLOBAL vars fnd_ticker & fnd_ticker_label will be filled.

Function lookup_cpt_data_file_num
Include file DTFL_ACC.H
Prototype int lookup_cpt_data_file_num( char *ticker )
Remarks The Computrac/Metastock master file lookup routine.

Function make_data_file_name
Include file DTFL_ACC.H
Prototype void make_data_file_name( int data_file_num )
Remarks data_path/F%d.dat

Function make_dop_file_name
Include file DTFL_ACC.H
Prototype void make_dop_file_name( int data_file_num )
Remarks data_path/F%d.dop

Function eat_EQUIS_flag_char
Include file DTFL_ACC.H
Prototype void eat_EQUIS_flag_char( char *str , int cnt )
Remarks EQUIS adds a flag character of a "*" to the end of the master.ticker so we need to eat it before we compare to the user's ticker_str.

Function trim_trailing_white_space_2_cnt
Include file DTFL_ACC.H
Prototype void trim_trailing_white_space_2_cnt( char *str , int cnt )
Remarks Trim a string to only useable stuff before we compare to it.

Function correct_CSI_ticker_error
Include file DTFL_ACC.H
Prototype void correct_CSI_ticker_error( char *str , int cnt )
Remarks CSI does not handle creating ticker fields in a Metastock master file correctly. They don't bother to init the unused space to spaces but they just leave it random dirty values. They just insert a single trailing space - by them using the space as a delimiter - it means you can't have embedded spaces in your ticker string.

Function lookup_csi_data_file_num
Include file DTFL_ACC.H
Prototype int lookup_csi_data_file_num( char *ticker )
Remarks The CSI master file lookup routine.

Function chk_this_csi_master_rec
Include file DTFL_ACC.H
Prototype int chk_this_csi_master_rec( char *ticker )
Remarks Compare the current csi_master to the user ticker, return TRUE if got_it

Function init_data_file_temps
Include file DTFL_ACC.H
Prototype void init_data_file_temps( void )
Remarks Initialize module & subsystem variables before the data file open.

Function open_data_file
Include file DTFL_ACC.H
Prototype FILE * open_data_file( void )
Remarks Main second entry point for this module. Open the data file pointed to by the data_file_name. After the open GLOBAL vars - num_of_data_recs, first_date_in_file, last_date_in_file, & output_places will have been set. Also for ASCII data we need to load the whole file now into far memory so we can support run-time user requests for specific records.

Function set_cpt_output_places
Include file DTFL_ACC.H
Prototype int set_cpt_output_places( void )
Remarks Computrac/Metastock doesn't have a scaler conversion factor like CSI so we need to calculate one.

Function get_data_record_n
Include file DTFL_ACC.H
Prototype void get_data_record_n( FILE *data_file , int rec_num , DATA_REC *data_ptr )
Remarks Main entry point # 3. Now that we have looked up the ticker and opened the file, let's get a specific record for the user.

Function get_next_data_record
Include file DTFL_ACC.H
Prototype void get_next_data_record( FILE *data_file , DATA_REC *data_ptr )
Remarks Main entry point # 4. Once we have first called get_data_record_n we then can call here repeatedly to fetch the next records in the file.

Function cnvt_cpt_data_rec
Include file DTFL_ACC.H
Prototype void cnvt_cpt_data_rec( DATA_REC *data_ptr )
Remarks Convert the current Computrac data record into the user's DATA_REC.

Function load_one_intraday_day
Include file DTFL_ACC.H
Prototype void load_one_intraday_day( FILE *data_file , DATA_REC *data_ptr , int day_num , int bars_per_day )
Remarks Alternate entry point to # 3 & 4. Given the day_num in the file and the intraday bars_per_day, this routine will calc the offset into the file and load one day's worth of intraday data.

Function read_dop_file
Include file DTFL_ACC.H
Prototype void read_dop_file( char *dop_line )
Remarks Called by rd_ascii_data_file to process each line in a Computrac DOP file. This routine will set the field index pointers for the data record convert.

Function fake_for_missing_dop_file
Include file DTFL_ACC.H
Prototype void fake_for_missing_dop_file( void )
Remarks Most programs do not seem to create dop files anymore - so fake up the read index for the missing dop file based on the record size. This of course means the field order is fixed.

Function store_csi_1st_rec_data
Include file DTFL_ACC.H
Prototype void store_csi_1st_rec_data( char *buff )
Remarks Convert and store the CSI vars - csi_file_end_rec_ptr, csi_max_data_ptr, csi_highest_high & csi_lowest_low as well as the normal first_date_in_file & last_date_in_file.

Function cnvt_csi_data_rec
Include file DTFL_ACC.H
Prototype void cnvt_csi_data_rec( DATA_REC *data_ptr )
Remarks Convert a CSI data record into the user's DATA_REC.

Function csi_points_2_dollars
Include file DTFL_ACC.H
Prototype float csi_points_2_dollars( long ltemp )
Remarks Convert and scale a CSI data value into a normal float.

Function csi_2byte_convert
Include file DTFL_ACC.H
Prototype void csi_2byte_convert( int var , float *float_ptr )
Remarks Convert and scale a CSI 2byte data value into a normal float.

Function csi_3byte_convert
Include file DTFL_ACC.H
Prototype void csi_3byte_convert( int var , int var2 , float *float_ptr )
Remarks Convert and scale a CSI 3byte data value into a normal float.

Function strncpy_n_uppercase_it
Include file DTFL_ACC.H
Prototype void strncpy_n_uppercase_it( char *dest , char *src , int cnt )
Remarks Do a normal strncpy into a local var & do a uppercase at the same time.

Function cnvt_null_bytes_2_spaces
Include file DTFL_ACC.H
Prototype void cnvt_null_bytes_2_spaces( char *dest , int cnt )
Remarks Change embedded null bytes (which are C str terminaters) into spaces which are harmless.

Function print_data_struct
Include file DTFL_ACC.H
Prototype void print_data_struct( DATA_REC *data_ptr )
Remarks If we get an error during the conversion of the raw data record (CSI/CPT) into the DATA_REC we come here to dump a debug look.

Function print_csi_1st_recs
Include file DTFL_ACC.H
Prototype void print_csi_1st_recs( void )
Remarks If we get an error during the conversion of the 1st CSI raw data record we come here to dump a debug look.

Function find_last_record
Include file DTFL_ACC.H
Prototype void find_last_record( FILE *file_ptr )
Remarks Read a CSI data file backwards till the 1st non-zero close.

Function clear_data_rec
Include file DTFL_ACC.H
Prototype void clear_data_rec( DATA_REC *data_ptr )
Remarks Clear all the fields in the user's DATA_REC before the record fetch.

Function print_cpt_master_rec
Include file DTFL_ACC.H
Prototype void print_cpt_master_rec( CPT_MASTER_REC *master )
Remarks If log_master_2_output_device is set lookup_cpt_data_file_num will call here to dump the current cpt_master.

Function cnvt_DATA_REC_2_MINI
Include file DTFL_ACC.H
Prototype MINI_DATA_REC * cnvt_DATA_REC_2_MINI( DATA_REC *src , MINI_DATA_REC *dest , int recs )
Remarks Convert a normal DATA_REC (7 fields) into a MINI_DATA_REC (4 fields) to save memory. Will do a automatic realloc if src == dest.

Function lookup_ascii_data_file
Include file DTFL_ACC.H
Prototype int lookup_ascii_data_file( char *ticker )
Remarks ASCII data files are expected to be named ticker.ext where ext is one of [ TXT , ASC , PRN , LOG ], so if we find one we will set the data_file_name for the future open_data_file() call.

Function chk_4_ascii_data_file
Include file DTFL_ACC.H
Prototype int chk_4_ascii_data_file( char *ticker , char *ext_str )
Remarks Check the disk for a specific ticker and extention str combination. If we get a hit, we'll also save the fnd_ticker & fnd_ticker_label vars. Return TRUE if found else FALSE.

Function farrealloc
Include file DTFL_ACC.H
Prototype static void *farrealloc( void *old_block , ULONG bytes_needed )
Remarks since Microsoft doesn't have a farrealloc() we need to do it ourself nope they now got one as of V6.0 except I don't like V6.0 so take your choice.

Function farrealloc
Include file DTFL_ACC.H
Prototype
Remarks //static void far *farrealloc( void far *old_block , size_t bytes_needed ) return _frealloc( old_block , bytes_needed ) ;

Function farrealloc
Include file DTFL_ACC.H
Prototype static void *farrealloc( void *old_block , size_t bytes_needed )
Remarks For VC use the normal realloc.

Function fetch_far_data_rec
Include file DTFL_ACC.H
Prototype void fetch_far_data_rec( DATA_REC *src_ptr , DATA_REC *dest_ptr )
Remarks Fetch a ASCII data record from far memory into the user's DATA_REC.

Function open_n_load_ascii_data_file
Include file DTFL_ACC.H
Prototype FILE *open_n_load_ascii_data_file( void )
Remarks Called by open_data_file, but will do much more. We need to load the whole file now into memory so the user at run-time can request random records.

Function process_1_ascii_line
Include file DTFL_ACC.H
Prototype void process_1_ascii_line( char *line )
Remarks Called by ld_ascii_data_file to process individual ASCII data records.

Function cnvt_commas_2_white_space
Include file DTFL_ACC.H
Prototype void cnvt_commas_2_white_space( char *str )
Remarks Convert all commas in str to harmless spaces.

Function fetch_data_field
Include file DTFL_ACC.H
Prototype float fetch_data_field( DATA_REC *data_ptr , int which )
Remarks Return the requested field from the DATA_REC (do the field switch() in one place so everybody can reuse). The field reference constants to use in the which parameter are - DF_DATE , DF_HIGH , DF_LOW , DF_CLOSE , DF_VOL , DF_OPEN & DF_OINT and are defined in DTFL_ACC.H.

Function store_data_field
Include file DTFL_ACC.H
Prototype void store_data_field( float new_data , DATA_REC *data_ptr , int which )
Remarks Store a new data value into a requested field in a DATA_REC (do the field switch() in one place so everybody can reuse).

Function ld_ind_from_DATA_REC_series
Include file DTFL_ACC.H
Prototype void ld_ind_from_DATA_REC_series( float *inds , DATA_REC *data_ptr , int rec_cnt , int which )
Remarks Load a daily data value or indicator value into a indicator data series from a compacted DATA_REC data series. An example might be storing

Function store_ind_in_DATA_REC_series
Include file DTFL_ACC.H
Prototype void store_ind_in_DATA_REC_series( float *inds , DATA_REC *data_ptr , int rec_cnt , int which )
Remarks Store a daily data value or indicator value into specific field of a DATA_REC data series to form a compacted DATA_REC data series for later output to disk.

Function close_data_file
Include file DTFL_ACC.H
Prototype void close_data_file( FILE *dt_file )
Remarks

Table of Contents Function Index

generated on 22 September 1998 - 12:54:47
© 1998 Tierra del Fuego Ltd.