TradingBuddy is a comprehensive trading automation and backtesting platform designed to help traders develop, test, and implement trading strategies.
- Backtesting Engine: Test trading strategies against historical data to evaluate performance
- Strategy Development: Create custom trading strategies with flexible parameters
- Automation Framework: Design and implement rule-based trading automations
- Data Management: MongoDB integration for storing and retrieving market data
/automation/: Core automation components including decision trees and evaluators/backtester/: Complete backtesting framework with strategy tools and performance analysis/experiment/: Django app for running backtests and analyzing results/project/: Django project configuration files/candlestick/: Candlestick pattern analysis tools/results/: Storage for backtesting results
- Clone the repository
- Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate - Install dependencies:
pip install django djangorestframework pandas numpy pymongo - Run the Django development server:
python manage.py runserver
Extend the Strategy base class in backtester/core/strategy.py:
from backtester.core.strategy import Strategy
class MyTradingStrategy(Strategy):
def init(self):
super().init()
# Initialize indicators and strategy parameters
def next(self):
super().next()
# Define trading logic based on market data
self.automation_evaluator.next()from backtester.core.backtesting import Backtest
from my_strategy import MyTradingStrategy
# Load market data
data = pd.DataFrame(...) # Your OHLCV data
# Create and run backtest
bt = Backtest(data, MyTradingStrategy, cash=100_000, exclusive_orders=False)
stats = bt.run()
# Analyze results
print(stats)The automation framework allows you to create rule-based trading decisions:
automation_flow = {
"root": {
"type": "decision",
"name": "Today is Thursday",
"criteria": {
"type": "any",
"criteria": [
{
"input": {"day": 4},
"type": "day_of_week"
}
]
},
"outcomes": [
# Define trading actions based on conditions
]
}
}GET /api/home/: Basic API health checkPOST /api/test-strategy/: Run backtests with custom automation flows
The project uses MongoDB for storing and retrieving market data. Configure your connection in database.py.