Trading System API  3.0
Library for Simulating and Deploying Trading and Investment Strategies
TSATransaction.h
1 
2 /* ===================================================================
3 *
4 * T R A D I N G S Y S T E M A P I ™
5 * Copyright © 1999 - 2014 by Peter Ritter ( TradingSystemAPI.com )
6 * A L L R I G H T S R E S E R V E D
7 *
8 * Consult your license regarding permissions and restrictions.
9 * You may obtain a copy of the License at:
10 * http://www.TradingSystemAPI.com/licenses/LICENSE-TSAPI-3.0.html
11 *
12 * ====================================================================
13 */
14 
15 #ifndef TSA_TRANSACTION__INCLUDED
16 #define TSA_TRANSACTION__INCLUDED
17 
18 #include "TSAOrder.h"
19 
20 namespace tsa {
21 
22  class strategy;
23  class instrument;
24 
29  /*
30  ** ====================================================
31  ** >>> class transaction <<<
32  ** ====================================================
33  */
34 
40  class dll_export transaction : public object {
41  tsa_declare_testable
42  private:
43  instrument* m_instrument_ptr;
44  identifier_t m_instrument_id;
45  double m_price;
46  date_time m_execution_bar_timestamp;
47  quantity_t m_quantity;
48  identifier_t m_order_id;
49  identifier_t m_transaction_id;
50  bool m_had_slippage;
51  std::string m_tag;
52  bool m_virtually_closes_position;
53  position_t m_post_transaction_position;
54  order::type m_order_type;
55  order::exec_interval m_execution_interval;
56  order::action m_order_action;
57  public:
58  void virtually_closes_open_position(bool flag);
59  bool virtually_closes_open_position(void) const;
60  bool incurred_slippage(void) const;
61  void incurred_slippage(bool flag);
62  void post_transaction_position(position_t position) const;
63  position_t post_transaction_position(void) const;
64  void copy_properties(const order_ref&);
65  public:
66  void set_id(identifier_t);
67  void price(double);
68  void quantity(quantity_t);
69  void order_tag(const std::string&);
70  void timestamp(const date_time&);
71  void order_id(identifier_t id);
72  void order_action(order::action);
73  void order_type(order::type);
74  void exec_ival(order::exec_interval);
75  void contract_id(identifier_t id);
76  void set_instrument_ptr(instrument*);
77  //IU
78  bool is_valid(void) const;
79  public:
80 
82  transaction(void);
83 
85  virtual ~transaction(void);
86 
91  bool defined(void) const;
92 
94  void clear(void);
95 
101  bool is_equal(const transaction& other) const;
102  public:
103 
108  instrument* instrument_ptr(void) const;
109 
114  identifier_t instrument_id(void) const;
115 
120  identifier_t id(void) const;
121 
126  double price(void) const;
127 
133  quantity_t size(void) const;
134 
139  quantity_t quantity(void) const;
140 
145  const date_time& timestamp() const;
146 
151  identifier_t order_id(void) const;
152 
157  order::action order_action(void) const;
158 
163  order::type order_type(void) const;
164 
169  order::exec_interval order_execution_interval(void) const;
170 
176  const std::string& order_tag(void) const;
177 
185  bool fills(const order_ref& order_ref) const;
186 
194  bool relates(const order_ref& order_ref) const;
195 
202  bool partially_fills(const order_ref& order) const;
203  public:
208  void print(std::ostream& stream) const;
209  };
210 
217  std::ostream& operator<< (std::ostream& stream, const transaction& t);
218 
220 
221 } //tsa
222 
223 #endif
type
Order type.
Definition: TSAOrder.h:101
Class order is the library&#39;s internal order representation. Users are not intended to interact with t...
Definition: TSAOrder.h:49
Namespace for the &#39;Trading System API&#39; library.
Definition: original1.TSA3Core.cpp:20
int64_t quantity_t
Definition: TSATypeDef.h:444
Represents a reference to an internally managed order object. Working with class order directly is no...
Definition: TSAOrder.h:422
Parent class for many library classes.
Definition: TSATypeDef.h:462
Represents a transaction that occurred on an exchange or as part of a simulation when an order is fil...
Definition: TSATransaction.h:40
action
Order action.
Definition: TSAOrder.h:94
Class representing a gregorian-date and time-of-day combination. The time component has microsecond r...
Definition: TSATime.h:428
int64_t identifier_t
type for ID&#39;s
Definition: TSATypeDef.h:117
int64_t position_t
Definition: TSATypeDef.h:447
exec_interval
The order &#39;execution interval&#39; determines when an order will be executed. Note: By default market ord...
Definition: TSAOrder.h:118
Class instrument represents a tradeable security such as a stock, option, futures contract...
Definition: TSAInstrument.h:64