Trading System API  3.0
Library for Simulating and Deploying Trading and Investment Strategies
TSADBTimescale.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_DBTIMESCALE__INCLUDED
16 #define TSA_DBTIMESCALE__INCLUDED
17 
18 #include "TSATypeDef.h"
19 #include "TSATime.h"
20 #include "TSAOS.h"
21 #include "TSADBBase.h"
22 
23 namespace tsa {
24 
25  namespace timescale{
26 
30  class dll_export converter_base : public tsa::object
31  {
32  public:
33  converter_base(void);
34  public:
35 
39  std::string target_table_data_definition = "open,high,low,close,volume";
40 
45 
50 
54  bool clear_target_table = false;
55 
59  bool clear_target_overlap = false;
60 
65 
69  tsa::date_time begin_time_point = date_time::min;
70 
74  tsa::date_time end_time_point = date_time::max;
75 
76  protected:
77  tsa::data_base* m_source_db_ptr;
78  tsa::data_base* m_target_db_ptr;
79 
80  void verify__source_table(void);
81  void make_or_check_target_ohlcv(void);
82  date_time fix_data_overlap(void);
83 
84  std::string make_tmp_db(void);
85  void copy_source_table_to_tmp_db(tsa::fast::database& db, date_time begin_time_point);
86  void copy_converted_table_data_to_target_table(tsa::fast::database& db,
87  const std::string& converted_table);
88  };
89 
90 
91  class tick_to_multi_tick : public converter_base
92  {
93  fast::database* m_tmp_db_ptr = nullptr;
94  public:
95 
99  size_t num_ticks_per_bar;
100 
104  std::string price_column_name = "last";
105 
109  std::string volume_column_name = "";
110 
111  void convert(tsa::data_base& database);
112  void convert(tsa::data_base& source_database, tsa::data_base& target_database);
113  protected:
114  void convert_table(tsa::fast::database& fast_db,
115  const std::string& source_table, const std::string& target_table);
116  };
117  } // namespace timescale
118 } // namespace tsa
119 
120 
121 #endif
Utility class to manipulate file system paths. This class is intended to fulfil the requirements of t...
Definition: TSAOS.h:36
Namespace for the 'Trading System API' library.
Definition: original1.TSA3Core.cpp:20
Class for managing native timeseries database files. Extremely high speed data access.
Definition: TSADatabase.h:118
Base class for all other database classes such as:
Definition: TSADBBase.h:47
tsa::os::path temp_directory
Pathname of the temporary directory.
Definition: TSADBTimescale.h:64
static const date_time min
Constant representing the smallest allowed date_time.
Definition: TSATime.h:449
std::string target_table_name
Name of the target table.
Definition: TSADBTimescale.h:49
Base class for objects performing timescale conversions.
Definition: TSADBTimescale.h:30
static const date_time max
Constant representing the largest allowed date_time.
Definition: TSATime.h:452
Parent class for many library classes.
Definition: TSATypeDef.h:462
Class representing a gregorian-date and time-of-day combination. The time component has microsecond r...
Definition: TSATime.h:428
std::string source_table_name
Name of the source table.
Definition: TSADBTimescale.h:44