Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions docs/release-4.1.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# 4.1.0

Release channel: `latest`. Minor release: one new entry point, no breaking change for 4.0.x users.

## Backtest API

New entry point `@mathieuc/tradingview/backtest`, built from the [honest-backtest](../examples/honest-backtest) example (#351, #352). You write the entry rule, `(candles) => [{ bar, direction }]`; the module applies the protocol and returns a JSON report. See the [backtest guide](backtest.md).

- `backtest()` downloads candles once with `getCandles` and freezes them; `runBacktest()` runs synchronously on candles or a saved snapshot; `backtestMany()` runs several markets, with exits per market if needed.
- Look-ahead check: the signal is rerun on truncated history, and the run stops with the new `TradingViewError` code `LOOK_AHEAD` when a signal depends on later bars or repaints.
- Protocol: entry at the next bar's open, fee and adverse slippage on both sides (random baseline included), stop and target in the same candle counted as a loss, gaps filled at the open, warm-up never traded, chronological 70/30 in-sample/out-of-sample split with no position across it, four interchangeable exits, 1 000 seeded random-entry runs per exit and split.
- The report holds identifiers and numbers only (exit ids, exit reasons, `IS`/`OOS`, warning codes), with metrics per segment, buy and hold, trades with bar indices and times. `chartData()` prepares a price chart, and `formatReport()` and `tradesToCsv()` render the report as text and CSV.
- `examples/honest-backtest` uses the module; `examples/backtest-custom-signal.js` shows a custom rule.

The module makes no claim of profitability: a negative or inconclusive result is a valid outcome.

Pre-releases 4.1.0-beta.1 and 4.1.0-beta.2 were published under the `beta` tag. 4.1.0 has the same code as 4.1.0-beta.2; only the version, these notes and the `llms.txt` line about the beta tag change.
2 changes: 1 addition & 1 deletion llms.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Low-level API: TradingViewClient, client.createChart() (ChartSession: setMarket,

Pine studies need a TradingView account (session cookies). Built-in studies and candles/quotes work anonymously, with history limits.
Docs: docs/data-api.md, docs/backtest.md, docs/low-level-api.md, docs/migration-v4.md, docs/v4-coverage.md, docs/v4-reliability.md, docs/protocol-contributing.md. Examples: examples/.
Backtest API (import from '@mathieuc/tradingview/backtest'; since 4.1.0-beta.1, npm tag beta; report format frozen in 4.1.0-beta.2): write only the entry rule, do not write an engine.
Backtest API (import from '@mathieuc/tradingview/backtest', since 4.1.0): write only the entry rule, do not write an engine.
- backtest({ symbol, timeframe, years?, credentials?, signal, exits?, fee?, slippage?, splitRatio?, runs?, seed? }) -> { report, snapshot }. runBacktest(candles | snapshot, options) -> report, synchronous, no network.
- signal(candles) -> [{ bar, direction: 'long' | 'short', refs? }]: decided at the close of `bar` using bars 0..bar only; entry is always the next bar's open. Optional signal.warmupBars (default 200) and signal.label.
- The engine reruns signal on truncated history and throws TradingViewError code LOOK_AHEAD if a signal depends on later bars (or repaints).
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mathieuc/tradingview",
"version": "4.1.0-beta.2",
"version": "4.1.0",
"description": "TradingView market data for JavaScript and TypeScript: candles, quotes, indicators and strategies, with a simple data API and full low-level access.",
"type": "module",
"main": "./dist/index.js",
Expand Down
Loading