tensortrade.oms.orders.order module¶
- class tensortrade.oms.orders.order.Order(step: int, side: TradeSide, trade_type: TradeType, exchange_pair: ExchangePair, quantity: Quantity, portfolio: Portfolio, price: float, criteria: Callable[[Order, Exchange], bool] = None, path_id: str = None, start: int = None, end: int = None)[source]¶
Bases:
TimedIdentifiable
,Observable
A class to represent ordering an amount of a financial instrument.
- Responsibilities of the Order:
Confirming its own validity.
Tracking its trades and reporting it back to the broker.
Managing movement of quantities from order to order.
Generating the next order in its path given that there is a ‘OrderSpec’ for how to make the next order.
Managing its own state changes when it can.
- Parameters:
side (TradeSide) – The side of the order.
- exchange_pairExchangePair
The exchange pair to perform the order for.
- pricefloat
The price of the order.
- trade_typeTradeType
The type of trade being made.
- exchange_pairExchangePair
The exchange pair that the order is made for.
- quantityQuantity
The quantity of the order.
- portfolioPortfolio
The portfolio being used in the order.
- criteriaCallable[[Order, Exchange], bool], optional
The criteria under which the order will be considered executable.
- path_idstr, optional
The path order id.
- startint, optional
The start time of the order.
- endint, optional
The end time of the order.
- Raises:
InvalidOrderQuantity – Raised if the given quantity has a size of 0.
- add_order_spec(order_spec: OrderSpec) Order [source]¶
Adds an order specification to the order.
- Parameters:
order_spec (OrderSpec) – An order specification.
- Returns:
Order – The current order.
- property base_instrument: Instrument¶
The base instrument of the pair being traded.
- cancel(reason: str = 'CANCELLED') None [source]¶
Cancels an order.
- Parameters:
reason (str, default 'CANCELLED') – The reason for canceling the order.
- fill(trade: Trade) None [source]¶
Fills the order.
- Parameters:
trade (Trade) – A trade to fill the order.
- property pair: TradingPair¶
The trading pair of the order. (TradingPair, read-only)
- property quote_instrument: Instrument¶
The quote instrument of the pair being traded.
- release(reason: str = 'RELEASE (NO REASON)') None [source]¶
Releases all quantities from every wallet that have been allocated for this order.
- Parameters:
reason (str, default 'RELEASE (NO REASON)') – The reason for releasing all locked quantities associated with the order.
- class tensortrade.oms.orders.order.OrderStatus(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
Enum
An enumeration for the status of an order.
- CANCELLED = 'cancelled'¶
- FILLED = 'filled'¶
- OPEN = 'open'¶
- PARTIALLY_FILLED = 'partially_filled'¶
- PENDING = 'pending'¶