tensortrade.oms.orders.order module¶
-
class
tensortrade.oms.orders.order.Order(step: int, side: tensortrade.oms.orders.trade.TradeSide, trade_type: tensortrade.oms.orders.trade.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:
tensortrade.core.base.TimedIdentifiable,tensortrade.core.base.ObservableA 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¶ 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.
-
complete() → tensortrade.oms.orders.order.Order[source]¶ Completes an order.
- Returns
Order – The completed order.
-
fill(trade: tensortrade.oms.orders.trade.Trade) → None[source]¶ Fills the order.
- Parameters
trade (Trade) – A trade to fill the order.
-
property
is_active¶ If this order is active. (bool, read-only)
-
property
is_buy¶ If this is a buy order. (bool, read-only)
-
property
is_cancelled¶ If this order is cancelled. (bool, read-only)
-
property
is_complete¶ If this order is complete. (bool, read-only)
-
property
is_executable¶ If this order is executable. (bool, read-only)
-
property
is_expired¶ If this order is expired. (bool, read-only)
-
property
is_limit_order¶ If this is a limit order. (bool, read-only)
-
property
is_market_order¶ If this is a market order. (bool, read-only)
-
property
is_sell¶ If this is a sell order. (bool, read-only)
-
property
pair¶ The trading pair of the order. (TradingPair, read-only)
-
property
quote_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.
-
property
size¶ The size of the order. (Decimal, read-only)