Skip to content

Japteg/TradingBuddy

Repository files navigation

TradingBuddy

TradingBuddy is a comprehensive trading automation and backtesting platform designed to help traders develop, test, and implement trading strategies.

Features

  • 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

Project Structure

  • /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

Getting Started

Installation

  1. Clone the repository
  2. Create a virtual environment:
    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
    
  3. Install dependencies:
    pip install django djangorestframework pandas numpy pymongo
    
  4. Run the Django development server:
    python manage.py runserver
    

Usage

Creating a Trading Strategy

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()

Running a Backtest

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)

Working with Automations

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
        ]
    }
}

API Endpoints

  • GET /api/home/: Basic API health check
  • POST /api/test-strategy/: Run backtests with custom automation flows

Data Management

The project uses MongoDB for storing and retrieving market data. Configure your connection in database.py.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors