reorganized data files and enhance backtesting structure, monte carlo sim

This commit is contained in:
moen0
2026-04-13 01:30:34 +02:00
parent 373e589297
commit 7d53f8589a
26 changed files with 65383 additions and 766 deletions
+27 -16
View File
@@ -1,31 +1,42 @@
def find_order_blocks(candles, structure, min_impulse=0.10):
def find_order_blocks(candles, structure, min_impulse=0.10, min_ob_size=0.0):
"""
Find Order Blocks based on structure breaks.
Args:
candles: list of Candle objects
structure: list of structure points from detect_structure
min_impulse: legacy param (unused, kept for compat)
min_ob_size: minimum OB size in price units (0 = no filter)
"""
obs = []
for point in structure:
if point["label"] == "HH":
# Bullish break of structure, look back for last bearish candle
idx = point["index"]
for j in range(idx - 1, max(idx - 20, 0), -1):
if candles[j].close < candles[j].open:
obs.append({
"index": j,
"type": "bullish",
"top": candles[j].open,
"bottom": candles[j].close
})
size = candles[j].open - candles[j].close
if size >= min_ob_size:
obs.append({
"index": j,
"type": "bullish",
"top": candles[j].open,
"bottom": candles[j].close,
})
break
elif point["label"] == "LL":
# Bearish break of structure, look back for last bullish candle
idx = point["index"]
for j in range(idx - 1, max(idx - 20, 0), -1):
if candles[j].close > candles[j].open:
obs.append({
"index": j,
"type": "bearish",
"top": candles[j].close,
"bottom": candles[j].open
})
size = candles[j].close - candles[j].open
if size >= min_ob_size:
obs.append({
"index": j,
"type": "bearish",
"top": candles[j].close,
"bottom": candles[j].open,
})
break
return obs
return obs