Trading System API  3.0
Library for Simulating and Deploying Trading and Investment Strategies
TSADBBase.h
1 /* ===================================================================
2 *
3 * T R A D I N G S Y S T E M A P I ™
4 * Copyright © 1999 - 2014 by Peter Ritter ( TradingSystemAPI.com )
5 * A L L R I G H T S R E S E R V E D
6 *
7 * Consult your license regarding permissions and restrictions.
8 * You may obtain a copy of the License at:
9 * http://www.TradingSystemAPI.com/licenses/LICENSE-TSAPI-3.0.html
10 *
11 * ====================================================================
12 */
13 
14 #ifndef TSA_DB_BASE__INCLUDED
15 #define TSA_DB_BASE__INCLUDED
16 
17 #include "TSATypeDef.h"
18 #include "TSADataDef.h"
19 #include "TSADBSeriesImport.h"
20 #include <string>
21 
22 namespace tsa {
23 
24  class in_stream_adaptor;
25  class out_stream_adaptor;
26  class mem_table;
27  class file_import_rules__obsolete;
28 
31 
32  /*
33  ** ====================================================
34  ** >>> class data_base <<<
35  ** ====================================================
36  */
37 
47  class dll_export data_base : public tsa::object {
48  std::string m_attach_name;
49  public:
50 
57  data_base(void) { ; }
58 
60  virtual ~data_base(void) { ; }
61 
67  virtual std::string type(void)const = 0;
68 
69  // ????
70  void attach_name(const std::string& name) { m_attach_name = name; }
71 
73  const std::string& attach_name(void)const { return m_attach_name; }
74 
83  void print_table_info(const std::string& table_name, std::ostream& stream);
84  public:
86  virtual in_stream_adaptor* make_input_stream_adaptor(const std::string& stream) = 0;
88  virtual out_stream_adaptor* make_output_stream_adaptor(void) = 0;
89  public:
97  virtual bool table_record_count_is_known(void)const=0;
98 
104  virtual int64_t table_record_count(const std::string& table_name) = 0;
105 
111  virtual date_time series_table_first_timestamp(const std::string& table_name) = 0;
112 
118  virtual date_time series_table_last_timestamp(const std::string& table_name) = 0;
119 
125  virtual bool table_has_data(const std::string& table_name) = 0;
126 
132  virtual tsa::column_defs series_table_column_defs(const std::string& table_name) = 0;
133 
141  virtual date_time series_table_closest_timestamp_LOE(const date_time& target, const std::string& table_name) = 0;
142 
151  virtual void series_load(const std::string& table_name, tsa::mem_table& mtable,
152  const date_time& from_timestamp, size_t num_records) = 0;
153 
161  bool series_columns_match(const std::string& table_name, const tsa::mem_table& m_table);
162 
170  virtual void series_append(const std::string& table_name, const tsa::mem_table& m_table) = 0;
171 
179  virtual void create_series_table(const std::string& table_name, const tsa::column_defs& columns) = 0;
180 
186  virtual bool table_exists(const std::string& table_name) const = 0;
187 
189  virtual bool drop_series_table(const std::string& table_name) = 0;
190 
197  virtual void truncate_series_table(const std::string& table_name,
198  const date_time& new_max_timestamp = date_time::min) = 0;
199 
205  void import(const file_import_rules__obsolete& import_properties);
206 
207  void import(const file_import_params& import_properties);
208 
218  void copy_table_from(data_base& source_db, const std::string& source_table_name,
219  const std::string& target_table_name, const table_copy_params& copy_prop = table_copy_params());
220 
221  // internal use
222  void fill_random(const std::string& table_name, const date_time& start_timestamp, const date_time& end_timestamp,
223  const duration& step, bool some_as_nil = true, size_t max_num_records = tsa::max_size_limit);
224 
225  // internal use
226  void fill_random_series(const std::string& table_name, const date_time& start_timestamp, const date_time& end_timestamp,
227  const duration& step, size_t max_num_records = tsa::max_size_limit);
228  private:
229  void raise__not_implemented(void) const {
230  throw tsa::exception(class_name(), "not implemented", SLOC);
231  }
232  };
233 
235 
236 }
237 
238 #endif
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
virtual ~data_base(void)
Destructor.
Definition: TSADBBase.h:60
Defines the columnar structure of a table. Each column has a name, data type and field size...
Definition: TSADataDef.h:88
#define SLOC
Macro to be passed as argument to Exception constructors. Contains information about the source locat...
Definition: TSAError.h:92
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
Parent class for &#39;in-stream adaptors&#39;. in_stream object rely on adaptors for access to underlying dat...
Definition: TSAStreams.h:52
Abstract base class for delegates of class out_stream.
Definition: TSAStreams.h:553
static const date_time min
Constant representing the smallest allowed date_time.
Definition: TSATime.h:449
Represents a duration - the difference between two date_time values.
Definition: TSATime.h:945
Class tsa::exception used by most classes of the Trading System API library. The class inherits from ...
Definition: TSAError.h:37
Parent class for many library classes.
Definition: TSATypeDef.h:462
data_base(void)
Constructor.
Definition: TSADBBase.h:57
Class representing a gregorian-date and time-of-day combination. The time component has microsecond r...
Definition: TSATime.h:428
Class mem_table represents a memory based table. mem_table objects can be used in strategies both for...
Definition: TSAMemTable.h:48