Overview of the wtpy sub-framework modules
masterThe wtpy sub-framework is the Python 3 adaptation for WonderTrader. It is organized into several functional modules:
apps module
Contains high-level analysis and optimization tools:
WtBtAnalyst.py: Backtesting analysis module that calculates metrics from backtest data and outputs toexcel.WtCtaOptimizer: CTA optimizer that usesmultiprocessingfor parallel backtesting and outputs statistics tocsv.WtHotPicker: Helper for domestic futures roll-over rules, supporting exchange website scraping or parsingdatakitsnapshot.csvfiles.
wrapper module
Provides interfaces for interacting with the C++ underlying core:
ContractLoader.py: Loadscommodities.jsonandcontracts.jsonvia interfaces likeCTP.WtBtWrapper.py: Interface for the backtesting engineC++core.WtDtWrapper.py: Interface for the data componentC++core.WtDtHelper.py: Converts user data intoWonderTraderinternal formats.WtDtServoApi.py: Provides Python access todatakitstored data.WtExecApi.py: Interface for theWtExecMonindependent execution module.WtWrapper.py: Interface for the live trading engineC++core.WtMQWrapper.py: Direct interface for the underlyingWtMsgQuemodule.
monitor module
Contains built-in monitoring services providing Http and websocket connections:
DataMgr.py: Reads and caches portfolio data.EventReceiver.py: Receives events forwarded by portfolios viaudpports.PushSvr.py: Provideswebsocketservices to the web.WatchDog.py: Automatically schedules server-side processes.WtBtMon.py: Manages backtesting.WtMonSvr.py: Core monitoring service usingflaskto implement anhttpservice interface.static: Containswebuistatic files.
Root Modules
Contains entry components and strategy definitions:
WtCoreDefs.py: Defines the Python version of the strategy base class for users to override.CodeHelper.py: Helper module for variety codes.ContractMgr.py: Manages and queriescontracts.jsonorstocks.json.CtaContext.py,HftContext.py,SelContext.py: Define the execution environments (contexts) forCTA,HFT, andSELstrategies respectively.ProductMgr.py: Queries contract and variety attributes in the Python environment.SessionMgr.py: Manages trading session templates.StrategyDefs.py: Defines base classes forCTA,HFT, andSELstrategies.WtBtEngine.py,WtDtEngine.py,WtEngine.py: Wrapper modules for the Backtesting, Data, and Trading engines respectively.