add drp add requests params
This commit is contained in:
parent
48b93fdddb
commit
e1eb673b76
@ -35,7 +35,7 @@ def create_app() -> FastAPI:
|
|||||||
lifespan=lifespan,
|
lifespan=lifespan,
|
||||||
)
|
)
|
||||||
# 注册静态文件目录
|
# 注册静态文件目录
|
||||||
app.mount("/static", StaticFiles(directory="app/static"), name="static")
|
# app.mount("/static", StaticFiles(directory="app/static"), name="static")
|
||||||
register_exceptions(app)
|
register_exceptions(app)
|
||||||
register_routers(app, prefix="/api")
|
register_routers(app, prefix="/api")
|
||||||
return app
|
return app
|
||||||
|
|||||||
@ -40,6 +40,64 @@ async def calculate_valuation(
|
|||||||
计算估值评估
|
计算估值评估
|
||||||
|
|
||||||
根据用户提交的估值评估数据,调用计算引擎进行经济价值B1计算
|
根据用户提交的估值评估数据,调用计算引擎进行经济价值B1计算
|
||||||
|
|
||||||
|
请求示例JSON (仅包含用户填写部分):
|
||||||
|
{
|
||||||
|
"asset_name": "传统刺绣工艺",
|
||||||
|
"institution": "某文化传承机构",
|
||||||
|
"industry": "传统手工艺",
|
||||||
|
|
||||||
|
// 财务状况 (用户填写)
|
||||||
|
"annual_revenue": "500", // 近12个月机构营收/万元
|
||||||
|
"rd_investment": "50", // 近12个月机构研发投入/万元
|
||||||
|
"three_year_income": [400, 450, 500], // 近三年机构收益/万元
|
||||||
|
|
||||||
|
// 非遗等级与技术 (用户填写)
|
||||||
|
"inheritor_level": "国家级传承人", // 非遗传承人等级
|
||||||
|
"inheritor_ages": [45, 60, 75], // 传承人年龄列表
|
||||||
|
"heritage_level": "国家级", // 非遗等级
|
||||||
|
"patent_application_no": "CN202310123456.7", // 专利申请号
|
||||||
|
"patent_remaining_years": "15", // 专利剩余年限
|
||||||
|
"historical_evidence": { // 历史证明证据及数量
|
||||||
|
"历史文献": 3,
|
||||||
|
"考古发现": 2,
|
||||||
|
"传承谱系": 5
|
||||||
|
},
|
||||||
|
"pattern_images": ["demo.jpg"], // 非遗纹样图片
|
||||||
|
|
||||||
|
// 非遗应用与推广 (用户填写)
|
||||||
|
"application_maturity": "成熟应用", // 应用成熟度
|
||||||
|
"application_coverage": "全国覆盖", // 应用覆盖范围
|
||||||
|
"cooperation_depth": "0.5", // 跨界合作深度
|
||||||
|
"offline_activities": "12", // 近12个月线下宣讲活动次数
|
||||||
|
"online_accounts": [ // 线上宣传账号信息
|
||||||
|
{"platform": "抖音", "account": "传统刺绣大师"},
|
||||||
|
{"platform": "微博", "account": "非遗传承人"}
|
||||||
|
],
|
||||||
|
|
||||||
|
// 市场信息 (用户填写)
|
||||||
|
"sales_volume": "1000", // 近12个月销售量
|
||||||
|
"link_views": "5000", // 近12个月链接浏览量
|
||||||
|
"circulation": "限量", // 发行量
|
||||||
|
"last_market_activity": "2024-01-15", // 最近一次市场活动时间
|
||||||
|
"price_fluctuation": [95.0, 105.0], // 近30天价格波动区间
|
||||||
|
"manual_bids": [48000.0, 50000.0, 52000.0], // 手动收集的竞价列表
|
||||||
|
|
||||||
|
// 政策相关 (用户填写)
|
||||||
|
"funding_status": "国家级资助", // 资金支持情况
|
||||||
|
"implementation_stage": "成熟应用" // 实施阶段
|
||||||
|
}
|
||||||
|
|
||||||
|
API获取参数 (系统自动获取,无需用户填写):
|
||||||
|
- 搜索指数: 百度、微信、微博搜索指数
|
||||||
|
- 社交媒体数据: 点赞数、评论数、转发数、粉丝数
|
||||||
|
- 交易数据: 近3个月加权平均价格
|
||||||
|
- 热度数据: 近7日日均浏览量、收藏数
|
||||||
|
- ESG评分: 根据行业自动匹配
|
||||||
|
- 行业系数: 根据行业ROE计算
|
||||||
|
- 政策匹配度: 根据行业自动匹配
|
||||||
|
- 专利验证: 通过API验证专利有效性
|
||||||
|
- 侵权记录: 通过API查询侵权诉讼历史
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
start_ts = time.monotonic()
|
start_ts = time.monotonic()
|
||||||
|
|||||||
9
app/utils/calculation_engine/drp/__init__.py
Normal file
9
app/utils/calculation_engine/drp/__init__.py
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
"""
|
||||||
|
动态质押率DPR计算包
|
||||||
|
动态质押率DPR=基础质押率*(1+ 流量修正系数)+ 政策加成系数- 流动性调节因子
|
||||||
|
"""
|
||||||
|
from .sub_formulas.dynamic_pledge_rate import DynamicPledgeRateCalculator
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
"DynamicPledgeRateCalculator"
|
||||||
|
]
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
from .dynamic_pledge_rate import DynamicPledgeRateCalculator
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
"DynamicPledgeRateCalculator"
|
||||||
|
]
|
||||||
|
|
||||||
@ -0,0 +1,106 @@
|
|||||||
|
"""
|
||||||
|
动态质押率DPR计算模块
|
||||||
|
|
||||||
|
动态质押率DPR=基础质押率*(1+ 流量修正系数)+ 政策加成系数- 流动性调节因子
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class DynamicPledgeRateCalculator:
|
||||||
|
"""DRP计算器"""
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def calculate_dynamic_pledge_rate(self,
|
||||||
|
monthly_amount: float,
|
||||||
|
heritage_level: str,
|
||||||
|
) -> float:
|
||||||
|
"""
|
||||||
|
动态质押率 DPR 计算公式:
|
||||||
|
DPR = 基础质押率 * (1 + 流量修正系数) + 政策加成系数 - 流动性调节因子
|
||||||
|
|
||||||
|
参数:
|
||||||
|
monthly_amount (float): 月交易额(万元)
|
||||||
|
heritage_level (str): 非遗等级
|
||||||
|
liquidity_adjustment (float): 流动性调节因子(例如 0.05 表示5%)
|
||||||
|
|
||||||
|
固定参数:
|
||||||
|
基础质押率 = 0.5
|
||||||
|
流量修正系数 = 0.3
|
||||||
|
"""
|
||||||
|
base_rate = 0.5
|
||||||
|
flow_correction = 0.3
|
||||||
|
|
||||||
|
# ① 交易额得分影响可嵌入流量修正或单独展示,这里保持原式不变
|
||||||
|
policy_bonus = self.get_heritage_level_score(heritage_level)
|
||||||
|
liquidity_adjustment = self.get_monthly_transaction_score(monthly_amount)
|
||||||
|
dpr = base_rate * (1 + flow_correction) + policy_bonus - liquidity_adjustment
|
||||||
|
return round(dpr, 4)
|
||||||
|
|
||||||
|
def get_heritage_level_score(self, level: str) -> float:
|
||||||
|
"""
|
||||||
|
根据用户所选的非遗等级匹配系数分数。
|
||||||
|
|
||||||
|
规则:
|
||||||
|
① 国家级非遗 => +0.05
|
||||||
|
② 省级非遗 => +0.03
|
||||||
|
③ 纳入《国家文化数字化战略清单》 => +0.02
|
||||||
|
④ 无 => 0.0
|
||||||
|
|
||||||
|
参数:
|
||||||
|
level (str): 用户选择的非遗等级描述
|
||||||
|
|
||||||
|
返回:
|
||||||
|
float: 对应的分数
|
||||||
|
"""
|
||||||
|
level = level.strip()
|
||||||
|
|
||||||
|
if "国家级" in level:
|
||||||
|
return 0.05
|
||||||
|
elif "省级" in level:
|
||||||
|
return 0.03
|
||||||
|
elif "国家文化数字化战略清单" in level:
|
||||||
|
return 0.02
|
||||||
|
else:
|
||||||
|
return 0.0
|
||||||
|
|
||||||
|
def get_monthly_transaction_score(self, monthly_amount: float) -> float:
|
||||||
|
"""
|
||||||
|
根据用户月交易额区间匹配评分。
|
||||||
|
|
||||||
|
规则:
|
||||||
|
① 月交易额 < 100万 => -0.1
|
||||||
|
② 月交易额 ∈ [100万, 500万) => 0
|
||||||
|
③ 月交易额 ≥ 500万 => +0.15
|
||||||
|
|
||||||
|
参数:
|
||||||
|
monthly_amount (float): 月交易额(单位:万元)
|
||||||
|
|
||||||
|
返回:
|
||||||
|
float: 对应的评分
|
||||||
|
"""
|
||||||
|
if monthly_amount < 100:
|
||||||
|
return -0.1
|
||||||
|
elif monthly_amount < 500:
|
||||||
|
return 0.0
|
||||||
|
else:
|
||||||
|
return 0.15
|
||||||
|
|
||||||
|
|
||||||
|
# 示例使用
|
||||||
|
if __name__ == "__main__":
|
||||||
|
# 创建计算器实例
|
||||||
|
calculator = DynamicPledgeRateCalculator()
|
||||||
|
# 示例1:国家级非遗,月交易额500万,流动性调节因子0.05
|
||||||
|
print(calculator.calculate_dynamic_pledge_rate(500, "国家级非遗"))
|
||||||
|
# 结果:0.55
|
||||||
|
|
||||||
|
# 示例2:省级非遗,流动性调节因子0.02
|
||||||
|
print(calculator.calculate_dynamic_pledge_rate(300, "省级非遗"))
|
||||||
|
# 结果:0.68
|
||||||
|
|
||||||
|
# 示例3:无非遗,流动性调节因子0.1
|
||||||
|
print(calculator.calculate_dynamic_pledge_rate(50, "无"))
|
||||||
|
# 0.75
|
||||||
Loading…
x
Reference in New Issue
Block a user