fromtypingimportAnyimportnumpyasnpfromnumbaimportfloat64,int64,uint8,from_dtype,uint64fromnumba.experimentalimportjitclassfrom.typesimportorder_dtypeUNSUPPORTED=255BUY=1"""In the market depth event, this indicates the bid side; in the market trade event, it indicates that the trade initiator is a buyer."""SELL=-1"""In the market depth event, this indicates the ask side; in the market trade event, it indicates that the trade initiator is a seller."""#: NONENONE=0#: NEWNEW=1#: EXPIREDEXPIRED=2#: FILLEDFILLED=3#: CANCELEDCANCELED=4#: PARTIALLY_FILLEDPARTIALLY_FILLED=5#: REJECTEDREJECTED=6#: Good 'till cancelGTC=0#: Post onlyGTX=1#: Fill or killFOK=2#: Immediate or cancelIOC=3#: LIMITLIMIT=0#: MARKETMARKET=1
[docs]classOrder:arr:from_dtype(order_dtype)[:]def__init__(self,arr:np.ndarray[Any,order_dtype]):self.arr=arr@propertydefprice(self)->float64:""" Returns the order price. """returnself.arr[0].price_tick*self.arr[0].tick_size@propertydefexec_price(self)->float64:""" Returns the executed price. This is only valid if :obj:`status` is :const:`FILLED` or :const:`PARTIALLY_FILLED`. """returnself.arr[0].exec_price_tick*self.arr[0].tick_size@propertydefcancellable(self)->bool:""" Returns whether this order can be canceled. The order can be canceled only if it is active, meaning its :obj:`status` should be :const:`NEW` or :const:`PARTIALLY_FILLED`. It is not necessary for there to be no ongoing requests on the order to cancel it. However, HftBacktest currently enforces that there are no ongoing requests to cancel this order to simplify the implementation. """return(self.arr[0].status==NEWorself.arr[0].status==PARTIALLY_FILLED)andself.arr[0].req==NONE@propertydefqty(self)->float64:""" Returns the order quantity. """returnself.arr[0].qty@propertydefleaves_qty(self)->float64:""" Returns the remaining active quantity after the order has been partially filled. In backtesting, this is only valid in exchange models that support partial fills, such as `PartialFillExchange` model. """returnself.arr[0].leaves_qty@propertydefprice_tick(self)->int64:""" Returns the order price in ticks. """returnself.arr[0].price_tick@propertydeftick_size(self)->float64:""" Returns the tick size. """returnself.arr[0].price_tick@propertydefexch_timestamp(self)->int64:""" Returns the timestamp when the order is processed by the exchange. """returnself.arr[0].exch_timestamp@propertydeflocal_timestamp(self)->int64:""" Returns the timestamp when the order request is made by the local. """returnself.arr[0].local_timestamp@propertydefexec_price_tick(self)->int64:""" Returns the executed price in ticks. This is only valid if :obj:`status` is :const:`FILLED` or :const:`PARTIALLY_FILLED`. """returnself.arr[0].exec_price_tick@propertydefexec_qty(self)->float64:""" Returns the executed quantity. This is only valid if :obj:`status` is :const:`FILLED` or :const:`PARTIALLY_FILLED`. """returnself.arr[0].exec_qty@propertydeforder_id(self)->uint64:""" Returns the order ID. """returnself.arr[0].order_id@propertydeforder_type(self)->uint8:""" Returns the order type. This can be one of the following values, but may vary depending on the exchange model. * :const:`MARKET` * :const:`LIMIT` """returnself.arr[0].order_type@propertydefreq(self)->uint8:""" Returns the type of the current ongoing request. This can be one of the following values, but may vary depending on the exchange model. * :const:`NONE` for no ongoing request. * :const:`NEW` for submitting a new order. * :const:`CANCELED` for canceling the order. """returnself.arr[0].req@propertydefstatus(self)->uint8:""" Returns the order status. This can be one of the following values, but may vary depending on the exchange model. * :const:`NONE` * :const:`NEW` * :const:`EXPIRED` * :const:`FILLED` * :const:`CANCELED` * :const:`PARTIALLY_FILLED` """returnself.arr[0].status@propertydefside(self)->uint8:""" Returns the order side. * :const:`BUY` * :const:`SELL` """returnself.arr[0].side@propertydeftime_in_force(self)->uint8:""" Returns the Time-In-Force of the order. This can be one of the following values, but may vary depending on the exchange model. * :const:`GTC` * :const:`GTX` * :const:`FOK` * :const:`IOC` """returnself.arr[0].time_in_force