indexcalculation/基本信用评级指标/资本结构/所有者权益.py

24 lines
438 B
Python
Raw Normal View History

2022-12-22 15:34:49 +08:00
from fastapi import APIRouter
from pydantic import BaseModel
INDEX = "所有者权益(亿元)"
router = APIRouter()
class Params(BaseModel):
2023-01-04 09:27:12 +08:00
所有者权益: float
2022-12-22 15:34:49 +08:00
@router.post("/{}".format(INDEX))
def func(p: Params):
try:
2023-01-04 09:27:12 +08:00
result = p.所有者权益 / 100000000
2022-12-22 15:34:49 +08:00
return round(result, 6)
except ZeroDivisionError:
return "算式无意义"
except Exception:
return "计算错误"