diff --git a/src/__pycache__/main.cpython-310.pyc b/src/__pycache__/main.cpython-310.pyc index 34a5471..2e7bef7 100644 Binary files a/src/__pycache__/main.cpython-310.pyc and b/src/__pycache__/main.cpython-310.pyc differ diff --git a/src/__pycache__/tortoises.cpython-310.pyc b/src/__pycache__/tortoises.cpython-310.pyc index 4e903d0..0946831 100644 Binary files a/src/__pycache__/tortoises.cpython-310.pyc and b/src/__pycache__/tortoises.cpython-310.pyc differ diff --git a/src/composite/__init__.py b/src/composite/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/composite/router.py b/src/composite/router.py new file mode 100644 index 0000000..e4f1382 --- /dev/null +++ b/src/composite/router.py @@ -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="多因子组合查询成功") \ No newline at end of file diff --git a/src/composite/schemas.py b/src/composite/schemas.py new file mode 100644 index 0000000..d3f5a12 --- /dev/null +++ b/src/composite/schemas.py @@ -0,0 +1 @@ + diff --git a/src/composite/service.py b/src/composite/service.py new file mode 100644 index 0000000..785ef5e --- /dev/null +++ b/src/composite/service.py @@ -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 \ No newline at end of file diff --git a/src/financial_reports/service.py b/src/financial_reports/service.py index 7c3fee6..42f22cf 100644 --- a/src/financial_reports/service.py +++ b/src/financial_reports/service.py @@ -30,7 +30,6 @@ async def financial_reports_query_service( try: # 判空处理,如果 searchKeyword 没有值,跳过关键词筛选逻辑 if not request.searchKeyword: - # 如果 searchKeyword 为空,跳过关键词筛选逻辑 pass else: # 根据 searchKeyword 的类型选择不同的查询字段 diff --git a/src/main.py b/src/main.py index 3e2fc73..8c9f684 100644 --- a/src/main.py +++ b/src/main.py @@ -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( diff --git a/src/models/user_strategy.py b/src/models/user_strategy.py new file mode 100644 index 0000000..5d1b819 --- /dev/null +++ b/src/models/user_strategy.py @@ -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" \ No newline at end of file diff --git a/src/settings/__pycache__/config.cpython-310.pyc b/src/settings/__pycache__/config.cpython-310.pyc index 280a2d6..f155fe8 100644 Binary files a/src/settings/__pycache__/config.cpython-310.pyc and b/src/settings/__pycache__/config.cpython-310.pyc differ diff --git a/src/settings/config.py b/src/settings/config.py index 9e04aec..901200c 100644 --- a/src/settings/config.py +++ b/src/settings/config.py @@ -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 diff --git a/src/tortoises.py b/src/tortoises.py index 1ec0d14..0d4fb8b 100644 --- a/src/tortoises.py +++ b/src/tortoises.py @@ -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" ]