tensortrade.oms.orders.criteria module

class tensortrade.oms.orders.criteria.Criteria[source]

Bases: object

A criteria to be satisfied before an order will be executed.

abstract check(order: Order, exchange: Exchange) bool[source]

Checks whether the order is executable on exchange.

Parameters:
  • order (Order) – An order.

  • exchange (Exchange) – The exchange to check.

Returns:

bool – Whether order is executable on exchange.

class tensortrade.oms.orders.criteria.CriteriaBinOp(left: Callable[[Order, Exchange], bool], right: Callable[[Order, Exchange], bool], op: Callable[[bool, bool], bool], op_str: str)[source]

Bases: Criteria

A class for using a binary operation for criteria.

Parameters:
  • left (Callable[[Order, Exchange], bool]) – The left criteria argument.

  • right (Callable[[Order, Exchange], bool]) – The right criteria argument.

  • op (Callable[[bool, bool], bool]) – The binary boolean operation.

  • op_str (str) – The string representing the op.

check(order: Order, exchange: Exchange) bool[source]

Checks whether the order is executable on exchange.

Parameters:
  • order (Order) – An order.

  • exchange (Exchange) – The exchange to check.

Returns:

bool – Whether order is executable on exchange.

class tensortrade.oms.orders.criteria.Limit(limit_price: float)[source]

Bases: Criteria

An order criteria that allows execution when the quote price for a trading pair is at or below a specific price, hidden from the public order book.

Parameters:

limit_price (float) – The quote price to check for execution.

check(order: Order, exchange: Exchange) bool[source]

Checks whether the order is executable on exchange.

Parameters:
  • order (Order) – An order.

  • exchange (Exchange) – The exchange to check.

Returns:

bool – Whether order is executable on exchange.

class tensortrade.oms.orders.criteria.NotCriteria(criteria: Callable[[Order, Exchange], bool])[source]

Bases: Criteria

A criteria to invert the truth value of another criteria.

Parameters:

criteria (Callable[[Order, Exchange], bool]) – The criteria to invert the truth value of.

check(order: Order, exchange: Exchange) bool[source]

Checks whether the order is executable on exchange.

Parameters:
  • order (Order) – An order.

  • exchange (Exchange) – The exchange to check.

Returns:

bool – Whether order is executable on exchange.

class tensortrade.oms.orders.criteria.Stop(direction: StopDirection | str, percent: float)[source]

Bases: Criteria

An order criteria that allows execution when the quote price for a trading pair is above or below a specific price.

Parameters:
  • direction (Union[StopDirection, str]) – The direction to watch for the stop criteria.

  • percent (float) – The percentage of the current price to use for watching.

check(order: Order, exchange: Exchange) bool[source]

Checks whether the order is executable on exchange.

Parameters:
  • order (Order) – An order.

  • exchange (Exchange) – The exchange to check.

Returns:

bool – Whether order is executable on exchange.

class tensortrade.oms.orders.criteria.StopDirection(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

An enumeration for the directions of a stop criteria.

DOWN = 'down'
UP = 'up'
class tensortrade.oms.orders.criteria.Timed(duration: float)[source]

Bases: Criteria

An order criteria for waiting a certain amount of time for execution.

Parameters:

duration (float) – The amount of time to wait.

check(order: Order, exchange: Exchange)[source]

Checks whether the order is executable on exchange.

Parameters:
  • order (Order) – An order.

  • exchange (Exchange) – The exchange to check.

Returns:

bool – Whether order is executable on exchange.