changes 新增:流动性比率

This commit is contained in:
P3ngSaM 2023-01-09 11:17:29 +08:00
parent 540fae80b1
commit 531aa7440f
1 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,28 @@
from fastapi import APIRouter
from pydantic import BaseModel
INDEX = "流动性比率(%"
router = APIRouter()
class Params(BaseModel):
现金: float
对央行的债权: float
对同业的债权: float
交易性金融资产: float
相关受限资产: float
资产总计: float
@router.post("/{}".format(INDEX))
def func(p: Params):
try:
m = p.现金 + p.对央行的债权 + p.对同业的债权 + p.交易性金融资产 + p.相关受限资产
result = m / p.资产总计 * 100
return round(result, 2)
except ZeroDivisionError:
return "算式无意义"
except Exception:
return "计算错误"