tensortrade.oms.wallets.wallet module

class tensortrade.oms.wallets.wallet.Transfer(quantity, commission, price)

Bases: tuple

commission

Alias for field number 1

price

Alias for field number 2

quantity

Alias for field number 0

class tensortrade.oms.wallets.wallet.Wallet(exchange: tensortrade.oms.exchanges.exchange.Exchange, balance: tensortrade.oms.instruments.quantity.Quantity)[source]

Bases: tensortrade.core.base.Identifiable

A wallet stores the balance of a specific instrument on a specific exchange.

Parameters:
  • exchange (Exchange) – The exchange associated with this wallet.
  • balance (Quantity) – The initial balance quantity for the wallet.
deposit(quantity: tensortrade.oms.instruments.quantity.Quantity, reason: str) → tensortrade.oms.instruments.quantity.Quantity[source]

Deposits funds into the wallet.

Parameters:
  • quantity (Quantity) – The amount to deposit into this wallet.
  • reason (str) – The reason for depositing the amount.
Returns:

Quantity – The deposited amount.

classmethod from_tuple(wallet_tuple: Tuple[tensortrade.oms.exchanges.exchange.Exchange, tensortrade.oms.instruments.instrument.Instrument, float]) → tensortrade.oms.wallets.wallet.Wallet[source]

Creates a wallet from a wallet tuple.

Parameters:wallet_tuple (Tuple[Exchange, Instrument, float]) – A tuple containing an exchange, instrument, and amount.
Returns:Wallet – A wallet corresponding to the arguments given in the tuple.
ledger = <tensortrade.oms.wallets.ledger.Ledger object>
lock(quantity, order: tensortrade.oms.orders.order.Order, reason: str) → tensortrade.oms.instruments.quantity.Quantity[source]

Locks funds for specified order.

Parameters:
  • quantity (Quantity) – The amount of funds to lock for the order.
  • order (Order) – The order funds will be locked for.
  • reason (str) – The reason for locking funds.
Returns:

Quantity – The locked quantity for order.

Raises:
  • DoubleLockedQuantity – Raised if the given amount is already a locked quantity.
  • InsufficientFunds – Raised if amount is greater the current balance.
locked

The current quantities that are locked for orders. (Dict[str, Quantity], read-only)

locked_balance

The total balance of the wallet locked in orders. (Quantity, read-only)

reset() → None[source]

Resets the wallet.

total_balance

The total balance of the wallet available for use and locked in orders. (Quantity, read-only)

static transfer(source: tensortrade.oms.wallets.wallet.Wallet, target: tensortrade.oms.wallets.wallet.Wallet, quantity: tensortrade.oms.instruments.quantity.Quantity, commission: tensortrade.oms.instruments.quantity.Quantity, exchange_pair: tensortrade.oms.instruments.exchange_pair.ExchangePair, reason: str) → tensortrade.oms.wallets.wallet.Transfer[source]

Transfers funds from one wallet to another.

Parameters:
  • source (Wallet) – The wallet in which funds will be transferred from
  • target (Wallet) – The wallet in which funds will be transferred to
  • quantity (Quantity) – The quantity to be transferred from the source to the target. In terms of the instrument of the source wallet.
  • commission (Quantity) – The commission to be taken from the source wallet for performing the transfer of funds.
  • exchange_pair (ExchangePair) – The exchange pair associated with the transfer
  • reason (str) – The reason for transferring the funds.
Returns:

Transfer – A transfer object describing the transaction.

Raises:

Exception – Raised if an equation that describes the conservation of funds is broken.

unlock(quantity: tensortrade.oms.instruments.quantity.Quantity, reason: str) → tensortrade.oms.instruments.quantity.Quantity[source]

Unlocks a certain amount from the locked funds of the wallet that are associated with the given quantity path id.

Parameters:
  • quantity (Quantity) – The quantity to unlock from the funds.
  • reason (str) – The reason for unlocking funds.
Returns:

Quantity – The free quantity.

Raises:
  • DoubleUnlockedFunds – Raised if quantity is not a locked quantity.
  • QuantityNotLocked – Raised if quantity has a path id that is not currently allocated in this wallet.
  • InsufficientFunds – Raised if quantity is greater than the amount currently allocated for the associated path id.
withdraw(quantity: tensortrade.oms.instruments.quantity.Quantity, reason: str) → tensortrade.oms.instruments.quantity.Quantity[source]

Withdraws funds from the wallet.

Parameters:
  • quantity (Quantity) – The amount to withdraw from this wallet.
  • reason (str) – The reason for withdrawing the amount.
Returns:

Quantity – The withdrawn amount.