This is a High-Frequency Trading (HFT) system designed to test various trading strategies through backtesting, as well as to manage risk with a set of defined risk strategies. The system includes a modular design for strategies, risk management, logging, and monitoring, allowing for easy expansion and customization.
- Backtesting: Simulates trades on historical data to assess strategy performance.
- Trading Strategies:
- Scalping
- Mean Reversion
- Custom strategies can be easily added.
- Risk Management:
- Max Drawdown Strategy
- Exposure Limit Strategy
- Support for additional risk strategies.
- Logging and Monitoring: Captures key metrics and logs during system execution.
- Docker and Kubernetes Support: The system can be containerized using Docker and orchestrated with Kubernetes.
- CMake: Make sure CMake is installed.
- GCC: C++ compiler for building the project.
- Google Test: For running the unit tests.
- Docker (optional): To run the system in a containerized environment.
-
Clone the repository:
git clone https://github.com/dkrizhanovskyi/hft_trading_system.git cd hft_trading_system
-
Build the project:
mkdir build && cd build cmake .. make
Once the project is built, you can run the system using the following command:
./HFTTradingSystem
-
Build the Docker image:
docker build -t hft_trading_system .
-
Run the container:
docker run -p 8080:8080 hft_trading_system
Unit tests are located in the tests/
directory. To run the tests, use the provided script or run them manually:
./scripts/run_tests.sh
Alternatively, if you are using CMake:
cd build
ctest --output-on-failure
- Backtesting: The system allows you to run backtests using historical data. Strategies are configurable through the
strategy_manager
module. - Risk Management: Implement risk strategies to avoid significant losses during trading. Custom risk strategies can be added.
- Logging: All trades and system metrics are logged, making it easier to track system performance.
Configurations are stored in include/config/settings.h
. Key parameters such as file paths for historical data, strategy thresholds, and risk limits can be adjusted here.
Example:
// include/config/settings.h
const std::string HISTORICAL_DATA_FILE = "data/historical_data.csv";
const double MAX_DRAWDOWN_LIMIT = 0.2;
const int SCALPING_STRATEGY_THRESHOLD = 5;
-
Deploy the application using Kubernetes:
kubectl apply -f kubernetes/deployment.yaml kubectl apply -f kubernetes/service.yaml
-
Check the status of pods and services:
kubectl get pods kubectl get services
-
Initialize Terraform:
cd terraform terraform init
-
Apply the Terraform configuration:
terraform apply
Feel free to fork this repository and contribute by submitting pull requests. Please ensure that your changes are well tested and documented.
This project is licensed under the MIT License - see the LICENSE file for details.