Trading System API  3.0
Library for Simulating and Deploying Trading and Investment Strategies
TSADBSeriesImport.h
1 
2 /* ===================================================================
3 *
4 * T R A D I N G S Y S T E M A P I ™
5 * Copyright © 1999 - 2014 by Peter Ritter ( TradingSystemAPI.com )
6 * A L L R I G H T S R E S E R V E D
7 *
8 * Consult your license regarding permissions and restrictions.
9 * You may obtain a copy of the License at:
10 * http://www.TradingSystemAPI.com/licenses/LICENSE-TSAPI-3.0.html
11 *
12 * ====================================================================
13 */
14 
15 #ifndef TSA_DBSERIES_IMPORT__INCLUDED
16 #define TSA_DBSERIES_IMPORT__INCLUDED
17 
18 #include "TSATypeDef.h"
19 #include "TSAOS.h"
20 #include "TSATime.h"
21 
22 namespace tsa{
23 
24  class database;
25  /*
26  ** ====================================================
27  ** >>> class file_import_rules <<<
28  ** ====================================================
29  */
30 
36  {
37  friend class data_base;
38  mutable date_time last_timestamp_imported = date_time::min;
39  public:
40 
45  public:
47  private:
48  void import_to(data_base& db)const;
49  public:
50 
53 
55  bool create_table = true;
56 
61  bool delete_existing_table = false;
62 
64  bool skip_first_line = false;
65 
73 
79 
81  bool auto_clear_overlap = false;
82 
85 
88 
94  bool timestamp_one_field = true;
95 
101  char datetime_separator = ' ';
102 
107  char field_separator = 0;
108 
116 
118  mutable size_t buffer_size = 10000;
119  };
120 
121  /*
122  ** ====================================================
123  ** >>> class file_import_params <<<
124  ** ====================================================
125  */
126 
127  class file_import_params : public tsa::object
128  {
129  friend class data_base;
130  mutable date_time last_timestamp_imported = date_time::min;
131  public:
132 
137  public:
138  file_import_params(void);
139  private:
140  void import_to(data_base& db)const;
141  public:
142 
145 
147  bool create_table = true;
148 
153  bool delete_existing_table = false;
154 
156  bool skip_first_line = false;
157 
164  std::string file_columns;
165 
167  std::string table_columns;
168 
169  //std::string skip_columns;
170 
176 
178  bool auto_clear_overlap = false;
179 
182 
185 
191  char datetime_separator = ' ';
192 
197  char field_separator = ',';
198 
200  std::string null_string;
201 
208  bool fix_duplicate_timestamps = false;
209 
210 
212  size_t max_records = tsa::max_size_limit;
213 
215  mutable size_t buffer_size = 10000;
216  };
217 
218 
219 
220 
221 
222  /*
223  ** ====================================================
224  ** >>> class table_copy_rules <<<
225  ** ====================================================
226  */
227 
233  {
234  public:
235 
239  table_copy_params(void);
240 
244  ~table_copy_params(void);
245 
249  date_time copy_from_timestamp = date_time::min;
250 
254  date_time copy_to_timestamp = date_time::max;
255 
259  bool delete_existing = false;
260 
265  bool clear_overlap_in_target = false;
266 
271  mutable size_t buffer_size = 100000;
272 
273  };
274 
275 
276 } // namespace tsa
277 
278 
279 #endif
Utility class to manipulate file system paths. This class is intended to fulfil the requirements of t...
Definition: TSAOS.h:36
bool create_table
true to create a database table if it does not exist.
Definition: TSADBSeriesImport.h:55
Namespace for the &#39;Trading System API&#39; library.
Definition: original1.TSA3Core.cpp:20
Describes the rules by which a file is to be imported. This structure is to be used in conjunction wi...
Definition: TSADBSeriesImport.h:35
Base class for all other database classes such as:
Definition: TSADBBase.h:47
std::string date_format
The date format (e.g. yyyymmdd, yyyy-mm-dd, dd/mm/yyyy, etc.). See class date for details...
Definition: TSADBSeriesImport.h:78
std::string columns
The field definitions (mandatory). Must be submitted as a data_def string (e.g. "open:d,high:d,low:d,close:d"). See class data_def for details. Note: Timestamp fields are implicit to every record. Do not add a timestamp field unless you need another timestamp that is unrelated to the record timestamp itself, which is created automatically.
Definition: TSADBSeriesImport.h:72
size_t buffer_size
Size of the buffer.
Definition: TSADBSeriesImport.h:118
bool auto_clear_overlap
true to automatically clear overlap.
Definition: TSADBSeriesImport.h:81
char field_separator
The field separator character (mandatory). Set the character that separates the fields in each record...
Definition: TSADBSeriesImport.h:107
bool timestamp_one_field
Timestamp information (date and time) is assumed to be in a single record field, at the beginning of ...
Definition: TSADBSeriesImport.h:94
A class representing the rules to use when copying database tables (usually between databases)...
Definition: TSADBSeriesImport.h:232
const size_t max_size_limit
The maximum value for size_t.
Definition: TSATypeDef.h:81
bool delete_existing_table
Flag to delete an existing table with given name if it exists at time of import. false by default...
Definition: TSADBSeriesImport.h:61
static const date_time min
Constant representing the smallest allowed date_time.
Definition: TSATime.h:449
bool fix_duplicate_timestamps
Often intraday data will not have a high enough timestamp resolution to guarantee unique records...
Definition: TSADBSeriesImport.h:115
static const date_time max
Constant representing the largest allowed date_time.
Definition: TSATime.h:452
std::string target_table
The table name (mandatory).
Definition: TSADBSeriesImport.h:52
Parent class for many library classes.
Definition: TSATypeDef.h:462
date_time skip_below
The skip below.
Definition: TSADBSeriesImport.h:84
char datetime_separator
If the timestamp consists of both a date and time, the separator character is assumed to be a space &#39;...
Definition: TSADBSeriesImport.h:101
bool skip_first_line
Skip the first line, in case the first line does not contain data.
Definition: TSADBSeriesImport.h:64
Class representing a gregorian-date and time-of-day combination. The time component has microsecond r...
Definition: TSATime.h:428
date_time skip_above
The skip above.
Definition: TSADBSeriesImport.h:87
os::path file_path
Full pathname of the file.
Definition: TSADBSeriesImport.h:44