/
fgtmenow
/
tb
Обзор
Документация
Войти
/
fgtmenow
/
tb
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
_common/api/GetMaintenanceMargin.py
34 строки
976 B
Azarev Artem
add test
26 мар 2025, 03:04
26 мар 2025, 03:04
3eee0a5
Код
Авторство
О чём код?
import json import os from pybit.unified_trading import HTTP from _common.domain.util.CacheUtil import get_cache_file_path from _common.domain.util.Logger import print_message def get_maintenance_margin( session: HTTP, trace: bool, symbol: str) -> float: cache_file_name = get_cache_file_path( filename=symbol, directory="ratelimit", ext="json" ) if os.path.exists(cache_file_name): response = json.load(open(os.path.join(os.getcwd(), cache_file_name))) else: response = session.get_risk_limit( category="linear", symbol=symbol ) if trace: print_message(message=response) json.dump(response, open(os.path.join(os.getcwd(), cache_file_name), 'w')) rates = response["result"]["list"] for r in rates: if r['isLowestRisk'] == 1: return float(r["maintenanceMargin"]) raise RuntimeError("No lovest rate")