Skip to content

Commit f04af70

Browse files
authored
Release 4.1.0 (#353)
Minor release: the backtest API (@mathieuc/tradingview/backtest) moves from the beta tag to latest. Same code as 4.1.0-beta.2.
1 parent 86dc3c3 commit f04af70

4 files changed

Lines changed: 21 additions & 4 deletions

File tree

‎docs/release-4.1.0.md‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# 4.1.0
2+
3+
Release channel: `latest`. Minor release: one new entry point, no breaking change for 4.0.x users.
4+
5+
## Backtest API
6+
7+
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).
8+
9+
- `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.
10+
- 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.
11+
- 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.
12+
- 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.
13+
- `examples/honest-backtest` uses the module; `examples/backtest-custom-signal.js` shows a custom rule.
14+
15+
The module makes no claim of profitability: a negative or inconclusive result is a valid outcome.
16+
17+
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.

‎llms.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Low-level API: TradingViewClient, client.createChart() (ChartSession: setMarket,
2222

2323
Pine studies need a TradingView account (session cookies). Built-in studies and candles/quotes work anonymously, with history limits.
2424
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/.
25-
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.
25+
Backtest API (import from '@mathieuc/tradingview/backtest', since 4.1.0): write only the entry rule, do not write an engine.
2626
- backtest({ symbol, timeframe, years?, credentials?, signal, exits?, fee?, slippage?, splitRatio?, runs?, seed? }) -> { report, snapshot }. runBacktest(candles | snapshot, options) -> report, synchronous, no network.
2727
- 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.
2828
- The engine reruns signal on truncated history and throws TradingViewError code LOOK_AHEAD if a signal depends on later bars (or repaints).

‎package-lock.json‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@mathieuc/tradingview",
3-
"version": "4.1.0-beta.2",
3+
"version": "4.1.0",
44
"description": "TradingView market data for JavaScript and TypeScript: candles, quotes, indicators and strategies, with a simple data API and full low-level access.",
55
"type": "module",
66
"main": "./dist/index.js",

0 commit comments

Comments
 (0)