tvfetch-backtest
Backtesting-focused variant — framework-aware data export
- License 许可
- MIT
- 最近更新
- 2026-04-09
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- tvfetch-backtest
- tools
- [ "Bash", "Read", "Write" ]
- version
- 1.0.0
- triggers
- [ "/tvfetch-backtest", "/backtest" ]
- description
- Backtesting-focused variant — framework-aware data export
03 SKILL.md 正文
tvfetch-backtest
Backtesting-focused data fetching. When saving data, always asks which framework the user targets and provides framework-specific code snippets.
Behavior
- Fetch OHLCV bars via
scripts/lib/fetch.py - When saving or exporting, ask: Which backtesting framework?
backtraderfreqtradevectorbt
- Output data in the framework's expected format with a ready-to-run code snippet
Framework Formats
backtrader
Save as CSV with columns: datetime,open,high,low,close,volume,openinterest
import backtrader as bt
class MyStrategy(bt.Strategy):
def __init__(self):
self.sma = bt.indicators.SimpleMovingAverage(self.data.close, period=20)
def next(self):
if self.data.close[0] > self.sma[0] and not self.position:
self.buy()
elif self.data.close[0] < self.sma[0] and self.position:
self.sell()
cerebro = bt.Cerebro()
data = bt.feeds.GenericCSVData(
dataname='{{FILE_PATH}}',
dtformat='%Y-%m-%d',
datetime=0, open=1, high=2, low=3, close=4, volume=5, openinterest=6
)
cerebro.adddata(data)
cerebro.run()
cerebro.plot()
freqtrade
Save as JSON in freqtrade's OHLCV format:
# Place in user_data/data/{{EXCHANGE}}/{{PAIR}}-{{TIMEFRAME}}.json
# Format: [[timestamp_ms, open, high, low, close, volume], ...]
# freqtrade backtesting command:
# freqtrade backtesting --strategy MyStrategy --timerange 20240101-20250101
vectorbt
Save as CSV, load with pandas:
import vectorbt as vbt
import pandas as pd
df = pd.read_csv('{{FILE_PATH}}', index_col='datetime', parse_dates=True)
close = df['close']
# Example: SMA crossover
fast_ma = vbt.MA.run(close, window=10)
slow_ma = vbt.MA.run(close, window=30)
entries = fast_ma.ma_crossed_above(slow_ma)
exits = fast_ma.ma_crossed_below(slow_ma)
pf = vbt.Portfolio.from_signals(close, entries, exits, init_cash=10000)
print(pf.stats())
Intent Parsing
| User says | Action |
|---|---|
BTC for backtrader |
Fetch 1D 365 bars, save as backtrader CSV |
AAPL 1h 1000 vectorbt |
Fetch 60m 1000 bars, save as vectorbt CSV |
get ETH data |
Fetch, then ask which framework before saving |
backtest BTC sma crossover |
Fetch, save, generate strategy skeleton |
Rules
- Always ask which framework before saving (unless already specified).
- Include the framework code snippet with the correct file path filled in.
- Default: 1D timeframe, 365 bars (one year of daily data).
- For freqtrade, use millisecond timestamps. For others, use ISO dates.
- If the user mentions a strategy, generate a minimal working skeleton for that framework.
04 同仓库更多 Skills
tvfetch-quant
Quantitative analysis variant — always includes indicators and stats
tvfetch-minimal
Minimal data-only variant — fetch and print, nothing else
tvfetch
暂无简介
tvfetch
Fetch TradingView market data — historical OHLCV bars, live price streams, symbol search, technical indicators, and statistical analysis for any symbol (stocks, crypto, forex, futures, indices, commodities). No API key required. Auto-activates for: candlestick data, OHLCV, historical prices, TradingView, backtesting data, fetch stock/crypto/forex prices, live streaming, bar data, price history, RSI, MACD, SMA, EMA, moving average, Bollinger Bands, "chart X", "get data for", "download prices", "how has X performed", any trading symbol (BTC, AAPL, EURUSD, SPX, GOLD, ETH, SOL, etc.)