rebalance.assets
Submodules
rebalance.assets.asset
-
class
Asset(ticker, quantity=0)[source] Bases:
objectAsset class.
Holds the name, number of units, and the
Priceof the asset.-
__init__(ticker, quantity=0)[source] Initialization.
Parameters: - ticker (str) – Ticker of the asset.
- quantity (int, optional) – Number of units of the asset. Default is zero.
-
buy(quantity, currency=None)[source] Buys (or sells) a specified amount of the asset.
Parameters: - quantity (int) – If positive, it is the quantity to buy. If negative, it is the quantity to sell.
- currency (str, optional) – Currency in which to obtain cost. Defaults to asset’s own currency.
Returns: (float) – Cost of the units bought in specified
currency.
-
cost_of(units, currency=None)[source] Computes the cost to purchase the specified number of units.
Parameters: - units (int) – Units interested in purchasing.
- currency (str, optional) – Currency in which to convert the cost. Default is asset’s own currency.
Returns: (float) – Cost of the purchase.
-
currency Currency of the asset.
Type: (str)
-
market_value()[source] Computes the market value of the asset.
Returns: float – Market value of the asset (in asset’s own currency).
-
market_value_in(currency)[source] Computes the market value of the asset in specified currency.
Parameters: currency (str) – Currency in which to obtain market value. Returns: float – Market value of the asset.
-
mer
-
price Price of the asset (in asset’s own currency).
Type: (float)
-
price_in(currency)[source] Price of the asset in specified currency.
Parameters: currency (str) – Currency in which to obtain price of asset.
-
quantity Number of units of the asset.
Type: (int)
-
ticker Ticker of the asset.
Type: (str)
-