Fix linting issues: line length, import sorting, unused variables
- Set ruff/black line length to 120 - Reformatted code with black - Fixed import ordering with ruff - Disabled lint for UI component files with long CSS strings - Updated pyproject.toml with proper tool configuration
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from .base import BaseStrategy, StrategyConfig
|
||||
from .engine import StrategySelectionEngine
|
||||
from .laddered_put import LadderSpec, LadderedPutStrategy
|
||||
from .laddered_put import LadderedPutStrategy, LadderSpec
|
||||
from .lease import LeaseAnalysisSpec, LeaseStrategy
|
||||
from .protective_put import ProtectivePutSpec, ProtectivePutStrategy
|
||||
|
||||
|
||||
@@ -3,10 +3,14 @@ from __future__ import annotations
|
||||
from dataclasses import dataclass
|
||||
from typing import Literal
|
||||
|
||||
from app.core.pricing.black_scholes import DEFAULT_GLD_PRICE, DEFAULT_RISK_FREE_RATE, DEFAULT_VOLATILITY
|
||||
from app.core.pricing.black_scholes import (
|
||||
DEFAULT_GLD_PRICE,
|
||||
DEFAULT_RISK_FREE_RATE,
|
||||
DEFAULT_VOLATILITY,
|
||||
)
|
||||
from app.models.portfolio import LombardPortfolio
|
||||
from app.strategies.base import BaseStrategy, StrategyConfig
|
||||
from app.strategies.laddered_put import LadderSpec, LadderedPutStrategy
|
||||
from app.strategies.laddered_put import LadderedPutStrategy, LadderSpec
|
||||
from app.strategies.lease import LeaseStrategy
|
||||
from app.strategies.protective_put import ProtectivePutSpec, ProtectivePutStrategy
|
||||
|
||||
@@ -54,11 +58,21 @@ class StrategySelectionEngine:
|
||||
ProtectivePutStrategy(config, ProtectivePutSpec(label="OTM_90", strike_pct=0.90, months=12)),
|
||||
LadderedPutStrategy(
|
||||
config,
|
||||
LadderSpec(label="50_50_ATM_OTM95", weights=(0.5, 0.5), strike_pcts=(1.0, 0.95), months=12),
|
||||
LadderSpec(
|
||||
label="50_50_ATM_OTM95",
|
||||
weights=(0.5, 0.5),
|
||||
strike_pcts=(1.0, 0.95),
|
||||
months=12,
|
||||
),
|
||||
),
|
||||
LadderedPutStrategy(
|
||||
config,
|
||||
LadderSpec(label="33_33_33_ATM_OTM95_OTM90", weights=(1 / 3, 1 / 3, 1 / 3), strike_pcts=(1.0, 0.95, 0.90), months=12),
|
||||
LadderSpec(
|
||||
label="33_33_33_ATM_OTM95_OTM90",
|
||||
weights=(1 / 3, 1 / 3, 1 / 3),
|
||||
strike_pcts=(1.0, 0.95, 0.90),
|
||||
months=12,
|
||||
),
|
||||
),
|
||||
LeaseStrategy(config),
|
||||
]
|
||||
@@ -73,7 +87,10 @@ class StrategySelectionEngine:
|
||||
protection_ltv = protection.get("hedged_ltv_at_threshold")
|
||||
if protection_ltv is None:
|
||||
duration_rows = protection.get("durations", [])
|
||||
protection_ltv = min((row["hedged_ltv_at_threshold"] for row in duration_rows), default=1.0)
|
||||
protection_ltv = min(
|
||||
(row["hedged_ltv_at_threshold"] for row in duration_rows),
|
||||
default=1.0,
|
||||
)
|
||||
comparisons.append(
|
||||
{
|
||||
"name": strategy.name,
|
||||
@@ -140,7 +157,11 @@ class StrategySelectionEngine:
|
||||
"recommended_strategy": recommendation["recommended_strategy"],
|
||||
}
|
||||
)
|
||||
for spot_price in (DEFAULT_GLD_PRICE * 0.9, DEFAULT_GLD_PRICE, DEFAULT_GLD_PRICE * 1.1):
|
||||
for spot_price in (
|
||||
DEFAULT_GLD_PRICE * 0.9,
|
||||
DEFAULT_GLD_PRICE,
|
||||
DEFAULT_GLD_PRICE * 1.1,
|
||||
):
|
||||
engine = StrategySelectionEngine(
|
||||
portfolio_value=self.portfolio_value,
|
||||
loan_amount=self.loan_amount,
|
||||
|
||||
@@ -3,7 +3,11 @@ from __future__ import annotations
|
||||
from dataclasses import dataclass
|
||||
|
||||
from app.strategies.base import BaseStrategy, StrategyConfig
|
||||
from app.strategies.protective_put import DEFAULT_SCENARIO_CHANGES, ProtectivePutSpec, ProtectivePutStrategy
|
||||
from app.strategies.protective_put import (
|
||||
DEFAULT_SCENARIO_CHANGES,
|
||||
ProtectivePutSpec,
|
||||
ProtectivePutStrategy,
|
||||
)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -31,10 +35,16 @@ class LadderedPutStrategy(BaseStrategy):
|
||||
|
||||
def _legs(self) -> list[tuple[float, ProtectivePutStrategy]]:
|
||||
legs: list[tuple[float, ProtectivePutStrategy]] = []
|
||||
for index, (weight, strike_pct) in enumerate(zip(self.spec.weights, self.spec.strike_pcts, strict=True), start=1):
|
||||
for index, (weight, strike_pct) in enumerate(
|
||||
zip(self.spec.weights, self.spec.strike_pcts, strict=True), start=1
|
||||
):
|
||||
leg = ProtectivePutStrategy(
|
||||
self.config,
|
||||
ProtectivePutSpec(label=f"{self.spec.label}_leg_{index}", strike_pct=strike_pct, months=self.spec.months),
|
||||
ProtectivePutSpec(
|
||||
label=f"{self.spec.label}_leg_{index}",
|
||||
strike_pct=strike_pct,
|
||||
months=self.spec.months,
|
||||
),
|
||||
)
|
||||
legs.append((weight, leg))
|
||||
return legs
|
||||
|
||||
@@ -3,12 +3,28 @@ from __future__ import annotations
|
||||
from dataclasses import dataclass
|
||||
from datetime import date, timedelta
|
||||
|
||||
from app.core.pricing.black_scholes import BlackScholesInputs, black_scholes_price_and_greeks
|
||||
from app.core.pricing.black_scholes import (
|
||||
BlackScholesInputs,
|
||||
black_scholes_price_and_greeks,
|
||||
)
|
||||
from app.models.option import Greeks, OptionContract
|
||||
from app.models.strategy import HedgingStrategy
|
||||
from app.strategies.base import BaseStrategy, StrategyConfig
|
||||
|
||||
DEFAULT_SCENARIO_CHANGES = (-0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0.0, 0.1, 0.2, 0.3, 0.4, 0.5)
|
||||
DEFAULT_SCENARIO_CHANGES = (
|
||||
-0.6,
|
||||
-0.5,
|
||||
-0.4,
|
||||
-0.3,
|
||||
-0.2,
|
||||
-0.1,
|
||||
0.0,
|
||||
0.1,
|
||||
0.2,
|
||||
0.3,
|
||||
0.4,
|
||||
0.5,
|
||||
)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
|
||||
Reference in New Issue
Block a user