Skip to content

Commit

Permalink
Update backend snapshot retaking
Browse files Browse the repository at this point in the history
  • Loading branch information
SinaKhalili committed Nov 6, 2024
1 parent a90fb3e commit 3b01312
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
3 changes: 0 additions & 3 deletions backend/api/price_shock.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
router = APIRouter()


@functools.lru_cache()
async def _get_price_shock(
snapshot_path: str,
vat: Vat,
drift_client: DriftClient,
oracle_distortion: float = 0.1,
Expand All @@ -38,7 +36,6 @@ async def get_price_shock(
n_scenarios: int = 5,
):
return await _get_price_shock(
request.state.backend_state.current_pickle_path,
request.state.backend_state.vat,
request.state.backend_state.dc,
oracle_distortion,
Expand Down
4 changes: 2 additions & 2 deletions backend/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,13 @@ async def lifespan(app: FastAPI):
print("Loading cached vat")
await state.load_pickle_snapshot(cached_vat_path[-1])
# await repeatedly_clean_cache(state)
# await repeatedly_retake_snapshot(state)
await repeatedly_retake_snapshot(state)
else:
print("No cached vat found, bootstrapping")
await state.bootstrap()
await state.take_pickle_snapshot()
# await repeatedly_clean_cache(state)
# await repeatedly_retake_snapshot(state)
await repeatedly_retake_snapshot(state)
state.ready = True
# print("Checking price shock")
# await price_shock._get_price_shock(
Expand Down
8 changes: 4 additions & 4 deletions backend/utils/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,16 @@ def get_rattt(row):
(
f"perp_{perp_market_index}_long",
lambda v: (
v / row["spot_asset"] * row["net_p"][perp_market_index]
if v > 0 and row["net_p"][0] > 0
v / row["spot_asset"] * float(row["net_p"][perp_market_index])
if v > 0 and float(row["net_p"][perp_market_index]) > 0
else 0
),
),
(
f"perp_{perp_market_index}_short",
lambda v: (
v / row["spot_asset"] * row["net_p"][perp_market_index]
if v > 0 and row["net_p"][perp_market_index] < 0
v / row["spot_asset"] * float(row["net_p"][perp_market_index])
if v > 0 and float(row["net_p"][perp_market_index]) < 0
else 0
),
),
Expand Down

0 comments on commit 3b01312

Please sign in to comment.