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: Exchange, balance: Quantity)[source]¶
Bases:
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: Quantity, reason: str) 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[Exchange, Instrument, float]) 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: Order, reason: str) 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.
- property locked: Dict[str, Quantity]¶
The current quantities that are locked for orders. (Dict[str, Quantity], read-only)
- property locked_balance: Quantity¶
The total balance of the wallet locked in orders. (Quantity, read-only)
- property total_balance: Quantity¶
The total balance of the wallet available for use and locked in orders. (Quantity, read-only)
- static transfer(source: Wallet, target: Wallet, quantity: Quantity, commission: Quantity, exchange_pair: ExchangePair, reason: str) 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: Quantity, reason: str) 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.