Modular, Connectable, and Scalable Quant & Algo Trading Platform for VN Stocks, Crypto, Forex, and Gold Markets.
TempusOnePs operates as a pipeline-based system where data flows through a series of stages:
- Data: Fetches market data from various sources.
- Signals: Processes data to generate trading signals (Buy, Sell, Close, etc.). This stage runs in parallel using multiprocessing for performance.
- Execution: Executes trades based on the generated signals.
- Log: Logs the results of the pipeline execution.
The system is built around a ServiceLoader that dynamically loads services defined in config/config.json.
The system behavior is controlled by config/config.json. This file defines the pipeline stages and the services to run in each stage.
Example structure:
{
"cron": "*/5 * * * *", // Cron expression for scheduling
"interval": 5, // Interval in seconds (optional override)
"pipeline": {
"data": [ ... ],
"signals": [ ... ],
"execution": [ ... ],
"log": [ ... ]
}
}Each service entry in the pipeline looks like this:
{
"name": "ServiceName",
"class": "ClassName",
"path": "module.path",
"enabled": true,
"other_params": "value"
}To run the pipeline once immediately:
python run.py --mod <module_name>To run the pipeline continuously based on the cron schedule defined in the config:
python run-cron.py --mod <module_name>If --mod is not provided, the system will look for config/config.json in the root directory.
If --mod <module_name> is provided, it will look for modules/<module_name>/config/config.json.
To add a new service (e.g., a new signal strategy):
- Create a new Python file in
modules/(or appropriate subdirectory). - Define a class that inherits from the appropriate base class:
BaseServicePluginfor general services.BaseSignalPluginfor signal services.
- Implement the
runmethod. - Add the new service to
config/config.jsonunder the appropriate pipeline stage.
from core.service.base_signal import BaseSignalPlugin
class MyStrategy(BaseSignalPlugin):
def run(self, df):
# Implement logic here
# df['signal'] = ...
return df