46 order_exec_check_role = 1,
47 order_exec_fix_qty = 2,
48 order_exec_replace_send = 4
79 uint32_t cancel_attempts;
80 uint64_t cancel_timeout_us;
81 uint32_t resend_attempts;
82 uint64_t resend_timeout_us;
100 uint32_t cancel_attempts;
101 uint64_t cancel_timeout_us;
106 uint32_t resend_attempts;
107 uint64_t resend_timeout_us;
110 xroad_broker_t* broker;
111 xroad_currency_t* hedge_cur;
112 xroad_portfolio_t* portfolio;
132 void (*on_before_send)(order_t*);
140 void (*on_trade)(order_t*, xroad_trade_t*);
144 void (*on_canceled)(order_t*, xroad_rej_reason_t,
xroad_str_t, xroad_timestamp_t);
148 void (*on_unexpected_canceled)(order_t*, xroad_rej_reason_t,
xroad_str_t, xroad_timestamp_t);
152 void (*on_destroyed)(order_t*);
160 void (*on_rejected)(order_t*, xroad_rej_reason_t,
xroad_str_t, xroad_timestamp_t);
164 void (*on_cancel_rejected)(order_t*, xroad_rej_reason_t,
xroad_str_t, xroad_timestamp_t);
168 void (*on_replace_rejected)(order_t*, xroad_rej_reason_t,
xroad_str_t, xroad_timestamp_t);
172 void (*on_pre_trade)(order_t*, xroad_pre_trade_t*);
176 void (*on_resend)(order_t*);
210 xroad_instr_t* instr,
223 uint32_t cancel_attempts,
224 uint64_t cancel_timeout_us,
229 uint32_t resend_attempts,
230 uint64_t resend_timeout_us,
233 xroad_portfolio_t* portfolio,
234 xroad_broker_t* broker,
235 xroad_currency_t* hedge_cur);
237 #define order_create(instr, side, callback, ...) \
239 order_create_args_t _args_ = {.type = xroad_ord_type_limit, .tif = xroad_tif_day, ## __VA_ARGS__}; \
240 if (_args_.till_date.year == 0 && _args_.till_date.month == 0 && _args_.till_date.day == 0) \
242 _args_.till_date = xroad_date_null; \
244 order_create_ex(instr, side, callback, _args_.name, _args_.account, _args_.client_code, _args_.type, _args_.qty, \
245 _args_.price, _args_.ext_ref, _args_.flags, _args_.tif, _args_.till_date, _args_.cancel_attempts, \
246 _args_.cancel_timeout_us, _args_.exec_flags, _args_.comment, _args_.ctx, _args_.logger, \
247 _args_.resend_attempts, _args_.resend_timeout_us, _args_.sender, _args_.err, _args_.portfolio, \
248 _args_.broker, _args_.hedge_cur); \
282 #define order_cancel(o, ...) \
284 order_cancel_args_t args = {.send = true, ## __VA_ARGS__}; \
285 order_cancel_ex(o, args.send); \
296 #define order_replace(o, ...) \
298 order_replace_args_t _args_ = (order_replace_args_t){ \
301 .cancel_attempts = UINT32_MAX, \
302 .cancel_timeout_us = UINT64_MAX, \
303 .resend_attempts = UINT32_MAX, \
304 .resend_timeout_us = UINT64_MAX, ## __VA_ARGS__}; \
305 _args_.mask |= (_args_.qty == INT64_MAX) ? 0 : order_replace_qty; \
306 _args_.mask |= !xroad_dbl_cmp(_args_.price, DBL_MAX) ? 0 : order_replace_price; \
307 _args_.mask |= (_args_.cancel_attempts == UINT32_MAX) ? 0 : order_replace_cancel_attempts; \
308 _args_.mask |= (_args_.cancel_timeout_us == UINT64_MAX) ? 0 : order_replace_cancel_timeout_us; \
309 _args_.mask |= (_args_.resend_attempts == UINT32_MAX) ? 0 : order_replace_resend_attempts; \
310 _args_.mask |= (_args_.resend_timeout_us == UINT64_MAX) ? 0 : order_replace_resend_timeout_us; \
311 order_replace_ex(o, _args_); \
432 void order_log_debug(order_t* o,
char* title);
446 order_bad_corr_id = ~0ul
order_state_t
Definition: order.h:25
@ order_state_awaiting_replace
order is in awaiting replace state
Definition: order.h:36
@ order_state_awaiting_destroy
order is in awaiting destroyed state
Definition: order.h:34
@ order_state_expired
order is in expired state
Definition: order.h:32
@ order_state_awaiting_cancel
order is in awaiting cancel state
Definition: order.h:35
@ order_state_filled
order is in filled state
Definition: order.h:31
@ order_state_destroyed
order is in destroyed state
Definition: order.h:28
@ order_state_awaiting_cancel_resend
order is in awaiting cancel resend state
Definition: order.h:41
@ order_state_initial
order is in initial state
Definition: order.h:26
@ order_state_canceled
order is in canceled state
Definition: order.h:29
@ order_state_resend
order is in resend state
Definition: order.h:40
@ order_state_rejected
order is in rejected state
Definition: order.h:30
@ order_state_awaiting_cancel_replace
order is in awaiting cancel replace state
Definition: order.h:37
@ order_state_active
order is in active state
Definition: order.h:27
@ order_state_awaiting_suspend
order is in awaiting suspended state
Definition: order.h:38
@ order_state_awaiting_active
order is in awaiting active state
Definition: order.h:33
@ order_state_suspended
order is in suspended state
Definition: order.h:39
order_trace_corr_t * order_trace_init(xroad_str_t path, size_t max_rec)
Allocates and initializes structures for orders tracing.
int32_t order_get_flags(const order_t *o)
xroad_str_t order_get_name(const order_t *o)
xroad_qty_t order_get_replace_qty(const order_t *o)
xroad_errno_t order_replace_ex(order_t *o, order_replace_args_t args)
xroad_order_t * order_get_xorder(const order_t *o)
order_t * order_create_ex(xroad_instr_t *instr, xroad_side_t side, order_callback_t callback, xroad_str_t name, xroad_str_t account, xroad_str_t client_code, xroad_ord_type_t type, xroad_qty_t qty, xroad_price_t price, xroad_str_t ext_ref, int32_t flags, xroad_tif_t tif, xroad_date_t till_date, uint32_t cancel_attempts, uint64_t cancel_timeout_us, int32_t exec_flags, xroad_str_t comment, void *ctx, xroad_logger_t *logger, uint32_t resend_attempts, uint64_t resend_timeout_us, xroad_str_t sender, xroad_str_t *err, xroad_portfolio_t *portfolio, xroad_broker_t *broker, xroad_currency_t *hedge_cur)
xroad_instr_t * order_get_instr(const order_t *o)
xroad_ord_type_t order_get_type(const order_t *o)
xroad_price_t order_get_price(const order_t *o)
xroad_qty_t order_get_qty(const order_t *o)
xroad_errno_t order_send(order_t *o)
xroad_qty_t order_get_leaves_qty(const order_t *o)
void order_reset(order_t *o)
xroad_price_t order_get_avg_price(const order_t *o)
order_state_t order_get_state(const order_t *o)
xroad_errno_t order_cancel_ex(order_t *o, bool send)
xroad_price_t order_get_replace_price(const order_t *o)
xroad_errno_t order_destroy(order_t *o, bool force)
xroad_side_t order_get_side(const order_t *o)
xroad_qty_t order_get_total_qty(const order_t *o)
xroad_errno_t order_pre_trade_ack(order_t *o, xroad_pre_trade_t *pre_trade, xroad_pre_trade_status_t status)
order_replace_mask_t
Definition: order.h:55
@ order_replace_price
replace price
Definition: order.h:57
@ order_replace_resend_timeout_us
replace resend_timeout_us
Definition: order.h:61
@ order_replace_cancel_timeout_us
replace cancel_timeout_us
Definition: order.h:59
@ order_replace_cancel_attempts
replace cancel_attempts
Definition: order.h:58
@ order_replace_qty
replace qty
Definition: order.h:56
@ order_replace_resend_attempts
replace resend_attemts
Definition: order.h:60
void * order_get_ctx(const order_t *o)
xroad_str_t order_print(const order_t *o)
xroad_str_t order_state_to_str(order_state_t state)
Correlation information for tracing.
Definition: order.h:436
uint64_t corr_id
ID of an event triggered the order.
Definition: order.h:437
uint16_t corr_tag
Definition: order.h:438
Definition: xroad_date.h:37
Struct of logger.
Definition: xroad_logger_types.h:21
Definition: xroad_string.h:29
struct xroad_str_s xroad_str_t
see common/xroad_string.h for details
Definition: xroad_common_fwd.h:39
CAUTION: do not change this file - it is autogenerated.
xroad_ord_type_t
Definition: xroad_objects_types.h:290
int64_t xroad_qty_t
Definition: xroad_objects_types.h:191
xroad_pre_trade_status_t
Definition: xroad_objects_types.h:601