14 #ifndef TSA_ORDER__INCLUDED 15 #define TSA_ORDER__INCLUDED 21 #include "TSAString.h" 22 #include "TSASupport.h" 26 class position_manager;
27 class instrument_price_bar;
51 friend class order_manager;
78 pending_cancel_replace = 5,
174 double m_price = 0.0;
175 double m_aux_price = 0.0;
176 bool m_is_stop_limit =
false;
177 double m_limit_fill_proviso = 0.0;
178 bool m_is_marked_for_deletion =
false;
179 bool m_is_partially_filled =
false;
184 bool m_is_smart =
false;
187 int64_t m_created_on_bar = 0;
189 std::vector<order::order_info>* m_orders_to_cancel_ptr =
nullptr;
191 virtual void calculate_estimated_transaction_price(
const instrument_price_bar& price_bar) = 0;
192 double estimated_transaction_price(
void);
193 double abs_price_diff_between_open_and_estimated_exec_price(
void)
const;
194 bool is_assumed_to_be_executed_before(
const order* order_ptr)
const;
195 virtual bool TRY_FILL(
const instrument_price_bar& price_bar,
transaction&);
197 virtual bool try_fill__long(
const instrument_price_bar& price_bar,
double& transact_price,
bool& had_slippage) = 0;
198 virtual bool try_fill__short(
const instrument_price_bar& price_bar,
double& transact_price,
bool& had_slippage) = 0;
203 virtual ~
order(
void);
209 bool has_orders_to_cancel_on_fill(
void)
const;
210 const std::vector<order::order_info>& get_orders_to_cancel_on_fill(
void)
const;
228 quantity_t get_remaining_quantity(
void)
const;
233 void set_create_timestamp(
const date_time&);
234 const date_time& get_create_timestamp(
void)
const;
235 void set_create_bar(int64_t);
236 int64_t get_create_bar(
void)
const;
237 int64_t get_age_in_bars(
void)
const;
249 const date_time& get_expiry_time_point(
void)
const;
251 void set_time_in_force_time_point(
const date_time&);
252 void set_price(
double);
253 double get_price(
void)
const;
254 void set_aux_price(
double);
255 double get_aux_price(
void)
const;
256 void set_last_fill_price(
double);
257 double get_last_fill_price(
void);
258 void set_fixed_fill_price(
double);
259 double get_fixed_fill_price(
void);
260 void set_is_stop_limit(
bool);
261 bool get_is_stop_limit(
void)
const;
262 void set_limit_fill_proviso(
double);
263 double get_limit_fill_proviso(
void)
const;
264 bool get_is_filled(
void)
const;
265 void set_is_partial_fill(
bool);
266 bool get_is_partial_fill(
void)
const;
270 void set_last_fill_timestamp(
const date_time&);
271 const date_time& get_last_fill_timestamp(
void)
const;
272 void set_is_smart(
bool);
273 bool get_is_smart(
void)
const;
274 void set_is_marked_for_deletion(
bool);
275 bool get_is_marked_for_deletion(
void)
const;
276 bool get_is_eod(
void)
const;
277 bool get_is_cancelled(
void)
const;
278 bool get_is_active(
void)
const;
282 virtual void print(std::ostream& stream)
const;
284 quantity_t calc_rounded_order_quantity_for_ccy_amount(
double unit_cost,
double amount);
285 quantity_t calculate_initial_order_size(
double price);
287 static bool try_fill__long_stop
288 (
double stop_price,
double& transaction_price,
double o,
double h,
double l);
289 static bool try_fill__short_stop
290 (
double stop_price,
double& transaction_price,
double o,
double h,
double l);
292 static bool try_fill__long_limit
293 (
double limit_price,
double& transaction_price,
double o,
double h,
double l);
294 static bool try_fill__short_limit
295 (
double limit_price,
double& transaction_price,
double o,
double h,
double l);
423 tsa_declare_testable;
426 order* order_ptr(
void)
const;
429 void verify_init(
const char* hint)
const;
430 size_t ref_count(
void)
const;
431 void verify_inactive()
const;
489 void update_price(
double new_price);
497 void update_price(
double new_price,
double new_aux_price);
504 void update_quantity(
quantity_t new_quantity);
517 order*
get(void)
const;
523 void print(std::ostream& stream)
const;
611 double price(
void)
const;
620 void fixed_fill_price(
double fixed_fill_price);
626 double fixed_fill_price(
void)
const;
687 double aux_price(
void)
const;
692 bool is_stop_limit(
void)
const;
706 date_time last_fill_timestamp(
void)
const;
718 int64_t create_bar_ordinal(
void)
const;
725 int64_t age_in_bars(
void)
const;
748 bool defined(
void)
const;
755 operator bool(
void)
const;
764 bool is_filled(
void)
const;
767 bool active(
void)
const;
779 bool is_active(
void)
const;
788 bool is_partially_filled(
void)
const;
793 bool cancelled(
void)
const;
798 bool is_cancelled(
void)
const;
804 bool marked_for_deletion(
void)
const;
822 bool is_pending_submit(
void);
828 bool is_pre_submitted(
void);
834 bool is_acknowledged(
void);
840 bool is_submitted(
void);
847 bool is_pending_cancel(
void);
853 bool is_cancelled(
void);
861 void mark_for_deletion(
void);
899 void one_cancels_other(
order_ref& other_order);
911 void on_fill_cancel(
const order_ref& other_order);
924 bool has_orders_to_cancel_on_fill(
void)
const;
929 const std::vector<order::order_info>& orders_to_cancel(
void)
const;
964 class dll_export order__on_stop :
public order {
967 order__on_stop(
order::action,
double price,
double auxPrice);
968 virtual ~order__on_stop();
969 virtual bool try_fill__long(
const instrument_price_bar& price_bar,
970 double& transaction_price,
bool& incurred_slippage)
override;
971 virtual bool try_fill__short(
const instrument_price_bar& price_bar,
972 double& transaction_price,
bool& incurred_slippage)
override;
974 virtual void calculate_estimated_transaction_price(
const instrument_price_bar& price_bar)
override;
978 class dll_export order__at_limit :
public order {
981 virtual ~order__at_limit(
void);
982 virtual bool try_fill__long(
const instrument_price_bar& price_bar,
983 double& transaction_price,
bool& incurred_slippage)
override;
984 virtual bool try_fill__short(
const instrument_price_bar& price_bar,
985 double& transaction_price,
bool& incurred_slippage)
override;
986 virtual void calculate_estimated_transaction_price(
const instrument_price_bar& price_bar)
override;
990 class dll_export order__at_market :
public order {
993 virtual ~order__at_market(
void);
994 virtual bool try_fill__long(
const instrument_price_bar& price_bar,
995 double& transaction_price,
bool& incurred_slippage)
override;
996 virtual bool try_fill__short(
const instrument_price_bar& price_bar,
997 double& transaction_price,
bool& incurred_slippage)
override;
998 virtual void calculate_estimated_transaction_price(
const instrument_price_bar& price_bar)
override;
type
Order type.
Definition: TSAOrder.h:101
double max(const series< double > &series, size_t period)
Returns the highest value found in series over given .
Definition: TSAFunctionsScalar.cpp:180
Expires at the end of day/session.
Definition: TSAOrder.h:135
At the 'close' of the next bar.
Definition: TSAOrder.h:120
internal use
Definition: TSAOrder.h:105
identifier_t instrument_id
The instrument ID.
Definition: TSAOrder.h:142
internal use
Definition: TSAOrder.h:97
Class order is the library's internal order representation. Users are not intended to interact with t...
Definition: TSAOrder.h:49
Namespace for the 'Trading System API' library.
Definition: original1.TSA3Core.cpp:20
status
Order state.
Definition: TSAOrder.h:57
Definition: TSAOrder.h:125
Good Till Cancel (default).
Definition: TSAOrder.h:134
int64_t quantity_t
Definition: TSATypeDef.h:444
variant objects can represent values of different types.
Definition: TSAVariant.h:140
Represents a reference to an internally managed order object. Working with class order directly is no...
Definition: TSAOrder.h:422
Represents a duration - the difference between two date_time values.
Definition: TSATime.h:945
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
sref< bool > operator==(numeric_series_cref a, numeric_series_cref b)
comparison.
Definition: TSADSLBase.cpp:130
Information about an order.
Definition: TSAOrder.h:140
action
Order action.
Definition: TSAOrder.h:94
The order is a 'buy' order.
Definition: TSAOrder.h:95
time_in_force
Time-in-force (TIF). By default all orders are placed as good-till-cancel (GTC) orders. See instrument::default_time_in_force(order::time_in_force).
Definition: TSAOrder.h:133
'Limit' order.
Definition: TSAOrder.h:104
identifier_t order_id
The order ID.
Definition: TSAOrder.h:141
The order is a 'sell' order.
Definition: TSAOrder.h:96
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's
Definition: TSATypeDef.h:117
'Stop' order (includes 'stop limit' orders).
Definition: TSAOrder.h:103
The order has been created but has not been transmitted, and can still be modified.
Definition: TSAOrder.h:60
During the entire next 'bar'.
Definition: TSAOrder.h:121
exec_interval
The order 'execution interval' 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
'Market' order.
Definition: TSAOrder.h:102
At the 'open' of next bar.
Definition: TSAOrder.h:119