![]() |
Trading System API
3.0
Library for Simulating and Deploying Trading and Investment Strategies
|
Represents a database table in fast::database. More...
#include <TSADBTable.h>
Classes | |
class | iterator |
Table iterator. Supports forward iteration only. More... | |
Public Member Functions | |
virtual | ~table (void) |
Destructor. Calls Commit() and Close(). | |
void | close (void) |
Releases the internal database connection is_init() will return false after this call. This operation cannot be undone! Do not re-use the object after invoking this member. | |
virtual void | cmp__finalize (void) override |
Override this member in any derived class. It will be invoked when the strategy is finalized. Use it to deallocate memory or close any streams. | |
bool | is_init (void) const |
Returns true if the object is initialized. This member returns false after close() is invoked. More... | |
const std::string & | name (void) const |
Returns the name of the table to which self is connected. More... | |
virtual void | osa__append (const date_time &, std::vector< variant > &) override |
Implement this member in any derived class and to append a new record and time_stamp. More... | |
virtual void | osa__prepare_stream (const std::string &source_name, const tsa::column_defs &) override |
Implement this member in any derived class. This member is called before any records are passed. Use it for initialization purposes, such as creating a new table in a series_base. More... | |
![]() | |
virtual | ~out_stream_adaptor (void) |
Destructor. | |
![]() | |
virtual void | cmp__evaluate_bar (const date_time &) |
virtual void | cmp__post_evaluate_bar (const date_time &) |
bool | is_registered_with_strategy (void) const |
void | register_with_strategy (strategy *) |
![]() | |
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... | |
Row Information | |
const std::string & | column_name (size_t position) const |
Returns the name of the column at given position. More... | |
size_t | column_number (const std::string &column_name) const |
Returns the ordinal position of the column with given column_name. More... | |
virtual size_t | column_count (void) const |
Returns the number of columns in the table. The returned number does NOT include the timestamp column which is implicit to all series tables. More... | |
type_t | column_type (size_t position) const |
Returns the type of the column at given position. More... | |
size_t | column_field_length (size_t column_position) const |
Returns the column field length. This is relevant only for character string fields. More... | |
const std::string & | column_defs__name (void) const |
const class tsa::column_defs | columns (void) const |
Returns the corresponding column_defs object. | |
Record Operations | |
iterator | end_iterator |
iterator | seek (const date_time &target_timestamp) |
Positions the iterator on the record with the given target_timestamp. Note that if the target_timestamp is within the table range, but no record with the target_timestamp exists, than the cursor will be positioned on the record with a timestamp that is immediately lower than the requested target_timestamp. More... | |
iterator | seek (size_t record_position) |
Positions the iterator on the record at the given position, where the record with the lowest timestamp is at position 0. More... | |
iterator | begin (void) |
Returns an iterator to the beginning of the table. Will be equal to end() if the table is empty. More... | |
const iterator & | end (void) |
Returns an iterator past the end of the table, as is common for STL containers. This way the current iterator can be compared to the iterator returned by end() during a loop. More... | |
virtual class record | record (void) |
virtual void | append (const class record &record, append_flag_type flag=error_on_duplicate_timestamp) |
Appends the given record to the table. Series tables do not allow duplicate timestamps. By passing append_flag. More... | |
void | push_back (const class record &rec, append_flag_type flag=error_on_duplicate_timestamp) |
size_t | size (void) const |
Returns the number of records in the table. More... | |
bool | empty (void) const |
Returns true if the table contains no records. More... | |
const date_time & | first_timestamp (void) const |
Returns the timestamp of the first record in the table. More... | |
const date_time & | last_timestamp (void) const |
Returns the timestamp of the last record in the table. More... | |
const date_time & | timestamp (void) const |
Returns the timestamp of the record on which the cursor is positioned. More... | |
void | commit (void) |
Flushes unsaved data to disk. Do NOT call this member after every 'append' operation in a bulk operation for performance reasons! Commit is called automatically when the object is destroyed. More... | |
void | read (class record &rec) const |
Reads a table record into the record instance rec. Call this member after a successful seek(), or access a record via an iterator. More... | |
void | clear () |
Deletes all records in the table. | |
void | truncate (size_t new_size) |
Truncates the table to new_size. Any records deleted are deleted from the 'back' of the table. More... | |
void | truncate (const date_time &new_highest_timestamp) |
Truncates the 'back' of the table. The timestamp of the last record will be smaller or equal to new_highest_timestamp. More... | |
Printing | |
void | print_timestamp (bool _b) |
void | print_fp_precision (size_t _n) |
void | print_limit (size_t _n) |
void | print_range (const date_time &_start, const date_time &_end) |
void | print (std::ostream &stream) |
void | printv (std::ostream &stream) |
void | html (const os::path &dir, const std::string &alt_name="") |
void | csv (std::ostream &) |
Represents a database table in fast::database.
|
virtual |
Appends the given record to the table. Series tables do not allow duplicate timestamps. By passing append_flag.
record | The record. |
flag | The flag. |
Implements tsa::appendable.
table::iterator tsa::fast::table::begin | ( | void | ) |
Returns an iterator to the beginning of the table. Will be equal to end() if the table is empty.
|
virtual |
Returns the number of columns in the table. The returned number does NOT include the timestamp column which is implicit to all series tables.
Implements tsa::appendable.
size_t tsa::fast::table::column_field_length | ( | size_t | column_position | ) | const |
Returns the column field length. This is relevant only for character string fields.
column_position | The column position. |
const std::string & tsa::fast::table::column_name | ( | size_t | position | ) | const |
Returns the name of the column at given position.
position | The column position. |
size_t tsa::fast::table::column_number | ( | const std::string & | column_name | ) | const |
Returns the ordinal position of the column with given column_name.
column_name | The column name. |
type_t tsa::fast::table::column_type | ( | size_t | position | ) | const |
Returns the type of the column at given position.
position | The column position. |
void tsa::fast::table::commit | ( | void | ) |
Flushes unsaved data to disk. Do NOT call this member after every 'append' operation in a bulk operation for performance reasons! Commit is called automatically when the object is destroyed.
The Commit() function is called automatically when a TableWriter object goes out of scope, and writes various caches and the current record page to disk.
Call this before calling any function that could inadvertently terminate the process, but not after every 'append' operation, as this would cause serious performance problems!
bool tsa::fast::table::empty | ( | void | ) | const |
Returns true if the table contains no records.
const table::iterator & tsa::fast::table::end | ( | void | ) |
Returns an iterator past the end of the table, as is common for STL containers. This way the current iterator can be compared to the iterator returned by end() during a loop.
.
const date_time & tsa::fast::table::first_timestamp | ( | void | ) | const |
Returns the timestamp of the first record in the table.
bool tsa::fast::table::is_init | ( | void | ) | const |
Returns true if the object is initialized. This member returns false after close() is invoked.
const date_time & tsa::fast::table::last_timestamp | ( | void | ) | const |
Returns the timestamp of the last record in the table.
const std::string & tsa::fast::table::name | ( | void | ) | const |
Returns the name of the table to which self is connected.
|
overridevirtual |
Implement this member in any derived class and to append a new record and time_stamp.
time_stamp | The time stamp. | |
[in,out] | record | The record. |
Implements tsa::out_stream_adaptor.
|
overridevirtual |
Implement this member in any derived class. This member is called before any records are passed. Use it for initialization purposes, such as creating a new table in a series_base.
stream_name | Name of the stream. |
field_list | List of fields. |
Implements tsa::out_stream_adaptor.
void tsa::fast::table::read | ( | class record & | rec | ) | const |
Reads a table record into the record instance rec. Call this member after a successful seek(), or access a record via an iterator.
[in,out] | rec | The record to read. |
table::iterator tsa::fast::table::seek | ( | const date_time & | target_timestamp | ) |
Positions the iterator on the record with the given target_timestamp. Note that if the target_timestamp is within the table range, but no record with the target_timestamp exists, than the cursor will be positioned on the record with a timestamp that is immediately lower than the requested target_timestamp.
target_timestamp | Target timestamp. |
table::iterator tsa::fast::table::seek | ( | size_t | record_position | ) |
Positions the iterator on the record at the given position, where the record with the lowest timestamp is at position 0.
record_position | The record position. |
size_t tsa::fast::table::size | ( | void | ) | const |
Returns the number of records in the table.
const date_time & tsa::fast::table::timestamp | ( | void | ) | const |
Returns the timestamp of the record on which the cursor is positioned.
void tsa::fast::table::truncate | ( | size_t | new_size | ) |
Truncates the table to new_size. Any records deleted are deleted from the 'back' of the table.
new_size | Size of table after truncate operation (assuming original table is larger or equal) |
void tsa::fast::table::truncate | ( | const date_time & | _tNewEndTime | ) |
Truncates the 'back' of the table. The timestamp of the last record will be smaller or equal to new_highest_timestamp.
new_highest_timestamp | The new highest timestamp. |
trucates the table so that newEndTime will the be last record time. If no record exists with given time, the next earliest existing record time will be used instead