tensortrade.wallets.portfolio module

class tensortrade.wallets.portfolio.Portfolio(base_instrument, wallets=None, order_listener=None, performance_listener=None)[source]

Bases: tensortrade.base.component.Component, tensortrade.base.core.TimedIdentifiable, tensortrade.data.stream.listeners.FeedListener

A portfolio of wallets on exchanges.

add(wallet)[source]
balance(instrument)[source]

The total balance of the portfolio in a specific instrument available for use.

Return type:Quantity
balances

The current unlocked balance of each instrument over all wallets.

Return type:List[Quantity]
base_balance

The current balance of the base instrument over all wallets.

Return type:Quantity
base_instrument

The exchange instrument used to measure value and performance statistics.

Return type:Instrument
exchange_pairs
Return type:List[ForwardRef]
exchanges
Return type:List[ForwardRef]
static find_keys(data)[source]
get_wallet(exchange_id, instrument)[source]
initial_balance

The initial balance of the base instrument over all wallets, set by calling reset.

Return type:Quantity
initial_net_worth
locked_balance(instrument)[source]

The total balance of the portfolio in a specific instrument locked in orders.

Return type:Quantity
locked_balances

The current locked balance of each instrument over all wallets.

Return type:List[Quantity]
net_worth

Calculate the net worth of the active account on thenge.

Return type:float
Returns:The total portfolio value of the active account on the exchange.
on_next(data)[source]
order_listener

The order listener to set for all orders executed by this portfolio.

Return type:Instrument
performance

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

Return type:DataFrame
Returns:A pandas.DataFrame with the locked and unlocked balance of each wallet at each time step.
performance_listener

The performance listener to send all portfolio updates to.

Return type:Instrument
profit_loss

Calculate the percentage change in net worth since the last reset.

Return type:float
Returns:The percentage change in net worth since the last reset. i.e. A return value of 2 would indicate a 100% increase in net worth (e.g. $100 -> $200)
registered_name = 'portfolio'
remove(wallet)[source]
remove_pair(exchange, instrument)[source]
reset()[source]
total_balance(instrument)[source]

The total balance of the portfolio in a specific instrument, both available for use and locked in orders.

Return type:Quantity
total_balances

The current total balance of each instrument over all wallets.

Return type:List[Quantity]
wallets
Return type:List[Wallet]