Welcome to the Trading Strategy Builder, a Streamlit-based application that allows users to create, visualize, and run custom trading strategies using a decision tree approach. This tool integrates with the SigTech platform to execute strategies and analyze their performance.
It specializes in path-dependent strategies (sig.DynamicStrategy
) based on conditions set by indicators (such as RSI,
cumulative returns, and others).
- Interactive GUI: Use Streamlit to interactively manage conditions and actions for your trading strategy.
- Decision Tree Visualization: Visualize your strategy's decision tree using Graphviz.
- Strategy Execution: Run your strategy using historical data through the SigTech platform.
- Performance Analysis: View and analyze the performance of your strategies with customizable plots.
- Strategy Management: Save and load multiple strategies for comparison and further analysis.
- Python 3.7 or higher
- SigTech Python Framework
- Required Python packages listed in
requirements.txt
-
Clone the Repository
git clone https://github.com/salimtlemcani/conditional_decision_graph_based_strategies.git cd conditional_decision_graph_based_strategies
-
Create a Virtual Environment
python -m venv venv
-
Activate the Virtual Environment
-
On Windows:
venv\Scripts\activate
-
On macOS/Linux:
source venv/bin/activate
-
-
Install Dependencies
pip install -r requirements.txt
-
Set Up SigTech Environment
- Ensure you have access to the SigTech platform.
- Configure your SigTech credentials as per their documentation.
-
Navigate to the Project Directory
cd conditional_decision_graph_based_strategies
-
Run the Streamlit Application
streamlit run app.py
-
Access the App
- Open your web browser and go to the localhost port shown in your console (likely
http://localhost:8501
)
- Open your web browser and go to the localhost port shown in your console (likely
The application is divided into several sections accessible from the sidebar:
- Add New Condition: Define new conditions based on indicators like RSI, Volatility, or Cumulative Return.
- Edit Existing Conditions: Modify or update existing conditions.
- Add New Action: Define new actions specifying ETF allocations.
- Edit Existing Actions: Modify or update existing actions.
- Conditions: View all defined conditions in JSON format.
- Actions: View all defined actions in JSON format.
- Download Specifications: Download conditions and actions as JSON files.
- Decision Tree Visualization: Generate and view the decision tree based on your conditions and actions using Graphviz.
- Run New Strategy: Execute your strategy over a specified date range and initial cash amount.
- View Saved Strategies: View and analyze the performance of saved strategies.
conditional_decision_graph_based_strategies/
├── app.py # Main Streamlit application
├── modules/ # Application modules (formerly 'pages')
│ ├── manage_conditions.py
│ ├── manage_actions.py
│ ├── view_specs.py
│ ├── visualize_decision_tree.py
│ └── my_strategies.py
├── utils/ # Utility modules
│ ├── __init__.py
│ ├── data_utils.py
│ ├── decision_tree_utils.py
│ ├── helper.py # Utility functions for indicators and comparisons
│ └── plotting_utils.py
├── strategy_builder.py # Builds the decision tree from specifications
├── strategy_execution.py # Contains the basket creation method
├── conditions.json # JSON file storing condition specifications
├── actions.json # JSON file storing action specifications
├── strategies/ # Directory to store saved strategy objects
├── requirements.txt # Python dependencies
└── README.md # Project documentation
- Indicators: Extend
utils/helper.py
to include additional financial indicators as needed. - ETFs: Modify the list of ETFs in
app.py
or in the modules to include those relevant to your strategies. - Visualization: Customize the plotting functions in
utils/plotting_utils.py
to adjust the appearance of performance graphs.
Note: This application requires access to the SigTech platform. Ensure you have the necessary permissions and credentials to use their services.