新增查询用户组合接口
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:
|
||||
# 判空处理,如果 searchKeyword 没有值,跳过关键词筛选逻辑
|
||||
if not request.searchKeyword:
|
||||
# 如果 searchKeyword 为空,跳过关键词筛选逻辑
|
||||
pass
|
||||
else:
|
||||
# 根据 searchKeyword 的类型选择不同的查询字段
|
||||
|
@ -23,7 +23,8 @@ from src.models.financial_reports import FinancialReport
|
||||
from src.utils.update_financial_reports_spider import combined_search_and_list
|
||||
from src.financial_reports.router import financial_reports_router
|
||||
from src.utils.generate_pinyin_abbreviation import generate_pinyin_abbreviation
|
||||
|
||||
from src.composite.router import composite_router
|
||||
|
||||
from xtquant import xtdata
|
||||
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(combine_router, prefix="/combine", 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:
|
||||
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.
@ -1,52 +1,52 @@
|
||||
from typing import Any
|
||||
|
||||
from pydantic import RedisDsn, model_validator
|
||||
from pydantic_settings import BaseSettings
|
||||
|
||||
from src.constants import Environment
|
||||
|
||||
|
||||
class Config(BaseSettings):
|
||||
DATABASE_PREFIX: str = ""
|
||||
DATABASE_URL: str
|
||||
DATABASE_CREATE_URL: str
|
||||
REDIS_URL: RedisDsn
|
||||
|
||||
SITE_DOMAIN: str = "myapp.com"
|
||||
|
||||
ENVIRONMENT: Environment = Environment.PRODUCTION
|
||||
|
||||
SENTRY_DSN: str | None = None
|
||||
|
||||
CORS_ORIGINS: list[str]
|
||||
CORS_ORIGINS_REGEX: str | None = None
|
||||
CORS_HEADERS: list[str]
|
||||
|
||||
APP_VERSION: str = "1"
|
||||
APP_ROUTER_PREFIX: str = "/api/v1"
|
||||
|
||||
SHOULD_SEND_SMS: bool = False
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_sentry_non_local(self) -> "Config":
|
||||
if self.ENVIRONMENT.is_deployed and not self.SENTRY_DSN:
|
||||
raise ValueError("Sentry is not set")
|
||||
|
||||
return self
|
||||
|
||||
|
||||
settings = Config()
|
||||
|
||||
# fastapi/applications.py
|
||||
app_configs: dict[str, Any] = {
|
||||
"title": "Wance QMT API",
|
||||
"root_path": settings.APP_ROUTER_PREFIX,
|
||||
"docs_url": "/api/docs",
|
||||
}
|
||||
|
||||
# app_configs['debug'] = True
|
||||
# if settings.ENVIRONMENT.is_deployed:
|
||||
# app_configs["root_path"] = f"/v{settings.APP_VERSION}"
|
||||
#
|
||||
# if not settings.ENVIRONMENT.is_debug:
|
||||
# app_configs["openapi_url"] = None # hide docs
|
||||
from typing import Any
|
||||
|
||||
from pydantic import RedisDsn, model_validator
|
||||
from pydantic_settings import BaseSettings
|
||||
|
||||
from src.constants import Environment
|
||||
|
||||
|
||||
class Config(BaseSettings):
|
||||
DATABASE_PREFIX: str = ""
|
||||
DATABASE_URL: str
|
||||
DATABASE_CREATE_URL: str
|
||||
REDIS_URL: RedisDsn
|
||||
|
||||
SITE_DOMAIN: str = "myapp.com"
|
||||
|
||||
ENVIRONMENT: Environment = Environment.PRODUCTION
|
||||
|
||||
SENTRY_DSN: str | None = None
|
||||
|
||||
CORS_ORIGINS: list[str]
|
||||
CORS_ORIGINS_REGEX: str | None = None
|
||||
CORS_HEADERS: list[str]
|
||||
|
||||
APP_VERSION: str = "1"
|
||||
APP_ROUTER_PREFIX: str = "/api/v1"
|
||||
|
||||
SHOULD_SEND_SMS: bool = False
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_sentry_non_local(self) -> "Config":
|
||||
if self.ENVIRONMENT.is_deployed and not self.SENTRY_DSN:
|
||||
raise ValueError("Sentry is not set")
|
||||
|
||||
return self
|
||||
|
||||
|
||||
settings = Config()
|
||||
|
||||
# fastapi/applications.py
|
||||
app_configs: dict[str, Any] = {
|
||||
"title": "Wance QMT API",
|
||||
"root_path": settings.APP_ROUTER_PREFIX,
|
||||
"docs_url": "/api/docs",
|
||||
}
|
||||
|
||||
# app_configs['debug'] = True
|
||||
# if settings.ENVIRONMENT.is_deployed:
|
||||
# app_configs["root_path"] = f"/v{settings.APP_VERSION}"
|
||||
#
|
||||
# if not settings.ENVIRONMENT.is_debug:
|
||||
# app_configs["openapi_url"] = None # hide docs
|
||||
|
@ -72,7 +72,8 @@ models = [
|
||||
"src.models.stock_hu_shen300",
|
||||
"src.models.stock_zhong_zheng_500",
|
||||
"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