tensortrade.oms.wallets.portfolio module¶
-
class
tensortrade.oms.wallets.portfolio.Portfolio(*args, **kwargs)[source]¶ Bases:
tensortrade.core.component.Component,tensortrade.core.base.TimedIdentifiableA portfolio of wallets on exchanges.
- Parameters
base_instrument (Instrument) – The exchange instrument used to measure value and performance statistics.
wallets (List[WalletType]) – The wallets to be used in the portfolio.
order_listener (OrderListener) – The order listener to set for all orders executed by this portfolio.
performance_listener (Callable[[pd.DataFrame], None]) – The performance listener to send all portfolio updates to.
-
add(wallet: WalletType) → None[source]¶ Adds a wallet to the portfolio.
- Parameters
wallet (WalletType) – The wallet to add to the portfolio.
-
balance(instrument: tensortrade.oms.instruments.instrument.Instrument) → tensortrade.oms.instruments.quantity.Quantity[source]¶ Gets the total balance of the portfolio in a specific instrument available for use.
- Parameters
instrument (Instrument) – The instrument to compute the balance for.
- Returns
Quantity – The balance of the instrument over all wallets.
-
property
balances¶ The current unlocked balance of each instrument over all wallets. (List[Quantity], read-only)
-
property
base_balance¶ The current balance of the base instrument over all wallets. (Quantity, read-only)
-
property
exchange_pairs¶ All the exchange pairs in the portfolio. (List[ExchangePair], read-only)
-
property
exchanges¶ All the exchanges in the portfolio. (List[Exchange], read-only)
-
get_wallet(exchange_id: str, instrument: tensortrade.oms.instruments.instrument.Instrument) → tensortrade.oms.wallets.wallet.Wallet[source]¶ Gets wallet by the exchange_id and instrument.
- Parameters
exchange_id (str) – The exchange id used to identify the wallet.
instrument (Instrument) – The instrument used to identify the wallet.
- Returns
Wallet – The wallet associated with exchange_id and instrument.
-
property
initial_balance¶ The initial balance of the base instrument over all wallets. (Quantity, read-only)
-
property
initial_net_worth¶ The initial net worth of the portfolio. (float, read-only)
-
property
ledger¶ The ledger that keeps track of transactions. (Ledger, read-only)
-
locked_balance(instrument: tensortrade.oms.instruments.instrument.Instrument) → tensortrade.oms.instruments.quantity.Quantity[source]¶ Gets the total balance a specific instrument locked in orders over the entire portfolio.
- Parameters
instrument (Instrument) – The instrument to find locked balances for.
- Returns
Quantity – The total locked balance of the instrument.
-
property
locked_balances¶ The current locked balance of each instrument over all wallets. (List[Quantity], read-only)
-
property
net_worth¶ The current net worth of the portfolio. (float, read-only)
-
on_next(data: dict) → None[source]¶ Updates the performance metrics.
- Parameters
data (dict) – The data produced from the observer feed that is used to update the performance metrics.
-
property
performance¶ The performance of the portfolio since the last reset. (pd.DataFrame, read-only)
-
property
profit_loss¶ The percent change in net worth since the last reset. (float, read-only)
-
registered_name= 'portfolio'¶
-
remove(wallet: tensortrade.oms.wallets.wallet.Wallet) → None[source]¶ Removes a wallet from the portfolio.
- Parameters
wallet (Wallet) – The wallet to be removed.
-
remove_pair(exchange: tensortrade.oms.exchanges.exchange.Exchange, instrument: tensortrade.oms.instruments.instrument.Instrument) → None[source]¶ Removes a wallet from the portfolio by exchange and instrument.
- Parameters
exchange (Exchange) – The exchange of the wallet to be removed.
instrument (Instrument) – The instrument of the wallet to be removed.
-
total_balance(instrument: tensortrade.oms.instruments.instrument.Instrument) → tensortrade.oms.instruments.quantity.Quantity[source]¶ Gets the total balance of a specific instrument over the portfolio, both available for use and locked in orders.
- Parameters
instrument (Instrument) – The instrument to get total balance of.
- Returns
Quantity – The total balance of instrument over the portfolio.
-
property
total_balances¶ The current total balance of each instrument over all wallets. (List[Quantity], read-only)
-
property
wallets¶ All the wallets in the portfolio. (List[Wallet], read-only)