module protocol.order_single
Generic FIX Order single module.
Global Variables
- nan
class FIXNewOrderSingle
Generic FIXNewOrderSingle wrapper.
Attributes:
clord_id
: current order ClOrdIDorig_clord_id
: order OrigClOrdID (when canceling / replacing)order_id
: executed order idticker
: user order tickerside
: order sideprice
: order priceqty
: order quantityleaves_qty
: order remaining qtycum_qty
: order filled qtyavg_px
: average fill priceord_type
: order typeaccount
: order accountstatus
: current order statustarget_price
: order target execution price
method __init__
__init__(
clord_id: str,
cl_ticker: str,
side: FOrdSide | str,
price: float,
qty: float,
ord_type: FOrdType | str = <FOrdType.LIMIT: '2'>,
account: str | dict = '000000',
target_price: float | None = None
)
Initialize order.
Args:
clord_id
: root ClOrdIDcl_ticker
: client ticker (can by any accepted by user's OMS)side
: order sideprice
: order initial price (current price, changes if replaced)qty
: order quantityord_type
: order typeaccount
: order account (optional)target_price
: order initial target execution price (useful for slippage)
property clord_id_root
Current order ClOrdID root.
method can_cancel
can_cancel() → bool
Check if order can be canceled from its current state.
method can_replace
can_replace() → bool
Check if order can be replaced from its current state.
method cancel_req
cancel_req() → FIXMessage
Creates order cancel request.
Raises:
FIXError
: if order can't be canceled
method change_status
change_status(
status: FOrdStatus,
fix_msg_type: FMsg,
msg_exec_type: FExecType,
msg_status: FOrdStatus,
raise_on_err: bool = True
) → FOrdStatus | None
FIX Order State transition algo.
:param status: current order status :param fix_msg_type: incoming/or requesting order type, these are supported: '8' - execution report, '9' - Order Cancel reject, 'F' - Order cancel request (if possible to cancel current order) 'G' - Order replace request (if possible to replace current order) :param msg_exec_type: (only for execution report), for other should be 0 :param msg_status: new fix msg order status, or required status :return: FOrdStatus if state transition is possible, None - if transition is valid, but need to wait for a good state raises FIXError - when transition is invalid
method clord_next
clord_next() → str
New ClOrdID for current order management.
method clord_root
clord_root(clord_id: str) → str
Order ClOrdID root, as given at initialization.
Args:
clord_id
: current order one of the clord_next()
Returns: string
method current_datetime
current_datetime()
Date for TransactTime field.
method is_finished
is_finished() → bool
Check if order is in terminal state (no subsequent changes expected).
method new_req
new_req() → FIXMessage
Creates NewOrderSingle message.
method process_cancel_rej_report
process_cancel_rej_report(m: FIXMessage) → bool
Processes incoming cancel reject report message.
method process_execution_report
process_execution_report(m: FIXMessage) → bool
Processes incoming execution report for an order.
Raises:
FIXError
: if ClOrdID mismatch
method replace_req
replace_req(price: float = nan, qty: float = nan) → FIXMessage
Creates order replace request.
Args:
price
: alternative priceqty
: alternative qty
Returns: message
Raises:
FIXError
: if order can't be replaced or price/qty unchanged
method set_account
set_account(ord_msg: FIXMessage)
Set account definition (override this in child).
Args:
ord_msg
: new or replaced order
method set_instrument
set_instrument(ord_msg: FIXMessage)
Set order instrument definition (override this in child).
Args:
ord_msg
: new or replaced order
method set_price_qty
set_price_qty(ord_msg: FIXMessage, price: float, qty: float)
Set order price and qty definition (override this in child).
This method handles custom price/qty rounding/decimal formatting, or maybe conditional presence of two fields based on order type
Args:
ord_msg
: new or replaced orderprice
: new order price (unformatted / unrounded)qty
: new order qty (unformatted / unrounded)
This file was automatically generated via lazydocs.