File size: 1,771 Bytes
1a56c89
 
094a5f6
 
 
 
 
 
 
1a56c89
 
 
 
 
 
094a5f6
1a56c89
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
094a5f6
1a56c89
 
 
094a5f6
 
 
 
1a56c89
 
094a5f6
 
 
 
 
 
 
 
 
1a56c89
 
 
 
 
 
 
 
094a5f6
1a56c89
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# warmup.jl β€” JIT-compile all hot paths at build time.
# Failures are non-fatal: print warning and exit 0.
push!(LOAD_PATH, @__DIR__)
include(joinpath(@__DIR__, "QuantEngine.jl"))
using .QuantEngine
using Statistics, Random

println("Warming up all Julia hot paths...")

n=500
c=100.0.*exp.(cumsum(randn(n).*0.005))
h=c.*(1.0.+abs.(randn(n)).*0.005)
l=c.*(1.0.-abs.(randn(n)).*0.005)
o=c.*(1.0.+randn(n).*0.002)
v=abs.(randn(n)).*2000.0.+1000.0

# Warm indicators
for (name, fn) in [
    ("sma",    ()-> sma(c,20)),
    ("ema",    ()-> ema(c,20)),
    ("rsi",    ()-> rsi(c,14)),
    ("macd",   ()-> macd(c)),
    ("atr",    ()-> atr(h,l,c,14)),
    ("bbands", ()-> bbands(c,20,2.0)),
    ("donchian",()-> donchian(h,l,20)),
    ("adx",    ()-> adx(h,l,c,14)),
    ("stoch",  ()-> stoch(h,l,c)),
    ("zscore", ()-> zscore(c,20)),
]
    try; fn(); println("  $name βœ“")
    catch e; println("  $name βœ— $e"); end
end
println("Indicators warmed βœ“")

# Warm full pipeline (non-fatal)
try
    code = """
function get_param_grid() :: Dict{String, Vector{Float64}}
    return Dict("period" => [10.0, 20.0, 30.0])
end
function generate_signals(open_p, high, low, close, volume, params)
    n  = length(close)
    p  = Int(round(get(params, "period", 20.0)))
    ma = sma(close, p)
    signals = zeros(Int, n)
    for i in (p+1):n
        isnan(ma[i]) && continue
        signals[i] = close[i] > ma[i] ? 1 : -1
    end
    return signals
end
"""
    result = full_backtest_pipeline(
        code, "WarmupTest", o, h, l, c, v, "1h", "TEST";
        n_windows=2, max_combos=3, min_trades=1,
    )
    println("Pipeline warmup: is_valid=$(result[\"is_valid\"]) βœ“")
catch e
    println("Pipeline warmup skipped (non-fatal): $e")
end

println("\nβœ… Julia warmup complete.")