<?php

// FX-HUNTER → Python Strategy Engine Bridge

$input = file_get_contents("php://input");

$ch = curl_init("http://127.0.0.1:8001/backtest");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ["Content-Type: application/json"]);
curl_setopt($ch, CURLOPT_POSTFIELDS, $input);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);

$response = curl_exec($ch);

if($response === false){
    http_response_code(500);
    echo json_encode(["error"=>"ENGINE_UNREACHABLE"]);
    exit;
}

curl_close($ch);

header("Content-Type: application/json");
echo $response;