Trading System API  3.0
Library for Simulating and Deploying Trading and Investment Strategies
tsa::in_stream_adaptor Class Referenceabstract

Parent class for 'in-stream adaptors'. in_stream object rely on adaptors for access to underlying data source. In order to support access to new data sources, new in_stream_adaptor derived classes must be implemented. More...

#include <TSAStreams.h>

Inheritance diagram for tsa::in_stream_adaptor:
tsa::component tsa::manual_ohlcv tsa::mem_table tsa::random_walk_stream

Public Member Functions

 in_stream_adaptor (void)
 Constructor.
 
 ~in_stream_adaptor (void)
 Destructor.
 
size_t close_field_position (void) const
 Returns the index of the 'close' field. More...
 
virtual void cmp__evaluate_bar (const date_time &) override
 
virtual void cmp__finalize (void) override
 
void current_value (const variant &value)
 Sets the current value. More...
 
bool get_is_strategy_scheduler (void) const
 Returns true. More...
 
size_t high_field_position (void) const
 Returns the index of the 'high' field. More...
 
bool is_connected (void) const
 Returns true if the object state is 'connected'. More...
 
size_t low_field_position (void) const
 Returns the index of the 'low' field. More...
 
size_t open_field_position (void) const
 Returns the index of the 'open' field. More...
 
void set_connected (bool is_connected_flag=true)
 Sets the object state to is_connected_flag. More...
 
void stream_name (const std::string &stream_name)
 Sets the data source_name. More...
 
const std::stringstream_name (void) const
 Returns the data source name. More...
 
- Public Member Functions inherited from tsa::component
virtual void cmp__post_evaluate_bar (const date_time &)
 
bool is_registered_with_strategy (void) const
 
void register_with_strategy (strategy *)
 

Virtual Members To Override

virtual void isa__set_forward_shift (size_t)
 
virtual void isa__set_position (const date_time &)=0
 
virtual bool isa__field_exists (const std::string &)=0
 
virtual type_t isa__field_type (size_t)=0
 
virtual size_t isa__field_index (const std::string &)=0
 
virtual size_t isa__field_count ()=0
 
virtual const std::stringisa__field_name (size_t)=0
 
virtual date_time isa__get_record_timestamp (void)=0
 This member must be overridden, and must return the current record's timestamp which may or may not correspond to the strategy's current timestamp. More...
 
virtual date_time isa__begin (void)=0
 
virtual date_time isa__end (void)=0
 
virtual size_t isa__size (void)=0
 
virtual void isa__on_open (void)=0
 
virtual variant isa__get_variant (size_t idx)=0
 
virtual double isa__get_double (size_t idx)=0
 
virtual void isa__update_value_at_position (size_t idx)=0
 
virtual void isa__get_price_bar (const date_time &date_time, instrument_price_bar &priceBar)=0
 Abstract member to be implemented by derived classes. In derived classes, this member should populate priceBar with data corresponding to the current strategy date_time. If no corresponding price data exists for the given strategy date_time, then the most recently available price data may be returned, or else an exception must be thrown. More...
 
virtual bool isa__get_time_of_next_bar (date_time &nextDateTime, const date_time &currentDateTime)=0
 Abstract member which should return the timestamp of the strategy's next price bar (nextDateTime) when given the strategy's currentDateTime. The member should return true if successful. More...
 
virtual std::string isa__stream_name (void) const =0
 Abstract member. In derived classes should return the data source name (e.g series_base table name). More...
 
virtual bool isa__implements_scheduling (void) const =0
 Query if this object isa implements scheduling. More...
 

Detailed Description

Parent class for 'in-stream adaptors'. in_stream object rely on adaptors for access to underlying data source. In order to support access to new data sources, new in_stream_adaptor derived classes must be implemented.

Member Function Documentation

size_t tsa::in_stream_adaptor::close_field_position ( void  ) const

Returns the index of the 'close' field.

Returns
A size_t.
void tsa::in_stream_adaptor::current_value ( const variant value)

Sets the current value.

Parameters
valueThe value.
bool tsa::in_stream_adaptor::get_is_strategy_scheduler ( void  ) const
inline

Returns true.

Returns
true if it succeeds, false if it fails.
size_t tsa::in_stream_adaptor::high_field_position ( void  ) const

Returns the index of the 'high' field.

Returns
A size_t.
bool tsa::in_stream_adaptor::is_connected ( void  ) const

Returns true if the object state is 'connected'.

Returns
true if connected, false if not.
virtual void tsa::in_stream_adaptor::isa__get_price_bar ( const date_time date_time,
instrument_price_bar &  priceBar 
)
pure virtual

Abstract member to be implemented by derived classes. In derived classes, this member should populate priceBar with data corresponding to the current strategy date_time. If no corresponding price data exists for the given strategy date_time, then the most recently available price data may be returned, or else an exception must be thrown.

Parameters
date_timeThe date time.
[in,out]priceBarThe price bar.

Implemented in tsa::mem_table, tsa::manual_ohlcv, and tsa::random_walk_stream.

virtual date_time tsa::in_stream_adaptor::isa__get_record_timestamp ( void  )
pure virtual

This member must be overridden, and must return the current record's timestamp which may or may not correspond to the strategy's current timestamp.

Returns
A date_time.

Implemented in tsa::mem_table, tsa::manual_ohlcv, and tsa::random_walk_stream.

virtual bool tsa::in_stream_adaptor::isa__get_time_of_next_bar ( date_time nextDateTime,
const date_time currentDateTime 
)
pure virtual

Abstract member which should return the timestamp of the strategy's next price bar (nextDateTime) when given the strategy's currentDateTime. The member should return true if successful.

This member is important when 'externally scheduling' a strategy. If the derived component is set as TIME_MASTER, then the strategy will retrieve the 'scheduling sequence' via this member.

It is important to properly handle the condition that arises when the strategy date_time reaches the timestamp of last record in the source table, at which point this member must return false.

Scheduling a strategy internal beyond this point won't be possible.

Parameters
[in,out]nextDateTimeThe next date time.
currentDateTimeThe current date time.
Returns
true if it succeeds, false if it fails.

Implemented in tsa::mem_table, tsa::manual_ohlcv, and tsa::random_walk_stream.

virtual bool tsa::in_stream_adaptor::isa__implements_scheduling ( void  ) const
pure virtual

Query if this object isa implements scheduling.

Returns
true if it succeeds, false if it fails.

Implemented in tsa::mem_table, tsa::manual_ohlcv, and tsa::random_walk_stream.

virtual std::string tsa::in_stream_adaptor::isa__stream_name ( void  ) const
pure virtual

Abstract member. In derived classes should return the data source name (e.g series_base table name).

Returns
A std::string.

Implemented in tsa::mem_table, tsa::manual_ohlcv, and tsa::random_walk_stream.

size_t tsa::in_stream_adaptor::low_field_position ( void  ) const

Returns the index of the 'low' field.

Returns
A size_t.
size_t tsa::in_stream_adaptor::open_field_position ( void  ) const

Returns the index of the 'open' field.

Returns
A size_t.
void tsa::in_stream_adaptor::set_connected ( bool  is_connected_flag = true)

Sets the object state to is_connected_flag.

Parameters
is_connected_flagtrue if this object is connected flag.
void tsa::in_stream_adaptor::stream_name ( const std::string stream_name)

Sets the data source_name.

Parameters
stream_nameName of the stream.
const std::string & tsa::in_stream_adaptor::stream_name ( void  ) const

Returns the data source name.

Returns
A std::string&