|
@@ -24,15 +24,11 @@ _BITSTAMP_CLIENTS: dict[str, BitstampClient] = {}
|
|
|
_BITSTAMP_CLIENTS_GUARD = threading.Lock()
|
|
_BITSTAMP_CLIENTS_GUARD = threading.Lock()
|
|
|
|
|
|
|
|
|
|
|
|
|
-def _ttl_from_env_ms(name: str, default_ms: int, *, legacy_seconds_name: str | None = None) -> float:
|
|
|
|
|
|
|
+def _ttl_from_env_ms(name: str, default_ms: int) -> float:
|
|
|
try:
|
|
try:
|
|
|
raw = os.getenv(name)
|
|
raw = os.getenv(name)
|
|
|
if raw is not None:
|
|
if raw is not None:
|
|
|
return max(float(raw) / 1000.0, 0.0)
|
|
return max(float(raw) / 1000.0, 0.0)
|
|
|
- if legacy_seconds_name:
|
|
|
|
|
- legacy_raw = os.getenv(legacy_seconds_name)
|
|
|
|
|
- if legacy_raw is not None:
|
|
|
|
|
- return max(float(legacy_raw), 0.0)
|
|
|
|
|
return max(float(default_ms) / 1000.0, 0.0)
|
|
return max(float(default_ms) / 1000.0, 0.0)
|
|
|
except Exception:
|
|
except Exception:
|
|
|
return max(float(default_ms) / 1000.0, 0.0)
|
|
return max(float(default_ms) / 1000.0, 0.0)
|
|
@@ -130,7 +126,7 @@ def fetch_trading_fees(account_id: str, market_symbol: str | None = None) -> dic
|
|
|
else:
|
|
else:
|
|
|
result = {"source": "bitstamp", "market": market_symbol, "raw": payload}
|
|
result = {"source": "bitstamp", "market": market_symbol, "raw": payload}
|
|
|
|
|
|
|
|
- repo.cache_put(cache_key, result, _ttl_from_env("BITSTAMP_FEES_CACHE_TTL_SECONDS", FEES_CACHE_TTL_SECONDS))
|
|
|
|
|
|
|
+ repo.cache_put(cache_key, result, FEES_CACHE_TTL_SECONDS)
|
|
|
return result
|
|
return result
|
|
|
|
|
|
|
|
|
|
|
|
@@ -228,11 +224,7 @@ def fetch_account_balance(account_id: str) -> dict:
|
|
|
repo.cache_put(
|
|
repo.cache_put(
|
|
|
cache_key,
|
|
cache_key,
|
|
|
result,
|
|
result,
|
|
|
- _ttl_from_env_ms(
|
|
|
|
|
- "BITSTAMP_BALANCE_CACHE_TTL_MS",
|
|
|
|
|
- BALANCE_CACHE_TTL_MS,
|
|
|
|
|
- legacy_seconds_name="BITSTAMP_BALANCE_CACHE_TTL_SECONDS",
|
|
|
|
|
- ),
|
|
|
|
|
|
|
+ _ttl_from_env_ms("BITSTAMP_BALANCE_CACHE_TTL_MS", BALANCE_CACHE_TTL_MS),
|
|
|
)
|
|
)
|
|
|
repo.cache_put(_stale_key(cache_key), result, STALE_CACHE_TTL_SECONDS)
|
|
repo.cache_put(_stale_key(cache_key), result, STALE_CACHE_TTL_SECONDS)
|
|
|
return result
|
|
return result
|
|
@@ -303,11 +295,7 @@ def fetch_account_info(account_id: str) -> dict:
|
|
|
repo.cache_put(
|
|
repo.cache_put(
|
|
|
cache_key,
|
|
cache_key,
|
|
|
result,
|
|
result,
|
|
|
- _ttl_from_env_ms(
|
|
|
|
|
- "BITSTAMP_ACCOUNT_INFO_CACHE_TTL_MS",
|
|
|
|
|
- ACCOUNT_INFO_CACHE_TTL_MS,
|
|
|
|
|
- legacy_seconds_name="BITSTAMP_ACCOUNT_INFO_CACHE_TTL_SECONDS",
|
|
|
|
|
- ),
|
|
|
|
|
|
|
+ _ttl_from_env_ms("BITSTAMP_ACCOUNT_INFO_CACHE_TTL_MS", ACCOUNT_INFO_CACHE_TTL_MS),
|
|
|
)
|
|
)
|
|
|
repo.cache_put(_stale_key(cache_key), result, STALE_CACHE_TTL_SECONDS)
|
|
repo.cache_put(_stale_key(cache_key), result, STALE_CACHE_TTL_SECONDS)
|
|
|
return result
|
|
return result
|