<?php
require_once "auth.php";
$user = API_AUTH();

$q = $conn->prepare("
    SELECT ticket,symbol,type,volume,open_price,close_price,profit,open_time,close_time
    FROM trades
    WHERE user_id=?
    ORDER BY open_time DESC
");
$q->bind_param("i", $user['id']);
$q->execute();
$res = $q->get_result();

$data = [];
while($row = $res->fetch_assoc()) $data[] = $row;

echo json_encode($data);
?>
