def __mul__(self, scalar): """Scale/multiply the contents of the position. Args: scalar: A Decimal. Returns: An instance of Inventory. """ return Position(amount_mul(self.units, scalar), self.cost)
def get_cost(self): """Return the cost associated with this position. The cost is the number of units of the lot times the cost of the lot. If the lot has no associated cost, the amount of the position is returned as its cost. Returns: An instance of Amount. """ warnings.warn("Position.get_cost() is deprecated; " "use convert.get_cost(position) instead") cost = self.cost if cost is None: rcost = self.units else: rcost = amount_mul(cost, self.units.number) return rcost
def amount_distrib(amount: Amount, weight: Decimal, total_weight: Decimal): return amount_div(amount_mul(amount, weight), total_weight)