tensortrade.oms.exchanges.exchange module

class tensortrade.oms.exchanges.exchange.Exchange(name: str, service: Callable, options: tensortrade.oms.exchanges.exchange.ExchangeOptions = None)[source]

Bases: tensortrade.core.component.Component, tensortrade.core.base.TimedIdentifiable

An abstract exchange for use within a trading environment.

Parameters:
  • name (str) – The name of the exchange.
  • service (Union[Callable, str]) – The service to be used for filling orders.
  • options (ExchangeOptions) – The options used to specify the setting of the exchange.
__call__(*streams) → tensortrade.oms.exchanges.exchange.Exchange[source]

Sets up the price streams used to generate the prices.

Parameters:*streams – The positional arguments each being a price stream.
Returns:Exchange – The exchange the price streams were passed in for.
execute_order(order: Order, portfolio: Portfolio) → None[source]

Execute an order on the exchange.

Parameters:
  • order (Order) – The order to execute.
  • portfolio (Portfolio) – The portfolio to use.
is_pair_tradable(trading_pair: tensortrade.oms.instruments.trading_pair.TradingPair) → bool[source]

Whether or not the specified trading pair is tradable on this exchange.

Parameters:trading_pair (TradingPair) – The trading pair to test the tradability of.
Returns:bool – Whether or not the pair is tradable.
quote_price(trading_pair: tensortrade.oms.instruments.trading_pair.TradingPair) → decimal.Decimal[source]

The quote price of a trading pair on the exchange, denoted in the core instrument.

Parameters:trading_pair (TradingPair) – The trading pair to get the quote price for.
Returns:Decimal – The quote price of the specified trading pair, denoted in the core instrument.
registered_name = 'exchanges'
streams() → List[Stream[float]][source]

Gets the price streams for the exchange.

Returns:List[Stream[float]] – The price streams for the exchange.
class tensortrade.oms.exchanges.exchange.ExchangeOptions(commission: float = 0.003, min_trade_size: float = 1e-06, max_trade_size: float = 1000000.0, min_trade_price: float = 1e-08, max_trade_price: float = 100000000.0, is_live: bool = False)[source]

Bases: object

An options class to specify the settings of an exchange.

Parameters:
  • commission (float, default 0.003) – The percentage of the order size taken by the exchange.
  • min_trade_size (float, default 1e-6) – The minimum trade size an order can have.
  • max_trade_size (float, default 1e6) – The maximum trade size an order can have.
  • min_trade_price (float, default 1e-8) – The minimum price an exchange can have.
  • max_trade_price (float, default 1e8) – The maximum price an exchange can have.
  • is_live (bool, default False) – Whether live orders should be submitted to the exchange.