boglehead/portfolio.py
def sell(self, sell_value):
        """Sell `value` off from assets in a rebalanced way"""
        self.rebalance()
        current_value = self.value()
        if sell_value > current_value:
            raise ValueError("can't sell that much")
        sell_ratio = sell_value / current_value
        for fund in self.funds:
            fund.units *= 1 - sell_ratio
        if abs(self.value() - (current_value - sell_value)) > EPSILON:
            raise ValueError("#sellfail")
        return self.value()
Sell `value` off from assets in a rebalanced way
Sell `value` off from assets in a rebalanced way
Sell ` value ` off from assets in a rebalanced way
def sell(self, sell_value):
        self.rebalance()
        current_value = self.value()
        if sell_value > current_value:
            raise ValueError("can't sell that much")
        sell_ratio = sell_value / current_value
        for fund in self.funds:
            fund.units *= 1 - sell_ratio
        if abs(self.value() - (current_value - sell_value)) > EPSILON:
            raise ValueError("#sellfail")
        return self.value()
def sell ( self , sell_value ) : self . rebalance ( ) current_value = self . value ( ) if sell_value > current_value : raise ValueError ( "can't sell that much" ) sell_ratio = sell_value / current_value for fund in self . funds : fund . units *= 1 - sell_ratio if abs ( self . value ( ) - ( current_value - sell_value ) ) > EPSILON : raise ValueError ( "#sellfail" ) return self . value ( )
Sell `value` off from assets in a rebalanced way
Sell ` value ` off from assets in a rebalanced way
"""Sell `value` off from assets in a rebalanced way"""
self
sell_value