File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { readFile } from "node:fs/promises" ;
2+ import { join } from "node:path" ;
3+ import { describe , expect , it } from "vitest" ;
4+ import {
5+ REQUIRED_PINE_MARKERS ,
6+ validateAcceptedPine
7+ } from "../research/regime-trend-v1/pine-readiness-tools.mjs" ;
8+
9+ const pinePath = join (
10+ process . cwd ( ) ,
11+ "research" ,
12+ "regime-trend-v1" ,
13+ "pine" ,
14+ "regime-trend-v1-ratchet-v1.pine"
15+ ) ;
16+
17+ describe ( "Regime Trend v1 accepted Pine strategy" , ( ) => {
18+ it ( "contains every frozen implementation marker" , async ( ) => {
19+ const code = await readFile ( pinePath , "utf8" ) ;
20+ const result = validateAcceptedPine ( code ) ;
21+
22+ expect ( result . checks ) . toHaveLength ( REQUIRED_PINE_MARKERS . length ) ;
23+ expect ( result . checks . filter ( ( check ) => ! check . passed ) ) . toEqual ( [ ] ) ;
24+ expect ( result . forbidden . filter ( ( check ) => ! check . passed ) ) . toEqual ( [ ] ) ;
25+ expect ( result . passed ) . toBe ( true ) ;
26+ expect ( result . sha256 ) . toMatch ( / ^ [ a - f 0 - 9 ] { 64 } $ / ) ;
27+ } ) ;
28+
29+ it ( "rejects lookahead and short-entry regressions" , ( ) => {
30+ const unsafe = `//@version=6\nstrategy("unsafe")\nbarmerge.lookahead_on\nstrategy.entry("S", strategy.short)` ;
31+ const result = validateAcceptedPine ( unsafe ) ;
32+
33+ expect ( result . passed ) . toBe ( false ) ;
34+ expect ( result . forbidden . find ( ( check ) => check . id === "lookahead-on" ) ?. passed ) . toBe ( false ) ;
35+ expect ( result . forbidden . find ( ( check ) => check . id === "short-entry" ) ?. passed ) . toBe ( false ) ;
36+ } ) ;
37+ } ) ;
You can’t perform that action at this time.
0 commit comments