Skip to content

Commit 366a313

Browse files
committed
fix: black formatting fixed
1 parent 1f51b6a commit 366a313

File tree

5 files changed

+37
-26
lines changed

5 files changed

+37
-26
lines changed

src/quant_research_starter/api/auth.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ async def get_current_user(
9595
return user
9696

9797

98-
async def require_active_user(current_user: Annotated[models.User, Depends(get_current_user)]):
98+
async def require_active_user(
99+
current_user: Annotated[models.User, Depends(get_current_user)],
100+
):
99101
if not current_user.is_active:
100102
raise HTTPException(status_code=400, detail="Inactive user")
101103
return current_user

src/quant_research_starter/api/routers/auth.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ async def login_for_access_token(
4949
try:
5050
token_response = supabase.sign_in(form_data.username, form_data.password)
5151
# token_response may contain access_token and refresh_token
52-
return {"access_token": token_response.get("access_token"), "token_type": "bearer"}
52+
return {
53+
"access_token": token_response.get("access_token"),
54+
"token_type": "bearer",
55+
}
5356
except Exception as exc:
5457
raise HTTPException(status_code=400, detail=str(exc)) from exc
5558

src/quant_research_starter/api/supabase.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ def signup(email: str, password: str) -> dict:
2929
assert is_enabled(), "Supabase not configured"
3030
url = f"{SUPABASE_URL.rstrip('/')}/auth/v1/signup"
3131
headers = {"apikey": SUPABASE_ANON_KEY, "Content-Type": "application/json"}
32-
resp = requests.post(url, json={"email": email, "password": password}, headers=headers)
32+
resp = requests.post(
33+
url, json={"email": email, "password": password}, headers=headers
34+
)
3335
resp.raise_for_status()
3436
return resp.json()
3537

@@ -39,7 +41,9 @@ def sign_in(email: str, password: str) -> dict:
3941
assert is_enabled(), "Supabase not configured"
4042
url = f"{SUPABASE_URL.rstrip('/')}/auth/v1/token?grant_type=password"
4143
headers = {"apikey": SUPABASE_ANON_KEY, "Content-Type": "application/json"}
42-
resp = requests.post(url, json={"email": email, "password": password}, headers=headers)
44+
resp = requests.post(
45+
url, json={"email": email, "password": password}, headers=headers
46+
)
4347
resp.raise_for_status()
4448
return resp.json()
4549

src/quant_research_starter/api/tasks/tasks.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ def _safe_publish(channel: str, payload: str):
2525
try:
2626
redis_client.publish(channel, payload)
2727
except Exception:
28-
logger.warning("Could not publish to Redis channel %s (connection unavailable)", channel)
28+
logger.warning(
29+
"Could not publish to Redis channel %s (connection unavailable)", channel
30+
)
2931

3032

3133
@celery_app.task(bind=True, name="quant_research_starter.api.tasks.tasks.run_backtest")

tests/test_factors.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,19 @@ def test_momentum_values(self):
6969
lb = getattr(momentum, "lookback", 5)
7070

7171
# Ensure there is enough data for the expected calculation
72-
assert len(prices) > (skip + lb), (
73-
"test setup doesn't have enough data for momentum calculation"
74-
)
72+
assert len(prices) > (
73+
skip + lb
74+
), "test setup doesn't have enough data for momentum calculation"
7575

7676
expected_momentum = (
7777
prices.shift(skip).iloc[-1, 0] / prices.shift(skip + lb).iloc[-1, 0]
7878
) - 1
7979
actual = result.iloc[-1, 0]
8080

8181
assert np.isfinite(actual), f"momentum result is not finite: {actual}"
82-
assert np.isclose(actual, expected_momentum, atol=1e-6), (
83-
f"momentum mismatch: got {actual}, expected {expected_momentum}"
84-
)
82+
assert np.isclose(
83+
actual, expected_momentum, atol=1e-6
84+
), f"momentum mismatch: got {actual}, expected {expected_momentum}"
8585

8686

8787
class TestValueFactor:
@@ -168,9 +168,9 @@ def test_volatility_calculation(self):
168168

169169
# Allow NaNs during rolling warm-up; only validate values after the lookback window is available.
170170
post_warmup = result.iloc[lookback:].values.flatten()
171-
assert np.all(np.isfinite(post_warmup)), (
172-
"volatility results contain non-finite values after warm-up"
173-
)
171+
assert np.all(
172+
np.isfinite(post_warmup)
173+
), "volatility results contain non-finite values after warm-up"
174174

175175
# Compute realized rolling volatility (std of pct-change) over the lookback window for each series
176176
realized = (
@@ -179,23 +179,23 @@ def test_volatility_calculation(self):
179179
factor_last = result.iloc[-1] # Series: index=columns
180180

181181
# Sanity: realized vol should be finite and non-equal
182-
assert np.all(np.isfinite(realized)), (
183-
"realized volatility contains non-finite values"
184-
)
185-
assert not np.allclose(realized.values, realized.values[0]), (
186-
"realized vols are identical; test input invalid"
187-
)
182+
assert np.all(
183+
np.isfinite(realized)
184+
), "realized volatility contains non-finite values"
185+
assert not np.allclose(
186+
realized.values, realized.values[0]
187+
), "realized vols are identical; test input invalid"
188188

189189
# Use Spearman rank correlation to check monotonic relation between factor and realized vol.
190190
# We expect a negative correlation: higher factor -> lower realized vol (i.e., factor encodes low-vol signal).
191191
spearman_corr = factor_last.corr(realized, method="spearman")
192192

193-
assert np.isfinite(spearman_corr), (
194-
f"spearman corr is not finite: {spearman_corr}"
195-
)
196-
assert spearman_corr < -0.5, (
197-
f"volatility factor should be negatively correlated with realized volatility (spearman={spearman_corr})"
198-
)
193+
assert np.isfinite(
194+
spearman_corr
195+
), f"spearman corr is not finite: {spearman_corr}"
196+
assert (
197+
spearman_corr < -0.5
198+
), f"volatility factor should be negatively correlated with realized volatility (spearman={spearman_corr})"
199199

200200

201201
class TestBollingerBandsFactor:

0 commit comments

Comments
 (0)