tensortrade.exchanges.simulated.simulated_exchange module

class tensortrade.exchanges.simulated.simulated_exchange.SimulatedExchange(data_frame=None, **kwargs)[source]

Bases: tensortrade.exchanges.instrument_exchange.InstrumentExchange

An instrument exchange, in which the price history is based off the supplied data frame and trade execution is largely decided by the designated slippage model.

If the data_frame parameter is not supplied upon initialization, it must be set before the exchange can be used within a trading environment.

property balance

The current balance of the base symbol on the exchange.

Return type

float

current_price(symbol)[source]

The current price of an instrument on the exchange, denoted in the base instrument.

Parameters

symbol (str) – The exchange symbol of the instrument to get the price for.

Return type

float

Returns

The current price of the specified instrument, denoted in the base instrument.

property data_frame

The underlying data model backing the price and volume simulation.

Return type

DataFrame

execute_trade(trade)[source]

Execute a trade on the exchange, accounting for slippage.

Parameters

trade (Trade) – The trade to execute.

Return type

Trade

Returns

The filled trade.

property generated_columns

The list of column names of the observation data frame generated by the exchange, before feature transformations.

Return type

List[str]

property generated_space

The initial shape of the observations generated by the exchange, before feature transformations.

Return type

Space

property has_next_observation

If False, the exchange’s data source has run out of observations.

Resetting the exchange may be necessary to continue generating observations.

Return type

bool

Returns

Whether or not the specified instrument has a next observation.

property initial_balance

The initial balance of the base symbol on the exchange.

Return type

float

property performance

The performance of the active account on the exchange since the last reset.

Return type

DataFrame

property portfolio

The current balance of each symbol on the exchange (non-positive balances excluded).

Return type

Dict[str, float]

reset()[source]

Reset the feature pipeline, initial balance, trades, performance, and any other temporary stateful data.

property trades

A list of trades made on the exchange since the last reset.

Return type

DataFrame