You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think there are issues/bugs inside Portfolio.adjust_percents. This could have been a pull request, but I'd rather have a discussion in case I'm mistaken. I'll walk through what I think are the problems.
def adjust_percents(self, date, prices, weights, row, directions=None):
w = {}
# Get current weights
for symbol in self.symbols:
w[symbol] = self.share_percent(row, symbol)
Weights in other functions are converted between whole numbers and floats. We don't know if the user is passing in whole numbers or floats yet. Later sorting will fail if there's a mismatch. I think this should be something like:
convert_weight = lambda weight: self._float(weight) if weight <= 1 else self._float(weight) / self._float(100)
weights = {symbol: convert_weight(weight) for symbol, weight in weights.items()}
w = {}
Get current weights
for symbol in self.symbols:
w[symbol] = convert_weight(self.share_percent(row, symbol, field=field))
The text was updated successfully, but these errors were encountered:
I think there are issues/bugs inside Portfolio.adjust_percents. This could have been a pull request, but I'd rather have a discussion in case I'm mistaken. I'll walk through what I think are the problems.
def adjust_percents(self, date, prices, weights, row, directions=None):
w = {}
Weights in other functions are converted between whole numbers and floats. We don't know if the user is passing in whole numbers or floats yet. Later sorting will fail if there's a mismatch. I think this should be something like:
convert_weight = lambda weight: self._float(weight) if weight <= 1 else self._float(weight) / self._float(100)
weights = {symbol: convert_weight(weight) for symbol, weight in weights.items()}
w = {}
Get current weights
for symbol in self.symbols:
w[symbol] = convert_weight(self.share_percent(row, symbol, field=field))
The text was updated successfully, but these errors were encountered: