tensortrade.oms.orders.broker module

class tensortrade.oms.orders.broker.Broker[source]

Bases: tensortrade.oms.orders.order_listener.OrderListener, tensortrade.core.base.TimeIndexed

A broker for handling the execution of orders on multiple exchanges. Orders are kept in a virtual order book until they are ready to be executed.

unexecuted

The list of orders the broker is waiting to execute, when their criteria is satisfied.

Type:List[Order]
executed

The dictionary of orders the broker has executed since resetting, organized by order id.

Type:Dict[str, Order]
trades

The dictionary of trades the broker has executed since resetting, organized by order id.

Type:Dict[str, Trade]
cancel(order: tensortrade.oms.orders.order.Order) → None[source]

Cancels an order.

Parameters:order (Order) – The order to be canceled.
on_fill(order: Order, trade: Trade) → None[source]

Updates the broker after an order has been filled.

Parameters:
  • order (Order) – The order that is being filled.
  • trade (Trade) – The trade that is being made to fill the order.
reset() → None[source]

Resets the broker.

submit(order: tensortrade.oms.orders.order.Order) → None[source]

Submits an order to the broker.

Adds order to the queue of orders waiting to be executed.

Parameters:order (Order) – The order to be submitted.
update() → None[source]

Updates the brokers order management system.

The broker will look through the unexecuted orders and if an order is ready to be executed the broker will submit it to the executed list and execute the order.

Then the broker will find any orders that are active, but expired, and proceed to cancel them.