![]() |
Trading System API
3.0
Library for Simulating and Deploying Trading and Investment Strategies
|
Base class for all other database classes such as: More...
#include <TSADBBase.h>
Public Member Functions | |
data_base (void) | |
Constructor. | |
virtual | ~data_base (void) |
Destructor. | |
void | copy_table_from (data_base &source_db, const std::string &source_table_name, const std::string &target_table_name, const table_copy_params ©_prop=table_copy_params()) |
Copies a table, potentially from one database to another, according to the given table_copy_properties object, which by default copies the entire table. See class table_copy_properties for more details. More... | |
virtual void | create_series_table (const std::string &table_name, const tsa::column_defs &columns)=0 |
Creates a new series table. A series table is a table that has a timestamp as first column. Recall that the timestamp is implicit to all series tables and must not be given as part of the columns definition. More... | |
virtual bool | drop_series_table (const std::string &table_name)=0 |
??????? drop_table | |
void | import (const file_import_rules__obsolete &import_properties) |
Imports records from a text file according to the given import properties. See class file_import_properties for more information. More... | |
void | print_table_info (const std::string &table_name, std::ostream &stream) |
Prints basic information about the table. More... | |
virtual void | series_append (const std::string &table_name, const tsa::mem_table &m_table)=0 |
Appends the records from the given m_table to a database table. This operation will fail if there is overal in the range of timestamps, or if the column structure does not match. More... | |
bool | series_columns_match (const std::string &table_name, const tsa::mem_table &m_table) |
Returns true if a database table has an identical column structure to a given mem_table. More... | |
virtual void | series_load (const std::string &table_name, tsa::mem_table &mtable, const date_time &from_timestamp, size_t num_records)=0 |
Loads a number of series records from a given database table into a mem_table (memory based table) object. More... | |
virtual date_time | series_table_closest_timestamp_LOE (const date_time &target, const std::string &table_name)=0 |
Returns the record timestamp that is closest to, but lower than, the given target timestamp. More... | |
virtual tsa::column_defs | series_table_column_defs (const std::string &table_name)=0 |
Returns the column definition structure. More... | |
virtual date_time | series_table_first_timestamp (const std::string &table_name)=0 |
Returns the timestamp of the first record in the table. More... | |
virtual date_time | series_table_last_timestamp (const std::string &table_name)=0 |
Returns the timestamp of the last records in the table. More... | |
virtual bool | table_exists (const std::string &table_name) const =0 |
Returns true if a database table exists. More... | |
virtual bool | table_has_data (const std::string &table_name)=0 |
Returns true if the table has records, false if empty. More... | |
virtual int64_t | table_record_count (const std::string &table_name)=0 |
Returns the number of records in the table. More... | |
virtual bool | table_record_count_is_known (void) const =0 |
Returns true if the database system knows the size (record count) of a table at all times, or whether it needs to iterate through the table to calculate the size. In the native fast::database knows the table size at all times, whereas SQL databases need to launch the 'select count(*)' command. More... | |
virtual void | truncate_series_table (const std::string &table_name, const date_time &new_max_timestamp=date_time::min)=0 |
Truncates a database table by deleting all records higher than a given new_max_timestamp. More... | |
virtual std::string | type (void) const =0 |
Returns the 'type' of the database as a string, such as "sqlite", "postgresql" or the native "fast". More... | |
![]() | |
object (void) | |
Constructor. | |
virtual | ~object (void) |
Destructor. | |
const char * | class_name (void) const |
Returns the class name as returned by the 'Real Time Type Information' (RTTI) mechanism. More... | |
bool | has_same_class_as (const object &other) const |
Returns true if self has the same type as other object. More... | |
Base class for all other database classes such as:
void tsa::data_base::copy_table_from | ( | data_base & | source_db, |
const std::string & | source_table_name, | ||
const std::string & | target_table_name, | ||
const table_copy_params & | copy_prop = table_copy_params() |
||
) |
Copies a table, potentially from one database to another, according to the given table_copy_properties object, which by default copies the entire table. See class table_copy_properties for more details.
[in,out] | source_db | Source database. |
source_table_name | Name of the source table. | |
target_table_name | Name of the target table. | |
copy_prop | The property of the copy operation. |
|
pure virtual |
Creates a new series table. A series table is a table that has a timestamp as first column. Recall that the timestamp is implicit to all series tables and must not be given as part of the columns definition.
table_name | The name of the new series table. |
columns | The columnar structure. |
Implemented in tsa::sqlite::database, tsa::fast::database, and tsa::postgres::database.
void tsa::data_base::import | ( | const file_import_rules__obsolete & | import_properties | ) |
Imports records from a text file according to the given import properties. See class file_import_properties for more information.
import_properties | The import properties. |
void tsa::data_base::print_table_info | ( | const std::string & | table_name, |
std::ostream & | stream | ||
) |
Prints basic information about the table.
table_name | Name of the table. | |
[in,out] | stream | The stream. |
|
pure virtual |
Appends the records from the given m_table to a database table. This operation will fail if there is overal in the range of timestamps, or if the column structure does not match.
table_name | Name of the target databse table. |
m_table | The memory based table. |
Implemented in tsa::fast::database, tsa::sqlite::database, and tsa::postgres::database.
bool tsa::data_base::series_columns_match | ( | const std::string & | table_name, |
const tsa::mem_table & | m_table | ||
) |
Returns true if a database table has an identical column structure to a given mem_table.
table_name | Name of the database table. |
m_table | The memory based table. |
|
pure virtual |
Loads a number of series records from a given database table into a mem_table (memory based table) object.
table_name | Name of the database table. | |
[in,out] | mtable | The mem_table. |
from_timestamp | The timestamp of the first record to load. | |
num_records | The number of records to load. |
Implemented in tsa::fast::database, tsa::sqlite::database, and tsa::postgres::database.
|
pure virtual |
Returns the record timestamp that is closest to, but lower than, the given target timestamp.
target | The target timestamp. |
table_name | Name of the table. |
Implemented in tsa::fast::database, tsa::sqlite::database, and tsa::postgres::database.
|
pure virtual |
Returns the column definition structure.
table_name | Name of the table. |
Implemented in tsa::fast::database, tsa::sqlite::database, and tsa::postgres::database.
|
pure virtual |
Returns the timestamp of the first record in the table.
table_name | Name of the table. |
Implemented in tsa::fast::database, tsa::sqlite::database, and tsa::postgres::database.
|
pure virtual |
Returns the timestamp of the last records in the table.
table_name | Name of the table. |
Implemented in tsa::fast::database, tsa::sqlite::database, and tsa::postgres::database.
|
pure virtual |
Returns true if a database table exists.
table_name | Name of the database table. |
Implemented in tsa::fast::database, tsa::sqlite::database, and tsa::postgres::database.
|
pure virtual |
Returns true if the table has records, false if empty.
table_name | Name of the table. |
Implemented in tsa::fast::database, tsa::sqlite::database, and tsa::postgres::database.
|
pure virtual |
Returns the number of records in the table.
table_name | Name of the table. |
Implemented in tsa::fast::database, tsa::sqlite::database, and tsa::postgres::database.
|
pure virtual |
Returns true if the database system knows the size (record count) of a table at all times, or whether it needs to iterate through the table to calculate the size. In the native fast::database knows the table size at all times, whereas SQL databases need to launch the 'select count(*)' command.
Implemented in tsa::fast::database, tsa::sqlite::database, and tsa::postgres::database.
|
pure virtual |
Truncates a database table by deleting all records higher than a given new_max_timestamp.
table_name | Name of the table. |
new_max_timestamp | The new maximum record timestamp. |
Implemented in tsa::fast::database, tsa::sqlite::database, and tsa::postgres::database.
|
pure virtual |
Returns the 'type' of the database as a string, such as "sqlite", "postgresql" or the native "fast".
Implemented in tsa::sqlite::database, tsa::fast::database, and tsa::postgres::database.