搜索

PythonReactSEOPDF
OpenClaw

Quant Trading Backtrader

quant trading backtrader

gmsx000-cloud0 来源安装数☆ 0 仓库 Stars

安装与使用

请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。

SkillHub CLI

skillhub install gmsx000-cloud/quant-trading-backtrader

打开来源仓库,查看说明和兼容环境后,按来源提供的命令或步骤安装。

将来源链接提供给你的 Agent,让它先读取说明、核对依赖,并向你说明将执行的安装步骤。

查看来源 ↗使用指南

技能说明

quant-trading-backtrader

A comprehensive skill for building, backtesting, and optimizing quantitative trading strategies using the Backtrader framework in Python.

Features

  • Backtesting Engine: Simulates trading strategies on historical data with support for multiple data feeds.
  • Strategy Development: Provides a structured Strategy class to define indicators (SMA, EMA, RSI, etc.) and trading logic.
  • Risk Management: Examples of implementing stop-loss, take-profit, and position sizing (e.g., fractional Kelly).
  • Data Handling: Support for CSV data ingestion (customizable formats) and pandas DataFrame integration.
  • Reporting: Generates transaction logs, trade analysis (PNL), and portfolio value tracking.

Usage

This skill provides a foundation for creating quantitative trading bots. It includes templates and examples to get you started.

1. Installation

Ensure you have the required dependencies:

pip install backtrader matplotlib
2. Basic Strategy Template

Create a new strategy file (e.g., my_strategy.py) using the template structure:

import backtrader as bt

class MyStrategy(bt.Strategy):
    params = (
        ('period', 15),
    )

    def __init__(self):
        self.sma = bt.indicators.SimpleMovingAverage(self.data.close, period=self.params.period)

    def next(self):
        if self.sma > self.data.close:
            # Do something
            pass
3. Running a Backtest

Use bt.Cerebro to orchestrate the backtest:

cerebro = bt.Cerebro()
cerebro.addstrategy(MyStrategy)
# ... add data ...
cerebro.run()

Examples

Check the examples/ directory for full working examples:

  • sma_crossover.py: A classic Trend Following strategy with Stop-Loss.

Best Practices

  • Avoid Overfitting: Use Walk-Forward Analysis (train on past, test on unseen future data).
  • Risk Control: Always implement stop-loss orders. Position sizing is critical for survival.
  • **Data Qu...

来源信息

Source
github
Repository
openclaw/skills
Path
skills/gmsx000-cloud/quant-trading-backtrader
Version
—
Commit
5ddeebe22dd1d9b16da76c579feb6e4ea92383e6
分类来源
rules
状态
active
可见性
public

这些信息来自收录时的来源分析,可能滞后;使用前请核对最新来源文件。

来源内容

SKILL.md
# quant-trading-backtrader

A comprehensive skill for building, backtesting, and optimizing quantitative trading strategies using the Backtrader framework in Python.

## Features

- **Backtesting Engine**: Simulates trading strategies on historical data with support for multiple data feeds.
- **Strategy Development**: Provides a structured `Strategy` class to define indicators (SMA, EMA, RSI, etc.) and trading logic.
- **Risk Management**: Examples of implementing stop-loss, take-profit, and position sizing (e.g., fractional Kelly).
- **Data Handling**: Support for CSV data ingestion (customizable formats) and pandas DataFrame integration.
- **Reporting**: Generates transaction logs, trade analysis (PNL), and portfolio value tracking.

## Usage

This skill provides a foundation for creating quantitative trading bots. It includes templates and examples to get you started.

### 1. Installation

Ensure you have the required dependencies:

```bash
pip install backtrader matplotlib
```

### 2. Basic Strategy Template

Create a new strategy file (e.g., `my_strategy.py`) using the template structure:

```python
import backtrader as bt

class MyStrategy(bt.Strategy):
    params = (
        ('period', 15),
    )

    def __init__(self):
        self.sma = bt.indicators.SimpleMovingAverage(self.data.close, period=self.params.period)

    def next(self):
        if self.sma > self.data.close:
            # Do something
            pass
```

### 3. Running a Backtest

Use `bt.Cerebro` to orchestrate the backtest:

```python
cerebro = bt.Cerebro()
cerebro.addstrategy(MyStrategy)
# ... add data ...
cerebro.run()
```

## Examples

Check the `examples/` directory for full working examples:
- `sma_crossover.py`: A classic Trend Following strategy with Stop-Loss.

## Best Practices

- **Avoid Overfitting**: Use Walk-Forward Analysis (train on past, test on unseen future data).
- **Risk Control**: Always implement stop-loss orders. Position sizing is critical for survival.
- **Data Qu...

相关技能

OpenClaw

a-stock-trader

bombfuock

A股模拟交易系统 - 数据爬取、存储、策略回测、模拟交易 / A-Share Paper Trading System - Data Fetch, Storage, Backtest, Simulation

OpenClaw

adaptive-skill-factory

505768069-rgb

Discover, install, update, or create the right skill when a workflow gap appears. Use when a task is repetitive, a role lacks a reliable procedure, an existing skill might save time, ClawHub search/install coul...