<?php
$api_key = 'ATKpagYXMd22yzPfCm';
$secret_key = 'rTj3hThcJ5gvo4yRwB29bvXDQB90xh3tRuQI';
$timestamp = round(microtime(true) * 1000); // Current timestamp in milliseconds

$take_profit = 0.007; // Set a take-profit price
$stop_loss = 0.007; // Set a stop-loss price
$trailing_stop = 0; 

$params = [
    'api_key' => $api_key,
     'accountType' => 'UNIFIED',
     'category' => 'linear',
    'symbol' => 'BOMEUSDT', // Replace with your desired symbol
    'timestamp' => $timestamp,
];

// Sort parameters
ksort($params);

// Create query string
$query_string = http_build_query($params, '', '&', PHP_QUERY_RFC3986);

// Generate the signature
$sign = hash_hmac('sha256', $query_string, $secret_key);

// Add the sign to the parameters
$params['sign'] = $sign;

// Build the URL
$url = "https://api.bybit.com/v5/position/list?" . http_build_query($params);

// Initialize cURL session
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// Execute the request
$response = curl_exec($ch);
curl_close($ch);

// Parse the response
$response_data = json_decode($response, true);

echo '<pre>';
print_r($response_data);
echo '</pre>';
