cyberkyne's picture
Upload 22 files
1a56c89 verified
# 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.")