forked from chiki2bum2/SniperGold_ML
54 lines
2.1 KiB
Python
54 lines
2.1 KiB
Python
# -*- coding: utf-8 -*-
| |||
"""P3-S.3 diagnostic: runtime-training pivot parity (strict vs equal-allowed) utk CHoCH."""
| |||
import os
| |||
import sys
| |||
| |||
import numpy as np
| |||
| |||
HERE = os.path.dirname(os.path.abspath(__file__))
| |||
REPO_ML = os.path.normpath(os.path.join(HERE, "..", "..", "..", "ml"))
| |||
REPO_P3 = os.path.normpath(os.path.join(REPO_ML, "p3"))
| |||
REPO_PARITY = os.path.normpath(os.path.join(REPO_ML, "parity"))
| |||
sys.path.insert(0, HERE)
| |||
sys.path.insert(0, REPO_ML)
| |||
sys.path.insert(0, REPO_P3)
| |||
sys.path.insert(0, REPO_PARITY)
| |||
| |||
import p3_common as P3
| |||
P3.DATA = r"D:\TradingTerminal\HFM Metatrader 5\MQL5\Files\AlgoForge\Data"
| |||
import smc_semantic_common as SC
| |||
import train_model as TM
| |||
import build_features_p2 as BFP
| |||
| |||
| |||
def main():
| |||
t, o, h, l, c, v, htf = SC.load_data()
| |||
n = len(c)
| |||
sw_at = np.zeros(n, dtype=int)
| |||
sw_s = TM.build_structure(o, h, l, c, SC.SWING_LEN, False, sw_at, begin=100)
| |||
inn_s = TM.build_structure(o, h, l, c, SC.INTERNAL_LEN, True,
| |||
sw_s["trend"].copy(), begin=100)
| |||
sw_e = BFP.build_structure_fast(o, h, l, c, SC.SWING_LEN, False, sw_at, begin=100)
| |||
inn_e = BFP.build_structure_fast(o, h, l, c, SC.INTERNAL_LEN, True,
| |||
sw_e["trend"].copy(), begin=100)
| |||
cd_s, cd_e = inn_s["choch_dir"], inn_e["choch_dir"]
| |||
cb_s, cb_e = inn_s["choch_bar"], inn_e["choch_bar"]
| |||
out = {
| |||
"n_bars": int(n),
| |||
"choch_dir_mismatch": int((cd_s != cd_e).sum()),
| |||
"choch_dir_mismatch_pct": round(float((cd_s != cd_e).sum()) / n * 100.0, 4),
| |||
"choch_bar_mismatch": int((cb_s != cb_e).sum()),
| |||
"onsets_strict": int((cb_s == np.arange(n)).sum()),
| |||
"onsets_equal_allowed": int((cb_e == np.arange(n)).sum()),
| |||
"note": "strict = train_model.build_structure (equal TIDAK allowed); "
| |||
"equal = build_features_p2.build_structure_fast / EA IsPivotHigh (equal allowed)",
| |||
}
| |||
print(out)
| |||
with open(os.path.join(HERE, "output", "parity_choch_pivot_strict_vs_equal.json"),
| |||
"w", encoding="utf-8") as f:
| |||
import json
| |||
json.dump(out, f, indent=2, default=str)
| |||
| |||
| |||
if __name__ == "__main__":
| |||
main()
|