Skip to content

Commit

Permalink
BLACK: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
attack68 committed Apr 27, 2024
1 parent c2400d2 commit 4cfad55
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
16 changes: 12 additions & 4 deletions rateslib/calendars.py
Original file line number Diff line number Diff line change
Expand Up @@ -1152,19 +1152,27 @@ def _dcf_actacticma(
# roll is used here to roll a negative months forward eg, 30 sep minus 6M = 30/31 March.
if end == termination: # stub is a BACK stub:
fwd_end_0, fwd_end_1, fraction = start, start, -1.0
while end > fwd_end_1: # Handle Long Stubs which require repeated periods, and Zero frequencies.
while (
end > fwd_end_1
): # Handle Long Stubs which require repeated periods, and Zero frequencies.
fwd_end_0 = fwd_end_1
fraction += 1.0
fwd_end_1 = _add_months(start, (int(fraction) + 1) * frequency_months, "NONE", calendar, roll)
fwd_end_1 = _add_months(
start, (int(fraction) + 1) * frequency_months, "NONE", calendar, roll
)

fraction += (end - fwd_end_0) / (fwd_end_1 - fwd_end_0)
return fraction * frequency_months / 12.0
else: # stub is a FRONT stub
prev_start_0, prev_start_1, fraction = end, end, -1.0
while start < prev_start_1: # Handle Long Stubs which require repeated periods, and Zero frequencies.
while (
start < prev_start_1
): # Handle Long Stubs which require repeated periods, and Zero frequencies.
prev_start_0 = prev_start_1
fraction += 1.0
prev_start_1 = _add_months(end, -(int(fraction) + 1) * frequency_months, "NONE", calendar, roll)
prev_start_1 = _add_months(
end, -(int(fraction) + 1) * frequency_months, "NONE", calendar, roll
)

fraction += (prev_start_0 - start) / (prev_start_0 - prev_start_1)
return fraction * frequency_months / 12.0
Expand Down
2 changes: 1 addition & 1 deletion rateslib/periods.py
Original file line number Diff line number Diff line change
Expand Up @@ -2483,7 +2483,7 @@ def _get_interval_for_premium_adjusted_delta(self, unadj_k, half_vol_sq_t, vol_s
d_ = 1.08648555952878920
f_ = -3.0101764849574044
g_ = 0.198384242124144070
root_appx = a_ * vol_sqrt_t ** b_ + c_ * vol_sqrt_t ** d_ + f_ * vol_sqrt_t ** g_
root_appx = a_ * vol_sqrt_t**b_ + c_ * vol_sqrt_t**d_ + f_ * vol_sqrt_t**g_

def root(x):
return vol_sqrt_t * dual_norm_cdf(x) - dual_exp(-0.5 * x**2) / sqrt(2 * pi)
Expand Down
5 changes: 4 additions & 1 deletion rateslib/scheduling.py
Original file line number Diff line number Diff line change
Expand Up @@ -1280,7 +1280,10 @@ def _generate_irregular_schedule_unadjusted(
else:
yield ueffective
yield from _generate_regular_schedule_unadjusted(
ufront_stub, utermination if uback_stub is NoInput.blank else uback_stub, frequency, roll
ufront_stub,
utermination if uback_stub is NoInput.blank else uback_stub,
frequency,
roll,
)
if uback_stub is not NoInput(0):
yield utermination
Expand Down
6 changes: 3 additions & 3 deletions rateslib/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -1342,9 +1342,9 @@ def iterate(self):
# condition is set to less than to avoid the case where a null update
# results in the same solution and this is erroneously categorised
# as a converged solution.
return self._solver_result(1, i, time()-t0)
return self._solver_result(1, i, time() - t0)
elif self.g.real < self.func_tol:
return self._solver_result(2, i, time()-t0)
return self._solver_result(2, i, time() - t0)

# v_0 = self.v.copy()
v_1 = self._update_step_(self.algorithm)
Expand Down Expand Up @@ -1394,7 +1394,7 @@ def _update_curves_with_parameters(self, v_new):
ident[0, :].tolist(),
*DualArgs[1:],
)
for i, k in enumerate(curve.node_dates[curve._ini_solve:]):
for i, k in enumerate(curve.node_dates[curve._ini_solve :]):
curve.nodes[k] = DualType.vars_from(
d_vars,
v_new[var_counter].real,
Expand Down

0 comments on commit 4cfad55

Please sign in to comment.