WRT_DT_R.C - WRiTe DaTa Routines
ANSI C routines to support creation, writing & updating of CompuTrac &
MetaStock datafiles. Warning though - they do not update the label field
in the master record.
Also creation & writing of ASCII files is supported.
There are 4 main entry points to this module.
output_cpt_dt_file() is used to write a data series to disk in a
binary Computrac/Metastock format. The resulting data file will
contain only the given data.
output_ascii_dt_file() is used to write a data series to disk in a
ASCII format. The resulting data file will contain only the given data.
append_cpt_dt_file() is used to append a data series to a disk file.
The data file will contain its original data plus the new data.
update_cpt_data_record() is used to update an existing data record
on disk.
update_cpt_data_record() standard call flow -
1. lookup_data_file_num() // lookup your ticker
2. open_date_file_4_update()
3. get_data_record_n() // fetch the target record
4. do your updating on the DATA_REC
5. update_cpt_data_record() // and put it back
Function
|
create_empty_data_file
|
Include file
|
WRT_DT_R.H
|
Prototype
|
V 1.4 Added create_empty_data_file()
IMPORT void init_data_file_temps( void ) ;
IMPORT void local_exit( int exit_code ) ;
IMPORT void read_dop_file( char *dop_line ) ;
IMPORT void fake_for_missing_dop_file( void ) ;
static void empty_cpt_data_file( int data_file_num ) ;
static void create_cpt_data_file( int data_file_num ) ;
static void create_cpt_dop_file( int data_file_num ) ;
static void update_cpt_master_file( CPT_MASTER_REC *mstrec_ptr , int rec_num ) ;
static void update_cpt_master_file_cnts( void ) ;
static void update_cpt_dt_file_reccnt( void ) ;
static void cnvt_DATA_REC_2_cpt_dt_format( DATA_REC *dt_ptr , long cpt_dt_recs[] ) ;
static CPT_MASTER_REC *get_cur_cpt_master_rec( void ) ;
static CPT_MASTER_REC *get_new_cpt_master_rec( char *ticker , int file_num ) ;
|
Remarks
|
|
Function
|
output_cpt_dt_file
|
Include file
|
WRT_DT_R.H
|
Prototype
|
void output_cpt_dt_file( char *dtbase_path ,
char *ticker , DATA_REC *data_ptr , int rec_cnt , int field_cnt )
|
Remarks
|
This is the only routine you need to call to get a data series dumped to
disk as a Computrac / Metastock data file. This one call will do it all
(assuming you do have a master file in the dtbase_path directory).
|
Function
|
append_cpt_dt_file
|
Include file
|
WRT_DT_R.H
|
Prototype
|
void append_cpt_dt_file(
char *ticker , DATA_REC *data , int rec_cnt , int field_cnt )
|
Remarks
|
Use this routine to append 1 to N new records to a Computrac / Metastock
data file contained in the current database directory data_path.
|
Function
|
update_cpt_data_record
|
Include file
|
WRT_DT_R.H
|
Prototype
|
void update_cpt_data_record(
FILE *data_file , DATA_REC *new_data , int rec_num )
|
Remarks
|
Update a target Computrac / Metastock data rec on disk with the user's
DATA_REC. This routine does not update the record count field in the data
file header nor the date fields in the master file so it must only be used
to update existing records.
|
Function
|
empty_cpt_data_file
|
Include file
|
WRT_DT_R.H
|
Prototype
|
static void empty_cpt_data_file( int data_file_num )
|
Remarks
|
Delete an existing data file and build a new data file with just a
file header in it.
|
Function
|
create_cpt_data_file
|
Include file
|
WRT_DT_R.H
|
Prototype
|
static void create_cpt_data_file( int data_file_num )
|
Remarks
|
Create a new data file and update the master file to reflect it.
|
Function
|
create_cpt_dop_file
|
Include file
|
WRT_DT_R.H
|
Prototype
|
static void create_cpt_dop_file( int data_file_num )
|
Remarks
|
Create a 4, 5, 6 or 7 field (as created by Metastock RT) dop file.
|
Function
|
update_cpt_master_file
|
Include file
|
WRT_DT_R.H
|
Prototype
|
static void update_cpt_master_file( CPT_MASTER_REC *mstrec_ptr , int rec_num )
|
Remarks
|
Update the disk master file with this individual master record.
|
Function
|
update_cpt_master_file_cnts
|
Include file
|
WRT_DT_R.H
|
Prototype
|
static void update_cpt_master_file_cnts( void )
|
Remarks
|
Update the master file data file number counts in the file header.
|
Function
|
update_cpt_dt_file_reccnt
|
Include file
|
WRT_DT_R.H
|
Prototype
|
static void update_cpt_dt_file_reccnt( void )
|
Remarks
|
Update the data file's record count in the file header.
|
Function
|
get_cur_cpt_master_rec
|
Include file
|
WRT_DT_R.H
|
Prototype
|
static CPT_MASTER_REC *get_cur_cpt_master_rec( void )
|
Remarks
|
Get a copy of the master file record that cpt_master_found_idx is
pointing at.
|
Function
|
get_new_cpt_master_rec
|
Include file
|
WRT_DT_R.H
|
Prototype
|
static CPT_MASTER_REC *get_new_cpt_master_rec( char *ticker , int file_num )
|
Remarks
|
Build a new master file record for this ticker.
|
Function
|
open_data_file_4_update
|
Include file
|
WRT_DT_R.H
|
Prototype
|
FILE * open_data_file_4_update( void )
|
Remarks
|
Open the data file in update mode ( "r+b" ).
|
Function
|
cnvt_DATA_REC_2_cpt_dt_format
|
Include file
|
WRT_DT_R.H
|
Prototype
|
static void cnvt_DATA_REC_2_cpt_dt_format( DATA_REC *dt_ptr , long cpt_dt_recs[] )
|
Remarks
|
Convert the DATA_REC record into a Computrac record ready to store to disk.
|
Function
|
output_ascii_dt_file
|
Include file
|
WRT_DT_R.H
|
Prototype
|
void output_ascii_dt_file(
char *out_file_name , DATA_REC *data_ptr , int rec_cnt , int out_7_field )
|
Remarks
|
Output a DATA_REC series to a ASCII file for passing to another program.
|
Function
|
calc_output_places
|
Include file
|
WRT_DT_R.H
|
Prototype
|
int calc_output_places( DATA_REC *data_ptr )
|
Remarks
|
Calculate a output_places value for a given DATA_REC data series. The
calculation is based on the first close in the series.
|
Function
|
create_empty_data_file
|
Include file
|
WRT_DT_R.H
|
Prototype
|
void create_empty_data_file( int field_cnt , char *ticker , char *desc )
|
Remarks
|
|
Function
|
create_empty_cpt_master
|
Include file
|
WRT_DT_R.H
|
Prototype
|
int create_empty_cpt_master( LPTSTR master_loc )
|
Remarks
|
|
Table of Contents
Function Index
generated on 22 September 1998 - 12:56:01
© 1998 Tierra del Fuego Ltd.
|