Skip to content

Commit

Permalink
Merge pull request #467 from pmorissette/dependabot/pip/ruff-gte-0.5.…
Browse files Browse the repository at this point in the history
…0-and-lt-0.10

Update ruff requirement from <0.9,>=0.5.0 to >=0.5.0,<0.10
  • Loading branch information
timkpaine authored Feb 2, 2025
2 parents a458fe4 + 9ddf4ab commit 771ec80
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions bt/backtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def __init__(
):
if data.columns.duplicated().any():
cols = data.columns[data.columns.duplicated().tolist()].tolist()
raise Exception("data provided has some duplicate column names: \n%s \n" "Please remove duplicates!" % cols)
raise Exception("data provided has some duplicate column names: \n%s \nPlease remove duplicates!" % cols)

# we want to reuse strategy logic - copy it!
# basically strategy is a template
Expand Down Expand Up @@ -549,7 +549,7 @@ def plot_histogram(self, statistic="monthly_sharpe", figsize=(15, 5), title=None
"""
if statistic not in self.r_stats.index:
raise ValueError("Invalid statistic. Valid statistics" "are the statistics in self.stats")
raise ValueError("Invalid statistic. Valid statisticsare the statistics in self.stats")

if title is None:
title = "%s histogram" % statistic
Expand Down Expand Up @@ -588,7 +588,7 @@ class RenormalizedFixedIncomeResult(Result):
def __init__(self, normalizing_value, *backtests):
for backtest in backtests:
if not backtest.strategy.fixed_income:
raise ValueError("Cannot apply RenormalizedFixedIncomeResult " "because backtest %s is not on a fixed income " "strategy" % backtest.name)
raise ValueError("Cannot apply RenormalizedFixedIncomeResult because backtest %s is not on a fixed income strategy" % backtest.name)
if not isinstance(normalizing_value, dict):
normalizing_value = {x.name: normalizing_value for x in backtests}
tmp = [pd.DataFrame({x.name: self._price(x.strategy, normalizing_value[x.name])}) for x in backtests]
Expand Down
18 changes: 9 additions & 9 deletions bt/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ def bidoffer_paid(self):
self.root.update(self.now, None)
return self._bidoffer_paid
else:
raise Exception("Bid/offer accounting not turned on: " '"bidoffer" argument not provided during setup')
raise Exception('Bid/offer accounting not turned on: "bidoffer" argument not provided during setup')

@property
def bidoffers_paid(self):
Expand All @@ -487,7 +487,7 @@ def bidoffers_paid(self):
self.root.update(self.now, None)
return self._bidoffers_paid.loc[: self.now]
else:
raise Exception("Bid/offer accounting not turned on: " '"bidoffer" argument not provided during setup')
raise Exception('Bid/offer accounting not turned on: "bidoffer" argument not provided during setup')

@property
def universe(self):
Expand Down Expand Up @@ -560,7 +560,7 @@ def setup(self, universe, **kwargs):
# strategies as the "price" is just a reference
# value and should not be used for capital allocation
if self.fixed_income and not self.parent.fixed_income:
raise ValueError("Cannot have fixed income " "strategy child (%s) of non-" "fixed income strategy (%s)" % (self.name, self.parent.name))
raise ValueError("Cannot have fixed income strategy child (%s) of non-fixed income strategy (%s)" % (self.name, self.parent.name))

# determine if needs paper trading
# and setup if so
Expand Down Expand Up @@ -1286,7 +1286,7 @@ def bidoffers(self):
self.update(self.root.now)
return self._bidoffers.loc[: self.now]
else:
raise Exception("Bid/offer accounting not turned on: " '"bidoffer" argument not provided during setup')
raise Exception('Bid/offer accounting not turned on: "bidoffer" argument not provided during setup')

@property
def bidoffer_paid(self):
Expand All @@ -1311,7 +1311,7 @@ def bidoffers_paid(self):
self.root.update(self.root.now, None)
return self._bidoffers_paid.loc[: self.now]
else:
raise Exception("Bid/offer accounting not turned on: " '"bidoffer" argument not provided during setup')
raise Exception('Bid/offer accounting not turned on: "bidoffer" argument not provided during setup')

def setup(self, universe, **kwargs):
"""
Expand Down Expand Up @@ -1424,7 +1424,7 @@ def update(self, date, data=None, inow=None):
if is_zero(self._position):
self._value = 0
else:
raise Exception("Position is open (non-zero: %s) and latest price is NaN " "for security %s on %s. Cannot update node value." % (self._position, self.name, date))
raise Exception("Position is open (non-zero: %s) and latest price is NaN for security %s on %s. Cannot update node value." % (self._position, self.name, date))
else:
self._value = self._position * self._price * self.multiplier

Expand Down Expand Up @@ -1482,7 +1482,7 @@ def allocate(self, amount, update=True):
raise Exception("Cannot allocate capital to a parentless security")

if is_zero(self._price) or np.isnan(self._price):
raise Exception("Cannot allocate capital to " "%s because price is %s as of %s" % (self.name, self._price, self.parent.now))
raise Exception("Cannot allocate capital to %s because price is %s as of %s" % (self.name, self._price, self.parent.now))

# buy/sell
# determine quantity - must also factor in commission
Expand Down Expand Up @@ -1623,7 +1623,7 @@ def transact(self, q, update=True, update_self=True, price=None):
return

if price is not None and not self._bidoffer_set:
raise ValueError('Cannot transact at custom prices when "bidoffer" has ' "not been passed during setup to enable bid-offer tracking.")
raise ValueError('Cannot transact at custom prices when "bidoffer" has not been passed during setup to enable bid-offer tracking.')

# this security will need an update, even if pos is 0 (for example if
# we close the positions, value and pos is 0, but still need to do that
Expand Down Expand Up @@ -1843,7 +1843,7 @@ def update(self, date, data=None, inow=None):
if is_zero(self._position):
self._coupon = 0.0
else:
raise Exception("Position is open (non-zero) and latest coupon is NaN " "for security %s on %s. Cannot update node value." % (self.name, date))
raise Exception("Position is open (non-zero) and latest coupon is NaN for security %s on %s. Cannot update node value." % (self.name, date))
else:
self._coupon = self._position * coupon

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def local_file(filename):
"pyprind>=2.11",
"pytest",
"pytest-cov",
"ruff>=0.5.0,<0.9",
"ruff>=0.5.0,<0.10",
"setuptools",
"twine",
"wheel",
Expand Down

0 comments on commit 771ec80

Please sign in to comment.