Merge branch 'ps1' into 'main'

changes 新增:流动性比率

See merge request root/IndexCalculation!27
This commit is contained in:
彭森 2023-01-09 03:19:31 +00:00
commit b13819dfb3
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 "计算错误"