Trading System API  3.0
Library for Simulating and Deploying Trading and Investment Strategies
tsa::manual_ohlcv Class Reference

Allows users to manually submit record data for the next bar. This is useful for testing new functionality. More...

#include <TSACompInput.h>

Inheritance diagram for tsa::manual_ohlcv:
tsa::in_stream_adaptor tsa::object tsa::component

Public Member Functions

 manual_ohlcv (void)
 Constructor.
 
virtual ~manual_ohlcv (void)
 Destructor.
 
virtual void isa__get_price_bar (const date_time &date_time, instrument_price_bar &priceBar) override
 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 date_time isa__get_record_timestamp (void) override
 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 bool isa__get_time_of_next_bar (date_time &nextDateTime, const date_time &currentDateTime) override
 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 bool isa__implements_scheduling (void) const override
 Query if this object isa implements scheduling. More...
 
virtual std::string isa__stream_name (void) const override
 Abstract member. In derived classes should return the data source name (e.g series_base table name). More...
 
void set_next_bar (const date_time &ts, double o, double h, double l, double c, double v)
 Call this member from strategy::on_bar_close() to define the next bar's timestamp, price and volume data. More...
 
- Public Member Functions inherited from tsa::in_stream_adaptor
 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...
 
virtual void isa__set_forward_shift (size_t)
 
- 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 *)
 
- Public Member Functions inherited from tsa::object
 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...
 

Detailed Description

Allows users to manually submit record data for the next bar. This is useful for testing new functionality.

Member Function Documentation

void tsa::manual_ohlcv::isa__get_price_bar ( const date_time date_time,
instrument_price_bar &  priceBar 
)
overridevirtual

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.

Implements tsa::in_stream_adaptor.

date_time tsa::manual_ohlcv::isa__get_record_timestamp ( void  )
overridevirtual

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.

Implements tsa::in_stream_adaptor.

bool tsa::manual_ohlcv::isa__get_time_of_next_bar ( date_time nextDateTime,
const date_time currentDateTime 
)
overridevirtual

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.

Implements tsa::in_stream_adaptor.

bool tsa::manual_ohlcv::isa__implements_scheduling ( void  ) const
overridevirtual

Query if this object isa implements scheduling.

Returns
true if it succeeds, false if it fails.

Implements tsa::in_stream_adaptor.

std::string tsa::manual_ohlcv::isa__stream_name ( void  ) const
overridevirtual

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

Returns
A std::string.

Implements tsa::in_stream_adaptor.

void tsa::manual_ohlcv::set_next_bar ( const date_time ts,
double  o,
double  h,
double  l,
double  c,
double  v 
)

Call this member from strategy::on_bar_close() to define the next bar's timestamp, price and volume data.

Parameters
tsNext bar's timestamp. Must be higher than current timestamp
oNext bar's open price.
hNext bar's high price.
lNext bar's low price.
cNext bar's close price.
vNext bar's volume.