13 #ifndef __TSC_WRAPPER_H 14 #define __TSC_WRAPPER_H 23 class plot::plot_base;
61 void height(
size_t height_);
63 size_t height(
void)
const;
65 void plot_bg(
const color& bg_color);
67 void header_bg(
const color& bg_color);
69 void show_header(
bool show_flag =
true);
71 void x_axis_legend(
bool show_flag);
73 void background(
const color& bg_color);
79 void y_axis_legend(
const color& clr);
81 void x_axis_legend(
const color& clr);
83 void v_lines(
bool enable_flag);
85 void h_lines(
bool enable_flag);
87 void dashed_v_lines(
bool enable_flag =
true);
89 void dashed_h_lines(
bool enable_flag =
true);
102 void y_max(
double max);
106 void ShowTransactions(
size_t _plotID,
bool b =
true);
107 void ShowTransactionPrices(
size_t _plotID,
bool b =
true);
110 void ShowTrades(
size_t plotID,
119 class graphics_plot_info :
public tsa::object,
public chart_property_map {
121 graphics_plot_info(
void) {
122 set_property(
"VISUALIZE_TRADES",
false);
123 set_property(
"TYPE",
"UNDEFINED");
125 virtual ~graphics_plot_info(
void) { ; }
131 class pane_info :
public chart_property_map,
public tsa::object {
133 std::vector<graphics_plot_info> m_plot_infos;
134 std::vector<horizontal_line> m_CustomHLines;
135 std::vector<horizontal_line> m_AxisHLines;
136 std::vector<trend_line> m_TLines;
137 graphics_plot_info& GetPlotInfo(
size_t idx);
160 pane(
unsigned height,
const color& bg_color);
162 pane(
unsigned height);
176 color_manager m_color_man;
177 std::vector<pane_info> m_pane_infos;
179 std::vector<tsa::variant> m_Rec;
180 bool m_bFirstPreEval;
181 bool m_bTrackTransactAndPosition;
182 int m_nMaxChartsToSave;
183 int m_nMaxBarsPerChart;
184 std::vector<tsa::transaction> m_tmpTransArr;
186 pane_info& get_pane_info(
size_t _idx);
191 bool m_using_mem_table;
194 void prepare_chart_maker(chart_maker& _chartMaker,
203 chart(tsa::series_base& _db);
206 virtual ~
chart(
void);
210 int max_bars_per_chart(
void)
const;
214 void max_bars_per_chart(
int);
218 int max_charts_to_save(
void)
const;
221 void max_charts_to_save(
int max_num_charts);
224 void set_color(DefaultColorID
id,
const color& c);
227 void width(
int width);
230 int width(
void)
const;
245 size_t pane_count(
void)
const;
248 const std::string& title(
void)
const {
return m_title; }
250 void title(
const tsa::string& _s) { m_title = _s; }
252 pane_proxy get_pane_proxy(
size_t idx,
bool noCreate);
254 void SetTrackTransactionsAndPosition(
bool b =
true);
268 size_t save_png_book(
const tsa::os::path& dir_path,
size_t bars_per_page = 0);
270 void print_table(std::ostream&);
274 void save_multi_gif(
const tsa::string& fileName,
size_t nBarsPerPage = 0);
276 bool m_columns_defined;
277 bool m_prev_input_was_field_name;
280 size_t m_curr_input_pos;
281 size_t m_num_named_fields;
284 std::vector<tsa::type_t> m_types;
285 std::vector<size_t> m_first_column_positions;
286 std::vector<bool> m_input_is_name;
289 virtual void cmp__evaluate_bar(
const date_time&)
override;
290 virtual void cmp__finalize(
void)
override;
291 void reset_counters(
void);
292 bool FirstRecordCompletedAndSchemaReset(
void)
const;
299 chart& operator<<(
const char* name);
302 chart& operator<<(
const string& name);
305 chart& operator<<(
double value);
308 chart& operator<<(int64_t value);
316 chart& operator<<(const functor::parent<T>& _functor) {
317 if(!m_columns_defined) {
324 size_t pane_count = this->pane_count();
325 if(pane_count == 0) {
328 pane_proxy pp = this->get_pane(pane_count - 1);
330 if(_functor.pane_y_max.defined()) {
331 pp.
y_max((
double)_functor.pane_y_max);
333 if(_functor.pane_y_min.defined()) {
334 pp.
y_min((
double)_functor.pane_y_min);
337 for(
size_t l = 0; l < _functor.m_h_lines.size(); l++) {
338 double y_value = _functor.m_h_lines[l].y_value;
339 color c = _functor.m_h_lines[l].clr;
340 int w = _functor.m_h_lines[l].weight;
345 size_t num_plots = _functor.output_count();
346 for(
size_t pl = 0; pl < num_plots; pl++) {
347 auto p = _functor.get_plot_info(pl);
359 *
this <<
plot::line(_functor.value(pl), p.clr, p.weight) << p.name;
361 *
this <<
plot::area(_functor.value(pl), p.clr) << p.name;
363 *
this <<
plot::bar(_functor.value(pl), p.clr) << p.name;
365 throw exception(class_name(),
"unrecognized plot type",
SLOC);
372 chart& operator<<(const series_tuple<T>& _tuple) {
373 if(!m_columns_defined) {
380 size_t pane_count = this->pane_count();
381 if(pane_count == 0) {
386 if(_tuple.pane_y_max().defined()) {
387 pp.
y_max((
double)_tuple.pane_y_max());
389 if(_tuple.pane_y_min().defined()) {
390 pp.
y_min((
double)_tuple.pane_y_min());
393 auto hl = _tuple.pane_h_lines();
394 for(
size_t l = 0; l < hl.size(); l++) {
395 double y_value = hl[l].y_value;
397 int w = hl[l].weight;
400 size_t num_plots = _tuple.size();
401 for (
size_t pl = 0; pl < num_plots; pl++) {
402 if (_tuple[pl].empty())
407 size_t num_plots = _tuple.size();
408 for(
size_t pl = 0; pl < num_plots; pl++) {
409 auto p = _tuple[pl].plot_info();
421 *
this <<
plot::line(_tuple[pl][0], p.clr, p.weight) << p.name;
423 *
this <<
plot::area(_tuple[pl][0], p.clr) << p.name;
425 *
this <<
plot::bar(_tuple[pl][0], p.clr) << p.name;
427 throw exception(class_name(),
"unrecognized plot type",
SLOC);
439 chart& operator<<(const series<T>& _ser) {
440 if(!m_columns_defined) {
447 size_t pane_count = this->pane_count();
448 if(pane_count == 0) {
453 if(_ser.pane_y_max().defined()) {
454 pp.
y_max((
double)_ser.pane_y_max());
456 if(_ser.pane_y_min().defined()) {
457 pp.
y_min((
double)_ser.pane_y_min());
460 auto hl = _ser.pane_h_lines();
461 for(
size_t l = 0; l < hl.size(); l++) {
462 double y_value = hl[l].y_value;
464 int w = hl[l].weight;
469 throw exception(class_name(),
"Cannot plot an empty series",
SLOC);
473 auto p = _ser.plot_info();
474 tsa_assert(p.plot_it);
488 *
this <<
plot::line(_ser[0], p.clr, p.weight) << p.name;
490 *
this <<
plot::area(_ser[0], p.clr) << p.name;
492 *
this <<
plot::bar(_ser[0], p.clr) << p.name;
494 throw exception(class_name(),
"unrecognized plot type",
SLOC);
double max(const series< double > &series, size_t period)
Returns the highest value found in series over given .
Definition: TSAFunctionsScalar.cpp:180
Utility class to manipulate file system paths. This class is intended to fulfil the requirements of t...
Definition: TSAOS.h:36
Class representing a timeseries chart.
Definition: TSCWrapper.h:147
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
color line_color
The line color.
Definition: TSCWrapper.h:41
static const color auto_color
Definition: TSATypeDef.h:1099
void name(const tsa::string &_s)
Sets the chart name which is used to name the chart directory when saving the chart as a chart book...
Definition: TSCWrapper.h:234
static const color white
Definition: TSATypeDef.h:1201
void y_min(double)
Sets the pane minimum y-value to at at most min.
Definition: TSCWrapper.cpp:182
tsa::date_time start_timestamp
Trendline start timestamp.
Definition: TSCWrapper.h:30
void y_max(double max)
Sets the pane maximum y-value to at least max.
Definition: TSCWrapper.cpp:177
Parent class for all plot types.
Definition: TSCPlots.h:30
Defines the columnar structure of a table. Each column has a name, data type and field size...
Definition: TSADataDef.h:88
double start_price
Trendline start price.
Definition: TSCWrapper.h:31
#define SLOC
Macro to be passed as argument to Exception constructors. Contains information about the source locat...
Definition: TSAError.h:92
Plots a 'bars' on a chart pane where bars are drawn from the zero line. Bars essentially oscillate ar...
Definition: TSCPlots.h:169
Parent class.
Definition: TSAFunctorParent.h:260
bool is_registered_with_strategy(void) const
Definition: TSAComponent.cpp:50
Class tsa::exception used by most classes of the Trading System API library. The class inherits from ...
Definition: TSAError.h:37
Parent class for many library classes.
Definition: TSATypeDef.h:462
Class that represents a horizontal line to be drawn on a chart.
Definition: TSCWrapper.h:39
color line_color
Trendline color.
Definition: TSCWrapper.h:34
tsa::date_time end_timestamp
Trendline end date_time.
Definition: TSCWrapper.h:32
int weight
The line weight.
Definition: TSCWrapper.h:42
Plots a 'line plot' on a chart pane.
Definition: TSCPlots.h:127
Class representing a 'pane' on a chart.
Definition: TSCWrapper.h:151
Represents a color for use in graphics operations.
Definition: TSATypeDef.h:1041
const std::string & name(void) const
Returns the chart name.
Definition: TSCWrapper.h:237
A line.
Definition: TSASeriesTemplate.h:136
Proxy class for class chart::pane. To be used for setting pane properties. An instance of this class ...
Definition: TSCWrapper.h:49
double end_price
Trendine end price.
Definition: TSCWrapper.h:33
Plots a series as an 'area plot' on a chart pane.
Definition: TSCPlots.h:213
Class representing a gregorian-date and time-of-day combination. The time component has microsecond r...
Definition: TSATime.h:428
void h_line(double y_value, const color &clr=color::white, size_t weight=1)
Adds a horizonal line to the pane, at given y_value, with given clr and weight.
Definition: TSCWrapper.cpp:153
int weight
Trendline weight.
Definition: TSCWrapper.h:35
void register_with_strategy(strategy *)
Definition: TSAComponent.cpp:54
Base class for components such as series_base adaptors.
Definition: TSAComponent.h:34
Class mem_table represents a memory based table. mem_table objects can be used in strategies both for...
Definition: TSAMemTable.h:48
double y_value
The y-value for which the line is drawn.
Definition: TSCWrapper.h:40