changes 新增:流动性比率
This commit is contained in:
parent
540fae80b1
commit
531aa7440f
|
@ -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 "计算错误"
|
Loading…
Reference in New Issue