Qt s0, qt_example partially merged in this branch#272
Conversation
…g and add tests for index_weight - Modified the 'index_weight' entry in `data_channels.py` to change the parameters for better clarity and usage. - Updated the `composite` function in `tsfuncs.py` to reflect the new parameter name for index handling. - Added unit tests in `test_channels.py` to validate argument parsing for the 'index_weight' table, ensuring correct handling of date ranges and index parameters. - Adjusted the setup method in `test_eastmoney.py` to configure the environment for testing.
…and functionality - Updated the TraderShell class to streamline the shutdown process, replacing direct task management with a more cohesive stop method. - Refactored the Trader class to implement dedicated start, stop, and join methods for managing trader and broker threads, enhancing thread lifecycle management. - Modified the CLI and TUI implementations to utilize the new start and stop methods, ensuring consistent behavior across interfaces. - Added unit tests to validate the shutdown process and runtime management, confirming correct interactions with the Trader's lifecycle methods.
…ror handling - Introduced a new `TaskSpec` dataclass to encapsulate task details, including retry logic and status tracking. - Updated task processing logic to utilize `TaskSpec`, improving clarity and maintainability. - Implemented enhanced error handling for task failures, including retry mechanisms and dead-letter task management. - Added unit tests to validate task management features, including task addition, cancellation, and failure handling.
…nhance task scheduling in Trader class - Added a static method `_build_schedule_time_kwargs_from_config` in the `Operator` class to construct trading session parameters from a configuration dictionary, improving the preparation of running schedules. - Refactored the `Trader` class to utilize the new method for generating schedule time arguments, enhancing clarity and maintainability in task scheduling. - Introduced a new `create_daily_task_plan` function in `trading_util.py` to standardize daily task creation, replacing the previous `create_daily_task_schedule` function. - Updated unit tests to validate the new scheduling features and ensure correct mapping of configuration to schedule parameters.
… support and new broker result handling - Introduced a `db_run_in_transaction` method in the `DataSource` class to facilitate transaction management, allowing for commit and rollback operations. - Updated existing database execution methods to support transaction reuse, improving efficiency and consistency in database interactions. - Enhanced trade recording functions to include a `transaction` parameter, enabling atomic updates for account balances, positions, and trade orders. - Added a new `broker_result_id` field in the trade results schema to ensure unique identification of trade results and prevent duplicate processing. - Implemented unit tests to validate transaction behavior and idempotency of trade result processing, ensuring robustness in trade handling.
- Resolved issues in the `realize` method to improve parameter validation and trading signal calculations. - Ensured proper handling of multi-parameter scenarios in the `RuleIterator` class for better state updates. - Enhanced data processing to check for NaN values in historical price data before generating trading signals.
- Introduced seven new Jupyter notebook examples demonstrating various trading strategies, including dual moving average, alpha stock selection, and grid trading. - Each example includes detailed markdown explanations, code implementations, and backtesting results for clarity and usability. - Strategies cover a range of methodologies, from multi-factor models to cross-asset arbitrage, enhancing the educational resources available for users transitioning to JoinQuant.
- Added references to new Jupyter notebook sources in the markdown files for various trading strategies, enhancing clarity and usability. - Updated the .gitignore file to exclude additional file types and directories related to the migration process, ensuring a cleaner repository. - Improved organization of example files to facilitate easier access and understanding for users transitioning to JoinQuant.
- Updated `create_headless_notebook_session` to include parameters for real-time trading and isolated data sources, improving flexibility for testing scenarios. - Added functions for configuring the notebook operator and preparing isolated replay data, enhancing the setup process for testing. - Improved documentation within the script to clarify usage and parameters, aiding user understanding and facilitating smoother integration into workflows.
- Added '/sql/' to .gitignore to exclude SQL files from version control. - Improved column validation in the DataSource class to prevent KeyError by checking for the existence of specified columns before filtering data. - Updated documentation in datatables.py to clarify the structure definitions and improve consistency in naming conventions.
…onfiguration and timeout options - Added functions to set the repository root for subprocesses and construct the environment for unittest execution, improving the flexibility of the testing setup. - Introduced a timeout parameter for subprocess execution in the `stage1_preflight_tests` function, allowing users to specify maximum wait times for tests. - Updated documentation to clarify the new parameters and their usage, enhancing user understanding and integration into workflows.
|
架构原则与验收锚点 以下原则作为全计划与后续各阶段的验收锚点:除各阶段条目验收外,不得与已承诺原则相冲突;若某阶段暂不实现,须在计划或 PR 中显式标注 deferred 并说明风险接受范围。
|
- Introduced a new test file `test_notebook_headless_integration.py` to validate the functionality of the headless notebook trader script. - Implemented tests for session creation and operator group validation, ensuring correct initialization and task scheduling. - Added checks for idempotent cancellation and delivery processes in the notebook's trading phases, enhancing regression testing capabilities. - Utilized isolated data sources to ensure test reliability and prevent interference with real-time data.
- Implemented a new test suite in `test_notebook_headless_integration.py` to validate the functionality of the headless notebook trader script. - Added tests for session creation, operator group validation, and task scheduling to ensure correct initialization. - Included checks for idempotent cancellation and delivery processes in trading phases, enhancing regression testing capabilities. - Utilized isolated data sources to improve test reliability and prevent interference with real-time data.
…ry policies - Updated the Broker class to include a new method `poll_messages` for asynchronous message retrieval, improving communication handling. - Modified the `poll_fills` method to check the legacy result queue when no pending fills are available, enhancing compatibility. - Introduced reentry policies for task management in the Trader class, allowing for more flexible task execution strategies. - Updated unit tests to validate the new message polling functionality and task reentry behavior, ensuring robustness in trading operations.
…ult_id column Co-authored-by: Cursor <cursoragent@cursor.com>
…proved shutdown process - Updated the `stage5_stage0to3_regression` function to include checks for broker API availability and detailed statistics on skipped and rejected tasks, enhancing diagnostic capabilities. - Modified the shutdown process to align with the TraderRuntime semantics, ensuring a more graceful termination of the trader session. - Improved logging to provide clearer insights into the state of the trader and its tasks during execution.
…(SettingWithCopyWarning) Co-authored-by: Cursor <cursoragent@cursor.com>
…y failures Co-authored-by: Cursor <cursoragent@cursor.com>
…atched table fetch - Add _hist_dnld_thread_pool_max_workers(); 0 maps to 1 for ThreadPoolExecutor - fetch_real_time_klines parallel path reads QT_CONFIG hist_dnld_parallel - fetch_batched_table_data uses same when process_count is None - Update hist_dnld_parallel config text; add TestHistDnldParallelWorkers Co-authored-by: Cursor <cursoragent@cursor.com>
…g and add tests for index_weight - Modified the 'index_weight' entry in `data_channels.py` to change the parameters for better clarity and usage. - Updated the `composite` function in `tsfuncs.py` to reflect the new parameter name for index handling. - Added unit tests in `test_channels.py` to validate argument parsing for the 'index_weight' table, ensuring correct handling of date ranges and index parameters. - Adjusted the setup method in `test_eastmoney.py` to configure the environment for testing.
…and functionality - Updated the TraderShell class to streamline the shutdown process, replacing direct task management with a more cohesive stop method. - Refactored the Trader class to implement dedicated start, stop, and join methods for managing trader and broker threads, enhancing thread lifecycle management. - Modified the CLI and TUI implementations to utilize the new start and stop methods, ensuring consistent behavior across interfaces. - Added unit tests to validate the shutdown process and runtime management, confirming correct interactions with the Trader's lifecycle methods.
…ror handling - Introduced a new `TaskSpec` dataclass to encapsulate task details, including retry logic and status tracking. - Updated task processing logic to utilize `TaskSpec`, improving clarity and maintainability. - Implemented enhanced error handling for task failures, including retry mechanisms and dead-letter task management. - Added unit tests to validate task management features, including task addition, cancellation, and failure handling.
…nhance task scheduling in Trader class - Added a static method `_build_schedule_time_kwargs_from_config` in the `Operator` class to construct trading session parameters from a configuration dictionary, improving the preparation of running schedules. - Refactored the `Trader` class to utilize the new method for generating schedule time arguments, enhancing clarity and maintainability in task scheduling. - Introduced a new `create_daily_task_plan` function in `trading_util.py` to standardize daily task creation, replacing the previous `create_daily_task_schedule` function. - Updated unit tests to validate the new scheduling features and ensure correct mapping of configuration to schedule parameters.
… support and new broker result handling - Introduced a `db_run_in_transaction` method in the `DataSource` class to facilitate transaction management, allowing for commit and rollback operations. - Updated existing database execution methods to support transaction reuse, improving efficiency and consistency in database interactions. - Enhanced trade recording functions to include a `transaction` parameter, enabling atomic updates for account balances, positions, and trade orders. - Added a new `broker_result_id` field in the trade results schema to ensure unique identification of trade results and prevent duplicate processing. - Implemented unit tests to validate transaction behavior and idempotency of trade result processing, ensuring robustness in trade handling.
- Resolved issues in the `realize` method to improve parameter validation and trading signal calculations. - Ensured proper handling of multi-parameter scenarios in the `RuleIterator` class for better state updates. - Enhanced data processing to check for NaN values in historical price data before generating trading signals.
- Introduced seven new Jupyter notebook examples demonstrating various trading strategies, including dual moving average, alpha stock selection, and grid trading. - Each example includes detailed markdown explanations, code implementations, and backtesting results for clarity and usability. - Strategies cover a range of methodologies, from multi-factor models to cross-asset arbitrage, enhancing the educational resources available for users transitioning to JoinQuant.
- Added references to new Jupyter notebook sources in the markdown files for various trading strategies, enhancing clarity and usability. - Updated the .gitignore file to exclude additional file types and directories related to the migration process, ensuring a cleaner repository. - Improved organization of example files to facilitate easier access and understanding for users transitioning to JoinQuant.
- Updated `create_headless_notebook_session` to include parameters for real-time trading and isolated data sources, improving flexibility for testing scenarios. - Added functions for configuring the notebook operator and preparing isolated replay data, enhancing the setup process for testing. - Improved documentation within the script to clarify usage and parameters, aiding user understanding and facilitating smoother integration into workflows.
- Resolved issues in the `realize` method to improve parameter validation and trading signal calculations. - Ensured proper handling of multi-parameter scenarios in the `RuleIterator` class for better state updates. - Enhanced data processing to check for NaN values in historical price data before generating trading signals.
- Introduced seven new Jupyter notebook examples demonstrating various trading strategies, including dual moving average, alpha stock selection, and grid trading. - Each example includes detailed markdown explanations, code implementations, and backtesting results for clarity and usability. - Strategies cover a range of methodologies, from multi-factor models to cross-asset arbitrage, enhancing the educational resources available for users transitioning to JoinQuant.
- Added references to new Jupyter notebook sources in the markdown files for various trading strategies, enhancing clarity and usability. - Updated the .gitignore file to exclude additional file types and directories related to the migration process, ensuring a cleaner repository. - Improved organization of example files to facilitate easier access and understanding for users transitioning to JoinQuant.
- Updated `create_headless_notebook_session` to include parameters for real-time trading and isolated data sources, improving flexibility for testing scenarios. - Added functions for configuring the notebook operator and preparing isolated replay data, enhancing the setup process for testing. - Improved documentation within the script to clarify usage and parameters, aiding user understanding and facilitating smoother integration into workflows.
- Added '/sql/' to .gitignore to exclude SQL files from version control. - Improved column validation in the DataSource class to prevent KeyError by checking for the existence of specified columns before filtering data. - Updated documentation in datatables.py to clarify the structure definitions and improve consistency in naming conventions.
…onfiguration and timeout options - Added functions to set the repository root for subprocesses and construct the environment for unittest execution, improving the flexibility of the testing setup. - Introduced a timeout parameter for subprocess execution in the `stage1_preflight_tests` function, allowing users to specify maximum wait times for tests. - Updated documentation to clarify the new parameters and their usage, enhancing user understanding and integration into workflows.
- Introduced a new test file `test_notebook_headless_integration.py` to validate the functionality of the headless notebook trader script. - Implemented tests for session creation and operator group validation, ensuring correct initialization and task scheduling. - Added checks for idempotent cancellation and delivery processes in the notebook's trading phases, enhancing regression testing capabilities. - Utilized isolated data sources to ensure test reliability and prevent interference with real-time data.
- Implemented a new test suite in `test_notebook_headless_integration.py` to validate the functionality of the headless notebook trader script. - Added tests for session creation, operator group validation, and task scheduling to ensure correct initialization. - Included checks for idempotent cancellation and delivery processes in trading phases, enhancing regression testing capabilities. - Utilized isolated data sources to improve test reliability and prevent interference with real-time data.
…ry policies - Updated the Broker class to include a new method `poll_messages` for asynchronous message retrieval, improving communication handling. - Modified the `poll_fills` method to check the legacy result queue when no pending fills are available, enhancing compatibility. - Introduced reentry policies for task management in the Trader class, allowing for more flexible task execution strategies. - Updated unit tests to validate the new message polling functionality and task reentry behavior, ensuring robustness in trading operations.
…ult_id column Co-authored-by: Cursor <cursoragent@cursor.com>
…proved shutdown process - Updated the `stage5_stage0to3_regression` function to include checks for broker API availability and detailed statistics on skipped and rejected tasks, enhancing diagnostic capabilities. - Modified the shutdown process to align with the TraderRuntime semantics, ensuring a more graceful termination of the trader session. - Improved logging to provide clearer insights into the state of the trader and its tasks during execution.
…(SettingWithCopyWarning) Co-authored-by: Cursor <cursoragent@cursor.com>
…y failures Co-authored-by: Cursor <cursoragent@cursor.com>
…atched table fetch - Add _hist_dnld_thread_pool_max_workers(); 0 maps to 1 for ThreadPoolExecutor - fetch_real_time_klines parallel path reads QT_CONFIG hist_dnld_parallel - fetch_batched_table_data uses same when process_count is None - Update hist_dnld_parallel config text; add TestHistDnldParallelWorkers Co-authored-by: Cursor <cursoragent@cursor.com>
…onfiguration - Added new configuration options for live trading: `live_trade_split_strategy_prepare`, `live_trade_strategy_snapshot_max_age_seconds`, `live_trade_prepare_lead_seconds`, and `live_trade_startup_gate_mode`. - Implemented logic to handle snapshot preparation before running trading strategies, enhancing the trading workflow. - Updated the trader class to incorporate startup gate checks, allowing for conditional execution of trading tasks based on the configured gate mode. - Enhanced task scheduling to ensure that snapshot preparation occurs prior to strategy execution when enabled. Co-authored-by: Cursor <cursoragent@cursor.com>
- Updated `live_grid_multi.py` to allow account deletion based on provided account ID or by resolving an existing account using a username. - Introduced logic to handle cases where no account ID is provided, prompting the user to specify either an account ID or a username for account creation. - Refactored `qt_operator.py` to utilize a resolved account ID for live trading operations, improving the handling of data sources. - Added a new function `resolve_live_trade_account_id` in `trade_recording.py` to streamline account ID resolution from configuration. - Expanded unit tests to cover scenarios for account creation and reuse based on username, ensuring robust account management in live trading. Co-authored-by: Cursor <cursoragent@cursor.com>
…and functionality - Updated the TraderShell class to streamline the shutdown process, replacing direct task management with a more cohesive stop method. - Refactored the Trader class to implement dedicated start, stop, and join methods for managing trader and broker threads, enhancing thread lifecycle management. - Modified the CLI and TUI implementations to utilize the new start and stop methods, ensuring consistent behavior across interfaces. - Added unit tests to validate the shutdown process and runtime management, confirming correct interactions with the Trader's lifecycle methods.
- Added '/sql/' to .gitignore to exclude SQL files from version control. - Improved column validation in the DataSource class to prevent KeyError by checking for the existence of specified columns before filtering data. - Updated documentation in datatables.py to clarify the structure definitions and improve consistency in naming conventions.
- Introduced a new test file `test_notebook_headless_integration.py` to validate the functionality of the headless notebook trader script. - Implemented tests for session creation and operator group validation, ensuring correct initialization and task scheduling. - Added checks for idempotent cancellation and delivery processes in the notebook's trading phases, enhancing regression testing capabilities. - Utilized isolated data sources to ensure test reliability and prevent interference with real-time data.
…ry policies - Updated the Broker class to include a new method `poll_messages` for asynchronous message retrieval, improving communication handling. - Modified the `poll_fills` method to check the legacy result queue when no pending fills are available, enhancing compatibility. - Introduced reentry policies for task management in the Trader class, allowing for more flexible task execution strategies. - Updated unit tests to validate the new message polling functionality and task reentry behavior, ensuring robustness in trading operations.
- Introduced a new reentry policy mechanism for task management, allowing tasks to be queued, dropped, or rejected based on their defined policies. - Updated the Trader class to utilize broker API for polling fills and messages, improving the efficiency of task execution and message handling. - Refactored task specification creation to include reentry policies, ensuring tasks are managed according to their defined strategies. - Enhanced error handling and logging for task execution, providing clearer insights into task status and reasons for skipping tasks.
- Introduced the BrokerFacade class to provide a unified interface for different broker implementations, enhancing flexibility and maintainability. - Added the `enqueue_order` method to the Broker class for streamlined order processing, ensuring orders are validated before being queued. - Updated various components, including the Trader and CLI/TUI interfaces, to utilize the new `enqueue_order` method, improving code consistency. - Enhanced unit tests to validate the functionality of the BrokerFacade and the new order handling mechanisms, ensuring robust integration and behavior.
…andling - Added the `submit_with_ack` method to the Broker class for synchronous order submission with acknowledgment, returning structured results for acceptance and rejection. - Updated the BrokerFacade to expose the new `submit_with_ack` method, ensuring consistent order handling across interfaces. - Enhanced the Trader class to manage order submission rejections, storing the last rejection reason for improved user feedback. - Modified the trade order status update logic to include 'rejected' as a valid state, refining the order lifecycle management. - Expanded unit tests to validate the new functionality of `submit_with_ack` and its integration with the Trader class, ensuring robust error handling and order processing.
- Introduced a `reject_submit_probability` parameter in the `SimulatorBroker` class to simulate random order rejections during the `submit_with_ack` process. - Added a pool of predefined rejection reasons for enhanced user feedback when orders are rejected. - Updated the `submit_with_ack` method to incorporate the new rejection logic, returning structured results for acceptance and rejection scenarios. - Modified existing tests to validate the new rejection feature, ensuring correct behavior under various rejection probabilities and conditions.
- Updated the CLI to differentiate between market and limit orders based on the presence of a price argument, improving user experience. - Enhanced the `cancel_order` function to include an optional `account_id` parameter, restricting order cancellation to the specified account. - Modified the `update_trade_order` function to allow for 'rejected' status updates, ensuring accurate order lifecycle management. - Expanded unit tests to validate the new order type handling and cancellation restrictions, ensuring robust functionality across different accounts.
- Changed the expected order status from 'created' to 'rejected' in the test for order history, aligning with the new rejection logic. - Updated the CLI tests to reflect the change from 'market' to 'limit' order types, ensuring consistency in order processing and validation. - Enhanced the test for the `do_run` method to include a mock for the `_run_task` method, improving test reliability by avoiding external dependencies.
目标:将 Trader 升级为可脱离 UI 稳定长期运行的实盘核心运行时,具备可控任务管理、可编排日程、可插拔 Broker、可审计本地记录与日志。
本轮路线:
运行时模型采用“单线程事件循环为核心,耗时 I/O 放受控 worker”。
Broker 重构采用“兼容层渐进迁移”,避免一次性切换风险。
非目标(本计划外):一次性重写全部 UI、一次性替换所有历史 Broker 实现。
读者反馈吸收(原则层,非 qteasy_ext 实现承诺):独立线程 ≠ 主链路可阻塞;process_trade_result 须事务化以防半提交脏账;Trader 仅通过 Broker 公开 API 消费回报/消息;任务重入与 skip 须有枚举原因便于分桶诊断;日程与「启动前校验 gate」解耦,避免带病启动污染策略输入。