新增查询用户组合接口
This commit is contained in:
parent
01c80653d9
commit
023cc64d20
Binary file not shown.
Binary file not shown.
0
src/composite/__init__.py
Normal file
0
src/composite/__init__.py
Normal file
17
src/composite/router.py
Normal file
17
src/composite/router.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
from fastapi import APIRouter
|
||||||
|
from fastapi.responses import JSONResponse
|
||||||
|
|
||||||
|
from src.responses import response_list_response
|
||||||
|
from src.composite.service import *
|
||||||
|
|
||||||
|
composite_router = APIRouter()
|
||||||
|
|
||||||
|
@composite_router.get("/query-composite")
|
||||||
|
async def composite_router_query_composite(user_id: int )-> JSONResponse:
|
||||||
|
"""
|
||||||
|
查询已有多因子组合
|
||||||
|
"""
|
||||||
|
|
||||||
|
result = await composite_router_query_composite_service(user_id)
|
||||||
|
|
||||||
|
return response_list_response(data=result, message="多因子组合查询成功")
|
1
src/composite/schemas.py
Normal file
1
src/composite/schemas.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
|
10
src/composite/service.py
Normal file
10
src/composite/service.py
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
from src.models.user_strategy import *
|
||||||
|
|
||||||
|
async def composite_router_query_composite_service(
|
||||||
|
user_id: int
|
||||||
|
) -> list:
|
||||||
|
|
||||||
|
# 查询所有符合条件的记录并转为字典
|
||||||
|
user_strategies = await UserStrategy.filter(user_id=user_id).values() # 转换为字典列表
|
||||||
|
return user_strategies
|
@ -30,7 +30,6 @@ async def financial_reports_query_service(
|
|||||||
try:
|
try:
|
||||||
# 判空处理,如果 searchKeyword 没有值,跳过关键词筛选逻辑
|
# 判空处理,如果 searchKeyword 没有值,跳过关键词筛选逻辑
|
||||||
if not request.searchKeyword:
|
if not request.searchKeyword:
|
||||||
# 如果 searchKeyword 为空,跳过关键词筛选逻辑
|
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
# 根据 searchKeyword 的类型选择不同的查询字段
|
# 根据 searchKeyword 的类型选择不同的查询字段
|
||||||
|
@ -23,6 +23,7 @@ from src.models.financial_reports import FinancialReport
|
|||||||
from src.utils.update_financial_reports_spider import combined_search_and_list
|
from src.utils.update_financial_reports_spider import combined_search_and_list
|
||||||
from src.financial_reports.router import financial_reports_router
|
from src.financial_reports.router import financial_reports_router
|
||||||
from src.utils.generate_pinyin_abbreviation import generate_pinyin_abbreviation
|
from src.utils.generate_pinyin_abbreviation import generate_pinyin_abbreviation
|
||||||
|
from src.composite.router import composite_router
|
||||||
|
|
||||||
from xtquant import xtdata
|
from xtquant import xtdata
|
||||||
from src.settings.config import app_configs, settings
|
from src.settings.config import app_configs, settings
|
||||||
@ -41,6 +42,7 @@ app.include_router(xtdata_router, prefix="/getwancedata", tags=["数据接口"])
|
|||||||
app.include_router(backtest_router, prefix="/backtest", tags=["回测接口"])
|
app.include_router(backtest_router, prefix="/backtest", tags=["回测接口"])
|
||||||
app.include_router(combine_router, prefix="/combine", tags=["组合接口"])
|
app.include_router(combine_router, prefix="/combine", tags=["组合接口"])
|
||||||
app.include_router(financial_reports_router, prefix="/financial-reports", tags=["财报接口"])
|
app.include_router(financial_reports_router, prefix="/financial-reports", tags=["财报接口"])
|
||||||
|
app.include_router(composite_router, prefix="/composite", tags=["vacode组合接口"])
|
||||||
|
|
||||||
if settings.ENVIRONMENT.is_deployed:
|
if settings.ENVIRONMENT.is_deployed:
|
||||||
sentry_sdk.init(
|
sentry_sdk.init(
|
||||||
|
16
src/models/user_strategy.py
Normal file
16
src/models/user_strategy.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
from tortoise import fields
|
||||||
|
from tortoise.models import Model
|
||||||
|
|
||||||
|
class UserStrategy(Model):
|
||||||
|
"""
|
||||||
|
用户多因子组合表
|
||||||
|
"""
|
||||||
|
id = fields.IntField(pk=True)
|
||||||
|
create_time = fields.DatetimeField(null=True)
|
||||||
|
user_id = fields.IntField(null=True)
|
||||||
|
strategy_request = fields.JSONField(null=False)
|
||||||
|
strategy_name = fields.CharField(max_length=30, null=True)
|
||||||
|
deleted_stock = fields.BinaryField(null=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
table = "user_strategy"
|
Binary file not shown.
@ -72,7 +72,8 @@ models = [
|
|||||||
"src.models.stock_hu_shen300",
|
"src.models.stock_hu_shen300",
|
||||||
"src.models.stock_zhong_zheng_500",
|
"src.models.stock_zhong_zheng_500",
|
||||||
"src.models.stock_guo_zheng_2000",
|
"src.models.stock_guo_zheng_2000",
|
||||||
"src.models.stock_hu_shen_jing_a"
|
"src.models.stock_hu_shen_jing_a",
|
||||||
|
"src.models.user_strategy"
|
||||||
|
|
||||||
|
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user