diff --git a/.cursor/rules/project-specific.mdc b/.cursor/rules/project-specific.mdc new file mode 100644 index 0000000..62908d3 --- /dev/null +++ b/.cursor/rules/project-specific.mdc @@ -0,0 +1,7 @@ +--- +description: +globs: +alwaysApply: true +--- +do not edit files in folder "xtquant" and its sub folders + diff --git a/.cursor/rules/python-general.mdc b/.cursor/rules/python-general.mdc new file mode 100644 index 0000000..e1d617e --- /dev/null +++ b/.cursor/rules/python-general.mdc @@ -0,0 +1,45 @@ +--- +description: +globs: +alwaysApply: true +--- +You are an AI assistant specialized in Python development. Your approach emphasizes: + +Clear project structure with separate directories for source code, tests, docs, and config. + +Modular design with distinct files for models, services, controllers, and utilities. + +Configuration management using environment variables. + +Robust error handling and logging, including context capture. + +Comprehensive testing with pytest. + +Detailed documentation using docstrings and README files. + +Dependency management via https://github.com/astral-sh/uv and virtual environments. + +Code style consistency using Ruff. + +CI/CD implementation with GitHub Actions or GitLab CI. + +AI-friendly coding practices: + +You provide code snippets and explanations tailored to these principles, optimizing for clarity and AI-assisted development. + +Follow the following rules: + +For any python file, be sure to ALWAYS add typing annotations to each function or class. Be sure to include return types when necessary. Add descriptive docstrings to all python functions and classes as well. Please use pep257 convention. Update existing docstrings if need be. + +Make sure you keep any comments that exist in a file. + +When writing tests, make sure that you ONLY use pytest or pytest plugins, do NOT use the unittest module. All tests should have typing annotations as well. All tests should be in ./tests. Be sure to create all necessary files and folders. If you are creating files inside of ./tests or ./src/goob_ai, be sure to make a init.py file if one does not exist. + +All tests should be fully annotated and should contain docstrings. Be sure to import the following if TYPE_CHECKING: + +from _pytest.capture import CaptureFixture +from _pytest.fixtures import FixtureRequest +from _pytest.logging import LogCaptureFixture +from _pytest.monkeypatch import MonkeyPatch +from pytest_mock.plugin import MockerFixture + diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..ba90b54 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,3 @@ +# Project Documentation + +This directory contains the detailed documentation for the RealTrader project. \ No newline at end of file diff --git a/src/__init__.py b/src/__init__.py new file mode 100644 index 0000000..0519ecb --- /dev/null +++ b/src/__init__.py @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/trade_constants.py b/src/trade_constants.py index 0f16c9b..61a83aa 100644 --- a/src/trade_constants.py +++ b/src/trade_constants.py @@ -1,18 +1,26 @@ +""" +交易相关的常量定义。 + +本模块定义了在交易系统中常用的常量,例如交易类型、订单状态、订单类型和订单方向。 +""" + +from typing import Final + # 交易常量 -TRADE_TYPE_REAL = 'real' -TRADE_TYPE_SIMULATION = 'simulation' +TRADE_TYPE_REAL: Final[str] = 'real' +TRADE_TYPE_SIMULATION: Final[str] = 'simulation' # 订单状态 -ORDER_STATUS_PENDING = 'pending' -ORDER_STATUS_PARTIAL = 'partial' -ORDER_STATUS_COMPLETED = 'completed' -ORDER_STATUS_CANCELLED = 'cancelled' +ORDER_STATUS_PENDING: Final[str] = 'pending' +ORDER_STATUS_PARTIAL: Final[str] = 'partial' +ORDER_STATUS_COMPLETED: Final[str] = 'completed' +ORDER_STATUS_CANCELLED: Final[str] = 'cancelled' # 订单类型 -ORDER_TYPE_LIMIT = 'limit' -ORDER_TYPE_MARKET = 'market' +ORDER_TYPE_LIMIT: Final[str] = 'limit' +ORDER_TYPE_MARKET: Final[str] = 'market' # 订单方向 -ORDER_DIRECTION_BUY = 'buy' -ORDER_DIRECTION_SELL = 'sell' +ORDER_DIRECTION_BUY: Final[str] = 'buy' +ORDER_DIRECTION_SELL: Final[str] = 'sell' diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..0519ecb --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tests/real/__init__.py b/tests/real/__init__.py new file mode 100644 index 0000000..0519ecb --- /dev/null +++ b/tests/real/__init__.py @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tests/simulation/__init__.py b/tests/simulation/__init__.py new file mode 100644 index 0000000..0519ecb --- /dev/null +++ b/tests/simulation/__init__.py @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tests/utils/__init__.py b/tests/utils/__init__.py new file mode 100644 index 0000000..0519ecb --- /dev/null +++ b/tests/utils/__init__.py @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tests/xtquant/__init__.py b/tests/xtquant/__init__.py new file mode 100644 index 0000000..0519ecb --- /dev/null +++ b/tests/xtquant/__init__.py @@ -0,0 +1 @@ + \ No newline at end of file